From ae7ff214cb0c0f90960a341025c212f8d0b9cafe Mon Sep 17 00:00:00 2001 From: barak igal Date: Mon, 7 Feb 2022 15:01:23 +0200 Subject: [PATCH] refactor(module-utils): 24.20x speed-up for generate dts tests (#2315) --- packages/dom-test-kit/test/stylable-dom-util.spec.ts | 2 +- packages/e2e-test-kit/src/dts-kit.ts | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/dom-test-kit/test/stylable-dom-util.spec.ts b/packages/dom-test-kit/test/stylable-dom-util.spec.ts index f381a523d..336eb7eb8 100644 --- a/packages/dom-test-kit/test/stylable-dom-util.spec.ts +++ b/packages/dom-test-kit/test/stylable-dom-util.spec.ts @@ -57,6 +57,6 @@ describe('stylable-dom-utils type compliance', function () { }); tk.linkNodeModules(); - expect(tk.typecheck('test.ts')).to.equal(''); + expect(tk.typecheck('test.ts', ['lib.dom.d.ts', 'lib.es2020.d.ts'])).to.equal(''); }); }); diff --git a/packages/e2e-test-kit/src/dts-kit.ts b/packages/e2e-test-kit/src/dts-kit.ts index aa2d11362..4661f1ce4 100644 --- a/packages/e2e-test-kit/src/dts-kit.ts +++ b/packages/e2e-test-kit/src/dts-kit.ts @@ -42,7 +42,7 @@ export class DTSKit { } } - public typecheck(internalPath: string) { + public typecheck(internalPath: string, lib: string[] = []) { const filePath = this.sourcePath(internalPath); const program = createProgram({ options: { @@ -51,7 +51,8 @@ export class DTSKit { target: ScriptTarget.ES2020, strict: true, types: [], - lib: ['lib.dom.d.ts', 'lib.es2020.d.ts'], + skipDefaultLibCheck: true, + lib: lib.length ? lib : ['lib.es2020.d.ts'], }, rootNames: [filePath], });