microsoft / microsoft/vscode-textbuffer
DefaultEndOfLine enum not accessible in Javacript API
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 113
- Forks
- 19
- Avg merge
- 12h 46m
- Merged PRs (30d)
- 2
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.
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.
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.
Assessment
- Tech stack
- coffeescript, javascript, typescript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100