rokucommunity / rokucommunity/brighterscript

Support `import type`

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

Nobody has claimed this yet.

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

Description

Many times, developers want to declare an interface next to a function. However, when other files need to utilize that interface, they are currently forced to also bring along the runtime functions with it.

'pkg:/components/Button.bs
interface ButtonBase
    text as string
end interface

sub init()
end sub
'pkg:/components/MainMenu.bs
import type "pkg:/components/Button.bs"

'yay, no "duplicate function named init" diagnostic
sub init()
    button = {} as ButtonBase
end sub

Requirements:

1 ) add a new type keyword to the import statement (i.e. import type "pkg:/source/common.brs")

Implementation details:

  • import type will bring along all:
    • interfaces
    • enums
  • these script imports are deleted from the xml file at transpile time since they do not represent any runtime code

Future enhancements can be to import classes as types, but there's more work involved with that as we need to flag certain types

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 tracing how import statements are parsed and how script imports are emitted into the XML during transpilation. Check the existing handling for interfaces and enums, then verify that import type makes those declarations available without runtime imports. Done means type-only imports are removed from the generated XML while ordinary imports retain their current behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.