DonJayamanne / typescript-notebook

Run JavaScript and TypeScript in node.js within VS Code notebooks with excellent support for debugging, tensorflowjs visulizations, plotly, danfojs, etc
https://marketplace.visualstudio.com/items?itemName=donjayamanne.typescript-notebook
MIT License
905 stars 40 forks source link

Custom TypeScript language and language service extension for better DX #36

Open dmisdm opened 2 years ago

dmisdm commented 2 years ago

Hey there! Super into this project!

Bear in mind, i may be missing crucial bits of information to this project as i'm new to it, and what i've done may not be the most ideal.

I noticed a few quirks within TypeScript cells, such as top level awaits showing up as errors (for a few possible reasons such as requiring "module": "ESNext"), and that TypeScript doesn't know about variables shared between cells.

I've been playing around with making this work, and had a bit of sucess with shipping a new language and language service extension (cloned from the existing typescript extensions), as this allowed me to change one tiny detail: image

which made top level awaits work (if you import something): image

I'm completely aware that this may be a drastic change (shipping a new language) however i'm hoping that it just becomes a matter of importing and augmenting the existing extensions rather than shipping 99% of the same code...if that makes any sense?

My question is: would you accept this kind of contribution given it was designed well?

Also, some background: i'm also trying to solve the same issue for a similar side project https://dmisdm.github.io/ts-notebook/

I haven't yet thought of a cleaner way to solve these issues, and i'm not 100% a new language is the best way. E.g. i also thought a lot could be done using a custom "typescript.tsdk" (VSCode config), similar to what @yarnpkg/pnpify does (it augments typescript/lib/tsserver.js to support loading definitions in a PnP environment), however this has it's drawbacks too.

DonJayamanne commented 2 years ago

would you accept this kind of contribution given it was designed well?

Absolutely yes.

My only concern is the fact that it's a custom language, however there's only one way to learn of this is a problem or not, and that's to get it in from of the users

DonJayamanne commented 2 years ago

Looking forward to ur PR, thanks