rokucommunity / rokucommunity/brighterscript

Support for declaring all roku types in typedefs

Open
#1,412 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
208
Forks
68
Avg merge
8h 39m
Merged PRs (30d)
39

Description

We should have a way to declare all (or almost all) built-in roku types in typedefs. This would provide several benefits:

  • more flexibility for contributors wanting to improve the documentation on the native types
  • more options for separating certain features into different libraries (like brightscript, brightsign, maybe future versions of brightscript with new features)
  • enables developers to use that same syntax to declare objects in their own code that might not be public knowledge (i.e. internal roku projects, select partners, etc).

I envision we move all of the built-in types and objects and components and interfaces into a single folder (maybe libs/brightscript.d.bs, and here is the syntax I'm currently envisioning.

  • the native interfaces can probably just use the existing interface keyword

    interface ifDateTime
        sub ToLocalTime() as Void
       ...etc
    end interface
    
  • "brightscript components" use the object keyword". We need a way to "spread" all of the functions of an interface onto the object. Maybe that's how "implements" works for object, or maybe we have some extra syntax to say "I'm not going to write them again, just copy them onto this thing".

    object roDateTime implements ifDateTime, ifToStr
        'objects can also have concrete methods declare on them, if you want to make an interface for them
        function someNonInteraceFunc() as integer
    end object
    
  • components would use the component keyword (like the component statement syntax mentioned in #575)

    component "Rectangle" extends "Group"
        'callfuncs
        public getBoundingRect() as roAssociativeArray
        'fields
        public someField as roAssociativeArray
    end component
    
  • Declaring these items with the declare keyword in a d.bs file might allow them to be exposed globally to the program. Like this:

    declare function abs(num) as number
    

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the proposed declarations in a possible libs/brightscript.d.bs file and the component statement syntax referenced in #575. Determine how interfaces, objects, components, and declare would fit together, then define a testable scope for built-in type declarations and global exposure; the issue does not identify existing implementation files or tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.