DefaultEndOfLine enum not accessible in Javacript API
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- coffeescript, javascript, typescript
- Domain
- api
Research direction
Start with the README example using DefaultEndOfLine.LF and inspect the TypeScript declaration and generated JavaScript for the Piece Tree API. Compare the TypeScript and JavaScript exports to determine how the enum is exposed at runtime. Done means the documented example works from plain JavaScript and CoffeeScript as well as TypeScript.
Written by the indexing model from the issue text.
Description
The following line from the README described API works in Typescript but not in Javascript or Coffeescript.
Piece Tree exports the DefaultEndOfLine enum as it is necessary for the API. Per the README:
const pieceTree = pieceTreeFactory.create(DefaultEndOfLine.LF);
This works in Typescript, but in plain Javascript or Coffeescript one gets the following:
TypeError: Cannot read property 'LF' of undefined`
I looked into it and learned that the Typescript compiler declares a const enum in the TS declaration files, but does not generate any JS code for it -- as constants they are completely erased (replaced with hardcoded underlying values) at compile time. Hence the error for any client that doesn't look at the TS declaration files, e.g. Javascript, Coffeescript, etc.
Removing the const keyword eliminates the error, but now there is a level of indirection when accessing Typescript values. Not sure what the ideal solution is.
- Dominant language
- TypeScript
- Stars
- 113
- Forks
- 19
- Avg merge
- 12h 46m
- Merged PRs (30d)
- 2
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/vscode-textbuffer
-
Difficulty 5/5 Over a week Newbie friendliness 15/100
-
Broken package Open
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
microsoft/vscode-textbuffer#21 · 1 comment ·
-
help wanted
Difficulty 5/5 Over a week Newbie friendliness 25/100
All issues in microsoft/vscode-textbuffer
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
danielmiessler/LifeOS#2218 ·