diff --git a/tests/baselines/reference/substitutionTypesInIndexedAccessTypes.js b/tests/baselines/reference/substitutionTypesInIndexedAccessTypes.js new file mode 100644 index 0000000000000..c8a8ad5f227e7 --- /dev/null +++ b/tests/baselines/reference/substitutionTypesInIndexedAccessTypes.js @@ -0,0 +1,30 @@ +//// [substitutionTypesInIndexedAccessTypes.ts] +// Repro from #31086 + +type UserArgs = { + select?: boolean +}; + +type Subset = { [key in keyof T]: key extends keyof U ? T[key] : never }; + +declare function withBoundary(args?: Subset): T; +declare function withoutBoundary(args?: T): T; + +const boundaryResult = withBoundary({ + select: true, +}); + +const withoutBoundaryResult = withoutBoundary({ + select: true, +}); + + +//// [substitutionTypesInIndexedAccessTypes.js] +"use strict"; +// Repro from #31086 +var boundaryResult = withBoundary({ + select: true +}); +var withoutBoundaryResult = withoutBoundary({ + select: true +}); diff --git a/tests/baselines/reference/substitutionTypesInIndexedAccessTypes.symbols b/tests/baselines/reference/substitutionTypesInIndexedAccessTypes.symbols new file mode 100644 index 0000000000000..a0633c2320ec1 --- /dev/null +++ b/tests/baselines/reference/substitutionTypesInIndexedAccessTypes.symbols @@ -0,0 +1,58 @@ +=== tests/cases/compiler/substitutionTypesInIndexedAccessTypes.ts === +// Repro from #31086 + +type UserArgs = { +>UserArgs : Symbol(UserArgs, Decl(substitutionTypesInIndexedAccessTypes.ts, 0, 0)) + + select?: boolean +>select : Symbol(select, Decl(substitutionTypesInIndexedAccessTypes.ts, 2, 17)) + +}; + +type Subset = { [key in keyof T]: key extends keyof U ? T[key] : never }; +>Subset : Symbol(Subset, Decl(substitutionTypesInIndexedAccessTypes.ts, 4, 2)) +>T : Symbol(T, Decl(substitutionTypesInIndexedAccessTypes.ts, 6, 12)) +>U : Symbol(U, Decl(substitutionTypesInIndexedAccessTypes.ts, 6, 14)) +>key : Symbol(key, Decl(substitutionTypesInIndexedAccessTypes.ts, 6, 23)) +>T : Symbol(T, Decl(substitutionTypesInIndexedAccessTypes.ts, 6, 12)) +>key : Symbol(key, Decl(substitutionTypesInIndexedAccessTypes.ts, 6, 23)) +>U : Symbol(U, Decl(substitutionTypesInIndexedAccessTypes.ts, 6, 14)) +>T : Symbol(T, Decl(substitutionTypesInIndexedAccessTypes.ts, 6, 12)) +>key : Symbol(key, Decl(substitutionTypesInIndexedAccessTypes.ts, 6, 23)) + +declare function withBoundary(args?: Subset): T; +>withBoundary : Symbol(withBoundary, Decl(substitutionTypesInIndexedAccessTypes.ts, 6, 79)) +>T : Symbol(T, Decl(substitutionTypesInIndexedAccessTypes.ts, 8, 30)) +>UserArgs : Symbol(UserArgs, Decl(substitutionTypesInIndexedAccessTypes.ts, 0, 0)) +>args : Symbol(args, Decl(substitutionTypesInIndexedAccessTypes.ts, 8, 50)) +>Subset : Symbol(Subset, Decl(substitutionTypesInIndexedAccessTypes.ts, 4, 2)) +>T : Symbol(T, Decl(substitutionTypesInIndexedAccessTypes.ts, 8, 30)) +>UserArgs : Symbol(UserArgs, Decl(substitutionTypesInIndexedAccessTypes.ts, 0, 0)) +>T : Symbol(T, Decl(substitutionTypesInIndexedAccessTypes.ts, 8, 30)) + +declare function withoutBoundary(args?: T): T; +>withoutBoundary : Symbol(withoutBoundary, Decl(substitutionTypesInIndexedAccessTypes.ts, 8, 81)) +>T : Symbol(T, Decl(substitutionTypesInIndexedAccessTypes.ts, 9, 33)) +>UserArgs : Symbol(UserArgs, Decl(substitutionTypesInIndexedAccessTypes.ts, 0, 0)) +>args : Symbol(args, Decl(substitutionTypesInIndexedAccessTypes.ts, 9, 53)) +>T : Symbol(T, Decl(substitutionTypesInIndexedAccessTypes.ts, 9, 33)) +>T : Symbol(T, Decl(substitutionTypesInIndexedAccessTypes.ts, 9, 33)) + +const boundaryResult = withBoundary({ +>boundaryResult : Symbol(boundaryResult, Decl(substitutionTypesInIndexedAccessTypes.ts, 11, 5)) +>withBoundary : Symbol(withBoundary, Decl(substitutionTypesInIndexedAccessTypes.ts, 6, 79)) + + select: true, +>select : Symbol(select, Decl(substitutionTypesInIndexedAccessTypes.ts, 11, 37)) + +}); + +const withoutBoundaryResult = withoutBoundary({ +>withoutBoundaryResult : Symbol(withoutBoundaryResult, Decl(substitutionTypesInIndexedAccessTypes.ts, 15, 5)) +>withoutBoundary : Symbol(withoutBoundary, Decl(substitutionTypesInIndexedAccessTypes.ts, 8, 81)) + + select: true, +>select : Symbol(select, Decl(substitutionTypesInIndexedAccessTypes.ts, 15, 47)) + +}); + diff --git a/tests/baselines/reference/substitutionTypesInIndexedAccessTypes.types b/tests/baselines/reference/substitutionTypesInIndexedAccessTypes.types new file mode 100644 index 0000000000000..df7e4af01e618 --- /dev/null +++ b/tests/baselines/reference/substitutionTypesInIndexedAccessTypes.types @@ -0,0 +1,46 @@ +=== tests/cases/compiler/substitutionTypesInIndexedAccessTypes.ts === +// Repro from #31086 + +type UserArgs = { +>UserArgs : UserArgs + + select?: boolean +>select : boolean | undefined + +}; + +type Subset = { [key in keyof T]: key extends keyof U ? T[key] : never }; +>Subset : Subset + +declare function withBoundary(args?: Subset): T; +>withBoundary : (args?: Subset | undefined) => T +>args : Subset | undefined + +declare function withoutBoundary(args?: T): T; +>withoutBoundary : (args?: T | undefined) => T +>args : T | undefined + +const boundaryResult = withBoundary({ +>boundaryResult : { select: true; } +>withBoundary({ select: true,}) : { select: true; } +>withBoundary : (args?: Subset | undefined) => T +>{ select: true,} : { select: true; } + + select: true, +>select : true +>true : true + +}); + +const withoutBoundaryResult = withoutBoundary({ +>withoutBoundaryResult : { select: true; } +>withoutBoundary({ select: true,}) : { select: true; } +>withoutBoundary : (args?: T | undefined) => T +>{ select: true,} : { select: true; } + + select: true, +>select : true +>true : true + +}); +