swc-project / swc-project/swc-node
Object.assign not working properly
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 95
- Avg merge
- 14d 11h
- Merged PRs (30d)
- 1
Description
@swc-node/jest behaves differently with jest 27.5.1.
As of yesterday when I updated jest, I'm getting some weird behavior from swc-node that is causing most of my unit tests to break. Object.assign is no longer working properly with this library.
The exact thing that is newly failing is the following (simplified for example):
export class Base<T> {
constructor(props: Partial<T> = {}) {
Object.assign(this, props);
}
}
export class SomeClass extends Base<SomeClass> {
a: string;
b: boolean;
c: number;
d: string;
}
Expected:
const test = new SomeClass({ a: 'hello', b: false })
// test -> { a: 'hello', b: 'false' }
Actual:
const test = new SomeClass({ a: 'hello', b: false })
// test -> { a: undefined, b: undefined, c: undefined, d: undefined }
Note that our code works fine with ts-jest while using the new jest version.
NPM Version: 8.3.2
Node Version: 16.10.0
@swc-node/core version: 1.8.2
@swc-node/jest version: 1.4.3
jest version: 27.5.1
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the supplied TypeScript example through @swc-node/jest with Jest 27.5.1, using the reported Node, @swc-node/core, and @swc-node/jest versions. Compare the behavior with ts-jest and inspect the @swc-node/jest integration to identify why Object.assign produces undefined fields; done means the example behaves correctly under the reported Jest version.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- testing-qa, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100