How to add TypeScript type safety to my redux action?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I'm writing my application in TypeScript and I'm using Redux to keep track of my app state. My redux store state looks something like this:
interface AppState {
readonly grid : IGridSettings;
readonly selected : ISelectedSettings;
[key : string] : IGridSettings | ISelectedSettings;
}
interface IGridSettings {
readonly extents : number;
readonly isXY : boolean;
readonly isXZ : boolean;
readonly isYZ : boolean;
readonly spacing : number;
[key : string] : number | boolean;
}
interface ISelectedSettings {
readonly bodyColor : number;
readonly colorGlow : number;
readonly lineColor : number;
readonly selection : number | undefined;
[key : string] : number | number | undefined;
}
I created the following action to let me update the store however the setPropertyValue function is not ideal since it has no type safety!
//How to add type safety to this function?
const setPropertyValue = ( property : string, value : any ) : SetPropertyValueAction => ( {
type: 'SET_PROPERTY_VALUE',
payload: {
property,
value,
}
} );
interface SetPropertyValueAction extends Action {
type : string;
payload : {
property : string;
value : any;
};
}
I can use this action in my code this way:
setPropertyValue( ['grid', 'extents'], 100 );
This works, but since there is no type safety in the setPropertyValue function there is nothing restricting me from feeding invalid values into the function like this:
setPropertyValue( ['grid', 'size'], 100 ); //invalid since IGridSettings doesn't have a 'size' property
setPropertyValue( ['grid', 'isXY'], -1 ); //value should be a boolean not a number
setPropertyValue( ['selected', 'bodyColor'], '255' ); //value should be a number not a string
Is there a way to rewrite the setPropertyValue function so that it only accepts arguments that are valid for the property name found in AppState. Also the value passed in must correspond to the correct type for the selected property.
Perhaps using a string array for the property to change is not ideal but I don't know of a better way to target only the properties that are available in AppState.
typescript redux type-safety
add a comment |
I'm writing my application in TypeScript and I'm using Redux to keep track of my app state. My redux store state looks something like this:
interface AppState {
readonly grid : IGridSettings;
readonly selected : ISelectedSettings;
[key : string] : IGridSettings | ISelectedSettings;
}
interface IGridSettings {
readonly extents : number;
readonly isXY : boolean;
readonly isXZ : boolean;
readonly isYZ : boolean;
readonly spacing : number;
[key : string] : number | boolean;
}
interface ISelectedSettings {
readonly bodyColor : number;
readonly colorGlow : number;
readonly lineColor : number;
readonly selection : number | undefined;
[key : string] : number | number | undefined;
}
I created the following action to let me update the store however the setPropertyValue function is not ideal since it has no type safety!
//How to add type safety to this function?
const setPropertyValue = ( property : string, value : any ) : SetPropertyValueAction => ( {
type: 'SET_PROPERTY_VALUE',
payload: {
property,
value,
}
} );
interface SetPropertyValueAction extends Action {
type : string;
payload : {
property : string;
value : any;
};
}
I can use this action in my code this way:
setPropertyValue( ['grid', 'extents'], 100 );
This works, but since there is no type safety in the setPropertyValue function there is nothing restricting me from feeding invalid values into the function like this:
setPropertyValue( ['grid', 'size'], 100 ); //invalid since IGridSettings doesn't have a 'size' property
setPropertyValue( ['grid', 'isXY'], -1 ); //value should be a boolean not a number
setPropertyValue( ['selected', 'bodyColor'], '255' ); //value should be a number not a string
Is there a way to rewrite the setPropertyValue function so that it only accepts arguments that are valid for the property name found in AppState. Also the value passed in must correspond to the correct type for the selected property.
Perhaps using a string array for the property to change is not ideal but I don't know of a better way to target only the properties that are available in AppState.
typescript redux type-safety
Are the index sigantures necessary for your use case or did you just add them to allow indexing ? (ex:[key : string] : IGridSettings | ISelectedSettings;
)
– Titian Cernicova-Dragomir
Jan 4 at 14:57
I needed to add the index signatures to get rid of an error message somewhere along the way. Without them, the TypeScript code would not compile for me.
– MarekKnows.com
Jan 4 at 15:01
add a comment |
I'm writing my application in TypeScript and I'm using Redux to keep track of my app state. My redux store state looks something like this:
interface AppState {
readonly grid : IGridSettings;
readonly selected : ISelectedSettings;
[key : string] : IGridSettings | ISelectedSettings;
}
interface IGridSettings {
readonly extents : number;
readonly isXY : boolean;
readonly isXZ : boolean;
readonly isYZ : boolean;
readonly spacing : number;
[key : string] : number | boolean;
}
interface ISelectedSettings {
readonly bodyColor : number;
readonly colorGlow : number;
readonly lineColor : number;
readonly selection : number | undefined;
[key : string] : number | number | undefined;
}
I created the following action to let me update the store however the setPropertyValue function is not ideal since it has no type safety!
//How to add type safety to this function?
const setPropertyValue = ( property : string, value : any ) : SetPropertyValueAction => ( {
type: 'SET_PROPERTY_VALUE',
payload: {
property,
value,
}
} );
interface SetPropertyValueAction extends Action {
type : string;
payload : {
property : string;
value : any;
};
}
I can use this action in my code this way:
setPropertyValue( ['grid', 'extents'], 100 );
This works, but since there is no type safety in the setPropertyValue function there is nothing restricting me from feeding invalid values into the function like this:
setPropertyValue( ['grid', 'size'], 100 ); //invalid since IGridSettings doesn't have a 'size' property
setPropertyValue( ['grid', 'isXY'], -1 ); //value should be a boolean not a number
setPropertyValue( ['selected', 'bodyColor'], '255' ); //value should be a number not a string
Is there a way to rewrite the setPropertyValue function so that it only accepts arguments that are valid for the property name found in AppState. Also the value passed in must correspond to the correct type for the selected property.
Perhaps using a string array for the property to change is not ideal but I don't know of a better way to target only the properties that are available in AppState.
typescript redux type-safety
I'm writing my application in TypeScript and I'm using Redux to keep track of my app state. My redux store state looks something like this:
interface AppState {
readonly grid : IGridSettings;
readonly selected : ISelectedSettings;
[key : string] : IGridSettings | ISelectedSettings;
}
interface IGridSettings {
readonly extents : number;
readonly isXY : boolean;
readonly isXZ : boolean;
readonly isYZ : boolean;
readonly spacing : number;
[key : string] : number | boolean;
}
interface ISelectedSettings {
readonly bodyColor : number;
readonly colorGlow : number;
readonly lineColor : number;
readonly selection : number | undefined;
[key : string] : number | number | undefined;
}
I created the following action to let me update the store however the setPropertyValue function is not ideal since it has no type safety!
//How to add type safety to this function?
const setPropertyValue = ( property : string, value : any ) : SetPropertyValueAction => ( {
type: 'SET_PROPERTY_VALUE',
payload: {
property,
value,
}
} );
interface SetPropertyValueAction extends Action {
type : string;
payload : {
property : string;
value : any;
};
}
I can use this action in my code this way:
setPropertyValue( ['grid', 'extents'], 100 );
This works, but since there is no type safety in the setPropertyValue function there is nothing restricting me from feeding invalid values into the function like this:
setPropertyValue( ['grid', 'size'], 100 ); //invalid since IGridSettings doesn't have a 'size' property
setPropertyValue( ['grid', 'isXY'], -1 ); //value should be a boolean not a number
setPropertyValue( ['selected', 'bodyColor'], '255' ); //value should be a number not a string
Is there a way to rewrite the setPropertyValue function so that it only accepts arguments that are valid for the property name found in AppState. Also the value passed in must correspond to the correct type for the selected property.
Perhaps using a string array for the property to change is not ideal but I don't know of a better way to target only the properties that are available in AppState.
typescript redux type-safety
typescript redux type-safety
edited Jan 4 at 15:03
MarekKnows.com
asked Jan 4 at 14:54
MarekKnows.comMarekKnows.com
355213
355213
Are the index sigantures necessary for your use case or did you just add them to allow indexing ? (ex:[key : string] : IGridSettings | ISelectedSettings;
)
– Titian Cernicova-Dragomir
Jan 4 at 14:57
I needed to add the index signatures to get rid of an error message somewhere along the way. Without them, the TypeScript code would not compile for me.
– MarekKnows.com
Jan 4 at 15:01
add a comment |
Are the index sigantures necessary for your use case or did you just add them to allow indexing ? (ex:[key : string] : IGridSettings | ISelectedSettings;
)
– Titian Cernicova-Dragomir
Jan 4 at 14:57
I needed to add the index signatures to get rid of an error message somewhere along the way. Without them, the TypeScript code would not compile for me.
– MarekKnows.com
Jan 4 at 15:01
Are the index sigantures necessary for your use case or did you just add them to allow indexing ? (ex:
[key : string] : IGridSettings | ISelectedSettings;
)– Titian Cernicova-Dragomir
Jan 4 at 14:57
Are the index sigantures necessary for your use case or did you just add them to allow indexing ? (ex:
[key : string] : IGridSettings | ISelectedSettings;
)– Titian Cernicova-Dragomir
Jan 4 at 14:57
I needed to add the index signatures to get rid of an error message somewhere along the way. Without them, the TypeScript code would not compile for me.
– MarekKnows.com
Jan 4 at 15:01
I needed to add the index signatures to get rid of an error message somewhere along the way. Without them, the TypeScript code would not compile for me.
– MarekKnows.com
Jan 4 at 15:01
add a comment |
1 Answer
1
active
oldest
votes
If you need the index signature then there is no way to validate the keys of the type (since after all the index signature would mean the class in indexable by any key, so any key would be valid)
To validate taht a string is a key of a type we can use the keyof
operator, in conjuction with some generic type parameters (to capture the actual key passed in)
interface AppState {
readonly grid : IGridSettings;
readonly selected: ISelectedSettings;
}
interface IGridSettings {
readonly extents : number;
readonly isXY : boolean;
readonly isXZ : boolean;
readonly isYZ : boolean;
readonly spacing: number;
}
interface ISelectedSettings {
readonly bodyColor : number;
readonly colorGlow : number;
readonly lineColor : number;
readonly selection : number | undefined;
}
const setPropertyValue = <KApp extends keyof AppState, KAppProp extends keyof AppState[KApp]>( property : [KApp, KAppProp], value : AppState[KApp][KAppProp] ) : SetPropertyValueAction => ( {
type: 'SET_PROPERTY_VALUE',
payload: {
property,
value,
}
} );
interface SetPropertyValueAction {
type : string;
payload : {
property : PropertyKey;
value : any;
};
}
setPropertyValue( ['grid', 'extents'], 100 );
setPropertyValue( ['grid', 'size'], 100 ); //err
setPropertyValue( ['grid', 'isXY'], -1 ); //err
setPropertyValue( ['selected', 'bodyColor'], '255' );// err
In the interface SetPropertyValueAction, you say that property is of type PropertyKey What is PropertyKey and how is that defined?
– MarekKnows.com
Jan 4 at 15:22
should SetPropertyValueAction 's value also be something other than any?
– MarekKnows.com
Jan 4 at 15:24
1
PropertyKey
is defined in lib.d.ts (the default ts library) it's just any key (a key can bestring | number | symbol
)
– Titian Cernicova-Dragomir
Jan 4 at 15:24
1
@MarekKnows.com I could be .. but you would need to add generics toSetPropertyValueAction
I can provide a sample of what that would look like
– Titian Cernicova-Dragomir
Jan 4 at 15:25
thanks, I'll give this a try and see if the compiler complains about me removing the index signature.
– MarekKnows.com
Jan 4 at 15:26
|
show 1 more comment
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54041309%2fhow-to-add-typescript-type-safety-to-my-redux-action%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
If you need the index signature then there is no way to validate the keys of the type (since after all the index signature would mean the class in indexable by any key, so any key would be valid)
To validate taht a string is a key of a type we can use the keyof
operator, in conjuction with some generic type parameters (to capture the actual key passed in)
interface AppState {
readonly grid : IGridSettings;
readonly selected: ISelectedSettings;
}
interface IGridSettings {
readonly extents : number;
readonly isXY : boolean;
readonly isXZ : boolean;
readonly isYZ : boolean;
readonly spacing: number;
}
interface ISelectedSettings {
readonly bodyColor : number;
readonly colorGlow : number;
readonly lineColor : number;
readonly selection : number | undefined;
}
const setPropertyValue = <KApp extends keyof AppState, KAppProp extends keyof AppState[KApp]>( property : [KApp, KAppProp], value : AppState[KApp][KAppProp] ) : SetPropertyValueAction => ( {
type: 'SET_PROPERTY_VALUE',
payload: {
property,
value,
}
} );
interface SetPropertyValueAction {
type : string;
payload : {
property : PropertyKey;
value : any;
};
}
setPropertyValue( ['grid', 'extents'], 100 );
setPropertyValue( ['grid', 'size'], 100 ); //err
setPropertyValue( ['grid', 'isXY'], -1 ); //err
setPropertyValue( ['selected', 'bodyColor'], '255' );// err
In the interface SetPropertyValueAction, you say that property is of type PropertyKey What is PropertyKey and how is that defined?
– MarekKnows.com
Jan 4 at 15:22
should SetPropertyValueAction 's value also be something other than any?
– MarekKnows.com
Jan 4 at 15:24
1
PropertyKey
is defined in lib.d.ts (the default ts library) it's just any key (a key can bestring | number | symbol
)
– Titian Cernicova-Dragomir
Jan 4 at 15:24
1
@MarekKnows.com I could be .. but you would need to add generics toSetPropertyValueAction
I can provide a sample of what that would look like
– Titian Cernicova-Dragomir
Jan 4 at 15:25
thanks, I'll give this a try and see if the compiler complains about me removing the index signature.
– MarekKnows.com
Jan 4 at 15:26
|
show 1 more comment
If you need the index signature then there is no way to validate the keys of the type (since after all the index signature would mean the class in indexable by any key, so any key would be valid)
To validate taht a string is a key of a type we can use the keyof
operator, in conjuction with some generic type parameters (to capture the actual key passed in)
interface AppState {
readonly grid : IGridSettings;
readonly selected: ISelectedSettings;
}
interface IGridSettings {
readonly extents : number;
readonly isXY : boolean;
readonly isXZ : boolean;
readonly isYZ : boolean;
readonly spacing: number;
}
interface ISelectedSettings {
readonly bodyColor : number;
readonly colorGlow : number;
readonly lineColor : number;
readonly selection : number | undefined;
}
const setPropertyValue = <KApp extends keyof AppState, KAppProp extends keyof AppState[KApp]>( property : [KApp, KAppProp], value : AppState[KApp][KAppProp] ) : SetPropertyValueAction => ( {
type: 'SET_PROPERTY_VALUE',
payload: {
property,
value,
}
} );
interface SetPropertyValueAction {
type : string;
payload : {
property : PropertyKey;
value : any;
};
}
setPropertyValue( ['grid', 'extents'], 100 );
setPropertyValue( ['grid', 'size'], 100 ); //err
setPropertyValue( ['grid', 'isXY'], -1 ); //err
setPropertyValue( ['selected', 'bodyColor'], '255' );// err
In the interface SetPropertyValueAction, you say that property is of type PropertyKey What is PropertyKey and how is that defined?
– MarekKnows.com
Jan 4 at 15:22
should SetPropertyValueAction 's value also be something other than any?
– MarekKnows.com
Jan 4 at 15:24
1
PropertyKey
is defined in lib.d.ts (the default ts library) it's just any key (a key can bestring | number | symbol
)
– Titian Cernicova-Dragomir
Jan 4 at 15:24
1
@MarekKnows.com I could be .. but you would need to add generics toSetPropertyValueAction
I can provide a sample of what that would look like
– Titian Cernicova-Dragomir
Jan 4 at 15:25
thanks, I'll give this a try and see if the compiler complains about me removing the index signature.
– MarekKnows.com
Jan 4 at 15:26
|
show 1 more comment
If you need the index signature then there is no way to validate the keys of the type (since after all the index signature would mean the class in indexable by any key, so any key would be valid)
To validate taht a string is a key of a type we can use the keyof
operator, in conjuction with some generic type parameters (to capture the actual key passed in)
interface AppState {
readonly grid : IGridSettings;
readonly selected: ISelectedSettings;
}
interface IGridSettings {
readonly extents : number;
readonly isXY : boolean;
readonly isXZ : boolean;
readonly isYZ : boolean;
readonly spacing: number;
}
interface ISelectedSettings {
readonly bodyColor : number;
readonly colorGlow : number;
readonly lineColor : number;
readonly selection : number | undefined;
}
const setPropertyValue = <KApp extends keyof AppState, KAppProp extends keyof AppState[KApp]>( property : [KApp, KAppProp], value : AppState[KApp][KAppProp] ) : SetPropertyValueAction => ( {
type: 'SET_PROPERTY_VALUE',
payload: {
property,
value,
}
} );
interface SetPropertyValueAction {
type : string;
payload : {
property : PropertyKey;
value : any;
};
}
setPropertyValue( ['grid', 'extents'], 100 );
setPropertyValue( ['grid', 'size'], 100 ); //err
setPropertyValue( ['grid', 'isXY'], -1 ); //err
setPropertyValue( ['selected', 'bodyColor'], '255' );// err
If you need the index signature then there is no way to validate the keys of the type (since after all the index signature would mean the class in indexable by any key, so any key would be valid)
To validate taht a string is a key of a type we can use the keyof
operator, in conjuction with some generic type parameters (to capture the actual key passed in)
interface AppState {
readonly grid : IGridSettings;
readonly selected: ISelectedSettings;
}
interface IGridSettings {
readonly extents : number;
readonly isXY : boolean;
readonly isXZ : boolean;
readonly isYZ : boolean;
readonly spacing: number;
}
interface ISelectedSettings {
readonly bodyColor : number;
readonly colorGlow : number;
readonly lineColor : number;
readonly selection : number | undefined;
}
const setPropertyValue = <KApp extends keyof AppState, KAppProp extends keyof AppState[KApp]>( property : [KApp, KAppProp], value : AppState[KApp][KAppProp] ) : SetPropertyValueAction => ( {
type: 'SET_PROPERTY_VALUE',
payload: {
property,
value,
}
} );
interface SetPropertyValueAction {
type : string;
payload : {
property : PropertyKey;
value : any;
};
}
setPropertyValue( ['grid', 'extents'], 100 );
setPropertyValue( ['grid', 'size'], 100 ); //err
setPropertyValue( ['grid', 'isXY'], -1 ); //err
setPropertyValue( ['selected', 'bodyColor'], '255' );// err
answered Jan 4 at 15:09
Titian Cernicova-DragomirTitian Cernicova-Dragomir
74.5k35371
74.5k35371
In the interface SetPropertyValueAction, you say that property is of type PropertyKey What is PropertyKey and how is that defined?
– MarekKnows.com
Jan 4 at 15:22
should SetPropertyValueAction 's value also be something other than any?
– MarekKnows.com
Jan 4 at 15:24
1
PropertyKey
is defined in lib.d.ts (the default ts library) it's just any key (a key can bestring | number | symbol
)
– Titian Cernicova-Dragomir
Jan 4 at 15:24
1
@MarekKnows.com I could be .. but you would need to add generics toSetPropertyValueAction
I can provide a sample of what that would look like
– Titian Cernicova-Dragomir
Jan 4 at 15:25
thanks, I'll give this a try and see if the compiler complains about me removing the index signature.
– MarekKnows.com
Jan 4 at 15:26
|
show 1 more comment
In the interface SetPropertyValueAction, you say that property is of type PropertyKey What is PropertyKey and how is that defined?
– MarekKnows.com
Jan 4 at 15:22
should SetPropertyValueAction 's value also be something other than any?
– MarekKnows.com
Jan 4 at 15:24
1
PropertyKey
is defined in lib.d.ts (the default ts library) it's just any key (a key can bestring | number | symbol
)
– Titian Cernicova-Dragomir
Jan 4 at 15:24
1
@MarekKnows.com I could be .. but you would need to add generics toSetPropertyValueAction
I can provide a sample of what that would look like
– Titian Cernicova-Dragomir
Jan 4 at 15:25
thanks, I'll give this a try and see if the compiler complains about me removing the index signature.
– MarekKnows.com
Jan 4 at 15:26
In the interface SetPropertyValueAction, you say that property is of type PropertyKey What is PropertyKey and how is that defined?
– MarekKnows.com
Jan 4 at 15:22
In the interface SetPropertyValueAction, you say that property is of type PropertyKey What is PropertyKey and how is that defined?
– MarekKnows.com
Jan 4 at 15:22
should SetPropertyValueAction 's value also be something other than any?
– MarekKnows.com
Jan 4 at 15:24
should SetPropertyValueAction 's value also be something other than any?
– MarekKnows.com
Jan 4 at 15:24
1
1
PropertyKey
is defined in lib.d.ts (the default ts library) it's just any key (a key can be string | number | symbol
)– Titian Cernicova-Dragomir
Jan 4 at 15:24
PropertyKey
is defined in lib.d.ts (the default ts library) it's just any key (a key can be string | number | symbol
)– Titian Cernicova-Dragomir
Jan 4 at 15:24
1
1
@MarekKnows.com I could be .. but you would need to add generics to
SetPropertyValueAction
I can provide a sample of what that would look like– Titian Cernicova-Dragomir
Jan 4 at 15:25
@MarekKnows.com I could be .. but you would need to add generics to
SetPropertyValueAction
I can provide a sample of what that would look like– Titian Cernicova-Dragomir
Jan 4 at 15:25
thanks, I'll give this a try and see if the compiler complains about me removing the index signature.
– MarekKnows.com
Jan 4 at 15:26
thanks, I'll give this a try and see if the compiler complains about me removing the index signature.
– MarekKnows.com
Jan 4 at 15:26
|
show 1 more comment
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54041309%2fhow-to-add-typescript-type-safety-to-my-redux-action%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Are the index sigantures necessary for your use case or did you just add them to allow indexing ? (ex:
[key : string] : IGridSettings | ISelectedSettings;
)– Titian Cernicova-Dragomir
Jan 4 at 14:57
I needed to add the index signatures to get rid of an error message somewhere along the way. Without them, the TypeScript code would not compile for me.
– MarekKnows.com
Jan 4 at 15:01