Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14901,6 +14901,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
symbol.links.checkFlags & CheckFlags.StripOptional ? removeMissingOrUndefinedType(propType) :
propType;
if (!popTypeResolution()) {
symbol.links.type = errorType;
error(currentNode, Diagnostics.Type_of_property_0_circularly_references_itself_in_mapped_type_1, symbolToString(symbol), typeToString(mappedType));
type = errorType;
}
Expand Down
12 changes: 12 additions & 0 deletions tests/baselines/reference/issue63090.errors.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
issue63090.ts(2,10): error TS2615: Type of property 'M' circularly references itself in mapped type '{ M: any; }'.
issue63090.ts(2,10): error TS2615: Type of property 'M' circularly references itself in mapped type '{ [P in "M"]: any; }'.


==== issue63090.ts (2 errors) ====
type N<T, K extends string> = T | { [P in K]: N<keyof T, K> }[K];
type M = N<number, "M">;
~~~~~~~~~~~~~~
!!! error TS2615: Type of property 'M' circularly references itself in mapped type '{ M: any; }'.
~~~~~~~~~~~~~~
!!! error TS2615: Type of property 'M' circularly references itself in mapped type '{ [P in "M"]: any; }'.

9 changes: 9 additions & 0 deletions tests/baselines/reference/issue63090.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//// [tests/cases/compiler/issue63090.ts] ////

//// [issue63090.ts]
type N<T, K extends string> = T | { [P in K]: N<keyof T, K> }[K];
type M = N<number, "M">;


//// [issue63090.js]
"use strict";
19 changes: 19 additions & 0 deletions tests/baselines/reference/issue63090.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//// [tests/cases/compiler/issue63090.ts] ////

=== issue63090.ts ===
type N<T, K extends string> = T | { [P in K]: N<keyof T, K> }[K];
>N : Symbol(N, Decl(issue63090.ts, 0, 0))
>T : Symbol(T, Decl(issue63090.ts, 0, 7))
>K : Symbol(K, Decl(issue63090.ts, 0, 9))
>T : Symbol(T, Decl(issue63090.ts, 0, 7))
>P : Symbol(P, Decl(issue63090.ts, 0, 37))
>K : Symbol(K, Decl(issue63090.ts, 0, 9))
>N : Symbol(N, Decl(issue63090.ts, 0, 0))
>T : Symbol(T, Decl(issue63090.ts, 0, 7))
>K : Symbol(K, Decl(issue63090.ts, 0, 9))
>K : Symbol(K, Decl(issue63090.ts, 0, 9))

type M = N<number, "M">;
>M : Symbol(M, Decl(issue63090.ts, 0, 65))
>N : Symbol(N, Decl(issue63090.ts, 0, 0))

11 changes: 11 additions & 0 deletions tests/baselines/reference/issue63090.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//// [tests/cases/compiler/issue63090.ts] ////

=== issue63090.ts ===
type N<T, K extends string> = T | { [P in K]: N<keyof T, K> }[K];
>N : N<T, K>
> : ^^^^^^^

type M = N<number, "M">;
>M : any
> : ^^^

2 changes: 2 additions & 0 deletions tests/cases/compiler/issue63090.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
type N<T, K extends string> = T | { [P in K]: N<keyof T, K> }[K];
type M = N<number, "M">;