Unable to require `.d.ts` file on Unix only
See original GitHub issueIssue :
Similar but not the same as #950.
Running tests on my TypeScript project, including a TypeScript dependency, succeeds on Windows. It fails on Linux and OSX with the following:
FAIL src/__tests__/storyshots.test.ts
● Test suite failed to run
TypeError: Unable to require `.d.ts` file.
This is usually the result of a faulty configuration or import. Make sure there is a `.js`, `.json` or another executable extension available alongside `Fields.ts`.
at getOutput (../node_modules/ts-jest/dist/compiler.js:163:23)
at Object.compile (../node_modules/ts-jest/dist/compiler.js:185:29)
at TsJestTransformer.process (../node_modules/ts-jest/dist/ts-jest-transformer.js:101:41)
at Object.<anonymous> (../node_modules/@adm/webpart-library/src/Types.ts:1:1)
Fields.ts
contains:
- An interface
- A type
- A function
All of which are exported.
Here is my jest.config.json
:
{
"preset": "@voitanos/jest-preset-spfx-react16",
"rootDir": "../src",
"reporters": ["default", "jest-junit"],
"coverageReporters": ["cobertura", "html"],
"collectCoverageFrom": ["**/*.{js,jsx,ts,tsx}", "!**/node_modules/**"],
"moduleNameMapper": {
"\\.(css|scss)$": "identity-obj-proxy",
"^resx-strings/en-us.json": "<rootDir>/node_modules/@microsoft/sp-core-library/lib/resx-strings/en-us.json",
"^office-ui-fabric-react/lib/(.*)$": "office-ui-fabric-react/lib-commonjs/$1",
"^@adm/(.*)/lib/(.*)$": "@adm/$1/src/$2",
"^@adm\/([^\/]*)$": "@adm/$1/src",
"telemetry": "identity-obj-proxy",
"PeopleSearchService": "identity-obj-proxy"
},
"transformIgnorePatterns": [
"node_modules/(?!@adm/)"
]
}
Expected behavior :
The test succeeds regardless of operating system.
Debug log:
Minimal repo :
Very sorry but I do not have time to set one of these up right now. I will try and find the time to get a repo set up as soon as I can.
I am using TS 3.5, NodeJS 8.10.0/10.16.x (tried both), Jest 24.9 and ts-jest 24.0.2.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:18
Top Results From Across the Web
TypeError: Unable to require `.d.ts` file - Stack Overflow
Solved this problem by having all external modules built with a Rollup in esm format and using them instead.
Read more >TSConfig Reference - Docs on every TSConfig option
This is useful when you only have a small number of files and don't need to ... files with supported extensions are included...
Read more >Types and Type Declarations | Manual - Deno
When TypeScript is type checking a file, it only cares about the types for ... not have direct control over, the ability to...
Read more >find ".ts" but not ".d.ts" - Unix & Linux Stack Exchange
Is there another quick way to filter out .d.ts files from my search results? % find --version find (GNU findutils) 4.7.0-git.
Read more >Mocha - the fun, simple, flexible JavaScript test framework
only () is disallowed). --forbid-only causes Mocha to fail when an exclusive (“only'd”) test or suite is encountered, and it will ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
PR #1385 solved something related and it was merged into master. However we are not sure that it will solve this issue. Can anyone please test the latest changes on master against this issue ?
tsconfig.json/compilerOptions.preserveSymlinks
fixed for me (I use Mac). Need some helps from community to investigate the solution.