Skip to content

Add compilerOptions group to bsconfig.json#1750

Open
markwpearce wants to merge 1 commit into
rokucommunity:v1from
markwpearce:compiler-options-group
Open

Add compilerOptions group to bsconfig.json#1750
markwpearce wants to merge 1 commit into
rokucommunity:v1from
markwpearce:compiler-options-group

Conversation

@markwpearce

Copy link
Copy Markdown
Collaborator

Summary

Introduces a dedicated compilerOptions object in bsconfig.json for options that control how BrighterScript interprets, validates, and compiles code — similar to TypeScript's compilerOptions — as opposed to top-level options that control project structure, file discovery, and tooling/reporting behavior.

Closes #1734

  • The following options move into compilerOptions: allowBrighterScriptInBrightScript, autoImportComponentScript, bslibDestinationDir, emitDefinitions, emitFullPaths, legacyCallfuncHandling, manifest, minFirmwareVersion, pruneEmptyCodeFiles, relativeSourceMaps, removeParameterTypes, resolveSourceRoot, sourceMap, sourceRoot, strict, strictCallFunc, strictNodeMembers.
  • Legacy top-level locations still work for backwards compatibility. If an option is set both at the top level and in compilerOptions, the compilerOptions value wins.
  • Using a deprecated top-level option loaded from an actual bsconfig.json file (including through an extends chain) now emits a deprecated-bsconfig-option warning diagnostic pointing at the compilerOptions equivalent. This is deliberately scoped to file-based config — options passed programmatically to Program/ProgramBuilder are not flagged, since that's direct API usage rather than bsconfig.json authoring.
  • compilerOptions deep-merges across an extends chain (matching TypeScript's behavior), unlike every other bsconfig key, where a child's value fully replaces the parent's.
  • Updated bsconfig.schema.json, docs/bsconfig.md, and the README.md example accordingly.

This is a first pass at the field list — the set of options that belongs in compilerOptions vs. top-level is intentionally open to discussion, per the linked issue.

Test plan

  • npm run build
  • npm run lint
  • npm run test:nocover (4271 passing)
  • New unit tests covering: precedence (compilerOptions wins over legacy), deep-merge across extends, deprecation warning scoped to file-loaded config only (not programmatic API usage), and end-to-end diagnostic surfacing through ProgramBuilder

Note

This PR was mostly written by Claude (Anthropic's Claude Code), working from a design discussion with @markwpearce. Flagging for reviewer awareness — please review as you would any other contribution.

🤖 Generated with Claude Code

Introduces a dedicated `compilerOptions` object (similar to TypeScript's) for options
that control how BrighterScript interprets, validates, and compiles code, as opposed
to top-level options that control project structure, file discovery, and tooling.

- 17 options move into `compilerOptions`: allowBrighterScriptInBrightScript,
  autoImportComponentScript, bslibDestinationDir, emitDefinitions, emitFullPaths,
  legacyCallfuncHandling, manifest, minFirmwareVersion, pruneEmptyCodeFiles,
  relativeSourceMaps, removeParameterTypes, resolveSourceRoot, sourceMap, sourceRoot,
  strict, strictCallFunc, strictNodeMembers.
- Legacy top-level locations still work; `compilerOptions` wins if both are set.
- Using a deprecated top-level option loaded from an actual bsconfig.json file (including
  via `extends`) emits a `deprecated-bsconfig-option` warning diagnostic. Options passed
  programmatically to Program/ProgramBuilder are not flagged, since that isn't bsconfig.json
  authoring.
- `compilerOptions` deep-merges across an `extends` chain, unlike other bsconfig keys.

Closes rokucommunity#1734

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@markwpearce

Copy link
Copy Markdown
Collaborator Author

FYI for reviewers: I checked how much of the existing test suite uses the legacy flat bsconfig option names (sourceMap, strict, minFirmwareVersion, manifest, etc.) directly on options objects passed to Program/ProgramBuilder.

  • 24 spec files, 112 occurrences use the legacy flat names — heaviest: Program.spec.ts (33, almost all sourceMap: true), bscPlugin/validation/ProgramValidator.spec.ts (10), bscPlugin/validation/BrsFileValidator.spec.ts (9), files/BrsFile.spec.ts (7).
  • None of these trip the new deprecated-bsconfig-option warning, since the warning is scoped to options loaded from an actual bsconfig.json file (including via extends) — not options passed programmatically to Program/ProgramBuilder. That scoping was actually driven by this exact pattern: an earlier version of this PR warned unconditionally and broke ~50 tests that construct Program/ProgramBuilder with plain option objects like { rootDir, sourceMap: true }.
  • So no test changes were needed for this PR to land, but if we ever want the test suite itself to model the new compilerOptions style, it's a real but mostly mechanical chunk of work (sourceMap: truecompilerOptions: { sourceMap: true }), concentrated in a handful of files.

Not blocking — just flagging for context/possible follow-up.

@markwpearce

Copy link
Copy Markdown
Collaborator Author

Building using this change shows warnings like this:

...
[04:07:09:929 PM] DiagnosticsManager.getDiagnostics()
[04:07:09:930 PM] diagnostic counts: total=81, after filter=77
[04:07:09:931 PM] DiagnosticsManager.getDiagnostics() finished. (1.422ms)

bsconfig.json:1:1 - warning deprecated-bsconfig-option: 'autoImportComponentScript' is deprecated at the top level of bsconfig.json. Move it into 'compilerOptions.autoImportComponentScript' instead

bsconfig.json:1:1 - warning deprecated-bsconfig-option: 'sourceMap' is deprecated at the top level of bsconfig.json. Move it into 'compilerOptions.sourceMap' instead

[04:07:09:932 PM] Building
....

@markwpearce
markwpearce marked this pull request as ready for review July 16, 2026 18:05
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.

1 participant