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
interfaceIItem{id: string;isOpen: boolean;}interfaceIRecord{id: string;}typeUpsertable<T>=Partial<T>&{id: string;};classA<TextendsIItem=IItem>{protectedsetItem(partialItem: Upsertable<T>): void{}}interfaceIMyItemextendsIItem{title: string;}classB<TextendsIMyItem>extendsA<T>{constructor(){super();constid: string='uniqueId';constisOpen: boolean=false;this.setItem({ id, isOpen });// error here: // Argument of type '{ id: string; isOpen: boolean; }' is not assignable to parameter of type 'Upsertable<T>'.// Type '{ id: string; isOpen: boolean; }' is not assignable to type 'Partial<T>'.}}
Expected behavior:
The given properties are valid with the type IMyItem, which in turn extends from IItem, and as all properties bar id are optional, having only isOpen and id should be fine.
Actual behavior:
Errors with Argument of type '{ id: string; isOpen: boolean; }' is not assignable to parameter of type 'Upsertable<T>'. Type '{ id: string; isOpen: boolean; }' is not assignable to type 'Partial<T>'.
Uh oh!
There was an error while loading. Please reload this page.
TypeScript Version: 3.1.1-insiders.20180925
Search Terms:
is not assignable to, partial
Code
Expected behavior:
The given properties are valid with the type IMyItem, which in turn extends from IItem, and as all properties bar id are optional, having only
isOpen
andid
should be fine.Actual behavior:
Errors with
Argument of type '{ id: string; isOpen: boolean; }' is not assignable to parameter of type 'Upsertable<T>'. Type '{ id: string; isOpen: boolean; }' is not assignable to type 'Partial<T>'.
Playground Link:
http://www.typescriptlang.org/play/#src=interface%20IItem%20%7B%0D%0A%20%20id%3A%20string%3B%0D%0A%20%20isOpen%3A%20boolean%3B%0D%0A%7D%0D%0A%0D%0Ainterface%20IRecord%20%7B%0D%0A%20%20id%3A%20string%3B%0D%0A%7D%0D%0A%0D%0Atype%20Upsertable%3CT%3E%20%3D%20Partial%3CT%3E%20%26%20%7B%20id%3A%20string%3B%20%7D%3B%0D%0A%0D%0Aclass%20A%3CT%20extends%20IItem%20%3D%20IItem%3E%20%7B%0D%0A%20%20protected%20setItem(partialItem%3A%20Upsertable%3CT%3E)%3A%20void%20%7B%0D%0A%0D%0A%20%20%7D%0D%0A%7D%0D%0A%0D%0Ainterface%20IMyItem%20extends%20IItem%20%7B%0D%0A%20%20title%3A%20string%3B%0D%0A%7D%0D%0A%0D%0Aclass%20B%3CT%20extends%20IMyItem%3E%20extends%20A%3CT%3E%20%7B%0D%0A%20%20constructor()%20%7B%0D%0A%20%20%20%20super()%3B%0D%0A%20%20%20%20const%20id%3A%20string%20%3D%20'uniqueId'%3B%0D%0A%20%20%20%20const%20isOpen%3A%20boolean%20%3D%20false%3B%0D%0A%20%20%20%20this.setItem(%7B%20id%2C%20isOpen%20%7D)%3B%0D%0A%20%20%7D%0D%0A%7D
Related Issues:
Maybe this bug: #12731?
The text was updated successfully, but these errors were encountered: