Created
April 25, 2020 22:23
-
-
Save nicoespeon/fb725f1f51e0b506cbfd3a1269efeff1 to your computer and use it in GitHub Desktop.
Trying to get inferred type of an identifier with @typescript/vfs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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