-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Allow --declaration
with --allowJs
#7546
Comments
PRs are welcomed. the fix should be removing the error, making sure the call is wired correctly, adding tests and making sure the declaration emitter handles the JS types correctly, |
anyone currently working on this? If not i may take a stab at it. |
got for it. |
This would be definitely helpful 👍 |
👍 |
Take a look at dts-gen and let us know what you think. At the moment it doesn't do a good job of detecting changes between generations. But let us know if this helps! |
Thanks @bowdenk7! Would a simple approach like #7535 (comment) (internally) be enough to check if the definition has changed? It would be great to be able to run |
Another use-case for this is that I have some plain JS tests that I use as both a form of documentation and as a way of validating that my code is callable from native ES5 in a way that is reasonable. All of my distributed source code is sourced from TypeScript and I would like to generate definition files for NPM publishing. However, because I have that one JS test sitting in my source tree I need |
@bengreenier Wondering if you have made much progress on this? Let me know if there is anyway I can help speed things up. Would love to see this out in the wild. |
Based on the discussion in #15747, we would like to take this change. |
@nojvek i've also made no more progress 😁 - got pulled into a different project and had to re-prioritize. |
@studds when I say a large legacy library, I mean a very large legacy library... The time it would take to convert all of the .js files over to .ts and add the syntax required to make them valid TS (even typing everything as any) would be obscene to say the least. Is saying |
That's my exact use case - generating Protobuf source code which includes
both .js and .d.ts files.
…On Wed, Sep 4, 2019 at 10:53 PM Christian Stewart ***@***.***> wrote:
I generate some Protobuf files (.js and .d.ts) which I want to include
with my library. I'd expect the Typescript compiler to pull the files
together into a bundle and produce combined definitions, but I get the
"simultaneous allowJs and declarations not allowed" issue
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#7546?email_source=notifications&email_token=AFLJ6KTEVJR5RBKLSL3RC7DQIAG4HA5CNFSM4B6JHBJ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD54YOPI#issuecomment-528058173>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFLJ6KUME3FNKB6EKOADFMLQIAG4HANCNFSM4B6JHBJQ>
.
|
@amitbeck I solved it for now by generating types separately and using --allowJs=false on the type generation step. |
I have an issue opened on TypeScript problems with understanding imported JSDoc types from imported node modules. It's currently flagged as backlog. Feel free to comment there to push this along: #33136. Getting this fixed would allow JavaScript authors to provide JSDoc types for their code that end users could take advantage of for type linting and Intellisense in VSCode with |
At Unsplash, this is blocking us from using project references aka |
Glorious day! Thanks @weswigham! Looks like this is slated for 3.7? Man that is going to be a great release. |
Does the conversion mechanism recognize node packaging? It seems it generates one module per file, although Node.js exports one module per dependency. |
A module is a file is a module; an npm package has 0, 1, or N files/modules. |
You are right. Still, it does not help with producing declarations compatible with the node module lookup mechanism. You may want to refer to this question on StackOverflow for an example of what is precisely happening: https://stackoverflow.com/questions/59564524/generating-typescript-declarations-for-re-exported-js-functions-in-a-node-js-mod |
is this resolved? |
From #7535, it would be useful for JavaScript package authors to have the ability to generate declarations from their project. This would help with getting started on a type definition (it would be populated with known interfaces/functions/types that are exported) and would also allow the creation of continuous integration scripts that check the JavaScript types with the hand-coded definition for inconsistencies.
The text was updated successfully, but these errors were encountered: