jest icon indicating copy to clipboard operation
jest copied to clipboard

Chore:-(Jest-types)-Added strict type for option extension toTreatAsEsm

Open Biki-das opened this issue 2 years ago • 6 comments

Make extensionsToTreatAsEsm type stricter by excluding 3 error cases .js, .cjs and .mjs.

Biki-das avatar Jan 13 '23 14:01 Biki-das

Can you add a type test?

SimenB avatar Jan 14 '23 09:01 SimenB

Sure could you give some direction how should i do it?

Biki-das avatar Jan 14 '23 09:01 Biki-das

https://github.com/facebook/jest/blob/601ba290cd3c456c433461326df4c98dd4d07161/packages/jest-types/typetests/config.test.ts

Then yarn test-types to run them

SimenB avatar Jan 14 '23 09:01 SimenB

https://github.com/facebook/jest/blob/601ba290cd3c456c433461326df4c98dd4d07161/packages/jest-types/typetests/config.test.ts

Then yarn test-types to run them

Thanks will wrap it up soon!

Biki-das avatar Jan 14 '23 09:01 Biki-das

@mrazauskas could you guide me up a little bit on how should i add test for the types, feeling overwhelmed looking at the config.test.ts file

Biki-das avatar Jan 15 '23 06:01 Biki-das

Probably something like this:

expectAssignable<Config.InitialOptions>({
  extensionsToTreatAsEsm: ['.ts'],
});

expectError<Config.InitialOptions>({
  extensionsToTreatAsEsm: '.ts', // should error, because the expression is not array
});

// test each excluded extension like this
expectError<Config.InitialOptions>({
  extensionsToTreatAsEsm: ['.js'], // should error if the implementation works
});

mrazauskas avatar Jan 15 '23 07:01 mrazauskas

This PR is stale because it has been open 1 year with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar Jan 29 '24 07:01 github-actions[bot]

This PR was closed because it has been stalled for 30 days with no activity. Please open a new PR if the issue is still relevant, linking to this one.

github-actions[bot] avatar Feb 28 '24 08:02 github-actions[bot]

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

github-actions[bot] avatar Mar 30 '24 00:03 github-actions[bot]