-
Notifications
You must be signed in to change notification settings - Fork 12.8k
In declaration files generated from JavaScript files and their JSDoc, unresolved types are not converted to any
.
#47025
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
Comments
any
.
Seems like we have two conflicting principles at work here:
I'm not sure |
On PDF.js's side, only
You can see the generated files: The generated When I call with
We had better say non-strict rather than invalid. I think TypeScript users know how to live with non-strict declaration files anyway. |
@tamuratak i am also a havy .js only typescript user and i think the current behavior is correct to keep the type declarations strict. when you get invalid types we need to fix that on a other end i am also working on tooling to package .d.ts files so that you could ship complet working types even when you package your code at the end. that is possible because .d.ts files can overlap so it does not hurt in normal cases. ProposalI would accept a --noneStrictDts setting that allows to convert unresolved to any but existing behavior should not change what do you think? |
This is somewhat unrelated to
We're in a similar situation over in the Gutenberg project (https://github.com/WordPress/gutenberg). While we are incorporating Typescript more and more, we have to rely on the jsdoc -> typescript workflow for many of the existing packages, some of which are quite large. While I'd love to fix every type issue that exists in the project, we mostly want to be able to publish types for users asap, and the vast majority of JSDoc types would still make this a decent experience.
The main issue we run into is that with In one example, just one error out of many got included into the *.d.ts file. Ideally, I would like |
@noahtallen it seems like "build with |
Thanks for chiming in! That does work 👍 I think it will be pretty easy to integrate in various workflows as well. |
Bug Report
With TypeScript 4.5.2, when we generate declaration files from JavaScript files and their JSDoc annotations with
tsc --allowJs --declaration --emitDeclarationOnly
, unresolved types are not converted toany
. I can see the same issue with4.6.0-dev.20211204
.🔎 Search Terms
JSDoc, allowJs, declaration
🕗 Version & Regression Information
💻 Code
Generate
main.d.ts
frommain.js
withtsc --allowJs --declaration --emitDeclarationOnly main.js
main.js
🙁 Actual behavior
With
4.6.0-dev.20211204
,main.d.ts
:🙂 Expected behavior
With
4.4.4
,main.d.ts
:The text was updated successfully, but these errors were encountered: