-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Validate JS file against typings? #7661
Comments
This could have a significant impact on typescript adoption considering this use case: Help package author to maintain their own
|
A related work to this thread is a paper for Checking Correctness of |
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. |
@billti Maybe I missed it. Where are the docs / usage for this feature? Thanks! |
There's a page at https://github.com/Microsoft/TypeScript/wiki/Type-Checking-JavaScript-Files which might be the best reference. |
However, that doesn't help typings authors to validate their typings. :( |
It is not about dynamic/runtime verification. Just need the same language service support to be available during compilation. |
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 |
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. |
With salsa provides typings support to javascript files, is there a way on the cli to use salsa to get a list of warning as in the language service?
If we can, we can use it to much quicker validate typings for typings authors by re-using test code available in the source package.
The text was updated successfully, but these errors were encountered: