Skip to content

fix(upgrade): bring an extension's TypeScript in line with the 4.9 Flarum builds with - #59

Merged
imorland merged 1 commit into
3.xfrom
im/upgrade-typescript-4-9
Oct 11, 2026
Merged

imorland merged 1 commit into
3.xfrom
im/upgrade-typescript-4-9

Conversation

@imorland

Copy link
Copy Markdown
Member

Fixes: no issue.

Changes proposed in this pull request:
Flarum 2.0 builds and checks its typings with TypeScript 4.9: core's ^4.5.4 resolves to 4.9.5. The upgrade now pins an extension's typescript to ^4.9.5, like the scaffold, and says why when it comes down from TypeScript 5.

It also handles what TypeScript 4.9 can't read:

  • it drops the tsconfig.json compiler options and values 4.9 doesn't have, using a list generated from typescript@4.9.5 itself, and reports what it removed;
  • it flags an extends list;
  • it puts a @TODO above syntax 4.9 can't compile: const type parameters, using, export type * and import attributes. TypeScript sources are only searched line by line, never parsed or reformatted.

post-build-typings now works with macOS's BSD sed as well as GNU sed, in the upgrade and the scaffold. JSON with a trailing comma before ], which tsconfig.json allows, no longer fails the step.

Reviewers should focus on:

  • Every flagged syntax, and every tsconfig rule, was checked against typescript@4.9.5 rather than release notes. That ruled out accessor, satisfies and import … assert, which 4.9 has.
  • Checked across 9,313 real TypeScript files (core, bundled and installed third-party extensions): no false positives.
  • Checked across 133 real tsconfig.jsons: only fof/links and fof/polls change, losing moduleResolution: "bundler". Six FoF configs with a trailing ,] used to fail the JSON parse; they now load.

Screenshot
N/A

Necessity

  • Has the problem that is being solved here been clearly explained?
  • If applicable, have various options for solving this problem been considered?
  • For core PRs, does this need to be in core, or could it be in an extension? (N/A)
  • Are we willing to maintain this for years / potentially forever?

Confirmed

  • Frontend changes: tested on a local Flarum installation. (The built CLI ran step 2 on a 1.x-style fixture extension, and the changes and the commit came out as intended.)
  • Frontend changes: tests are green (run yarn test in js/). (yarn test: 244 tests, plus Prettier, ESLint and tsc.)
  • Frontend changes: tests have been added, or are not appropriate here. (23 new tests, written first and seen failing. One runs the new post-build-typings for real, so CI checks it with GNU sed.)
  • Backend changes: tests are green (run composer test). (N/A)
  • Backend changes: tests have been added, or are not appropriate here. (N/A)
  • Where applicable, changes are suitable for all supported database drivers (MySQL, MariaDB, PostgreSQL, SQLite). (N/A)
  • Core developer confirmed locally this works as intended.
  • The description above is written by me and describes what this pull request actually does.

Required changes:

None.

…arum builds with

- Pin typescript to ^4.9.5 in the upgrade and the scaffold, and say why
  when it comes down from TypeScript 5.
- Drop the tsconfig.json compiler options and values TypeScript 4.9
  doesn't have, from a list generated from typescript@4.9.5, and flag an
  extends list.
- Put a @todo above syntax 4.9 can't compile: const type parameters,
  using declarations, export type *, and import attributes.
- Make post-build-typings work with BSD sed as well as GNU sed.
- Read JSON with a trailing comma before ], as tsconfig.json allows.
@imorland
imorland marked this pull request as ready for review October 11, 2026 11:31
@imorland
imorland merged commit af77138 into 3.x Oct 11, 2026
3 checks passed
@imorland
imorland deleted the im/upgrade-typescript-4-9 branch October 11, 2026 11:31
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