-
Notifications
You must be signed in to change notification settings - Fork 12.8k
support overload signature for deprecated. #39221
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
Conversation
@typescript-bot perf test. |
Heya @Kingwl, I've started to run the perf test suite on this PR at 482a4d3. You can monitor the build here. Update: The results are in! |
Hey @Kingwl, I've packed this into an installable tgz. You can install it for testing by referencing it in your
and then running There is also a playground for this build. |
@Kingwl Here they are:Comparison Report - master..39221
System
Hosts
Scenarios
|
@typescript-bot perf test. |
Heya @Kingwl, I've started to run the perf test suite on this PR at 482a4d3. You can monitor the build here. Update: The results are in! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also try to change it up so that we report the "x is deprecated" suggestion when a call resolves to one of the deprecated signatures?
@Kingwl Here they are:Comparison Report - master..39221
System
Hosts
Scenarios
|
Update for rules. Let me know if something is incorrect. |
@DanielRosenwasser this look good to you? It looks like it resolves the issue pretty well to me. |
@mjbvz please look at this changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of minor changes, but the big one is that we need to make sure performance is still OK, because this adds a symbol property and does work in the binder for every signature, even non-deprecated ones.
src/compiler/binder.ts
Outdated
else if (hasDeprecated) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else if (hasDeprecated) { | |
else if (hasDeprecated) { |
src/compiler/types.ts
Outdated
@@ -4592,6 +4592,7 @@ namespace ts { | |||
/* @internal */ isReplaceableByMethod?: boolean; // Can this Javascript class property be replaced by a method symbol? | |||
/* @internal */ isAssigned?: boolean; // True if the symbol is a parameter with assignments | |||
/* @internal */ assignmentDeclarationMembers?: Map<Declaration>; // detected late-bound assignment declarations associated with the symbol | |||
/* @internal */ allSignatureDeprecated?: boolean; // All signatures have the deprecated tag |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add an s: allSignaturesDeprecated
src/compiler/binder.ts
Outdated
symbol.flags &= ~SymbolFlags.Deprecated; | ||
} | ||
} | ||
else if (hasDeprecated) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merged signatures/other things will end up deprecating the whole thing, right?
/** @deprecated */
interface F { }
function F() { }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Later: No, the code correctly unsets the flag, but please add a test like this (or point me to an existing one).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had the same fear - I don't really understand why it needs to check the symbol if the resolved signature is already there though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because to avoid duplicate diagnostic. eg:
/* @deprecated */
declare function foo (); void;
foo;
~~~ // foo is deprecated. checked by identifier
foo();
~~~ // foo is deprecated. checked by identifier
~~~~~ // (): void is deprecated. checked by callExpression
@typescript-bot perf test. |
Heya @Kingwl, I've started to run the perf test suite on this PR at fcd722a. You can monitor the build here. Update: The results are in! |
@Kingwl Here they are:Comparison Report - master..39221
System
Hosts
Scenarios
|
@typescript-bot perf test. |
Heya @Kingwl, I've started to run the perf test suite on this PR at fcd722a. You can monitor the build here. Update: The results are in! |
@Kingwl Here they are:Comparison Report - master..39221
System
Hosts
Scenarios
|
After discussing this one-on-one, I think the best thing is to switch away from SymbolFlags.Deprecated and make the checker look at NodeFlags.Deprecated for specific declarations. |
@typescript-bot perf test. |
Heya @Kingwl, I've started to run the perf test suite on this PR at 2410ea6. You can monitor the build here. Update: The results are in! |
@typescript-bot perf test. |
Heya @Kingwl, I've started to run the perf test suite on this PR at aab7a32. You can monitor the build here. Update: The results are in! |
@Kingwl Here they are:Comparison Report - master..39221
System
Hosts
Scenarios
|
@Kingwl Here they are:Comparison Report - master..39221
System
Hosts
Scenarios
|
@typescript-bot perf test. |
Heya @Kingwl, I've started to run the perf test suite on this PR at aab7a32. You can monitor the build here. Update: The results are in! |
@Kingwl Here they are:Comparison Report - master..39221
System
Hosts
Scenarios
|
0dcf09c
to
c1911f6
Compare
This reverts commit d7a7297.
c1911f6
to
11340da
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a pretty good fix now. It just needs to use SymbolLinks instead of Symbol.
After that's done, let's just take whichever is faster, this or #39323.
src/compiler/utilities.ts
Outdated
} | ||
|
||
export function getDeprecatedFlags(symbol: Symbol) { | ||
if (symbol.flags & SymbolFlags.Deprecated) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of modifying Symbol
, please using SymbolLinks
with getSymbolLinks
to cache deprecatedFlags
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(the function should also move into the checker; pretty sure getSymbolLinks is not exported)
src/compiler/utilities.ts
Outdated
} | ||
|
||
export function getDeprecatedFlags(symbol: Symbol) { | ||
if (symbol.flags & SymbolFlags.Deprecated) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would invert the symbol.flags & SymbolFlags.Deprecated
check to immediately return None.
@typescript-bot pack this. |
Hey @Kingwl, I've packed this into an installable tgz. You can install it for testing by referencing it in your
and then running There is also a playground for this build. |
@typescript-bot perf test. |
Heya @Kingwl, I've started to run the perf test suite on this PR at 11340da. You can monitor the build here. Update: The results are in! |
@Kingwl Here they are:Comparison Report - master..39221
System
Hosts
Scenarios
|
@typescript-bot perf test. |
Heya @Kingwl, I've started to run the perf test suite on this PR at 2dd4148. You can monitor the build here. Update: The results are in! |
@Kingwl Here they are:Comparison Report - master..39221
System
Hosts
Scenarios
|
Fixes #39212
This or follow the below rules: