Open ndr47 opened 3 years ago
I have a code that give me an error only in VIM. If I try the same code in VisualStudio or Typescript Playground there error disappear.
The error is:
Argument of type 'ElementShape<E>' is not assignable to parameter of type 'Partial<ElementShape<E>>'
This is the code:
const element_def = { element1: { name: { } }, element2: { age: { } } } as const; const element_def_optional = { element1: { title: { } }, element2: { price: { } } } as const; export type ElementName = 'element1' | 'element2'; export type ElementShape<A extends ElementName> = { [k in keyof typeof element_def[A]]: string } & { [k in keyof typeof element_def_optional[A]]?: string }; function process_partial<E extends ElementName>(name: E, partial:Partial<ElementShape<E>>){ console.log(name, partial); } export function process_shape<E extends ElementName>(name: E, shape:ElementShape<E>):void{ process_partial(name, shape); // ~~~ Error: Argument of type 'ElementShape<E>' is not assignable to parameter of type 'Partial<ElementShape<E>>' }
Playground Link
I have a code that give me an error only in VIM. If I try the same code in VisualStudio or Typescript Playground there error disappear.
The error is:
This is the code:
Playground Link