rokucommunity / rokucommunity/brighterscript
Support `import type`
Nobody has claimed this yet.
- 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 typewill 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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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