Preserving delimiters of string literals
- Dominant language
- TypeScript
- Stars
- 5.3k
- Forks
- 363
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 3
Description
I'm trying to print string literals without comments. I.e. if I have
``` js
'foo' // bar
```
I want to get
```
'foo'
```
However, recast prints
```
"foo"
```
I remove the comments by simply doing `node.comments.length = 0;`.
So my questions are:
- Is there a better way to remove comments?
- Is it possible to preserve the type of quotes in this case?
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by tracing how recast handles comments and chooses quote delimiters when printing the JavaScript string literal in the example. Done means removing the trailing comment without mutating the literal's original single-quote delimiter, while clarifying whether node.comments.length = 0 is the supported removal approach.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100