You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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,
Reacted by Endel Dreyer, Benjamin Lupton, Steven, Martin Hochel and Thai Pangsakulyanont
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!
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 dts-gen in CI and error when there has been un-documented API changes to prompt an update to the .d.ts.
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 allowJs=true so the test will correctly land in the output directory (not committed to source control) and be run along with all of my other tests. This, of course, means I can't have TSC output definition files for the rest of my project.
Ben Greenier (@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.
For my use case, I have a large legacy library that was originally written
in plain JS. Since then, I've started slowly transitioning it to TS. All of
the publicly exported members have valid TS definitions, but I'm not able
to compile the lib with auto-constructed d.ts files due to the fact that I
need the allow JS flag in order to compile the TS files I have already
converted (due only to the flag conflict). I know that generation of
definition files for JS sources is a big task to take on, but perhaps a
good first step would be to allow commingling of the flags with any
exported members from .js files simply bring defined as type `any`?
On Sun, Sep 1, 2019, 9:41 AM Wesley Wigham ***@***.***> wrote:
There's also technical value in fixing this, namely enabling using
--incremental (and --composite) for projects with --allowJs, imo.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#7546?email_source=notifications&email_token=AECHXDS5DWSE2B4SCN6UCVDQHPWEVA5CNFSM4B6JHBJ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5UGGNY#issuecomment-526934839>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AECHXDWVTY5ST43TVBXNREDQHPWEVANCNFSM4B6JHBJQ>
.
Reacted by Jasin Yip, tu4mo, Rohit Gohri, Radosław Miernik, Jonas and PIMBA
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 type = importSourceType == js ? any : determineTSType(source) really that huge of a lift? Not familiar with the TS compiler code, but seems like this would be good bandaid solution that would help a lot of people out and should be much easier to implement than the solutions a lot of other people here are purposing....
Reacted by Kevin Verdieck, Radosław Miernik, Jonas and yucj
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>
.
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 allowjs set to true.
Glorious day! Thanks Wesley Wigham (@weswigham)! Looks like this is slated for 3.7? Man that is going to be a great release.
Reacted by Daniel Pereira and Frank Topel
Reacted by Jes Wulfsberg Nielsen, Connor Clark, Dmytro Yashyn, Thomas Eizinger, Shinigami, Rohit Gohri, Amit Beckenstein, Thomas Allmer, Steven, zernie and 16 more
Reacted by Wesley Wigham, Dmytro Yashyn, Shinigami, Amit Beckenstein, Steven, Julio, Bnaya Peretz, Jan Nicklas, Andrew Plummer, Tobias Pickel and 1 more
Reacted by Dmytro Yashyn, Thomas Eizinger, Tobias Cudnik, Shinigami, Aleksey Kulikov, Amit Beckenstein, Steven, Patrick Dahms, Bnaya Peretz, Jan Nicklas and 3 more
Activity
mhegazy commentedon Mar 16, 2016
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,
bengreenier commentedon May 30, 2016
anyone currently working on this? If not i may take a stab at it.
mhegazy commentedon Jun 1, 2016
got for it.
endel commentedon Nov 3, 2016
This would be definitely helpful 👍
trusktr commentedon Jan 24, 2017
👍
bowdenk7 commentedon Jan 25, 2017
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!
blakeembrey commentedon Jan 25, 2017
Thanks Bowden Kelly (@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
dts-genin CI and error when there has been un-documented API changes to prompt an update to the.d.ts.MicahZoltu commentedon Mar 27, 2017
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
allowJs=trueso the test will correctly land in the output directory (not committed to source control) and be run along with all of my other tests. This, of course, means I can't have TSC output definition files for the rest of my project.nojvek commentedon May 10, 2017
Ben Greenier (@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.
69 remaining items
industrialCoder commentedon Sep 2, 2019
studds commentedon Sep 4, 2019
Wesley Wigham (@weswigham) Jordan Harband (@ljharb) - not trying to argue this isn't valuable, I'd have loved it when I needed it. Just trying to identify some other approaches.
Ben Sawyer (@industrialCoder) would it be possible to change the rest of the files across to .ts and apply
anyyourself?industrialCoder commentedon Sep 4, 2019
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
type = importSourceType == js ? any : determineTSType(source)really that huge of a lift? Not familiar with the TS compiler code, but seems like this would be good bandaid solution that would help a lot of people out and should be much easier to implement than the solutions a lot of other people here are purposing....amitbeck commentedon Sep 4, 2019
paralin commentedon Sep 4, 2019
Amit Beckenstein (@amitbeck) I solved it for now by generating types separately and using --allowJs=false on the type generation step.
rbiggs commentedon Sep 5, 2019
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
allowjsset to true.OliverJAsh commentedon Sep 5, 2019
At Unsplash, this is blocking us from using project references aka
composite(becausecompositerequiresdeclarationto be turned on).nomcopter commentedon Sep 26, 2019
Glorious day! Thanks Wesley Wigham (@weswigham)! Looks like this is slated for 3.7? Man that is going to be a great release.
yin commentedon Jan 3, 2020
Does the conversion mechanism recognize node packaging? It seems it generates one module per file, although Node.js exports one module per dependency.
ljharb commentedon Jan 3, 2020
A module is a file is a module; an npm package has 0, 1, or N files/modules.
yin commentedon Jan 4, 2020
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
cecetipoi commentedon Apr 15, 2021
is this resolved?