Skip to content
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

Closed
unional opened this issue Mar 23, 2016 · 9 comments
Closed

Validate JS file against typings? #7661

unional opened this issue Mar 23, 2016 · 9 comments
Assignees
Labels
Suggestion An idea for TypeScript VS Code Tracked There is a VS Code equivalent to this issue

Comments

@unional
Copy link
Contributor

unional commented Mar 23, 2016

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.

@unional
Copy link
Contributor Author

unional commented Apr 12, 2016

This could have a significant impact on typescript adoption considering this use case:

Help package author to maintain their own .d.ts file.

Using this feature, package author can still write code in js and easily verify if their typings need to be updated.

🌹

cc @blakeembrey

@mhegazy
Copy link
Contributor

mhegazy commented Oct 11, 2017

A related work to this thread is a paper for Checking Correctness of
TypeScript Interfaces for JavaScript Libraries
.

@billti
Copy link
Member

billti commented 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.

@billti billti closed this as completed Oct 11, 2017
@styfle
Copy link
Contributor

styfle commented Oct 11, 2017

@billti Maybe I missed it. Where are the docs / usage for this feature? Thanks!

@billti
Copy link
Member

billti commented 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
Copy link
Contributor Author

unional commented Oct 11, 2017

However, that doesn't help typings authors to validate their typings. :(

@unional
Copy link
Contributor Author

unional commented Oct 11, 2017

No plans to add any type of dynamic/runtime verification at this point, so closing this issue.

It is not about dynamic/runtime verification. Just need the same language service support to be available during compilation.

@styfle
Copy link
Contributor

styfle commented 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
Copy link
Contributor

mhegazy commented 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.

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Suggestion An idea for TypeScript VS Code Tracked There is a VS Code equivalent to this issue
Projects
None yet
Development

No branches or pull requests

6 participants