Skip to content

FSHSP-228 fix(schematics): refuse another Angular major, keep project versions, handle inline type imports - #162

Merged
robinlopez merged 1 commit into
mainfrom
fix/FSHSP-228
Sep 25, 2026
Merged

robinlopez merged 1 commit into
mainfrom
fix/FSHSP-228

Conversation

@robinlopez

@robinlopez robinlopez commented Sep 25, 2026 •

Copy link
Copy Markdown
Collaborator

Jira: FSHSP-228. Reported after publishing 0.12.0; ships in 0.12.1.

Problems

  1. ng add on an Angular 20 project: the kit's peerDependencies (^22.0.0) were copied over the project's versions. core, common, forms, router, platform-browser moved to 22 while compiler-cli, build and cli stayed on 20, and npm stopped on ERESOLVE (@angular-devkit/build-angular@^22 vs @angular/compiler-cli@^20), leaving a half-migrated package.json.
  2. Copying ui-input-date failed since 0.11.0: "import(s) du kit non réadressé(s) … (symbole type UiIconSize)". The import rewrite read the inline type modifier (import { UiIcon, type UiIconSize }) as part of the symbol name.
  3. Library mode looked fine on Angular 20 because pnpm only warns on unmet peers (npm refuses). Documentation only.

Fix

  • ng-add, add and update check the project's Angular major first (utils/angular-version.ts) and stop before writing anything, printing the ng update steps, one major at a time.
  • ensureDependency: a declared dependency keeps its range; a missing @angular/* package takes the project's @angular/core range (framework packages peer each other at the exact version).
  • symbolName skips the inline type modifier for the lookup; the rewritten import keeps it.
  • First schematics tests: pnpm schematics:test (99 tests), run in Lint, types & docs. One renders every kit unit, so an unmapped import fails here instead of at a consumer's install.
  • READMEs: Angular 22 prerequisite in the schematics README, pnpm unmet-peer warning in the kit README. CHANGELOG under [Unreleased].

Test plan

  • pnpm schematics:test: 99 passed. With the type fix reverted, it fails exactly on ui-input-date (and the symbolName cases)
  • Clone of the reporter's Angular 20 project: clear refusal, package.json and angular.json unchanged, no file created
  • Fresh Angular 22 app installed with npm: ng-add --skip-components (with install) OK, Angular ranges untouched; add --all then ng build and build-storybook OK
  • Fresh Angular 22 app, library mode: npm install @4sh/ui-kit@0.12.0 + ng build OK
  • pnpm schematics:build, pnpm docs:config:check, Prettier

🤖 Generated with Claude Code

… versions, handle inline type imports

On an Angular 20 project, ng add copied the kit's peerDependencies over the
project's versions: core, common, forms, router and platform-browser moved to
^22 while compiler-cli, build and cli stayed on 20, and npm stopped on
ERESOLVE with @angular-devkit/build-angular@^22.

- ng-add, add and update check the project's Angular major first and stop
  before writing anything, printing the ng update steps to run.
- A declared dependency keeps its range; a missing Angular package takes
  the project's @angular/core range.
- The import rewrite read `type UiIconSize` as a symbol name, so copying
  ui-input-date failed since 0.11.0. The inline modifier is now skipped for
  the lookup and kept in the rewritten import.
- First schematics tests (pnpm schematics:test, run in PR checks), one of
  them rendering every kit unit so an unmapped import fails here, not at
  the consumer's install.
@robinlopez
robinlopez merged commit a26a37a into main Sep 25, 2026
4 checks passed
@robinlopez
robinlopez deleted the fix/FSHSP-228 branch September 25, 2026 12:37
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.

1 participant