The rk gen-types command generates .xml.d.ts type declarations for the XML components that the current project imports, without running a full build.

Usage

The following commands generate the declarations for the current project or for a specific config file:

rk gen-types
rk gen-types --config ./roku-config.ts

Deciding when to use rk gen-types

The .xml.d.ts files are gitignored build artifacts. The rk build and rk dev commands synchronize them automatically before type checking, but a plain tsc --noEmit (or an app's type-check script) does not. On a fresh checkout that has never been built, TypeScript then reports missing JSX intrinsics for custom XML tags (for example, measuredLabel).

The rk gen-types command runs the generation half of that synchronization so that the type check works before any build. It does not delete orphan .xml.d.ts files because a per-app type check can see shared workspace packages as search roots, and cleaning orphans there would remove declarations that other apps still need. Full builds (rk build and rk dev) still perform orphan cleanup.

The following package.json script runs the command before a type check:

{
    "scripts": {
        "type-check": "rk gen-types && tsc --noEmit"
    }
}

Options

See the generated rk gen-types reference for more information about every option.

The command uses app.tsconfigPath and dtsOptions from the project config in the same way that rk build does.

Related documentation

  • XML component imports — Describes how .xml.d.ts generation works.
  • rk build — Describes the full production build, which includes this step before the type check.

Did this page help you?