Skip to content

@deprecated strikethrough doesn't appear in many cases, such as JSX elements, const arrow functions, or properties. #39374

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

Open
threehams opened this issue Jul 2, 2020 · 15 comments
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue Rescheduled This issue was previously scheduled to an earlier milestone
Milestone

Comments

@threehams
Copy link

TypeScript Version: 4.0.0-dev.20200701
VS Code Version: 1.47.0-insider commit: b16b467

Search Terms:
deprecated

Code

/** @deprecated */
type Props = {
  /** @deprecated */
  old: string,
  new: string,
}

/** @deprecated */
const Component = (props: Props) => <div />;

<Component old="old" new="new" />

/** @deprecated */
type Options = {
  /** @deprecated */
  old: string;
  new: string;
}

/** @deprecated */
const deprecatedFunction = (options: Options) => {}

deprecatedFunction({
  old: "",
  new: "hi",
});

Expected behavior:
All deprecated usages have strikethrough styles: <Component>, the old prop on Component, deprecatedFunction, old

Actual behavior:
Only props and options have strikethrough styles.
Screenshot - 7_1_2020 , 9_07_19 PM

Playground Link:
Strikethrough isn't visible here, but ... is (just like stable VS Code vs. Insiders).
https://www.typescriptlang.org/play/?jsx=2&ts=4.0.0-beta&ssl=29&ssc=1&pln=1&pc=1#code/JYWwDg9gTgLgBAJQKYEMDG8BmUIjgIilQ3wG4AocgegCoa4ABAEyTCLRRiSbhqvJgBPMEjgAFHGADOcALxwA3uThxa9Zq3aduvfiogAbJgC44UmFGAA7AOYAaZXCtIA7qfOXbDgL6U1jFjYkDi4ePnI0CCtzOABhXEhnK3h5AAo2CGlTCUypAEo5AD44AB4mYAA3VUKKchL48CikZLhDJll8NvwnVw7nF26qQr86AM1g7TD+IRE4AHkwGGAomXklFX8NIJCdcP0jdwtrGwoVfsPPE-JfalGtrVDdCJX4QIfuADEAVysMZas5HBUpklitTAtQdECrJigobm8JqFvr9Ial1q0DgR8A4zq5TPgABbAbHXPIUIA

Related Issues:
None (feature is new to 4.0)

@Kingwl
Copy link
Contributor

Kingwl commented Jul 2, 2020

Thanks, I'll take a look

@threehams
Copy link
Author

All of these show as deprecated in Intellisense suggestions, so something's definitely aware of them.
Screenshot - 7_1_2020 , 9_19_24 PM

@Shinigami92
Copy link

Another case: TS Play

image

@ypresto
Copy link
Contributor

ypresto commented Oct 1, 2021

One cause of this is because current implementation reports deprecation (calling addDeprecatedSuggestion()) for property access (from getPropertyTypeForIndexType()) but not for object literal passed to assignments, jsx attributes, or calls.

Maybe we can place addDeprecatedSuggestion() to some place in checkObjectLiteral() or its callees (or perhaps checkTypeRelatedToAndOptionallyElaborate() where assignability is tested.)

ypresto added a commit to ypresto/TypeScript that referenced this issue Oct 1, 2021
ypresto added a commit to ypresto/TypeScript that referenced this issue Oct 1, 2021
@ypresto
Copy link
Contributor

ypresto commented Oct 1, 2021

Arrow function case is already resolved at least in TS 4.4.3.

@iliubinskii
Copy link

Have the same issue. Sample code:

f();

/**
 * @deprecated
 */
function f(): void {}

function x(): void {}

/**
 * @deprecated
 */
x.y = (): void => {};

x.y();

I get ts warning for "f();" but not for "x.y();"

@robsonvn
Copy link

robsonvn commented Jun 9, 2022

Another example

image

@npalmius
Copy link

One more example here, although admittedly perhaps quite niche:

image

Since whole namespaces can be deprecated, and the hover-message shows the deprecation, I would expect it to be shown strikethrough.

@gund
Copy link

gund commented Nov 1, 2022

I did a little exploration of new TS 4.8 and found that it now tracks deprecations in node/symbol flags.
However it looks like it's unable to link PropertyAssignment symbol to original PropertySignature which is what happens when you declare a prop on typed object where the type has deprecated comment.
This does not happen when you access the prop later on which means that PropertyAccessExpression has a symbol that links to PropertySignature which has a deprecated flag set on it.

Here is a code example that I used.

Here are the screenshots:
Type definition has deprecated flag (on PropertySignature symbol):
image

And property declaration (nor it's identifier) does not (as they have their own PropertyAssignment symbol):
image

And then property access is marked with deprecated flag (via PropertySignature symbol):
image

So the potential fix could be to link PropertyAssignment symbol to original PropertySignature or at least to take deprecation flag from it.

@fbarbare
Copy link

Any updates on this? This would be quite usefull when working on a big shared code-base

@rattrayalex
Copy link

@RyanCavanaugh the lack of this feature influences library API design negatively. Could it be reconsidered for the next minor version?

Without a strikethrough for deprecated methods and parameters, I as a library designer (eg; the openai package) have incentive to hide deprecated things completely from the TS types or make them private, so that users don't inadvertently depend on deprecated functionality.

@BrainCrumbz
Copy link

We were looking for a solution as well and search pointed to this issue. Just to mention a test tried today on deprecated property in TS playground. When referencing the property from the object instance the property is correctly highlighted, as in:

userInfo.sex;

But when creating an object and filling the property, that is not highlighted:

const anotherInfo: AccountInfo = {
  ...
  sex: 'female',
}

Here's the link to playground.

@sandersn
Copy link
Member

sandersn commented Apr 14, 2025

2025 Update: All the originally reported missing strikethroughs are resolved except for property assignments in object literals.

Edit: Unfortunately, the PR that adds the strikethrough there is too risky and has been untouched for 3 years, so it's not a viable fix.

@EKashpersky
Copy link

@sandersn can you share if this gets priority soon? Strikethrough really would help out in my current work prioritising development of new stuff in favour of deprecated, and further codebase refactoring.

@sandersn
Copy link
Member

sandersn commented May 7, 2025

The team is unlikely to have time to look at this because we're busy porting to Go right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue Rescheduled This issue was previously scheduled to an earlier milestone
Projects
None yet
Development

Successfully merging a pull request may close this issue.