Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ndr47 opened this issue Dec 24, 2020 · 0 comments

Comments

@ndr47
Copy link

ndr47 commented Dec 24, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant