Repository navigation
refactor(*): enable TypeScript strict mode - #1852
Open
ivanvpetrov wants to merge 4 commits into
Open
ivanvpetrov wants to merge 4 commits into
ivanvpetrov wants to merge 4 commits into
Conversation
- enable "strict": true in tsconfig.json, tsconfig-pack.json and the ng-schematics tsconfig - type lookup methods honestly (T | undefined / T | null) and fix all resulting compiler errors across core, cli, igx-templates, ng-schematics, scripts and specs - add @types/through2 (core) and @types/resolve (cli) dev dependencies
- cli upgrade, ng-schematics upgrade-packages: skip template resolution when the framework and project type resolve to no project library and report the existing "No valid Ignite UI project template" error instead of failing with a TypeError - add specs for both commands
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the strict-mode migration.
No open issues 🎉
What changed in this PR
Completes the strict-mode migration for #1613, building on the bug fixes in #1849 and test coverage in #1850. The changes align the CLI, shared core, templates, schematics, scripts, and specs with stricter TypeScript checks.
Changes:
- Enables strict compilation and adds the missing development-time type packages.
- Makes nullable lookup results, optional values, initialization assumptions, and public method signatures explicit.
- Adds safe defaults and upgrade guards, with regression tests for mismatched framework/project types.
| File | Description |
|---|---|
yarn.lock |
Locks the two added type packages. |
tsconfig.json |
Enables strict development compilation. |
tsconfig-pack.json |
Enables strict package compilation. |
spec/unit/upgrade-spec.ts |
Types mocks and tests mismatched project types. |
spec/unit/update-spec.ts |
Adds assertions for fixture lookups. |
spec/unit/TypeScript-AST-Transformer-spec.ts |
Types callbacks and nullable test values. |
spec/unit/ts-transform/TypeScriptUtils-spec.ts |
Types the newline lookup map. |
spec/unit/ts-transform/Mock-FS.ts |
Asserts mock filesystem initialization. |
spec/unit/TemplateManager-spec.ts |
Types mock libraries and module loaders. |
spec/unit/ProjectConfig-spec.ts |
Adjusts the filesystem spy typing. |
spec/unit/packageManager-spec.ts |
Types simulated process errors. |
spec/unit/new-spec.ts |
Explicitly casts intentionally incomplete mocks. |
spec/unit/GoogleAnalytic-spec.ts |
Types analytics spies. |
spec/unit/DotnetTemplateManager-spec.ts |
Types nullable statuses and expected calls. |
spec/unit/doc-spec.ts |
Types the module-loader callback’s this. |
spec/unit/cli-spec.ts |
Adjusts command-handler spy typing. |
spec/unit/BaseProjectLibrary-spec.ts |
Handles nullable component lookup types. |
spec/unit/base-templates/IgniteUIForAngularTemplate-spec.ts |
Types helper parameters and mocks. |
spec/unit/add-spec.ts |
Updates the mock filesystem return type. |
spec/templates/webcomponents-spec.ts |
Types template metadata and lookup assertions. |
spec/templates/template-contracts-spec.ts |
Asserts registered projects resolve. |
spec/templates/react-spec.ts |
Types template metadata and library lookups. |
spec/templates/blazor-spec.ts |
Asserts expected libraries and projects exist. |
spec/templates/angular-spec.ts |
Types template metadata and library lookups. |
spec/jasmine-runner.ts |
Explicitly casts the existing null argument. |
spec/helpers/utils.ts |
Adds a type assertion without changing helper behavior. |
spec/helpers/mocks.ts |
Types the mock library factory argument. |
spec/acceptance/new-spec.ts |
Types the test folder variable. |
scripts/versionScript.ts |
Adds a definite-assignment assertion. |
scripts/changelogScript.ts |
Types nullable versions and lookup keys. |
packages/ng-schematics/tsconfig.json |
Replaces individual checks with full strict mode. |
packages/ng-schematics/src/utils/NgFileSystem.ts |
Allows nullable visitor entries. |
packages/ng-schematics/src/utils/cli-config.ts |
Types caught errors and optional projects. |
packages/ng-schematics/src/upgrade-packages/index.ts |
Guards missing project libraries. |
packages/ng-schematics/src/upgrade-packages/index.spec.ts |
Tests the missing-library error path. |
packages/ng-schematics/src/prompt/SchematicsPromptSession.ts |
Marks externally initialized session fields. |
packages/ng-schematics/src/ng-new/schema.ts |
Clarifies initialized and optional options. |
packages/ng-schematics/src/ng-new/index.ts |
Uses standard context types and narrows optional values. |
packages/ng-schematics/src/component/schema.ts |
Clarifies required and optional component options. |
packages/ng-schematics/src/component/index.ts |
Asserts the built-in Angular library exists. |
packages/ng-schematics/src/app-projects/schema.ts |
Marks required options as initialized. |
packages/igx-templates/igx-ts/tree-grid/tree-grid-custom/index.ts |
Types configuration records and feature arrays. |
packages/igx-templates/igx-ts/projects/ai-config/index.ts |
Aligns the extra-configuration signature. |
packages/igx-templates/igx-ts/projects/_base/index.ts |
Types configuration input and generated variables. |
packages/igx-templates/igx-ts/hierarchical-grid/hierarchical-grid-custom/index.ts |
Types feature state and optional documentation URLs. |
packages/igx-templates/igx-ts/grid/multi-column-headers/index.ts |
Types extra-configuration storage and input. |
packages/igx-templates/igx-ts/grid/grid-custom/index.ts |
Types extra configuration and feature URLs. |
packages/igx-templates/igx-ts/calendar/default/index.ts |
Types extra-configuration storage and input. |
packages/igx-templates/IgniteUIForAngularTemplate.ts |
Types metadata and defaults generation options. |
packages/igx-templates/AngularTypeScriptFileUpdate.ts |
Types metadata access and guards optional AST values. |
packages/core/util/Util.ts |
Adds strict types and fixes dependency-sort accumulation. |
packages/core/util/Schematics.ts |
Adds assertions around tree reads and regex matches. |
packages/core/util/ProjectTemplateResolver.ts |
Makes upgrade eligibility a nullable type guard. |
packages/core/util/ProjectConfig.ts |
Types validation results and caught errors. |
packages/core/util/GoogleAnalytics.ts |
Types the request error callback. |
packages/core/update/Update.ts |
Types style extensions and workspace callbacks. |
packages/core/update/package-resolve.ts |
Types upgradeable-package lookup keys. |
packages/core/typescript/TypeScriptUtils.ts |
Declares explicit file-saving return types. |
packages/core/typescript/TypeScriptFileUpdate.ts |
Handles optional JSX settings and route identifiers. |
packages/core/typescript/TypeScriptAstTransformer.ts |
Types optional state and supplies empty JSX attributes. |
packages/core/typescript/TransformerFactories.ts |
Refines callback types, optional settings, and assertions. |
packages/core/types/types-typescript.ts |
Makes change-request nodes optional. |
packages/core/types/Template.ts |
Declares the registration return type. |
packages/core/types/ProjectLibrary.ts |
Exposes nullable lookup results. |
packages/core/types/BaseTemplate.ts |
Types extra-configuration input and return value. |
packages/core/templates/BaseTemplateManager.ts |
Exposes nullable framework and library results. |
packages/core/templates/BaseProjectLibrary.ts |
Types metadata, collections, and nullable lookups. |
packages/core/templates/BaseComponent.ts |
Marks subclass-initialized metadata. |
packages/core/prompt/TaskRunner.ts |
Initializes the nullable current task. |
packages/core/prompt/BasePromptSession.ts |
Types session state and asynchronous upgrade behavior. |
packages/core/packages/PackageManager.ts |
Types queued installs and process errors. |
packages/core/package.json |
Adds development typings for through2. |
packages/cli/templates/webcomponents/WebComponentsTypeScriptFileUpdate.ts |
Adds route and formatting assertions. |
packages/cli/templates/webcomponents/igc-ts/projects/side-nav/index.ts |
Adds a dependency-field initialization assertion. |
packages/cli/templates/webcomponents/igc-ts/projects/empty/index.ts |
Adds a dependency-field initialization assertion. |
packages/cli/templates/webcomponents/igc-ts/projects/base/index.ts |
Adds a dependency-field initialization assertion. |
packages/cli/templates/webcomponents/igc-ts/projects/ai-config/index.ts |
Initializes dependencies to an empty array. |
packages/cli/templates/webcomponents/igc-ts/projects/_base/index.ts |
Types extra-configuration input. |
packages/cli/templates/react/ReactTypeScriptFileUpdate.ts |
Supplies empty JSX attributes and route assertions. |
packages/cli/templates/react/igr-ts/projects/_base/index.ts |
Initializes dependencies to an empty array. |
packages/cli/templates/jquery/js/tree-grid/tree-grid/index.ts |
Types configuration records and selected features. |
packages/cli/templates/jquery/js/tree-grid/tree-grid-export/index.ts |
Types configuration records and selected features. |
packages/cli/templates/jquery/js/tree-grid/tree-grid-editing/index.ts |
Types configuration records and selected features. |
packages/cli/templates/jquery/js/tree-grid/tree-grid-custom/index.ts |
Types configuration records and selected features. |
packages/cli/templates/jquery/js/projects/empty/index.ts |
Initializes dependencies to an empty array. |
packages/cli/templates/jquery/js/hierarchical-grid/hierarchical-grid/index.ts |
Types configuration records and selected features. |
packages/cli/templates/jquery/js/hierarchical-grid/hierarchical-grid-export/index.ts |
Types configuration records and selected features. |
packages/cli/templates/jquery/js/hierarchical-grid/hierarchical-grid-editing/index.ts |
Types configuration records and selected features. |
packages/cli/templates/jquery/js/hierarchical-grid/hierarchical-grid-custom/index.ts |
Types configuration records and selected features. |
packages/cli/templates/jquery/js/grid/grid/index.ts |
Types configuration records and selected features. |
packages/cli/templates/jquery/js/grid/grid-templating/index.ts |
Types configuration records and selected features. |
packages/cli/templates/jquery/js/grid/grid-export/index.ts |
Types configuration records and selected features. |
packages/cli/templates/jquery/js/grid/grid-editing/index.ts |
Types configuration records and selected features. |
packages/cli/templates/jquery/js/grid/grid-custom/index.ts |
Types configuration records and selected features. |
packages/cli/templates/jquery/js/editors/index.ts |
Marks externally initialized editor metadata. |
packages/cli/templates/jquery/js/custom-templates/file-explorer/index.ts |
Types configuration records and selected features. |
packages/cli/templates/blazor/igb/projects/ai-config/index.ts |
Initializes dependencies to an empty array. |
packages/cli/package.json |
Adds development typings for resolve. |
packages/cli/lib/templates/jQueryTemplate.ts |
Types metadata and defaults generation options. |
packages/cli/lib/templates/IgniteUIForWebComponentsTemplate.ts |
Types metadata and defaults optional arguments. |
packages/cli/lib/templates/IgniteUIForReactTemplate.ts |
Types metadata and defaults optional arguments. |
packages/cli/lib/TemplateManager.ts |
Declares nullable template-loading results. |
packages/cli/lib/project-utility/GridHelper.ts |
Types feature records and mutation methods. |
packages/cli/lib/MultiTemplateComponent.ts |
Types constructors, metadata, and lookup results. |
packages/cli/lib/commands/upgrade.ts |
Guards missing libraries and types caught errors. |
packages/cli/lib/commands/types.ts |
Declares handler returns and browser-target types. |
packages/cli/lib/commands/new.ts |
Adds assertions for validated command arguments. |
packages/cli/lib/commands/list.ts |
Uses a typed group object and nullable framework lookup. |
packages/cli/lib/commands/generate.ts |
Adds assertions for required command arguments. |
packages/cli/lib/commands/config.ts |
Types dynamic configuration access and validation values. |
packages/cli/lib/commands/ai-config.ts |
Asserts the selected framework resolves. |
packages/cli/lib/commands/add.ts |
Adds assertions for validated template arguments. |
packages/cli/lib/cli.ts |
Requires string or string-array arguments. |
Review effort: Balanced
ivanvpetrov
marked this pull request as ready for review
November 2, 2026 08:36
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1613
Description
Enables
"strict": trueand fixes every compiler error it raised (697 acrosscore,cli,igx-templates,ng-schematics,scriptsand the specs).Config
strict: trueis set intsconfig.json,tsconfig-pack.jsonandpackages/ng-schematics/tsconfig.json. The ng-schematics config previously enabled onlynoImplicitAny,noImplicitThisandstrictNullChecks.@types/through2@^2.0.41incore@types/resolve@^1.20.6incliyarn.lockonly adds these two packages. Neither appears in the emitted declarations, so they stay dev-only.yarn install; without it the build fails with TS7016 forresolveandthrough2.How errors were fixed
!is used for properties assigned after construction (template metadata, prompt-session state, schematic options) and for values that can't be missing at runtime (for example, a name the user just picked from a list built from the same source).catchvariables are narrowed withas Error.getTemplateById,getTemplateByName,getComponentByName,getFrameworkById,getFrameworkByNameandgetProjectLibraryByNamereturnT | undefined.getProjectreturnsProjectTemplate | null.getProjectLibraryreturnsProjectLibrary | null | undefined, which matches what it returned before.upgrade) gained one. See below.!and casts. No existing assertion or test input changed.Public type changes (
@igniteui/cli-coredeclarations)TypeScript consumers that compile with
strictNullChecksmay need to handle the newundefined/nullresults. Worth a line in the release notes when the next version is cut.ProjectLibraryinterface: the matching lookup signatures.BaseTemplate.setExtraConfiguration: now takes{ [key: string]: unknown }and returnsvoid.Template.registerInProject: now returnsvoid.ProjectConfig.validateProperty: now returns{ message?: string, valid: boolean, value?: any }.ChangeRequest.nodeandTypeScriptAstTransformer.formatterare now optional.defaultDelimitersis nowRequired<TemplateDelimiters>.Changes that touch runtime code. Each one either gives the same result as before or replaces a code path that would have crashed:
generateConfig/registerInProjectin the React, Web Components, jQuery and Angular base templates now defaultoptionsto{}. Previously a missingoptionscrashed on the first property access.undefined(core AST transformer andReactTypeScriptFileUpdate). Both print<Tag />.dependenciesnow initialize it to[]. Only component templates'dependenciesare ever read.Util.formatPackageJson: the sortreduceno longer relies on(a = b) && acc, which would have returned""for an empty version string.cli.run(args)is typedstring | string[]instead ofargs = null. Every caller passes arguments, and yargs'parseAsyncrequires them.list: the group map is an object instead of an array used as a map. It is only read throughObject.keys, so the output is unchanged.upgrade(CLI) andupgrade-packages(ng-schematics): a framework and project type that don't match each other inignite-ui-cli.json(e.g.angularwithigc-ts) used to crash withCannot read properties of undefined (reading 'projectIds'). They now report the existing "No valid Ignite UI project template found to upgrade packages." error. A spec covers each command.ng-new: the "folder exists" check now skips a missing name explicitly. It already returnedfalsein that case.IgxSchematicContextinterface was removed; its extra fields were never read. Rules now useSchematicContext.Related Issue
Closes #1613
Type of Change
Affected Packages
igniteui-cli(packages/cli)@igniteui/cli-core(packages/core)@igniteui/angular-templates(packages/igx-templates)@igniteui/angular-schematics(packages/ng-schematics)@igniteui/mcp-server(packages/igniteui-mcp)Checklist
npm run test)npm run build)npm run lint)Additional Context
This is the last of three stacked PRs for #1613. It is based on #1850 (coverage), which is based on #1849 (bug fixes).
Verification
tscwithtsconfig.jsonand withtsconfig-pack.json: 0 errors.npm run test: 767 specs pass (2 pending, unchanged).npm run lint: 0 errors; the one warning (unusedeslint-disableinpackages/core/util/Schematics.ts) is already onmaster.scripts/smoke-test.sh:ig addsteps pass across the three frameworks.igniteui-angular@22.2.3, published 2026-10-19, is picked up by the templates'~22.2.0. It needsigniteui-grid-lite@~0.11.0, while the grid-lite template pins~0.10.0, and it rejects APIs the template payloads still use (igxButton="raised",actionStrip,IButtonGroupButton). This PR changes no template payloads (files/); a separate issue will cover it.Notes for reviewers
scripts/versionScript.tschanges by one character (let version!: string;), needed becausescripts/compiles under the roottsconfig.json.Follow-ups, out of scope here
packages/ng-schematics/tsconfig.jsonstill reports 22 errors that predate this PR: 21 unused locals/parameters from itsnoUnused*options, and 1esModuleInteroperror inigx-templates/index.ts. CI doesn't build with this config.spec/helpers/utils.tsfilesDiff()appliestransform1to the second list and globsfolderPath1twice. That is a bug in the test helper; it was left as is to keep test behaviour unchanged.cli.runstill checksargs ? yargs(args) : yargs, but sinceargsis now required, the bareyargsbranch can't be reached.