phil294 / coffeesense

IntelliSense for CoffeeScript. LSP implementation / VSCode extension
MIT License
47 stars 8 forks source link

Type assertion expressions can only be used in TypeScript files #14

Closed STRd6 closed 2 years ago

STRd6 commented 2 years ago

I'm not sure if this is a CoffeeSense issue or not but when using backticks to put literal JS/TS I get the following error: Type assertion expressions can only be used in TypeScript files

E2 = `createEnum(["heyy"] as const)`
phil294 commented 2 years ago

That's because CoffeeSense's output files are plain JavaScript. I did this because the normal compiler also does not output TS and any such syntax should therefore be an error. That said, it is of course a valid desire to get TS output. To make this work, the only changes needed are changing the two occurences of javascript to typescript in files embeddedSupport.ts and coffeescriptDocumentRegionParser.ts. I also did this in the typescript branch which uses a special CS fork by edemaine with actual and explicit TypeScript support. Afaik it's unfinished business, and it adds completely new syntax to CoffeeScript.

Now I could simply switch CoffeeSense to TS output, but there is (only?) one significant drawback: JSDoc typings don't work in TypeScript. That means, with the two changes mentioned above, your as const stuff above works, but e.g. func = (###* @type {string} param) => loses its meaning. I have no solution for this as of now, but maybe you have?

phil294 commented 2 years ago

to be clear, the error you're seeing does not come from the integrated CS compiler (because your code snippet is valid CS, but from the integrated TS type checking based on the JS that CS compiler outputs.

STRd6 commented 2 years ago

The JSDoc typings are much more valuable to me currently. I guess we need to find that TypeScript/CoffeeScript successor eventually 🚀