swc-project / swc-node

Faster ts-node without typecheck
MIT License
1.77k stars 74 forks source link

[jest] Typescript type checking errors in test cases are not been reported #614

Closed huozhi closed 2 years ago

huozhi commented 2 years ago

Hi, awesome project!

Description

I'm trying to adopt @swc-node/jest to replace ts-jest in our project but found the jest transform phase won't report any syntaxes error if the test cases written in ts have any.

Reproduction

create a empty folder and run

yarn add -D jest @swc-node/jest

Add jest.config.js

module.exports = {
  transform: {
    '^.+\\.(t|j)sx?$': [
      '@swc-node/jest',
      { jsc: { minify: false } },
    ],
  },
}

Create a simple jest test case index.test.ts in wrong ts syntax

test('should say hello', () => {
  let x: string = 123
  console.log('hello' as number)
})

Run it yarn jest index.test.ts

Expected

It should display type checking errors

Observed

Only passed without any type checking errors reported

Though ts-jest can cover the type checking but I'm not sure if the type checking is not included here for speed or it's sth missed in swc. Feel free to close if it's not the issue of this project. Thanks!

Brooooooklyn commented 2 years ago

It seems like not syntax error, it's typecheck error

huozhi commented 2 years ago

Thanks for correction, yeah it's type checking part, updated the description

Brooooooklyn commented 2 years ago

Yes, swc doesn't support typecheck for now

huozhi commented 2 years ago

Sounds good, we can cover it by tsc itself. Thanks!