Codemirror 6 and Typescript LSP

Hey @madebysid, had another question, this time regarding adding custom types declarations to tsserver. An example is that I am trying to have the tsserver autocomplete for $driver. I see in one of your earlier replies, you mentioned using createFile() but I don’t see that anywhere in tsserver’s documentation, so what exactly is it? Another question is that, since I am dealing with a large declaration, is that the best way to port over those definitions? My main issue is that I cannot pull the declarations in, so tsserver can therefore not add it using addLib(), which is where I am really stuck. Just lmk if I need to clarify more.

Dropping by the thread to say thanks @madebysid for the guidance on how to integrate Typescript. I got it working fairly quickly with your suggestions, and I feel like I’d have been stuck for a while otherwise.

If anyone is still having problems with this, I was able to create a small demo based on @madebysid comment, you can find it here: https://github.com/okikio/codemirror,

Demo Link: https://okikio-codemirror.netlify.app/

@Retr0djmarky The createFile method is on the env that you create from https://www.npmjs.com/package/@typescript/vfs (not on env.languageService).

For custom types, I think it’d be best to upload your types to a CDN and then download them lazily when your editor loads.

FWIW My implementation is also public now, if you want to take a look: https://github.com/prisma/text-editors/

1 Like