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

Using Parameters in a class member function gets incorrect result while all parameters are optional.  #53541

Copy link
Copy link
@LvChengbin

Description

@LvChengbin
Issue body actions

Bug Report

🔎 Search Terms

🕗 Version & Regression Information

5.0.2 and 4.9.5

  • This is a crash
  • This changed between versions ______ and _______
  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
  • I was unable to test this on prior versions because _______

⏯ Playground Link

https://www.typescriptlang.org/play?ts=5.0.2&ssl=15&ssc=1&pln=16&pc=1#code/FAYwNghgzlAEAqsDexZtgeg7AZgOwAoBKALlgDcB7ASwBMBuVdLXQ2PCAWwFMB+MqABcATtTwBzWKQo0GTNPgLsufASLHiANLCjcAHv3YBXTgCNuwqWSp1kAX2APgoSDFgBZADwANWPsHceLRw8AB8yPKwIJR4QsJGIIKUwkoADkamYNQgsJxkvkT2zuisSgB0FRDC4lBkAApVKgHCUD4A2gDk+B2wALrhhSglJYIAFtRQZZxlirAVZVU1UowlDk44RniJ1DGsAEzlldW1sA3CTRat8G2wXXg9-VIRJXjcAO4IxDNs84twRIw7EA

Playground link with relevant code

💻 Code

class T {
    // fn(): void;
    // fn( name?: string ): void;
    fn( name?: string, sex?: number ): void {}
}


class M<X extends T> {
    constructor( public m: X ) {}

    fn( ...args: Parameters<X['fn' ]> ) {
        this.m.fn( ...args );
    }
}

function fn2( ...args: Parameters<T[ 'fn' ]> ) {
    new T().fn( ...args );
}

🙁 Actual behavior

image

The fn method in class M has similar code with the global function fn2, but it get errors.

The error message disappears if I add function overload ( uncomment line 3 & 4 in playground ).

🙂 Expected behavior

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptA bug in TypeScriptDomain: check: Type InferenceRelated to type inference performed during signature resolution or `infer` type resolutionRelated to type inference performed during signature resolution or `infer` type resolutionHelp WantedYou can do thisYou can do this

    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.