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

importing JavaScript containing JsDoc comments #9317

Closed
tamird opened this issue Jun 22, 2016 · 5 comments
Closed

importing JavaScript containing JsDoc comments #9317

tamird opened this issue Jun 22, 2016 · 5 comments
Labels
Fixed A PR has been merged for this issue

Comments

@tamird
Copy link

tamird commented Jun 22, 2016

I've been trawling the repository and wiki for information regarding how to import commonjs modules (specifically, those generated by protoc's javascript code generator) into a typescript file.

In particular, these generated files have JsDoc comments such as:

/**
 * Serializes the message to binary data (in protobuf wire format).
 * @return {!Uint8Array}
 */
proto.cockroach.server.serverpb.ClusterFreezeResponse.prototype.serializeBinary = function() {
...
}

As you might imagine, typescript definitions are not generated. Here's where things get confusing: the wiki page https://github.com/Microsoft/TypeScript/wiki/JsDoc-support-in-JavaScript claims that typescript supports gathering type information from some forms of JsDoc comments, but it seems to be impossible to import these commonjs modules without first writing some definitions for them (which ISTM would trample the JsDoc type information).

Does anyone have an example (or even instructions) on how this is meant to work? @RyanCavanaugh you seem to have worked on some of this - do you have an insights?

@mhegazy
Copy link
Contributor

mhegazy commented Jun 22, 2016

this should be handled by #7075

@tamird
Copy link
Author

tamird commented Jun 28, 2016

@mhegazy now that #7075 is in, how does it handle this? In other words, what's the expected syntax to make this work?

@mhegazy
Copy link
Contributor

mhegazy commented Jun 28, 2016

Fixed by #7075

@mhegazy mhegazy closed this as completed Jun 28, 2016
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Jun 28, 2016
@mhegazy mhegazy added this to the TypeScript 2.0 milestone Jun 28, 2016
@tamird
Copy link
Author

tamird commented Jun 28, 2016

@mhegazy can you respond to my previous comment? Simply closing the issue isn't helpful.

@mhegazy
Copy link
Contributor

mhegazy commented Jun 28, 2016

I am assuming you are using this file as a module and importing it into a different file and you are not seeing the type information, correct? if so, then #7075 fixes this by loading the .js files from a node package. previously only .d.ts files are loaded, and if none is provided no type information is loaded from a node package.

@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
Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

2 participants