You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Invalid declaration emit for conditional type with 'infer' #22755
// ========== tsc input ==========// index.ts// @declaration: trueexportdeclarefunctionfoo<T>(obj: T): Textends()=> infer P ? P : never;exportfunctionbar<T>(obj: T){returnfoo(obj);}// ========== tsc output ==========// index.d.tsexportdeclarefunctionfoo<T>(obj: T): Textends()=> infer P ? P : never;exportdeclarefunctionbar<T>(obj: T): Textends()=>P ? P : never;
Expected behavior:
In the emitted declaration file, foo and bar should have equivalent return type annotations.
Actual behavior:
The return type annotation for bar is missing the infer keyword, making the declaration invalid. Any TypeScript project consuming this declaration file will produce the error "Cannot find name 'P'".
It might, by chance, because I introduced an actual InferType type kind in that PR so I could distinguish the infer location from the use locations for type parameter lists.
Activity
yortus commentedon Mar 21, 2018
Wesley Wigham (@weswigham) would #22368 fix this?
weswigham commentedon Mar 21, 2018
It might, by chance, because I introduced an actual
InferTypetype kind in that PR so I could distinguish the infer location from the use locations for type parameter lists.DanielRosenwasser commentedon Mar 21, 2018
Let's get a fix specifically for this first if we can, and then use #22368 if that gets pulled in.