-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[release-4.5] Exclude identity relation from mapped type relation che…
…ck (#46635) * Exclude identity relation from mapped type relation check * Add regression test Co-authored-by: Anders Hejlsberg <[email protected]>
- Loading branch information
1 parent
df53f4d
commit b8ee330
Showing
6 changed files
with
141 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
22 changes: 22 additions & 0 deletions
22
tests/baselines/reference/noExcessiveStackDepthError.errors.txt
This file contains 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,22 @@ | ||
tests/cases/compiler/noExcessiveStackDepthError.ts(13,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'FindConditions<any>', but here has type 'FindConditions<Entity>'. | ||
|
||
|
||
==== tests/cases/compiler/noExcessiveStackDepthError.ts (1 errors) ==== | ||
// Repro from #46631 | ||
|
||
interface FindOperator<T> { | ||
foo: T; | ||
} | ||
|
||
type FindConditions<T> = { | ||
[P in keyof T]?: FindConditions<T[P]> | FindOperator<FindConditions<T[P]>>; | ||
}; | ||
|
||
function foo<Entity>() { | ||
var x: FindConditions<any>; | ||
var x: FindConditions<Entity>; // Excessive stack depth error not expected here | ||
~ | ||
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'FindConditions<any>', but here has type 'FindConditions<Entity>'. | ||
!!! related TS6203 tests/cases/compiler/noExcessiveStackDepthError.ts:12:9: 'x' was also declared here. | ||
} | ||
|
This file contains 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,34 @@ | ||
//// [noExcessiveStackDepthError.ts] | ||
// Repro from #46631 | ||
|
||
interface FindOperator<T> { | ||
foo: T; | ||
} | ||
|
||
type FindConditions<T> = { | ||
[P in keyof T]?: FindConditions<T[P]> | FindOperator<FindConditions<T[P]>>; | ||
}; | ||
|
||
function foo<Entity>() { | ||
var x: FindConditions<any>; | ||
var x: FindConditions<Entity>; // Excessive stack depth error not expected here | ||
} | ||
|
||
|
||
//// [noExcessiveStackDepthError.js] | ||
"use strict"; | ||
// Repro from #46631 | ||
function foo() { | ||
var x; | ||
var x; // Excessive stack depth error not expected here | ||
} | ||
|
||
|
||
//// [noExcessiveStackDepthError.d.ts] | ||
interface FindOperator<T> { | ||
foo: T; | ||
} | ||
declare type FindConditions<T> = { | ||
[P in keyof T]?: FindConditions<T[P]> | FindOperator<FindConditions<T[P]>>; | ||
}; | ||
declare function foo<Entity>(): void; |
43 changes: 43 additions & 0 deletions
43
tests/baselines/reference/noExcessiveStackDepthError.symbols
This file contains 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,43 @@ | ||
=== tests/cases/compiler/noExcessiveStackDepthError.ts === | ||
// Repro from #46631 | ||
|
||
interface FindOperator<T> { | ||
>FindOperator : Symbol(FindOperator, Decl(noExcessiveStackDepthError.ts, 0, 0)) | ||
>T : Symbol(T, Decl(noExcessiveStackDepthError.ts, 2, 23)) | ||
|
||
foo: T; | ||
>foo : Symbol(FindOperator.foo, Decl(noExcessiveStackDepthError.ts, 2, 27)) | ||
>T : Symbol(T, Decl(noExcessiveStackDepthError.ts, 2, 23)) | ||
} | ||
|
||
type FindConditions<T> = { | ||
>FindConditions : Symbol(FindConditions, Decl(noExcessiveStackDepthError.ts, 4, 1)) | ||
>T : Symbol(T, Decl(noExcessiveStackDepthError.ts, 6, 20)) | ||
|
||
[P in keyof T]?: FindConditions<T[P]> | FindOperator<FindConditions<T[P]>>; | ||
>P : Symbol(P, Decl(noExcessiveStackDepthError.ts, 7, 5)) | ||
>T : Symbol(T, Decl(noExcessiveStackDepthError.ts, 6, 20)) | ||
>FindConditions : Symbol(FindConditions, Decl(noExcessiveStackDepthError.ts, 4, 1)) | ||
>T : Symbol(T, Decl(noExcessiveStackDepthError.ts, 6, 20)) | ||
>P : Symbol(P, Decl(noExcessiveStackDepthError.ts, 7, 5)) | ||
>FindOperator : Symbol(FindOperator, Decl(noExcessiveStackDepthError.ts, 0, 0)) | ||
>FindConditions : Symbol(FindConditions, Decl(noExcessiveStackDepthError.ts, 4, 1)) | ||
>T : Symbol(T, Decl(noExcessiveStackDepthError.ts, 6, 20)) | ||
>P : Symbol(P, Decl(noExcessiveStackDepthError.ts, 7, 5)) | ||
|
||
}; | ||
|
||
function foo<Entity>() { | ||
>foo : Symbol(foo, Decl(noExcessiveStackDepthError.ts, 8, 2)) | ||
>Entity : Symbol(Entity, Decl(noExcessiveStackDepthError.ts, 10, 13)) | ||
|
||
var x: FindConditions<any>; | ||
>x : Symbol(x, Decl(noExcessiveStackDepthError.ts, 11, 7), Decl(noExcessiveStackDepthError.ts, 12, 7)) | ||
>FindConditions : Symbol(FindConditions, Decl(noExcessiveStackDepthError.ts, 4, 1)) | ||
|
||
var x: FindConditions<Entity>; // Excessive stack depth error not expected here | ||
>x : Symbol(x, Decl(noExcessiveStackDepthError.ts, 11, 7), Decl(noExcessiveStackDepthError.ts, 12, 7)) | ||
>FindConditions : Symbol(FindConditions, Decl(noExcessiveStackDepthError.ts, 4, 1)) | ||
>Entity : Symbol(Entity, Decl(noExcessiveStackDepthError.ts, 10, 13)) | ||
} | ||
|
24 changes: 24 additions & 0 deletions
24
tests/baselines/reference/noExcessiveStackDepthError.types
This file contains 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,24 @@ | ||
=== tests/cases/compiler/noExcessiveStackDepthError.ts === | ||
// Repro from #46631 | ||
|
||
interface FindOperator<T> { | ||
foo: T; | ||
>foo : T | ||
} | ||
|
||
type FindConditions<T> = { | ||
>FindConditions : FindConditions<T> | ||
|
||
[P in keyof T]?: FindConditions<T[P]> | FindOperator<FindConditions<T[P]>>; | ||
}; | ||
|
||
function foo<Entity>() { | ||
>foo : <Entity>() => void | ||
|
||
var x: FindConditions<any>; | ||
>x : FindConditions<any> | ||
|
||
var x: FindConditions<Entity>; // Excessive stack depth error not expected here | ||
>x : FindConditions<any> | ||
} | ||
|
This file contains 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,17 @@ | ||
// @strict: true | ||
// @declaration: true | ||
|
||
// Repro from #46631 | ||
|
||
interface FindOperator<T> { | ||
foo: T; | ||
} | ||
|
||
type FindConditions<T> = { | ||
[P in keyof T]?: FindConditions<T[P]> | FindOperator<FindConditions<T[P]>>; | ||
}; | ||
|
||
function foo<Entity>() { | ||
var x: FindConditions<any>; | ||
var x: FindConditions<Entity>; // Excessive stack depth error not expected here | ||
} |