Skip to content

Diagnostics and quick info disagree on type of variable #19686

Closed as not planned
@ghost

Description

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions