From c035c2c23cb1f553cbc2b00443d68f9619dbd7b8 Mon Sep 17 00:00:00 2001 From: Stuart Miller Date: Mon, 13 Jun 2022 17:56:10 +1200 Subject: [PATCH 1/2] Don't read strict from tsconfig.json tsconfig's definition of strict is different to swc's, so we shouldn't treat them as the same field. Default swc strict mode to false. It can still be overridden by manual config if required. Fixes #10. --- src/index.ts | 3 +-- test/index.ts | 6 ++++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index f239188..6aa637d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -31,7 +31,6 @@ export function convertTsConfig( jsxFactory = 'React.createElement', jsxFragmentFactory = 'React.Fragment', jsxImportSource = 'react', - strict = false, alwaysStrict = false, noImplicitUseStrict = false, paths, @@ -44,7 +43,7 @@ export function convertTsConfig( sourceMaps: sourceMap, module: { type: ['commonjs', 'amd', 'umd'].includes(module) ? module : 'commonjs', - strict, + strict: false, strictMode: alwaysStrict || !noImplicitUseStrict, noInterop: !esModuleInterop, } as swcType.ModuleConfig, diff --git a/test/index.ts b/test/index.ts index 2410ceb..28f88b8 100644 --- a/test/index.ts +++ b/test/index.ts @@ -33,3 +33,9 @@ test('convert tsconfig file', (t) => { t.end() }) + +test('ignores strict from tsconfig', (t) => { + const result = convert() + t.equal(result.module?.strict, false) + t.end() +}) \ No newline at end of file From 8c6457934ab3a7b17d3320f4a08a62722bf43054 Mon Sep 17 00:00:00 2001 From: Stuart Miller Date: Mon, 13 Jun 2022 18:26:34 +1200 Subject: [PATCH 2/2] Don't set a default value for 'strict' 'false' is currently the default, but we want the default behaviour from swc so will leave it unset. Fixes #10. --- src/index.ts | 1 - test/index.ts | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 6aa637d..9a6a23d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -43,7 +43,6 @@ export function convertTsConfig( sourceMaps: sourceMap, module: { type: ['commonjs', 'amd', 'umd'].includes(module) ? module : 'commonjs', - strict: false, strictMode: alwaysStrict || !noImplicitUseStrict, noInterop: !esModuleInterop, } as swcType.ModuleConfig, diff --git a/test/index.ts b/test/index.ts index 28f88b8..eaba6ac 100644 --- a/test/index.ts +++ b/test/index.ts @@ -36,6 +36,6 @@ test('convert tsconfig file', (t) => { test('ignores strict from tsconfig', (t) => { const result = convert() - t.equal(result.module?.strict, false) + t.equal(result.module?.strict, undefined) t.end() }) \ No newline at end of file