microsoft / microsoft/TypeScript

Stripping types should include ts-ignore comments

Open
#37,144 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Awaiting More Feedback Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

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:

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the example in the linked TypeScript Playground and compare the emitted JavaScript with the expected behavior. Trace the compiler path responsible for stripping types and comments, then verify that @ts-ignore is removed while the ordinary comment remains.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.