Hi.
I'm working on a typescript project, and I'm using jest to run the tests.
I introduced ttypescript and ts-transform-paths but now I have a strange error: for each test I have an error with this message:
● Test suite failed to run
TypeError: Cannot read properties of undefined (reading 'impliedNodeFormat')
at Object.getModeForUsageLocation (node_modules/typescript/lib/typescript.js:114398:18)
at resolveExternalModule (node_modules/typescript/lib/typescript.js:50141:90)
at resolveExternalModuleNameWorker (node_modules/typescript/lib/typescript.js:50117:19)
at getExternalModuleFileFromDeclaration (node_modules/typescript/lib/typescript.js:85790:32)
at Object.getExternalModuleFileFromDeclaration (node_modules/typescript/lib/typescript.js:85629:36)
at tryGetModuleNameFromDeclaration (node_modules/typescript/lib/typescript.js:29494:59)
at Object.getExternalModuleNameLiteral (node_modules/typescript/lib/typescript.js:29458:20)
at createRequireCall (node_modules/typescript/lib/typescript.js:103357:33)
at visitImportDeclaration (node_modules/typescript/lib/typescript.js:103317:80)
at topLevelVisitor (node_modules/typescript/lib/typescript.js:102966:28)
The error doesn't come up if I remove { "transform": "@zerollup/ts-transform-paths" } from compilerOptions.plugins
For reference this is the content of my tsconfig.json
{
"compilerOptions": {
"baseUrl": "src",
"paths": {
"@/*": ["*"],
"@messages/*": ["messages/*"]
},
"module": "esnext",
"declaration": true,
"declarationMap": true,
"downlevelIteration": true,
"noImplicitAny": true,
"preserveConstEnums": true,
"sourceMap": true,
"target": "es5",
"noUnusedLocals": true,
"skipLibCheck": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"importHelpers": true,
"esModuleInterop": true,
"outDir": "./lib",
"lib": ["dom", "es2017"],
"experimentalDecorators": true,
"plugins": [
{ "transform": "@zerollup/ts-transform-paths" },
{ "transform": "typescript-is/lib/transform-inline/transformer" }
]
},
"typedocOptions": {
"entryPoints": ["src/index.ts", "src/config/index.ts", "src/errors/errors.ts"],
"out": "docs",
"theme": "markdown",
"exclude": "src/messages",
"entryPointStrategy": "resolve",
"plugin": ["typedoc-plugin-markdown", "typedoc-plugin-merge-modules", "typedoc-plugin-rename-defaults"],
"mergeModulesMergeMode": "module",
"mergeModulesRenameDefaults": true,
"includeVersion": true,
"excludePrivate": true,
"excludeNotDocumented": true,
"readme": "none",
"gitRevision": "main"
},
"include": ["src", "test"],
"exclude": ["node_modules"]
}
and the jest.config.cjs
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
globals: {
'ts-jest': {
compiler: 'ttypescript',
},
},
preset: 'ts-jest',
collectCoverageFrom: ['src/**', '!src/messages/**'],
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
'^@messages/(.*)$': '<rootDir>/src/messages/$1',
},
roots: ['src', 'test']
};
can you help me understanding what is going on?
Hi.
I'm working on a typescript project, and I'm using jest to run the tests.
I introduced ttypescript and ts-transform-paths but now I have a strange error: for each test I have an error with this message:
The error doesn't come up if I remove
{ "transform": "@zerollup/ts-transform-paths" }fromcompilerOptions.pluginsFor reference this is the content of my tsconfig.json
{ "compilerOptions": { "baseUrl": "src", "paths": { "@/*": ["*"], "@messages/*": ["messages/*"] }, "module": "esnext", "declaration": true, "declarationMap": true, "downlevelIteration": true, "noImplicitAny": true, "preserveConstEnums": true, "sourceMap": true, "target": "es5", "noUnusedLocals": true, "skipLibCheck": true, "moduleResolution": "node", "resolveJsonModule": true, "importHelpers": true, "esModuleInterop": true, "outDir": "./lib", "lib": ["dom", "es2017"], "experimentalDecorators": true, "plugins": [ { "transform": "@zerollup/ts-transform-paths" }, { "transform": "typescript-is/lib/transform-inline/transformer" } ] }, "typedocOptions": { "entryPoints": ["src/index.ts", "src/config/index.ts", "src/errors/errors.ts"], "out": "docs", "theme": "markdown", "exclude": "src/messages", "entryPointStrategy": "resolve", "plugin": ["typedoc-plugin-markdown", "typedoc-plugin-merge-modules", "typedoc-plugin-rename-defaults"], "mergeModulesMergeMode": "module", "mergeModulesRenameDefaults": true, "includeVersion": true, "excludePrivate": true, "excludeNotDocumented": true, "readme": "none", "gitRevision": "main" }, "include": ["src", "test"], "exclude": ["node_modules"] }and the jest.config.cjs
can you help me understanding what is going on?