Ts-jest: v23: Deprecated 'allowSyntheticDefaultImports' for synthetic modules

Created on 24 Jul 2018  路  5Comments  路  Source: kulshekhar/ts-jest

  • Issue
    The README file describes the use of allowSyntheticDefaultImports and the new tsconfig flag esModuleInterop. That description is unclear since allowSyntheticDefaultImports is no longer supported in version 23.
    https://github.com/kulshekhar/ts-jest/compare/v22.4.2...v23.0.0#diff-93e7c9f8fee0a72a9628c42ee26bc789L74 (src/postprocess.ts L74)
// These lines have been removed
if (tsCompilerOptions.allowSyntheticDefaultImports) {
    plugins.push('transform-es2015-modules-commonjs');
}
  • Expected behavior
    The documentation should describe that allowSyntheticDefaultImports is not longer supported and that the new flag (esModuleInterop) should be used instead.
Documentation

Most helpful comment

Dealing with the same issue as @kelly-tock right now. I switched my tsconfig.json file up a bit and replaced allowSyntheticDefaultImports: true with esModuleInterop: true. Per the intellisense, this option will, "Emit '__importStar' and '__importDefault' helpers for runtime babel ecosystem compatibility and enable '--allowSyntheticDefaultImports' for typesystem compatibility. Requires TypeScript version 2.7 or later."

All is well and I can get rid of the * now 馃槃

All 5 comments

I'm using esModuleInterop: true, and import * as React from 'react'; is the only thing that works. what is the right way to allow import React from 'react' when using this module?

Dealing with the same issue as @kelly-tock right now. I switched my tsconfig.json file up a bit and replaced allowSyntheticDefaultImports: true with esModuleInterop: true. Per the intellisense, this option will, "Emit '__importStar' and '__importDefault' helpers for runtime babel ecosystem compatibility and enable '--allowSyntheticDefaultImports' for typesystem compatibility. Requires TypeScript version 2.7 or later."

All is well and I can get rid of the * now 馃槃

Yup, moving to using esModuleInterop: true is the way to go, but yeah, doc should be fixed related to this

x-ref: #601

fixed in 23.10.0

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mikeyakymenko picture mikeyakymenko  路  3Comments

AlexGellert picture AlexGellert  路  4Comments

artola picture artola  路  3Comments

Slessi picture Slessi  路  3Comments

stephenotalora picture stephenotalora  路  3Comments