DEV: Update typescript to V6#464
Conversation
cc8469e to
56ae1f3
Compare
56ae1f3 to
8a9ea4d
Compare
8a9ea4d to
6df5dda
Compare
There was a problem hiding this comment.
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 thetsconfig.jsonfile 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 applicationmodule: Change fromESNexttopreserve. Both values are recommended when using a bundler (ie. Vite), butpreserveseems to be the better valuetarget: Change fromes2024toesnext. It should be ok to go with configuration that says the latest version, as the application will run on evergreen browserstypes: 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 optionsourceMap,declarationanddeclarationMap: AsnoEmitistruethese options are irrelevant- Bundler mode:
verbatimModuleSyntax: Set totrueisolatedModules: This option is by defaulttruewhenverbatimModuleSyntaxistrue, so the option can and should be removed from the configuration, as the default value is the needed valueskipLibCheck: Set totrue
- Linting options:
strict: The default value istrue, so setting this explicitly is not needednoUncheckedIndexedAccess: Set totrueexactOptionalPropertyTypes: Set totruenoUncheckedSideEffectImports: The default value istrue, so setting this explicitly is not needed
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.
|
Implemented the PR review follow-up.
Because |
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-xrules remain enabled and pass cleanly.Dependency Updates:
Updated TypeScript and related tooling in
package.jsonTypeScript Config
Removed the explicit
libsetting fromtsconfig.app.jsonTypeScript 6 now includes
DOM.Iterableas part ofDOM, and the defaultDOM/ES2024 libscover the previous explicit config. This addresses the TypeScript 6 release-note change aroundDOM.Iterable.React-X Lint Changes
The updated
eslint-plugin-react-xusage and state updates inside effects. This PR keeps those rules enabled and updates affected code paths instead of disabling the rules globally.Key Points :
react-x/use-state.Promise.resolve().then(...)to avoid synchronous state updates directly inside effect setuppnpm installmay still show a TypeScript peer warning from transitivetsconfck@3.1.6throughvite-tsconfig-pathsvite-tsconfig-pathsis already latest, andtsconfckdoes not currently publish a TypeScript 6-compatible peer range.Checklist
--cov=src/ --cov-report term-missing)