Skip to content

importing JavaScript containing JsDoc comments #9317

@tamird

Description

@tamird

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions