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
// ========== 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.
TypeScript Version: 2.8.0-rc
Search Terms: "invalid declaration emit", "declaration infer"
Code
Expected behavior:
In the emitted declaration file,
foo
andbar
should have equivalent return type annotations.Actual behavior:
The return type annotation for
bar
is missing theinfer
keyword, making the declaration invalid. Any TypeScript project consuming this declaration file will produce the error"Cannot find name 'P'"
.Related Issues:
The text was updated successfully, but these errors were encountered: