Skip to content

Migrate remaining JS/JSX files to TypeScript and improve type safety#25066

Merged
dennisoelkers merged 20 commits intomasterfrom
refactor/migrate-ts
Feb 24, 2026
Merged

Migrate remaining JS/JSX files to TypeScript and improve type safety#25066
dennisoelkers merged 20 commits intomasterfrom
refactor/migrate-ts

Conversation

@dennisoelkers
Copy link
Copy Markdown
Member

Description

Motivation and Context

  • Migrate ~90 remaining .js/.jsx files to TypeScript (.ts/.tsx), bringing the codebase to near-complete TypeScript coverage
  • Eliminate all as any casts introduced during migration, and reduce remaining as casts to only those structurally necessary
    (Immutable.js .toJS(), Reflux createActions, plugin binding contravariance, union narrowing)
  • Add proper types to stores and utilities that previously returned any: Store.get<T>(), Store.sessionGet<T>(),
    getValueFromInput(), SystemJobsActions.list(), and typed fetch<T>() generics across multiple Reflux stores

Details

Migrated files span actions, stores, logic/utility modules, components, tests, and barrel/index files. A small set of .js files are intentionally kept: ACE editor mode files, webpack-entry.js, polyfill.js, and logic/index.js (webpack require.context).

Type safety improvements:

  • Store.get / Store.sessionGet are now generic (get<T>(key): T | undefined) instead of returning any
  • getValueFromInput returns string | number | boolean | undefined instead of any
  • SidecarStatusEnum properties and methods are fully typed
  • Reflux store actions use fetch<T>() generics to type API responses (EventDefinitionsStore, SimulatorStore, SystemJobsStore,
    EnterpriseStore, EventsStore, PluginsStore)
  • Event handlers narrowed from SyntheticEvent to React.ChangeEvent<HTMLInputElement> where applicable

/nocl No user-facing change.
/prd Graylog2/graylog-plugin-enterprise#13306

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactoring (non-breaking change)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have requested a documentation update.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.

@dennisoelkers dennisoelkers marked this pull request as ready for review February 23, 2026 15:09
Copy link
Copy Markdown
Contributor

@linuspahl linuspahl left a comment

Choose a reason for hiding this comment

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

These changes look good to me!

.navbar-collapse,
.navbar-form {
border-color: ${chroma(theme.colors.gray[90]).darken(0.065)};
border-color: ${chroma(theme.colors.gray[90] as string)
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.

As far as I can tell we don't need to use as string here and in similar cases.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

help={futureTimestampNormalizationHelpText}
onChange={(event) =>
handleEnableFutureTimestampNormalisation(getValueFromInput(event.target), setFieldValue)
handleEnableFutureTimestampNormalisation(Boolean(getValueFromInput(event.target)), setFieldValue)
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.

I noticed that we sometimes use as to cast the result of getValueFromInput and sometimes we use String() or Boolean(). Is there a reason for it?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The first was Claude's attempt to do it, I corrected it to use String/Boolean, but it seems like it did not track back all of its changes :/

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed these and other occurences.

@dennisoelkers dennisoelkers merged commit eb120be into master Feb 24, 2026
24 checks passed
@dennisoelkers dennisoelkers deleted the refactor/migrate-ts branch February 24, 2026 08:02
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.

2 participants