Skip to content

ts-ignore is stripped from method in declaration output, causing downstream errors #44012

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

Closed
trusktr opened this issue May 9, 2021 · 4 comments
Labels
Duplicate An existing issue was already created

Comments

@trusktr
Copy link
Contributor

trusktr commented May 9, 2021

Bug Report

πŸ”Ž Search Terms

ts-ignore stripped from declaration output

πŸ•— Version & Regression Information

Tried on 4.2.3

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

class Base {
    foo(n: number) {}
}

new Base().foo(123) // ok

class Foo extends Base {
    // @ts-ignore overrides the signature
    foo(n: string) {}
}

new Foo().foo("123") // ok

Declaration output:

declare class Base {
    foo(n: number): void;
}
declare class Foo extends Base {
    foo(n: string): void; // ERROR here because ts-ignore comment is missing.
}

πŸ™ Actual behavior

A consumer of a library with this declaration output reports errors.

πŸ™‚ Expected behavior

The @ts-ignore comment should still be there, so that the types of the consumed library work the same as the library author wrote (without type errors on the Foo subclass).

@MartinJohns
Copy link
Contributor

Related: #37144

@MartinJohns
Copy link
Contributor

MartinJohns commented May 9, 2021

Duplicate of #38628. Used search terms: ts-ignore in:title

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label May 10, 2021
@typescript-bot
Copy link
Collaborator

This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

@tjjfvi
Copy link
Contributor

tjjfvi commented May 13, 2021

A (possibly non-ideal) fix for this specific instance is

class Foo extends Base {
    /** @ts-ignore overrides the signature */
    foo(n: string) {}
}

// Emitted .d.ts
declare class Foo extends Base {
    /** @ts-ignore overrides the signature */
    foo(n: string): void;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

5 participants