question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Stripping types should include ts-ignore comments

See original GitHub issue

TypeScript Version: 3.8 latest, playground

Search Terms: remove ts-ignore comment

Code

// this is a comment that should be kept
const message: string = 'hello world';
// the below ts-ignore comment should be removed, since it has no meaning in a non-TS context
// @ts-ignore
console.log(message);

Expected behavior: ts-ignore comment is stripped, other comments are kept.

Actual behavior: all comments are kept including ts-ignore comments.

Playground Link: https://www.typescriptlang.org/play/#code/PTAEBcAsEsGdTqAhqAxgewLaYKYDtwJIlDZJ0BXAGwBNQAjHUAaxwAdwAoDPWQ3WLCQBzHAC5QfAE7Q8w0AF5QAckg4qVdKADu6KbWUBuTiCJNGm7RFgBaaMLx6mGbPlLlqJsAAFwt+45SONzovOhUOAB0msIAFAJCogCUhkA

Related Issues:

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
fasttimecommented, Oct 13, 2020

I was actually surprised to find @ts-expect-error comments in my generated .js files. Like @ts-ignore, these are pointless outside TypeScript code.

0reactions
rflechtnercommented, Jun 24, 2021

I was actually surprised to find @ts-expect-error comments in my generated .js files. Like @ts-ignore, these are pointless outside TypeScript code.

I was even running into issues where explicitly escaping a type error with @ts-expect-error was compiled to js code where that type error was no longer detected, failing our tests (because the expected error did not occur).

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeScript remove comments | webhint documentation
typescript-config/no-comments checks that the property removeComments is enabled in your TypeScript configuration file (i.e. tsconfig.
Read more >
TypeScript compile and keep comments - tsc - Stack Overflow
Since 2015 you can create a tsconfig.json in your project and add "removeComments": false to its "compilerOptions" property in order to keep your...
Read more >
API - esbuild
Use of certain JavaScript features can disable many of esbuild's optimizations including minification. Specifically, using direct eval and/or the with statement ...
Read more >
TS Playground - An online editor for exploring TypeScript and ...
Disable truncating types in error messages. Emit ... Generate .d.ts files from TypeScript and JavaScript files in your project. ... Disable emitting comments....
Read more >
Comments - ts-morph
ts -morph parses out certain kinds of comments to make them easier to work with. This breaks away from the behaviour in the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found