swc-project / swc-node

Faster ts-node without typecheck
MIT License
1.69k stars 69 forks source link

TypeScript's "satisfies" operator causes Syntax Error #718

Closed yay closed 11 months ago

yay commented 11 months ago

Having something like this in the specs:

type Hello = {
  one: number;
};
const hello = {
  one: 1,
} satisfies Hello;

fails with the following error:

$ node --loader @swc-node/register/esm libs/domain/user/src/services/__tests__/User.spec.ts
(node:74511) ExperimentalWarning: Custom ESM Loaders is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
node:internal/process/esm_loader:97
    internalBinding('errors').triggerUncaughtException(
                              ^

[Error: 
  × Expected a semicolon
    ╭─[/Users/n771012/projects/platform-ui/libs/domain/user/src/services/__tests__/User.spec.ts:23:3]
 23 │ } satisfies Hello;
    ·   ─────────
    ╰────

Caused by:
    0: failed to process input file
    1: error was recoverable, but proceeding would result in wrong codegen
    2: Syntax Error] {
  code: 'GenericFailure'
}

I'm using "@swc-node/register": "1.6.5", "jest": "29.5.0", "ts-jest": "29.1.1", "typescript": "5.1.6",

Am I missing some config option to make this work? Would appreciate any help in fixing this.

yay commented 11 months ago

Bumping versions of these packages helped: "@swc/cli": "0.1.62", "@swc/core": "1.3.70", "@swc/helpers": "0.5.1", "@swc/jest": "0.2.26",