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

@deprecated appears for any element access that might access a deprecated member #39246

Closed
andrewbranch opened this issue Jun 24, 2020 · 2 comments · Fixed by #39314
Closed
Assignees
Labels
Needs Investigation This issue needs a team member to investigate its status.

Comments

@andrewbranch
Copy link
Member

TypeScript Version: 3.7.x-dev.201xxxxx

Search Terms: deprecated element access

Code

interface Foo {
	/** @deprecated - use `fullName` */
	full_name: string;
	fullName: string;
	email: string;
}

function getFromFoo(foo: Foo, key: keyof Foo) {
	return foo[key];
}

Expected behavior:

Don’t bother me

Actual behavior:

key is crossed out in 'foo[key]'

Playground Link

Related Issues: #33092, #38523

@Kingwl
Copy link
Contributor

Kingwl commented Jun 25, 2020

Thanks! I‘ll take a look

@luke-john
Copy link

This seems like the behaviour you'd want, otherwise the advantages of deprecating disappear.

I would expect the use of Exclude to be required in the provided example to avoid the message.

interface Foo {
	/** @deprecated - use `fullName` */
	full_name: string;
	fullName: string;
	email: string;
}

function getFromFoo(foo: Foo, key: Exclude<keyof Foo, 'full_name'>) {
	return foo[key];
}

Playground Link

@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label Jun 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Investigation This issue needs a team member to investigate its status.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants