forked from microsoft/TypeScript
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request microsoft#30856 from Microsoft/nonInferrableType
Add a proper non-inferrable type
- Loading branch information
1 parent
95e649a
commit 8ba211c
Showing
6 changed files
with
164 additions
and
28 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
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,26 @@ | ||
//// [genericFunctionInference2.ts] | ||
// Repro from #30685 | ||
|
||
type Reducer<S> = (state: S) => S; | ||
declare function combineReducers<S>(reducers: { [K in keyof S]: Reducer<S[K]> }): Reducer<S>; | ||
|
||
type MyState = { combined: { foo: number } }; | ||
declare const foo: Reducer<MyState['combined']['foo']>; | ||
|
||
const myReducer1: Reducer<MyState> = combineReducers({ | ||
combined: combineReducers({ foo }), | ||
}); | ||
|
||
const myReducer2 = combineReducers({ | ||
combined: combineReducers({ foo }), | ||
}); | ||
|
||
|
||
//// [genericFunctionInference2.js] | ||
// Repro from #30685 | ||
var myReducer1 = combineReducers({ | ||
combined: combineReducers({ foo: foo }) | ||
}); | ||
var myReducer2 = combineReducers({ | ||
combined: combineReducers({ foo: foo }) | ||
}); |
56 changes: 56 additions & 0 deletions
56
tests/baselines/reference/genericFunctionInference2.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,56 @@ | ||
=== tests/cases/compiler/genericFunctionInference2.ts === | ||
// Repro from #30685 | ||
|
||
type Reducer<S> = (state: S) => S; | ||
>Reducer : Symbol(Reducer, Decl(genericFunctionInference2.ts, 0, 0)) | ||
>S : Symbol(S, Decl(genericFunctionInference2.ts, 2, 13)) | ||
>state : Symbol(state, Decl(genericFunctionInference2.ts, 2, 19)) | ||
>S : Symbol(S, Decl(genericFunctionInference2.ts, 2, 13)) | ||
>S : Symbol(S, Decl(genericFunctionInference2.ts, 2, 13)) | ||
|
||
declare function combineReducers<S>(reducers: { [K in keyof S]: Reducer<S[K]> }): Reducer<S>; | ||
>combineReducers : Symbol(combineReducers, Decl(genericFunctionInference2.ts, 2, 34)) | ||
>S : Symbol(S, Decl(genericFunctionInference2.ts, 3, 33)) | ||
>reducers : Symbol(reducers, Decl(genericFunctionInference2.ts, 3, 36)) | ||
>K : Symbol(K, Decl(genericFunctionInference2.ts, 3, 49)) | ||
>S : Symbol(S, Decl(genericFunctionInference2.ts, 3, 33)) | ||
>Reducer : Symbol(Reducer, Decl(genericFunctionInference2.ts, 0, 0)) | ||
>S : Symbol(S, Decl(genericFunctionInference2.ts, 3, 33)) | ||
>K : Symbol(K, Decl(genericFunctionInference2.ts, 3, 49)) | ||
>Reducer : Symbol(Reducer, Decl(genericFunctionInference2.ts, 0, 0)) | ||
>S : Symbol(S, Decl(genericFunctionInference2.ts, 3, 33)) | ||
|
||
type MyState = { combined: { foo: number } }; | ||
>MyState : Symbol(MyState, Decl(genericFunctionInference2.ts, 3, 93)) | ||
>combined : Symbol(combined, Decl(genericFunctionInference2.ts, 5, 16)) | ||
>foo : Symbol(foo, Decl(genericFunctionInference2.ts, 5, 28)) | ||
|
||
declare const foo: Reducer<MyState['combined']['foo']>; | ||
>foo : Symbol(foo, Decl(genericFunctionInference2.ts, 6, 13)) | ||
>Reducer : Symbol(Reducer, Decl(genericFunctionInference2.ts, 0, 0)) | ||
>MyState : Symbol(MyState, Decl(genericFunctionInference2.ts, 3, 93)) | ||
|
||
const myReducer1: Reducer<MyState> = combineReducers({ | ||
>myReducer1 : Symbol(myReducer1, Decl(genericFunctionInference2.ts, 8, 5)) | ||
>Reducer : Symbol(Reducer, Decl(genericFunctionInference2.ts, 0, 0)) | ||
>MyState : Symbol(MyState, Decl(genericFunctionInference2.ts, 3, 93)) | ||
>combineReducers : Symbol(combineReducers, Decl(genericFunctionInference2.ts, 2, 34)) | ||
|
||
combined: combineReducers({ foo }), | ||
>combined : Symbol(combined, Decl(genericFunctionInference2.ts, 8, 54)) | ||
>combineReducers : Symbol(combineReducers, Decl(genericFunctionInference2.ts, 2, 34)) | ||
>foo : Symbol(foo, Decl(genericFunctionInference2.ts, 9, 31)) | ||
|
||
}); | ||
|
||
const myReducer2 = combineReducers({ | ||
>myReducer2 : Symbol(myReducer2, Decl(genericFunctionInference2.ts, 12, 5)) | ||
>combineReducers : Symbol(combineReducers, Decl(genericFunctionInference2.ts, 2, 34)) | ||
|
||
combined: combineReducers({ foo }), | ||
>combined : Symbol(combined, Decl(genericFunctionInference2.ts, 12, 36)) | ||
>combineReducers : Symbol(combineReducers, Decl(genericFunctionInference2.ts, 2, 34)) | ||
>foo : Symbol(foo, Decl(genericFunctionInference2.ts, 13, 31)) | ||
|
||
}); | ||
|
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,49 @@ | ||
=== tests/cases/compiler/genericFunctionInference2.ts === | ||
// Repro from #30685 | ||
|
||
type Reducer<S> = (state: S) => S; | ||
>Reducer : Reducer<S> | ||
>state : S | ||
|
||
declare function combineReducers<S>(reducers: { [K in keyof S]: Reducer<S[K]> }): Reducer<S>; | ||
>combineReducers : <S>(reducers: { [K in keyof S]: Reducer<S[K]>; }) => Reducer<S> | ||
>reducers : { [K in keyof S]: Reducer<S[K]>; } | ||
|
||
type MyState = { combined: { foo: number } }; | ||
>MyState : MyState | ||
>combined : { foo: number; } | ||
>foo : number | ||
|
||
declare const foo: Reducer<MyState['combined']['foo']>; | ||
>foo : Reducer<number> | ||
|
||
const myReducer1: Reducer<MyState> = combineReducers({ | ||
>myReducer1 : Reducer<MyState> | ||
>combineReducers({ combined: combineReducers({ foo }),}) : Reducer<{ combined: { foo: any; }; }> | ||
>combineReducers : <S>(reducers: { [K in keyof S]: Reducer<S[K]>; }) => Reducer<S> | ||
>{ combined: combineReducers({ foo }),} : { combined: Reducer<{ foo: number; }>; } | ||
|
||
combined: combineReducers({ foo }), | ||
>combined : Reducer<{ foo: number; }> | ||
>combineReducers({ foo }) : Reducer<{ foo: number; }> | ||
>combineReducers : <S>(reducers: { [K in keyof S]: Reducer<S[K]>; }) => Reducer<S> | ||
>{ foo } : { foo: Reducer<number>; } | ||
>foo : Reducer<number> | ||
|
||
}); | ||
|
||
const myReducer2 = combineReducers({ | ||
>myReducer2 : Reducer<{ combined: { foo: any; }; }> | ||
>combineReducers({ combined: combineReducers({ foo }),}) : Reducer<{ combined: { foo: any; }; }> | ||
>combineReducers : <S>(reducers: { [K in keyof S]: Reducer<S[K]>; }) => Reducer<S> | ||
>{ combined: combineReducers({ foo }),} : { combined: Reducer<{ foo: number; }>; } | ||
|
||
combined: combineReducers({ foo }), | ||
>combined : Reducer<{ foo: number; }> | ||
>combineReducers({ foo }) : Reducer<{ foo: number; }> | ||
>combineReducers : <S>(reducers: { [K in keyof S]: Reducer<S[K]>; }) => Reducer<S> | ||
>{ foo } : { foo: Reducer<number>; } | ||
>foo : Reducer<number> | ||
|
||
}); | ||
|
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,15 @@ | ||
// Repro from #30685 | ||
|
||
type Reducer<S> = (state: S) => S; | ||
declare function combineReducers<S>(reducers: { [K in keyof S]: Reducer<S[K]> }): Reducer<S>; | ||
|
||
type MyState = { combined: { foo: number } }; | ||
declare const foo: Reducer<MyState['combined']['foo']>; | ||
|
||
const myReducer1: Reducer<MyState> = combineReducers({ | ||
combined: combineReducers({ foo }), | ||
}); | ||
|
||
const myReducer2 = combineReducers({ | ||
combined: combineReducers({ foo }), | ||
}); |