rokucommunity / brighterscript

A superset of Roku's BrightScript language
MIT License
160 stars 46 forks source link

Support types declared in comments #1030

Open TwitchBronBron opened 8 months ago

TwitchBronBron commented 8 months ago

Many dev shops are not permitted to use the BrighterScript transpiled, and as such, cannot leverage all the advanced types we've added to v1.

We should support parsing and validating based on types that are declared in comments as well. (Typescript does this with jsdoc). Something like:

 '@param node roSGNodeLabel
 Function getLabelText(node)
     Return node.propNotOnLabel
                 ~~~~~ unknown prop
 End function

The above case is pretty cut and dry. Not sure how we should handle when the param has a basic type like object and the doc has a more complex type. Maybe a warning?

I think the declared type needs to win over a comment type.

We should use this typescript docs page for reference and inspiration: https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html

markwpearce commented 8 months ago

I agree that this should be in … but probably for a release after v1.0.0 That being said, Getting the @param tags out of the comment is pretty straightforward - this wouldn’t be very hard to do at all.

TwitchBronBron commented 8 months ago

The reason I think we might want to consider adding this for the v1 alphas is that it would allow even more dev shops to start testing out the actual type system before the final release which gives us higher confidence in the release.

But yeah, if we are getting to bogged down with other stuff, I agree this could go after v1 lands