Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Unexpected behavior when static methods are used in an array #41977

Copy link
Copy link
@AndrewKushnir

Description

@AndrewKushnir
Issue body actions

TypeScript Version: 4.2.0-dev.20201211 (also tested with 4.2.0)

Search Terms: static method(s)

Code

class S {
  static f(a: number|string): void {}
}

function g(a: number): void {}

// Uncomment to see a different behavior of the `output` const type.
// type G = typeof g;

const y = [S.f, g];
const output: ((ctrl: number|string) => void)[] = y;

Expected behavior:
Consistent type checking result (an error) for the output const with and without type G = typeof g.

Actual behavior:
If the type G = typeof g is present, the error is thrown (as expected), otherwise there is no error thrown.

Playground Link:
Playground link to reproduce the error.

// cc @alxhub @rkirov

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptA bug in TypeScriptDomain: check: Error InstabilityErrors appear or disappear based on order of checker operations, e.g. LS / tsc discrepanciesErrors appear or disappear based on order of checker operations, e.g. LS / tsc discrepanciesFix AvailableA PR has been opened for this issueA PR has been opened for this issue

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.