@typescript/vfs
import ts, { ScriptTarget } from 'typescript'
import { createDefaultMapFromCDN, createSystem, createVirtualTypeScriptEnvironment } from '@typescript/vfs'
;(async () => {
const compilerOptions = {
target: ScriptTarget.ES2015,
}
const fsMap = await createDefaultMapFromCDN(compilerOptions, ts.version, true, ts)
fsMap.set('index.ts', '') // error
const system = createSystem(fsMap)
const env = createVirtualTypeScriptEnvironment(system, ['index.ts'], ts, compilerOptions)
})()
Error:
Uncaught (in promise) Error: error TS6053: File 'index.ts' not found.
The file is in the program because:
Root file specified for compilation
at Module.createVirtualTypeScriptEnvironment (index.ts:58:11)
It may be because of this:
// "@typescript/vfs" line 553:
getScriptSnapshot: fileName => {
const contents = sys.readFile(fileName)
if (contents) { // <=
return ts.ScriptSnapshot.fromString(contents)
}
return
},
@typescript/vfsError:
It may be because of this: