Skip to content

Commit

Permalink
fix(matcher): change declareation lib config to use es2020
Browse files Browse the repository at this point in the history
  • Loading branch information
TomokiMiyauci committed Dec 31, 2021
1 parent 23752fe commit 557e2f1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
5 changes: 2 additions & 3 deletions cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
28 changes: 21 additions & 7 deletions helper/_option.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,38 @@
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,
};
}

/** make `createProgram` host option */
function makeHostOption(
system: System,
fs: Map<string, string>,
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) => {
Expand Down
3 changes: 0 additions & 3 deletions matcher/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

0 comments on commit 557e2f1

Please sign in to comment.