Quramy / tsuquyomi

A Vim plugin for TypeScript

Home Page:http://www.vim.org/scripts/script.php?script_id=5151

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Argument of type 'MyType<E>' is not assignable to parameter of type 'Partial<MyType<E>>'

ndr47 opened this issue · comments

commented

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