Add typescript target to pbjs #1580
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Well, clearly, this one is going to require a fair amount of discussion. We've been having ongoing problems with pbts because of various issues (see #998, #1217, #1414, etc). This PR removes the need for pbts (and the jsdoc dependency) by adding a typescript target to pbjs that directly generates a standard .ts file.
This PR should be considered only a proof of concept -- I wouldn't expect it to be merged as-is. But I wanted to judge the interest level in this (or something like it) before I spent more than the weekend on it.
In the current PR, this was done by forking static.js and modifying it to generate a TypeScript file. That's the real downside of the PR as-is, since a fair amount of the code is incredibly similar. I would be happy to look at instead modifying static.ts so that it can generate either JavaScript or TypeScript directly. I think the number of places that would need to be modified to handle that are relatively small.
There are also a few changes in typescript.js that cast to
as any
-- many of those are because of incorrect type definitions in protobuf's existing index.d.ts (particularly protobuf's Long is just a constructor and does not have the methods the real Long has).