Skip to content

Support minFirmwareVersion in bsconfig.json#1678

Merged
TwitchBronBron merged 9 commits intomasterfrom
copilot/add-minfirmwareversion-property
Apr 29, 2026
Merged

Support minFirmwareVersion in bsconfig.json#1678
TwitchBronBron merged 9 commits intomasterfrom
copilot/add-minfirmwareversion-property

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 23, 2026

Adds a minFirmwareVersion bsconfig option that restricts which BrightScript features are permitted based on the target Roku OS version. This applies to both .brs and .bs files — features such as optional chaining are not transpiled by BrighterScript and are emitted as-is, so the target device must natively support them.

Changes

  • BsConfig.ts — New optional minFirmwareVersion?: string property (semver-compatible string, e.g. "11.0.0")
  • DiagnosticMessages.ts — New diagnostic featureRequiresMinFirmwareVersion (code 1146)
  • BrsFileValidator.ts — Validates optional chaining operators (?., ?[, ?() in both .brs and .bs files against the configured version using semver.coerce + semver.lt; no-ops when minFirmwareVersion is unset
  • bsconfig.schema.json / docs/bsconfig.md — Schema and docs updated
  • package.jsonsemver promoted to explicit runtime dep; @types/semver added as dev dep

Example

Optional chaining was introduced in Roku OS 11. With minFirmwareVersion: "10.0.0":

' source/main.brs
sub main()
    value = obj?.name   ' Error: feature 'optional chaining' requires firmware 11.0.0, configured: 10.0.0
end sub
' source/main.bs — also produces an error, since optional chaining is not transpiled
sub main()
    value = obj?.name   ' Error: feature 'optional chaining' requires firmware 11.0.0, configured: 10.0.0
end sub

Features gated by firmware version (initial pass):

Feature Min Version
Optional chaining (?., ?[, ?() 11.0.0

Copilot AI linked an issue Apr 23, 2026 that may be closed by this pull request
…e validation

Agent-Logs-Url: https://github.com/rokucommunity/brighterscript/sessions/7c24c48c-8e2e-4615-9fbd-3e2231b68d4a

Co-authored-by: TwitchBronBron <2544493+TwitchBronBron@users.noreply.github.com>
Copilot AI changed the title [WIP] Add minFirmwareVersion property to bsconfig.json Support minFirmwareVersion in bsconfig.json Apr 23, 2026
Copilot AI requested a review from TwitchBronBron April 23, 2026 20:33
Copy link
Copy Markdown
Member

@TwitchBronBron TwitchBronBron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So actually, we don't currently transpile optional chaining even in .bs files. So that feature needs to be locked behind a firmware flag for both brs and bs files. Fix that and the tests. And comments everywhere.

…s since it is not transpiled

Agent-Logs-Url: https://github.com/rokucommunity/brighterscript/sessions/a5d96ac2-4cc8-40c7-a742-775cad61c763

Co-authored-by: TwitchBronBron <2544493+TwitchBronBron@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 23, 2026

So actually, we don't currently transpile optional chaining even in .bs files. So that feature needs to be locked behind a firmware flag for both brs and bs files. Fix that and the tests. And comments...

Fixed in 63f975f. Since optional chaining is emitted as-is (not transpiled to equivalent non-optional code), the firmware version check now applies to both .brs and .bs files. Added tests for both file types and updated the comments/docs accordingly.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 23, 2026

So actually, we don't currently transpile optional chaining even in .bs files. So that feature needs to be locked behind a firmware flag for both brs and bs files. Fix that and the tests. And comments...

Fixed in 63f975f. Removed the .brs-only guard from validateMinFirmwareVersionForOptionalChaining so the check now applies to both .brs and .bs files. Updated the JSDoc/inline comments throughout the method and the OPTIONAL_CHAINING_MIN_VERSION constant, and added matching .bs test cases (not set, 11.0.0, and below 11.0.0 for dotted get). Docs updated too.

@TwitchBronBron
Copy link
Copy Markdown
Member

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 27, 2026

@copilot nu-uh. https://github.com/rokucommunity/brighterscript/actions/runs/25012570834/job/73251900142?pr=1676

The CI run you linked (25012570834) is for PR #1676 (fix/pass-through-sourcemaps), not this PR. Its lint failure is an import() type annotation in util.ts that I never touched.

My PR #1678's CI (commit 2da91539) is all green — ubuntu, macOS, and Windows all pass. All 2642 tests pass and lint is clean locally too. Is there something specific in my changes you'd like me to fix?

@TwitchBronBron TwitchBronBron marked this pull request as ready for review April 29, 2026 15:35
Comment thread src/DiagnosticMessages.ts Outdated
@TwitchBronBron TwitchBronBron merged commit 56fbc13 into master Apr 29, 2026
7 checks passed
@TwitchBronBron TwitchBronBron deleted the copilot/add-minfirmwareversion-property branch April 29, 2026 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support minFirmwareVersion

2 participants