Skip to content

DEV: Update typescript to V6#464

Open
nourinmohd wants to merge 5 commits into
equinor:mainfrom
nourinmohd:new_update_typescript
Open

DEV: Update typescript to V6#464
nourinmohd wants to merge 5 commits into
equinor:mainfrom
nourinmohd:new_update_typescript

Conversation

@nourinmohd

@nourinmohd nourinmohd commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Resolves #461

This PR updates the frontend TypeScript toolchain to TypeScript 6 and applies the related package/config changes needed for the transition release.

It also updates React lint-related packages and adjusts affected React state code so the newer react-x rules remain enabled and pass cleanly.

Dependency Updates:
Updated TypeScript and related tooling in package.json

- typescript
- @hey-api/openapi-ts
- eslint-plugin-react-dom
- eslint-plugin-react-x

TypeScript Config
Removed the explicit lib setting from tsconfig.app.json

TypeScript 6 now includes DOM.Iterable as part of DOM, and the default DOM/ES2024 libs cover the previous explicit config. This addresses the TypeScript 6 release-note change around DOM.Iterable.

React-X Lint Changes
The updated eslint-plugin-react-x usage and state updates inside effects. This PR keeps those rules enabled and updates affected code paths instead of disabling the rules globally.

Key Points :

  • Setter naming was aligned with react-x/use-state.
  • Some state reset logic was changed to derived state instead of effect-driven state
  • Some effect-triggered state transitions were deferred with Promise.resolve().then(...) to avoid synchronous state updates directly inside effect setup
  • Stratigraphy mappings were changed from effect-initialized state to keyed state

pnpm install may still show a TypeScript peer warning from transitive tsconfck@3.1.6 through vite-tsconfig-paths vite-tsconfig-paths is already latest, and tsconfck does not currently publish a TypeScript 6-compatible peer range.

Checklist

  • Tests added (if not, comment why)
  • Test coverage equal or up from main (run pytest with --cov=src/ --cov-report term-missing)
  • If not squash merging, every commit passes tests
  • Appropriate commit prefix and precise commit message used
  • All debug prints and unnecessary comments removed
  • Docstrings are correct and updated
  • Documentation is updated, if necessary
  • Latest main rebased/merged into branch
  • Added comments on this PR where appropriate to help reviewers
  • Moved issue status on project board
  • Checked the boxes in this checklist ✅

@nourinmohd
nourinmohd force-pushed the new_update_typescript branch from cc8469e to 56ae1f3 Compare June 24, 2026 08:32
@nourinmohd
nourinmohd force-pushed the new_update_typescript branch from 56ae1f3 to 8a9ea4d Compare June 24, 2026 08:35
@nourinmohd
nourinmohd requested review from GibranAlfa and joargr June 24, 2026 08:46
@nourinmohd
nourinmohd marked this pull request as ready for review June 24, 2026 08:46
@nourinmohd
nourinmohd force-pushed the new_update_typescript branch from 8a9ea4d to 6df5dda Compare June 24, 2026 08:47
Comment thread frontend/package.json Outdated
Comment thread frontend/package.json

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

With the update to a new major version, I think it's natural to visit the TypeScript configuration as well. TypeScript 5.9 made changes to the initial configuration (as created by the command tsc --init), creating a tsconfig.json with modern configuration. Along with changes in TypeScript 6 and some guides, this can be used as a reference to update the TypeScript configuration in FMU Settings GUI.

Suggest doing the following changes in compilerOptions in tsconfig.app.json:

  • rootDir: In TypeScript 6, this now defaults to ., which is the directory where the tsconfig.json file resides. Source files are located in ./src, so it appears that this option needs to be set, however development seems to work like normal without this setting. It should probably only be set if there are errors when developing or building the application
  • module: Change from ESNext to preserve. Both values are recommended when using a bundler (ie. Vite), but preserve seems to be the better value
  • target: Change from es2024 to esnext. It should be ok to go with configuration that says the latest version, as the application will run on evergreen browsers
  • types: In TypeScript 6, this now defaults to []. I don't think the application needs to specify any types like this, so the empty array is probably ok. And as it is the default value, there is no need to explicitly set this option
  • sourceMap, declaration and declarationMap: As noEmit is true these options are irrelevant
  • Bundler mode:
    • verbatimModuleSyntax: Set to true
    • isolatedModules: This option is by default true when verbatimModuleSyntax is true, so the option can and should be removed from the configuration, as the default value is the needed value
    • skipLibCheck: Set to true
  • Linting options:

The tsconfig.node.json is the configuration when developing a Nodejs application, so that file is not relevant for FMU Settings GUI, and it can be ignored in this PR.

As the TypeScript configuration is set for the latest ECMAScript/JavaScript version, the ESLint configuration should be updated accordingly. In eslint.config.js, languageOptions.ecmaVersion is currently set to 2024. The default value of this option is latest, which is the needed value, so the option can be removed from the configuration.

@nourinmohd

Copy link
Copy Markdown
Contributor Author

Implemented the PR review follow-up.

  • Changed package.json and pnpm-lock.yaml to revert @hey-api/openapi-ts back to ^0.66.7, leaving the larger generator upgrade for the separate issue.
  • Updated tsconfig.app.json with the modern TS config changes target: esnext, module: preserve, verbatimModuleSyntax, skipLibCheck, noUncheckedIndexedAccess, exactOptionalPropertyTypesand removed ecmaVersion from eslint.config.js.

Because exactOptionalPropertyTypes and noUncheckedIndexedAccess expose real type issues, I also updated the affected frontend code to omit optional generated/API props when absent, widen internal optional prop types where the app intentionally passes undefined, and guard indexed lookups in form, history, masterdata, mapping, RMS, stratigraphy, and route components.

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.

Update TypeScript version to 6

2 participants