Skip to content

swc transpiler does not set strictMode to match tsconfig #1531

Description

@Janpot

Search Terms

swc

Expected Behavior

Running

functiondefaultHello(){return''}classX{constructor(x){this.hello=()=>(x.hello||defaultHello)()}}console.log(newX({hello(){returnthis.y||'this works'}}).hello())

using

"ts-node": {
"transpileOnly": true,
"transpiler": "ts-node/transpilers/swc-experimental"
},

will print

this works

(this is what is printed without using swc)

Actual Behavior

an error is printed:

/swctest/index.ts:13
return this.y || 'this works'
^
TypeError: Cannot read property 'y' of undefined
at hello (/swctest/index.ts:13:17)
at X.hello (/swctest/index.ts:7:50)
at Object.<anonymous> (/swctest/index.ts:15:4)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Module.m._compile (/swctest/node_modules/ts-node/src/index.ts:1371:23)
at Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Object.require.extensions.<computed> [as .ts] (/swctest/node_modules/ts-node/src/index.ts:1374:12)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)

Specifications

ts-node v10.4.0
node v14.16.0
compiler v4.4.4
@swc/core 1.2.103 
  • tsconfig.json, if you're using one:
{
"compilerOptions": {
"target": "es5", "module": "commonjs",
"esModuleInterop": true, "forceConsistentCasingInFileNames": true, "strict": false, "skipLibCheck": true },
"ts-node": {
"transpileOnly": true,
"transpiler": "ts-node/transpilers/swc-experimental"
},
}
  • Operating system and version: MacOS 11.6

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions