Repository navigation
refactor(*): enable TypeScript strict mode - #1852
Draft
ivanvpetrov wants to merge 3 commits into
Draft
ivanvpetrov wants to merge 3 commits into
ivanvpetrov wants to merge 3 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
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.