rokucommunity / brighterscript

A superset of Roku's BrightScript language
MIT License
152 stars 47 forks source link

Fixes issue with setting `roSGNodeTargetSet.targetRects` #1223

Closed markwpearce closed 1 month ago

markwpearce commented 1 month ago

Fixes #1219

Reason this was a problem is because the scraper did not understand array of rectangles as a type.

I wish Roku would use actual types here! The interface type should have been rect2dArray ... oh well..

I also updated the diagnostic message for type incompatibility to be able to add a override for the extended message which is useful if assigning Arrays of different default types, and the inner type is incompatible.

Example:

targetSet = createObject("roSGNode", "TargetSet")
targets = ["hello", "world"]
targetSet.targetRects = targets ' targetRects is an array of rectangles, which are AA's with x,y,width,height

Before

"Type 'Array<string>' is not compatible with type 'Array<roAssociativeArray>'
    Type 'Array<string>' is missing the following members: height, width, x, y, ifAssociativeArray, AddReplace, Append, Clear, Count, Delete, DoesExist, Items, Keys, Lookup, LookupCI, ...and 5 more"

Now:

"Type 'Array<string>' is not compatible with type 'Array<roAssociativeArray>'
    Type 'string' is missing the following members of type 'roAssociativeArray': height, width, x, y, ifAssociativeArray, AddReplace, Append, Clear, Count, Delete, DoesExist, Items, Keys, Lookup, LookupCI, ...and 5 more"

`

TwitchBronBron commented 1 month ago

Nice!