Disclaimer: Language Services Hosting API will be changed in future versions. I'm not sure what the full extent of the changes will be - I expect that everything will be basically the same, but the changes will almost certainly be broken.
In addition, there is a full implementation of the TypeScript hosting API in src\harness\harness.ts used for language service test modules that you can reference. Here is a conceptual breakdown of the functions you specified:
getScriptId()
You need to return a line unique to each file (script), but not changing from a call from a call. Returning the script file name will work beautifully.
getScriptIsResident()
The compiler has the concept of a "resident" file that is not changed (for example, lib.d.ts). Residency status is used for performance reasons - for example, types that come out of a resident file are considered immutable (which is why you see weirdness in Visual Studio when you try to extend the type defined in lib.d.ts). You can safely return false for all files here, or if you know the file is immutable, you can return true . The concept of a "resident" file will disappear in some future version of the compiler after type checking improves.
getScriptVersion()
Here you need to return a monotonically increasing number, which increases with every change to the script source. The language service uses this number to determine whether to re-check / re-check files.
getScriptEditRangeSinceVersion()
This function should return a list of editing ranges (hopefully taken for granted) that occurred between the present and the specified number of the previous version (see getScriptVersion above). Obviously, this is a little pain to implement, but TypeScript.ScriptEditRange.unknown() can be returned here, after which the language service will completely rewrite the file (significant performance), so try to do it sparingly in interactive contexts).
source share