-
Notifications
You must be signed in to change notification settings - Fork 13.2k
fix(51202): Circular instantiation expression crashing IDEs #51214
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
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
5f43525
fix(51202): serialize circular instantiation expression
a-tarasyuk 770e918
emit declarations
a-tarasyuk 5915024
clone type query node
a-tarasyuk 37aad60
update baseline
a-tarasyuk 1044cb5
Merge branch 'main' of https://github.com/microsoft/TypeScript into f…
a-tarasyuk f0db084
use serializeExistingTypeNode instead of factory.cloneNode
a-tarasyuk 82b6c3c
update baseline
a-tarasyuk 556e22b
add tests
a-tarasyuk 73ba4c0
Merge branch 'main' of https://github.com/microsoft/TypeScript into f…
a-tarasyuk 18084a7
update baseline
a-tarasyuk 69a89be
update baseline
a-tarasyuk 389e1e2
update tests
a-tarasyuk 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
11 changes: 11 additions & 0 deletions
11
tests/baselines/reference/circularInstantiationExpression.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,11 @@ | ||
| //// [circularInstantiationExpression.ts] | ||
| declare function foo<T>(t: T): typeof foo<T>; | ||
| foo(""); | ||
|
|
||
|
|
||
| //// [circularInstantiationExpression.js] | ||
| foo(""); | ||
|
|
||
|
|
||
| //// [circularInstantiationExpression.d.ts] | ||
| declare function foo<T>(t: T): typeof foo<T>; |
12 changes: 12 additions & 0 deletions
12
tests/baselines/reference/circularInstantiationExpression.symbols
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,12 @@ | ||
| === tests/cases/compiler/circularInstantiationExpression.ts === | ||
| declare function foo<T>(t: T): typeof foo<T>; | ||
| >foo : Symbol(foo, Decl(circularInstantiationExpression.ts, 0, 0)) | ||
| >T : Symbol(T, Decl(circularInstantiationExpression.ts, 0, 21)) | ||
| >t : Symbol(t, Decl(circularInstantiationExpression.ts, 0, 24)) | ||
| >T : Symbol(T, Decl(circularInstantiationExpression.ts, 0, 21)) | ||
| >foo : Symbol(foo, Decl(circularInstantiationExpression.ts, 0, 0)) | ||
| >T : Symbol(T, Decl(circularInstantiationExpression.ts, 0, 21)) | ||
|
|
||
| foo(""); | ||
| >foo : Symbol(foo, Decl(circularInstantiationExpression.ts, 0, 0)) | ||
|
|
11 changes: 11 additions & 0 deletions
11
tests/baselines/reference/circularInstantiationExpression.types
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,11 @@ | ||
| === tests/cases/compiler/circularInstantiationExpression.ts === | ||
| declare function foo<T>(t: T): typeof foo<T>; | ||
| >foo : <T>(t: T) => typeof foo<T> | ||
| >t : T | ||
| >foo : <T>(t: T) => typeof foo<T> | ||
|
|
||
| foo(""); | ||
| >foo("") : (t: string) => any | ||
| >foo : <T>(t: T) => (t: T) => any | ||
| >"" : "" | ||
|
|
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
124 changes: 124 additions & 0 deletions
124
tests/baselines/reference/quickInfoCircularInstantiationExpression.baseline
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,124 @@ | ||
| === /tests/cases/fourslash/quickInfoCircularInstantiationExpression.ts === | ||
| // declare function foo<T>(t: T): typeof foo<T>; | ||
| // foo(""); | ||
| // ^^^ | ||
| // | ---------------------------------------------------------------------- | ||
| // | function foo<string>(t: string): (t: string) => ... | ||
| // | ---------------------------------------------------------------------- | ||
|
|
||
| [ | ||
| { | ||
| "marker": { | ||
| "fileName": "/tests/cases/fourslash/quickInfoCircularInstantiationExpression.ts", | ||
| "position": 46, | ||
| "name": "" | ||
| }, | ||
| "item": { | ||
| "kind": "function", | ||
| "kindModifiers": "declare", | ||
| "textSpan": { | ||
| "start": 46, | ||
| "length": 3 | ||
| }, | ||
| "displayParts": [ | ||
| { | ||
| "text": "function", | ||
| "kind": "keyword" | ||
| }, | ||
| { | ||
| "text": " ", | ||
| "kind": "space" | ||
| }, | ||
| { | ||
| "text": "foo", | ||
| "kind": "functionName" | ||
| }, | ||
| { | ||
| "text": "<", | ||
| "kind": "punctuation" | ||
| }, | ||
| { | ||
| "text": "string", | ||
| "kind": "keyword" | ||
| }, | ||
| { | ||
| "text": ">", | ||
| "kind": "punctuation" | ||
| }, | ||
| { | ||
| "text": "(", | ||
| "kind": "punctuation" | ||
| }, | ||
| { | ||
| "text": "t", | ||
| "kind": "parameterName" | ||
| }, | ||
| { | ||
| "text": ":", | ||
| "kind": "punctuation" | ||
| }, | ||
| { | ||
| "text": " ", | ||
| "kind": "space" | ||
| }, | ||
| { | ||
| "text": "string", | ||
| "kind": "keyword" | ||
| }, | ||
| { | ||
| "text": ")", | ||
| "kind": "punctuation" | ||
| }, | ||
| { | ||
| "text": ":", | ||
| "kind": "punctuation" | ||
| }, | ||
| { | ||
| "text": " ", | ||
| "kind": "space" | ||
| }, | ||
| { | ||
| "text": "(", | ||
| "kind": "punctuation" | ||
| }, | ||
| { | ||
| "text": "t", | ||
| "kind": "parameterName" | ||
| }, | ||
| { | ||
| "text": ":", | ||
| "kind": "punctuation" | ||
| }, | ||
| { | ||
| "text": " ", | ||
| "kind": "space" | ||
| }, | ||
| { | ||
| "text": "string", | ||
| "kind": "keyword" | ||
| }, | ||
| { | ||
| "text": ")", | ||
| "kind": "punctuation" | ||
| }, | ||
| { | ||
| "text": " ", | ||
| "kind": "space" | ||
| }, | ||
| { | ||
| "text": "=>", | ||
| "kind": "punctuation" | ||
| }, | ||
| { | ||
| "text": " ", | ||
| "kind": "space" | ||
| }, | ||
| { | ||
| "text": "...", | ||
| "kind": "text" | ||
| } | ||
| ], | ||
| "documentation": [] | ||
| } | ||
| } | ||
| ] |
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,14 @@ | ||
| //// [selfReferentialFunctionType.ts] | ||
| declare function f<T>(args: typeof f<T>): T; | ||
| declare function g<T = typeof g>(args: T): T; | ||
| declare function h<T>(): typeof h<T>; | ||
|
|
||
|
|
||
| //// [selfReferentialFunctionType.js] | ||
| "use strict"; | ||
|
|
||
|
|
||
| //// [selfReferentialFunctionType.d.ts] | ||
| declare function f<T>(args: typeof f<T>): T; | ||
| declare function g<T = typeof g>(args: T): T; | ||
| declare function h<T>(): typeof h<T>; |
23 changes: 23 additions & 0 deletions
23
tests/baselines/reference/selfReferentialFunctionType.symbols
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,23 @@ | ||
| === tests/cases/compiler/selfReferentialFunctionType.ts === | ||
| declare function f<T>(args: typeof f<T>): T; | ||
| >f : Symbol(f, Decl(selfReferentialFunctionType.ts, 0, 0)) | ||
| >T : Symbol(T, Decl(selfReferentialFunctionType.ts, 0, 19)) | ||
| >args : Symbol(args, Decl(selfReferentialFunctionType.ts, 0, 22)) | ||
| >f : Symbol(f, Decl(selfReferentialFunctionType.ts, 0, 0)) | ||
| >T : Symbol(T, Decl(selfReferentialFunctionType.ts, 0, 19)) | ||
| >T : Symbol(T, Decl(selfReferentialFunctionType.ts, 0, 19)) | ||
|
|
||
| declare function g<T = typeof g>(args: T): T; | ||
| >g : Symbol(g, Decl(selfReferentialFunctionType.ts, 0, 44)) | ||
| >T : Symbol(T, Decl(selfReferentialFunctionType.ts, 1, 19)) | ||
| >g : Symbol(g, Decl(selfReferentialFunctionType.ts, 0, 44)) | ||
| >args : Symbol(args, Decl(selfReferentialFunctionType.ts, 1, 33)) | ||
| >T : Symbol(T, Decl(selfReferentialFunctionType.ts, 1, 19)) | ||
| >T : Symbol(T, Decl(selfReferentialFunctionType.ts, 1, 19)) | ||
|
|
||
| declare function h<T>(): typeof h<T>; | ||
| >h : Symbol(h, Decl(selfReferentialFunctionType.ts, 1, 45)) | ||
| >T : Symbol(T, Decl(selfReferentialFunctionType.ts, 2, 19)) | ||
| >h : Symbol(h, Decl(selfReferentialFunctionType.ts, 1, 45)) | ||
| >T : Symbol(T, Decl(selfReferentialFunctionType.ts, 2, 19)) | ||
|
|
15 changes: 15 additions & 0 deletions
15
tests/baselines/reference/selfReferentialFunctionType.types
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,15 @@ | ||
| === tests/cases/compiler/selfReferentialFunctionType.ts === | ||
| declare function f<T>(args: typeof f<T>): T; | ||
| >f : <T>(args: typeof f<T>) => T | ||
| >args : typeof f<T> | ||
| >f : <T>(args: typeof f<T>) => T | ||
|
|
||
| declare function g<T = typeof g>(args: T): T; | ||
| >g : <T = typeof g>(args: T) => T | ||
| >g : <T = typeof g>(args: T) => T | ||
| >args : T | ||
|
|
||
| declare function h<T>(): typeof h<T>; | ||
| >h : <T>() => typeof h<T> | ||
| >h : <T>() => typeof h<T> | ||
|
|
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,3 @@ | ||
| // @declaration: true | ||
| declare function foo<T>(t: T): typeof foo<T>; | ||
| foo(""); | ||
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,6 @@ | ||
| // @strict: true | ||
| // @declaration: true | ||
|
|
||
| declare function f<T>(args: typeof f<T>): T; | ||
| declare function g<T = typeof g>(args: T): T; | ||
| declare function h<T>(): typeof h<T>; |
6 changes: 6 additions & 0 deletions
6
tests/cases/fourslash/quickInfoCircularInstantiationExpression.ts
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,6 @@ | ||
| /// <reference path="fourslash.ts" /> | ||
|
|
||
| ////declare function foo<T>(t: T): typeof foo<T>; | ||
| /////**/foo(""); | ||
|
|
||
| verify.baselineQuickInfo(); |
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.
Uh oh!
There was an error while loading. Please reload this page.