rokucommunity / rokucommunity/brighterscript
?? operator transpiled code is needlessly verbose
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 208
- Forks
- 68
- Avg merge
- 8h 39m
- Merged PRs (30d)
- 39
Description
endpoints = mc.getPath(task.output, "data.endpoints") ?? {}
transpiles to :
endpoints = (function(mc, task)
__bsConsequent = mc_getPath(task.output, "data.endpoints")
if __bsConsequent <> invalid then
return __bsConsequent
else
return {}
end if
end function)(mc, task)
in this case, where there is no dotted get, we could just have a function?
also, given that we know this is a statement, we could actually insert the if inline, which will use up just as much script ram storage as this code here.
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 the ?? operator is transpiled, using the issue's example as the expected comparison. Check whether simple property access and statement assignments can use shorter output without changing semantics; done means equivalent transpiled code is less verbose and existing transpiler tests still pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100