diff --git a/cli.ts b/cli.ts index 480e828..42c6a61 100644 --- a/cli.ts +++ b/cli.ts @@ -25,16 +25,15 @@ const fsMap = await createDefaultMapFromCDN( ts as any, lzstring, ); -const system = createSystem(fsMap); filePaths.forEach((filePath) => { fsMap.set(filePath, Deno.readTextFileSync(filePath)); }); const program = ts.createProgram({ - rootNames: filePaths, + rootNames: [...filePaths, "/lib.es2020.full.d.ts"], options: compilerOptions, - host: makeHostOption(system, compilerOptions), + host: makeHostOption(fsMap, compilerOptions), }); const inspection = inspect(program); diff --git a/helper/_option.ts b/helper/_option.ts index b28cf1f..550af60 100644 --- a/helper/_option.ts +++ b/helper/_option.ts @@ -1,12 +1,13 @@ -import type { CompilerHost, CompilerOptions, System } from "../deps.ts"; -import { createVirtualCompilerHost, ts } from "../deps.ts"; +import type { CompilerHost, CompilerOptions } from "../deps.ts"; +import { createSystem, createVirtualCompilerHost, ts } from "../deps.ts"; /** make `createProgram` option */ function makeCompilerOption(): CompilerOptions { return { - strict: true, - module: ts.ModuleKind.ESNext, esModuleInterop: true, + module: ts.ModuleKind.ESNext, + target: ts.ScriptTarget.ESNext, + lib: ["dom", "esnext"], skipLibCheck: false, noEmit: true, }; @@ -14,11 +15,24 @@ function makeCompilerOption(): CompilerOptions { /** make `createProgram` host option */ function makeHostOption( - system: System, + fs: Map, compilerOptions: CompilerOptions, ): CompilerHost { - const host = createVirtualCompilerHost(system, compilerOptions, ts as any); - return host.compilerHost; + const system = createSystem(fs); + const { compilerHost } = createVirtualCompilerHost( + system, + compilerOptions, + ts as any, + ); + + compilerHost.getSourceFile = (fileName, lang) => { + const sourceText = fs.get(fileName); + if (sourceText) { + return ts.createSourceFile(fileName, sourceText, lang); + } + }; + + return compilerHost; // return { // readFile: (fileName) => { diff --git a/matcher/mod.ts b/matcher/mod.ts index 9196a22..ea340fc 100644 --- a/matcher/mod.ts +++ b/matcher/mod.ts @@ -12,11 +12,8 @@ import type { Matcher } from "./types.ts"; import type { RequiredByKeys } from "../_types.ts"; const ImportPathWithExtension = 2691; -// temporary -const IgnoreArrayLength = 2536; const IgnoreDiagnosticCodes = new Set([ ImportPathWithExtension, - IgnoreArrayLength, ]); const assertionMap = {