-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Generate names for type parameter declarations in inferred types #23902
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
Merged
weswigham
merged 5 commits into
microsoft:master
from
weswigham:declarations-synthesized-typeparams
May 10, 2018
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
68aac01
Generate names for type parameter declarations in inferred types
weswigham 37cedfe
Fix lint
weswigham 3844436
Merge functions, make overload private
weswigham 8278039
Handle some edge cases better (nodes in differing files than current …
weswigham ae14266
Account for transformed nodes
weswigham File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3031,7 +3031,7 @@ namespace ts { | |
// Options | ||
NoTruncation = 1 << 0, // Don't truncate result | ||
WriteArrayAsGenericType = 1 << 1, // Write Array<T> instead T[] | ||
// empty space | ||
GenerateNamesForShadowedTypeParams = 1 << 2, // When a type parameter T is shadowing another T, generate a name for it so it can still be referenced | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why does this need a flag? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't wanna bother renaming the conflicts in quickinfo and signature help, at least in my opinion. |
||
UseStructuralFallback = 1 << 3, // When an alias cannot be named by its symbol, rather than report an error, fallback to a structural printout if possible | ||
// empty space | ||
WriteTypeArgumentsOfSignature = 1 << 5, // Write the type arguments instead of type parameters of the signature | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
tests/baselines/reference/declarationEmitNestedGenerics.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
//// [declarationEmitNestedGenerics.ts] | ||
function f<T>(p: T) { | ||
let g: <T>(x: T) => typeof p = null as any; | ||
return g; | ||
} | ||
|
||
function g<T>(x: T) { | ||
let y: typeof x extends (infer T)[] ? T : typeof x = null as any; | ||
return y; | ||
} | ||
|
||
//// [declarationEmitNestedGenerics.js] | ||
function f(p) { | ||
var g = null; | ||
return g; | ||
} | ||
function g(x) { | ||
var y = null; | ||
return y; | ||
} | ||
|
||
|
||
//// [declarationEmitNestedGenerics.d.ts] | ||
declare function f<T>(p: T): <T_1>(x: T_1) => T; | ||
declare function g<T>(x: T): T extends (infer T_1)[] ? T_1 : T; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Anything that goes in
generatedNames
is already reserved throughout the entire generated output, so scoping these doesn't seem to make any sense. Why was this needed?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.
scoped
causes it to go intoreservedNames
instead ofgeneratedNames
; this allows, eg,T_1
to be reused in adjacent scopes.