Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QuickInfo misleading with signatures from higher order function type inference #30373

Open
ajafff opened this issue Mar 13, 2019 · 1 comment
Assignees
Labels
Bug A bug in TypeScript Domain: Quick Info e.g. hover text, tool-tips, and tooltips. Domain: Type Display Bugs relating to showing types in Quick Info/Tooltips, Signature Help, or Completion Info
Milestone

Comments

@ajafff
Copy link
Contributor

ajafff commented Mar 13, 2019

TypeScript Version: 3.4.0-dev.20190313

Search Terms:

Code

interface T1 {}

declare function pipe2<A, B, C, D>(ab: (a: A) => B, cd: (c: C) => D): (a: [A, C]) => [B, D];
declare function list<T extends T1>(a: T): T[];
declare function box<T extends T1>(x: T): { value: T };

const listBox = pipe2(list, box);

Expected behavior:

Propagated type parameters should be renamed if a different type with the same name is used in the constraint or initializer of any other propagated type parameter.

For example: <T extends T1, T2 extends T1>.

Actual behavior:

Hovering over listBox displays const listBox: <T extends T1, T1 extends T1>(a: [T, T1]) => [T[], {value: T1;}]

Note the T1 extends T1 and T extends T1 where T1 refers to something completely different.

This is not limited to renamed type parameters. Hovering over listBox in the following code displays circular type parameter constraints (<T extends V, V extends T>) without any renaming going on:

interface T {}
interface V {}

declare function pipe2<A, B, C, D>(ab: (a: A) => B, cd: (c: C) => D): (a: [A, C]) => [B, D];
declare function list<T extends V>(a: T): T[];
declare function box<V extends T>(x: V): { value: V };

const listBox = pipe2(list, box);
@DanielRosenwasser DanielRosenwasser added Bug A bug in TypeScript Domain: Type Display Bugs relating to showing types in Quick Info/Tooltips, Signature Help, or Completion Info Domain: Quick Info e.g. hover text, tool-tips, and tooltips. labels Mar 13, 2019
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Mar 14, 2019
@ajafff
Copy link
Contributor Author

ajafff commented Jun 3, 2019

This issue is actually not limited to type display in quick info.
The generated declaration file (when exporting listBox) also contains these invalid references and therefore causes type errors for consumers.

This looks related to #31605. Maybe it's fixed by #31544

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: Quick Info e.g. hover text, tool-tips, and tooltips. Domain: Type Display Bugs relating to showing types in Quick Info/Tooltips, Signature Help, or Completion Info
Projects
None yet
Development

No branches or pull requests

4 participants