Skip to content

Add strict TypeScript flags in setup wizard #1264

Description

@matejchalk

User story

The main advantage of integrating @code-pushup/typescript-plugin is that it allows setting a strict aspirational tsconfig.json, even though the current codebase isn't prepared to meet those standards. This can be set up with 2 tsconfigs - the old config that currently passes compilation, and a derived config with added strict flags for Code PushUp. This facilitates incremental improvements over a longer period of time, with progress being tracked and no blocking build errors.

Real-world example

tsconfig.json
{
"extends": "@strapi/typescript-utils/tsconfigs/server",
"compilerOptions": {
"jsx": "react",
"outDir": "dist",
"rootDir": ".",
"allowJs": true,
"baseUrl": "./",
"target": "esnext",
"skipLibCheck": true,
"strictNullChecks": true,
"noUncheckedIndexedAccess": true
},
"include": ["./"],
"exclude": ["node_modules/", "build/", "dist/", ".cache/", ".tmp/"]
}
tsconfig.strict.json
{
"extends": "./tsconfig.json",
"compilerOptions": {
"strict": true,
"noUncheckedIndexedAccess": true
}
}

Acceptance criteria

  • If the TypeScript plugin is selected in the setup wizard, then there is a further prompt (or CLI argument) to enable additional type-checking flags.
  • The user may choose any subset of the Type Checking compiler options.
  • The strict, noUncheckedIndexedAccess, and exactOptionalPropertyTypes compiler options are pre-selected.
  • The list of available options is filtered. Only options that aren't already enabled are listed.
  • If the strict flag is enabled but other flags within this family are disabled (e.g., strictNullChecks or noImplicitAny), then these flags are pre-selected.
  • If the user selects some additional compiler flags, then a new tsconfig.strict.json is created.
    • The tsconfig.strict.json extends the existing tsconfig (previously selected by the user in TypeScript plugin setup wizard #1256).
    • The tsconfig.strict.json enables the selected compiler options.
    • The @code-pushup/typescript-plugin setup in code-pushup.config.ts uses the new tsconfig.strict.json instead of the user-provided existing tsconfig.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions