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

Diagnostics and quick info disagree on type of variable #19686

Closed
ghost opened this issue Nov 2, 2017 · 2 comments
Closed

Diagnostics and quick info disagree on type of variable #19686

ghost opened this issue Nov 2, 2017 · 2 comments
Labels
Bug A bug in TypeScript
Milestone

Comments

@ghost
Copy link

ghost commented Nov 2, 2017

TypeScript Version: 2.7.0-dev.20171102

Code

declare function f(x: number): string[];
declare function each<T>(array: T[], callback: (a: T) => void): void;
each(f(), s => {
    s.toLowerCase();
});

Hover over s.

Expected behavior:

This test should pass:

/// <reference path='fourslash.ts'/>

////declare function f(x: number): string[];
////declare function each<T>(array: T[], callback: (a: T) => void): void;
////each(f(), /**/s => {
////    s.toLowerCase();
////});

verify.quickInfoAt("", "(parameter) s: string");
verify.numberOfErrorsInCurrentFile(1); // At the call to `f()`

Actual behavior:

The type in quick info is string, but we also get a diagnostic about it being {} instead.
In the real situation f() could be arbitrarily far away from the call to each, such as in a function with no explicit return type, so it's very hard to diagnose such an error when quick info tells you everything is fine!

@ghost ghost added the Bug A bug in TypeScript label Nov 2, 2017
@mhegazy
Copy link
Contributor

mhegazy commented Jul 20, 2018

Both now say T. which seems right to me.

@mhegazy mhegazy closed this as completed Jul 20, 2018
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Jul 20, 2018
@ghost
Copy link
Author

ghost commented Jul 20, 2018

When I run the fourslash test in the master branch, I still see a compile-time error Property 'toLowerCase' does not exist on type '{}'. (using debug.printErrorList();). But the quick info still says s is a string, not {}.

@mhegazy mhegazy reopened this Jul 20, 2018
@mhegazy mhegazy removed the Fixed A PR has been merged for this issue label Jul 20, 2018
@mhegazy mhegazy assigned ghost Jul 20, 2018
@mhegazy mhegazy added this to the TypeScript 3.1 milestone Jul 20, 2018
@ghost ghost modified the milestones: TypeScript 3.1, TypeScript 3.2 Sep 4, 2018
@ghost ghost removed their assignment Nov 16, 2018
@ghost ghost modified the milestones: TypeScript 3.2.1, TypeScript 3.3 Nov 16, 2018
@RyanCavanaugh RyanCavanaugh closed this as not planned Won't fix, can't repro, duplicate, stale Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript
Projects
None yet
Development

No branches or pull requests

3 participants