Skip to content

Instantly share code, notes, and snippets.

@nicoespeon
Created April 25, 2020 22:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicoespeon/fb725f1f51e0b506cbfd3a1269efeff1 to your computer and use it in GitHub Desktop.
Save nicoespeon/fb725f1f51e0b506cbfd3a1269efeff1 to your computer and use it in GitHub Desktop.
Trying to get inferred type of an identifier with @typescript/vfs
import {
createDefaultMapFromNodeModules,
createSystem,
createVirtualTypeScriptEnvironment,
} from "@typescript/vfs";
import * as ts from "typescript";
const fsMap = createDefaultMapFromNodeModules({
target: ts.ScriptTarget.ES2015,
});
fsMap.set("index.ts", `const hello = 'hi';`);
const system = createSystem(fsMap);
const env = createVirtualTypeScriptEnvironment(system, ["index.ts"], ts, {});
const result = env.languageService.getTypeDefinitionAtPosition("index.ts", 6);
console.log(result);
// => []
// 🤔 It's not undefined, but there's no type here…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment