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
We now have the checkjs option for now which allows for validating types in JavaScript as specified by JsDoc comments and basic inference. No plans to add any type of dynamic/runtime verification at this point, so closing this issue.
A note about the tapjs issue; if the author of the package is not maintaining the .d.ts file DefinitelyTyped is a better place. the ideal case is that the .js file and .d.ts ship in tandem, and that changes in one are reflected in the other, but that again requires some cooperation from the package maintainers, and not everyone is willing to make such commitments.
It would be great if we have a random js file and we can validate it conforms to a .d.ts file; it would also be helpful to have a tool that given a validated pair of .js and .d.ts, and an update to the .js file, would tell you what, if any, declarations need to be updated. These were the topics of a research paper i linked to erlier.
We do not believe the general solution is feasible just using static analysis, and some execution will be needed. For that we believe this is outside the scope of the TS project, but can be a target of community tooling. we have similar tools in dts-gen that use execution to generate a .d.ts file.
Activity
unional commentedon Apr 12, 2016
This could have a significant impact on typescript adoption considering this use case:
Help package author to maintain their own
.d.tsfile.Using this feature, package author can still write code in js and easily verify if their typings need to be updated.
🌹
cc Blake Embrey (@blakeembrey)
mhegazy commentedon Oct 11, 2017
A related work to this thread is a paper for Checking Correctness of
TypeScript Interfaces for JavaScript Libraries.
billti commentedon Oct 11, 2017
We now have the checkjs option for now which allows for validating types in JavaScript as specified by JsDoc comments and basic inference. No plans to add any type of dynamic/runtime verification at this point, so closing this issue.
styfle commentedon Oct 11, 2017
Bill Ticehurst (@billti) Maybe I missed it. Where are the docs / usage for this feature? Thanks!
billti commentedon Oct 11, 2017
There's a page at https://github.com/Microsoft/TypeScript/wiki/Type-Checking-JavaScript-Files which might be the best reference.
unional commentedon Oct 11, 2017
However, that doesn't help typings authors to validate their typings. :(
unional commentedon Oct 11, 2017
It is not about dynamic/runtime verification. Just need the same language service support to be available during compilation.
styfle commentedon Oct 11, 2017
Yes! As an example of why this is necessary, see this PR that never landed: tapjs/tapjs#256 (comment)
Also see a longer response why it never landed: tapjs/tapjs#237 (comment)
The reason is that the author has no way to test the typings that would be shipped with
node-tap.mhegazy commentedon Oct 11, 2017
A note about the tapjs issue; if the author of the package is not maintaining the .d.ts file DefinitelyTyped is a better place. the ideal case is that the .js file and .d.ts ship in tandem, and that changes in one are reflected in the other, but that again requires some cooperation from the package maintainers, and not everyone is willing to make such commitments.
It would be great if we have a random js file and we can validate it conforms to a .d.ts file; it would also be helpful to have a tool that given a validated pair of .js and .d.ts, and an update to the .js file, would tell you what, if any, declarations need to be updated. These were the topics of a research paper i linked to erlier.
We do not believe the general solution is feasible just using static analysis, and some execution will be needed. For that we believe this is outside the scope of the TS project, but can be a target of community tooling. we have similar tools in dts-gen that use execution to generate a .d.ts file.