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

ban usages of @ts-expect-error and @ts-ignore in places that would get stripped when emitting .d.ts files #46331

Open
5 tasks done
DetachHead opened this issue Oct 12, 2021 · 3 comments
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript

Comments

@DetachHead
Copy link
Contributor

Suggestion

πŸ” Search Terms

ts-ignore ts-expect-error d.ts

βœ… Viability Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

⭐ Suggestion

@ts-ignore and @ts-expect-error comments that end up exposed in .d.ts files are stripped when compiled, which results in downstream errors that can go undetected until someone tries to use your package. see #38628 (comment)

it would be nice to have an option to ban the comments in type definitions and signatures, where they'd need to be exposed in the .d.ts files.

@andrewbranch
Copy link
Member

I wonder if type checking your own .d.ts emit would be a workable alternative? This suggestion makes sense but I don’t think we have a great detection mechanism for it in place.

@andrewbranch andrewbranch added Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript labels Oct 12, 2021
DetachHead added a commit to DetachHead/typescript-nodejs-project that referenced this issue Oct 13, 2021
DetachHead added a commit to DetachHead/typescript-nodejs-project that referenced this issue Oct 13, 2021
@DetachHead
Copy link
Contributor Author

it's difficult because i often have to turn on skipLibCheck due to issues in node_modules that are outside of my control. is there a way to turn that compiler option off only for files that are part of my project?

@andrewbranch
Copy link
Member

No, but I think there might be a previous issue for that too πŸ˜†

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

2 participants