-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cache instantiation expression types early enough to prevent reentran…
…cy during printback (#59931)
- Loading branch information
Showing
8 changed files
with
204 additions
and
2 deletions.
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
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
28 changes: 28 additions & 0 deletions
28
tests/baselines/reference/instantiationExpressionErrorNoCrash.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,28 @@ | ||
instantiationExpressionErrorNoCrash.ts(15,38): error TS2344: Type 'typeof createCacheReducer<QR>' does not satisfy the constraint '(...args: any) => any'. | ||
Type 'typeof createCacheReducer<QR>' provides no match for the signature '(...args: any): any'. | ||
instantiationExpressionErrorNoCrash.ts(15,64): error TS2635: Type '<N extends string, QR>(queries: { [QK in keyof QR]: any; }) => (state?: { queries: QR; }) => { queries: QR; }' has no signatures for which the type argument list is applicable. | ||
|
||
|
||
==== instantiationExpressionErrorNoCrash.ts (2 errors) ==== | ||
const createCacheReducer = <N extends string, QR>( | ||
queries: Cache<N, QR>["queries"], | ||
) => { | ||
const queriesMap = {} as QR; | ||
|
||
const initialState = { | ||
queries: queriesMap, | ||
}; | ||
|
||
return (state = initialState) => state; | ||
}; | ||
|
||
export type Cache<N extends string, QR> = { | ||
queries: { | ||
[QK in keyof QR]: ReturnType<typeof createCacheReducer<QR>>; | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
!!! error TS2344: Type 'typeof createCacheReducer<QR>' does not satisfy the constraint '(...args: any) => any'. | ||
!!! error TS2344: Type 'typeof createCacheReducer<QR>' provides no match for the signature '(...args: any): any'. | ||
~~ | ||
!!! error TS2635: Type '<N extends string, QR>(queries: { [QK in keyof QR]: any; }) => (state?: { queries: QR; }) => { queries: QR; }' has no signatures for which the type argument list is applicable. | ||
}; | ||
}; |
34 changes: 34 additions & 0 deletions
34
tests/baselines/reference/instantiationExpressionErrorNoCrash.js
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 @@ | ||
//// [tests/cases/compiler/instantiationExpressionErrorNoCrash.ts] //// | ||
|
||
//// [instantiationExpressionErrorNoCrash.ts] | ||
const createCacheReducer = <N extends string, QR>( | ||
queries: Cache<N, QR>["queries"], | ||
) => { | ||
const queriesMap = {} as QR; | ||
|
||
const initialState = { | ||
queries: queriesMap, | ||
}; | ||
|
||
return (state = initialState) => state; | ||
}; | ||
|
||
export type Cache<N extends string, QR> = { | ||
queries: { | ||
[QK in keyof QR]: ReturnType<typeof createCacheReducer<QR>>; | ||
}; | ||
}; | ||
|
||
//// [instantiationExpressionErrorNoCrash.js] | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var createCacheReducer = function (queries) { | ||
var queriesMap = {}; | ||
var initialState = { | ||
queries: queriesMap, | ||
}; | ||
return function (state) { | ||
if (state === void 0) { state = initialState; } | ||
return state; | ||
}; | ||
}; |
52 changes: 52 additions & 0 deletions
52
tests/baselines/reference/instantiationExpressionErrorNoCrash.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,52 @@ | ||
//// [tests/cases/compiler/instantiationExpressionErrorNoCrash.ts] //// | ||
|
||
=== instantiationExpressionErrorNoCrash.ts === | ||
const createCacheReducer = <N extends string, QR>( | ||
>createCacheReducer : Symbol(createCacheReducer, Decl(instantiationExpressionErrorNoCrash.ts, 0, 5)) | ||
>N : Symbol(N, Decl(instantiationExpressionErrorNoCrash.ts, 0, 28)) | ||
>QR : Symbol(QR, Decl(instantiationExpressionErrorNoCrash.ts, 0, 45)) | ||
|
||
queries: Cache<N, QR>["queries"], | ||
>queries : Symbol(queries, Decl(instantiationExpressionErrorNoCrash.ts, 0, 50)) | ||
>Cache : Symbol(Cache, Decl(instantiationExpressionErrorNoCrash.ts, 10, 2)) | ||
>N : Symbol(N, Decl(instantiationExpressionErrorNoCrash.ts, 0, 28)) | ||
>QR : Symbol(QR, Decl(instantiationExpressionErrorNoCrash.ts, 0, 45)) | ||
|
||
) => { | ||
const queriesMap = {} as QR; | ||
>queriesMap : Symbol(queriesMap, Decl(instantiationExpressionErrorNoCrash.ts, 3, 9)) | ||
>QR : Symbol(QR, Decl(instantiationExpressionErrorNoCrash.ts, 0, 45)) | ||
|
||
const initialState = { | ||
>initialState : Symbol(initialState, Decl(instantiationExpressionErrorNoCrash.ts, 5, 9)) | ||
|
||
queries: queriesMap, | ||
>queries : Symbol(queries, Decl(instantiationExpressionErrorNoCrash.ts, 5, 26)) | ||
>queriesMap : Symbol(queriesMap, Decl(instantiationExpressionErrorNoCrash.ts, 3, 9)) | ||
|
||
}; | ||
|
||
return (state = initialState) => state; | ||
>state : Symbol(state, Decl(instantiationExpressionErrorNoCrash.ts, 9, 12)) | ||
>initialState : Symbol(initialState, Decl(instantiationExpressionErrorNoCrash.ts, 5, 9)) | ||
>state : Symbol(state, Decl(instantiationExpressionErrorNoCrash.ts, 9, 12)) | ||
|
||
}; | ||
|
||
export type Cache<N extends string, QR> = { | ||
>Cache : Symbol(Cache, Decl(instantiationExpressionErrorNoCrash.ts, 10, 2)) | ||
>N : Symbol(N, Decl(instantiationExpressionErrorNoCrash.ts, 12, 18)) | ||
>QR : Symbol(QR, Decl(instantiationExpressionErrorNoCrash.ts, 12, 35)) | ||
|
||
queries: { | ||
>queries : Symbol(queries, Decl(instantiationExpressionErrorNoCrash.ts, 12, 43)) | ||
|
||
[QK in keyof QR]: ReturnType<typeof createCacheReducer<QR>>; | ||
>QK : Symbol(QK, Decl(instantiationExpressionErrorNoCrash.ts, 14, 9)) | ||
>QR : Symbol(QR, Decl(instantiationExpressionErrorNoCrash.ts, 12, 35)) | ||
>ReturnType : Symbol(ReturnType, Decl(lib.es5.d.ts, --, --)) | ||
>createCacheReducer : Symbol(createCacheReducer, Decl(instantiationExpressionErrorNoCrash.ts, 0, 5)) | ||
>QR : Symbol(QR, Decl(instantiationExpressionErrorNoCrash.ts, 12, 35)) | ||
|
||
}; | ||
}; |
62 changes: 62 additions & 0 deletions
62
tests/baselines/reference/instantiationExpressionErrorNoCrash.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,62 @@ | ||
//// [tests/cases/compiler/instantiationExpressionErrorNoCrash.ts] //// | ||
|
||
=== instantiationExpressionErrorNoCrash.ts === | ||
const createCacheReducer = <N extends string, QR>( | ||
>createCacheReducer : <N extends string, QR>(queries: Cache<N, QR>["queries"]) => (state?: { queries: QR; }) => { queries: QR; } | ||
> : ^ ^^^^^^^^^ ^^ ^^ ^^ ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
><N extends string, QR>( queries: Cache<N, QR>["queries"],) => { const queriesMap = {} as QR; const initialState = { queries: queriesMap, }; return (state = initialState) => state;} : <N extends string, QR>(queries: Cache<N, QR>["queries"]) => (state?: { queries: QR; }) => { queries: QR; } | ||
> : ^ ^^^^^^^^^ ^^ ^^ ^^ ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
queries: Cache<N, QR>["queries"], | ||
>queries : { [QK in keyof QR]: any; } | ||
> : ^^^ ^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
) => { | ||
const queriesMap = {} as QR; | ||
>queriesMap : QR | ||
> : ^^ | ||
>{} as QR : QR | ||
> : ^^ | ||
>{} : {} | ||
> : ^^ | ||
|
||
const initialState = { | ||
>initialState : { queries: QR; } | ||
> : ^^^^^^^^^^^^^^^^ | ||
>{ queries: queriesMap, } : { queries: QR; } | ||
> : ^^^^^^^^^^^^^^^^ | ||
|
||
queries: queriesMap, | ||
>queries : QR | ||
> : ^^ | ||
>queriesMap : QR | ||
> : ^^ | ||
|
||
}; | ||
|
||
return (state = initialState) => state; | ||
>(state = initialState) => state : (state?: { queries: QR; }) => { queries: QR; } | ||
> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
>state : { queries: QR; } | ||
> : ^^^^^^^^^^^^^^^^ | ||
>initialState : { queries: QR; } | ||
> : ^^^^^^^^^^^^^^^^ | ||
>state : { queries: QR; } | ||
> : ^^^^^^^^^^^^^^^^ | ||
|
||
}; | ||
|
||
export type Cache<N extends string, QR> = { | ||
>Cache : Cache<N, QR> | ||
> : ^^^^^^^^^^^^ | ||
|
||
queries: { | ||
>queries : { [QK in keyof QR]: any; } | ||
> : ^^^ ^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
[QK in keyof QR]: ReturnType<typeof createCacheReducer<QR>>; | ||
>createCacheReducer : <N_1 extends string, QR_1>(queries: Cache<N_1, QR_1>["queries"]) => (state?: { queries: QR_1; }) => { queries: QR_1; } | ||
> : ^^^^^^^^^^^^^ ^^^^^^^^ ^^ ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
}; | ||
}; |
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
17 changes: 17 additions & 0 deletions
17
tests/cases/compiler/instantiationExpressionErrorNoCrash.ts
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 @@ | ||
const createCacheReducer = <N extends string, QR>( | ||
queries: Cache<N, QR>["queries"], | ||
) => { | ||
const queriesMap = {} as QR; | ||
|
||
const initialState = { | ||
queries: queriesMap, | ||
}; | ||
|
||
return (state = initialState) => state; | ||
}; | ||
|
||
export type Cache<N extends string, QR> = { | ||
queries: { | ||
[QK in keyof QR]: ReturnType<typeof createCacheReducer<QR>>; | ||
}; | ||
}; |