You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Argument of type '{ [x: string]: string; d: string; }' is not assignable to parameter of type 'Partial<MyType>'.
Object literal may only specify known properties, and 'd' does not exist in type 'Partial<MyType>'.
however if you do:
/* notice the 'd' in the type of updateProperty */
const subUpdater = (updateProperty: 'a' | 'd', value: string) => {
updater({
[updateProperty]: value,
})
}
it does not error.
Expected behavior:
the type of updateProperty should complain that the string is not compatible with Partial<MyType>
Actual behavior:
no error
The text was updated successfully, but these errors were encountered:
The type of { [updateProperty]: value } should be { "a" : string } | { "d": string } that is currently not the case, and is tracked by #13948. once that is fixed, you should get the error as expected.
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.
TypeScript Version: 2.7.0-dev.201xxxxx (on the playground)
I tried to find a similar issue, but didn't see one.
Code
consider this to start
now let's say I want to make a
subUpdater
that is only responsible for handling a pre-specified set of the properties of MyType but not others.rightly so, you get an error for
d: 'd'
:however if you do:
it does not error.
Expected behavior:
the type of
updateProperty
should complain that the string is not compatible withPartial<MyType>
Actual behavior:
no error
The text was updated successfully, but these errors were encountered: