-
-
Notifications
You must be signed in to change notification settings - Fork 431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No .d.ts Declaration Files for JS Files Are Emitted (allowJs: true) #1260
Comments
I guess this should be fixed by changing this line of code: if (fileName.match(constants.tsTsxRegex) === null) { into this, as done in this line: if (fileName.match(compilerOptions.allowJs === true
? constants.dtsTsTsxJsJsxRegex
: constants.dtsTsTsxRegex;) === null) { Edit: I can confirm that this fixes this issues. Idk whether it causes other issues. |
I looked at your repo and confirmed what you reported. I can also confirm that when using tsc and allowJs the declaration files are generated, so I don't see any reason why ts-loader should not do this. Perhaps you would like to submit a PR with your proposed fix. |
… allowJs is set to true.
I submitted a PR! |
one... year... later... |
) * Fixes #1260 by generating declaration files for js files if allowJs is set to true. * Fix declarationOutputAllowJs test Update expected test output for 4.7 and stabilize expectation to be OS independent. * Update package.json and CHANGELOG.md for 9.3.1 * Update CHANGELOG.md Co-authored-by: John Reilly <[email protected]> Co-authored-by: Henning Dieterichs <[email protected]> Co-authored-by: John Reilly <[email protected]>
When setting
allowJs: true
intsconfig.json
, typescript files can import javascript files.Typescript is also clever about the types used in javascript and infers as much as possible.
Such inferred javascript types might even be exported by typescript files and become part of the library API.
Expected Behaviour
ts-loader
should emit declaration files for javascript files whenallowJs
is set totrue
andts-loader
is configured to handle javascript files.Actual Behaviour
ts-loader
does not emit declaration files for javascript files that are imported in typescript files. This results in broken declaration files.Steps to Reproduce the Problem
yarn
yarn build
Location of a Minimal Repository that Demonstrates the Issue.
https://github.com/hediet/webpack-allowjs-declaration-issue-repro
Btw., thanks for creating and maintaining ts-loader!
The text was updated successfully, but these errors were encountered: