question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Async LanguageServiceHost

See original GitHub issue

Search Terms

language, service, host, async, api

Suggestion

It’d super awesome if Language Service would accept a LanguageServiceHost with async API

Use Cases

Using LanguageService in environments where readFileSync is not available like browsers (using browserfs package or fs provided by WebSockets)

I’m working on an app like CodeSandbox but a bit more sophisticated.

Examples

class Host implements ts.LanguageServiceHost {
  async getScriptSnapshot(filename: string): Promise<ts.IScriptSnapshot> { }
  async readFile(filename: string): Promise<string> {}
}

Checklist

My suggestion meets these guidelines:

  • This wouldn’t be a breaking change in existing TypeScript/JavaScript code
  • This wouldn’t change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn’t a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
  • This feature would agree with the rest of TypeScript’s Design Goals.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:12
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
manuthcommented, Dec 9, 2021

Does anyone of you know a workaround for creating an asynchronous getSemanticDiagnostics?

0reactions
kitsonkcommented, Sep 19, 2019

@oldrich-svec oooh… thank you! that is very very handy! 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

typescript LanguageService TypeScript Examples
async function measureLanguageService( languageService: LanguageService, args: MeasureLanguageServiceArgs ): Promise<LanguageServiceSingleMeasurement> ...
Read more >
How to use the typescript-json-schema.buildGenerator ... - Snyk
To help you get started, we've selected a few typescript-json-schema.buildGenerator examples, based on popular ways it is used in public projects.
Read more >
https://rd3space.com/node_modules/typescript/lib/t...
... Protected = 16, Static = 32, Readonly = 64, Abstract = 128, Async = 256, ... interface LanguageServiceHost extends GetEffectiveTypeRootsHost ...
Read more >
Documentation - TypeScript 4.7
lib.d.ts Updates · Stricter Spread Checks in JSX · Stricter Checks with Template String Expressions · readFile Method is No Longer Optional on...
Read more >
Async/await in TypeScript - LogRocket Blog
Async and await enable developers to write asynchronous code that looks and behaves like synchronous code and is easier to read, write, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found