|
1 | | -// Phase 22 (REQ-1/R3/R4/R9): this demo now consumes the per-module |
2 | | -// `<Name>.d.rozie.ts` sidecars emitted by @rozie/unplugin's buildStart hook — |
3 | | -// `import Foo, { type FooProps } from './Foo.rozie'` gets REAL Angular types |
4 | | -// (a typed `declare class Foo` + named `FooProps` + `$expose` handle methods). |
| 1 | +// TypeScript shim for `.rozie` imports — informs tsc / Angular's strict |
| 2 | +// templates that a `.rozie` import resolves to an Angular standalone |
| 3 | +// component class. |
5 | 4 | // |
6 | | -// The former broad `declare module '*.rozie'` wildcard is DEMOTED (deleted for |
7 | | -// this demo, which migrates 100% cleanly — every `.rozie` import here is |
8 | | -// in-`src` and has a sidecar). Per SPIKE-FINDINGS, Angular (`tsc`, typescript |
9 | | -// ~5.9.3) honors the sidecar ONLY with `allowArbitraryExtensions: true` (set in |
10 | | -// tsconfig.json); WITHOUT the flag the wildcard SHADOWS the sidecar (TS2614). |
| 5 | +// ANGULAR TYPED-IMPORT POSTURE (post-Phase-22 regression fix, 2026-06-02): |
| 6 | +// Angular does NOT use `.d.rozie.ts` sidecars. The typed import surface is the |
| 7 | +// disk-cache `<Name>.rozie.ts` that @rozie/unplugin's configResolved prebuild |
| 8 | +// writes next to each `.rozie` source — a real, fully-typed standalone |
| 9 | +// component class that both tsc AND ngtsc resolve via standard |
| 10 | +// extension-appending (`./Counter.rozie` → `Counter.rozie.ts`). |
11 | 11 | // |
12 | | -// CROSS-ROZIE COMPOSITION (Card → CardHeader, ModalConsumer → Modal/WrapperModal): |
13 | | -// the unplugin's prebuild emits a `<Name>.ts` re-export shim that now points at |
14 | | -// the disk-cache `<Name>.rozie.ts` via its `.rozie.js` specifier — NOT the bare |
15 | | -// `./<Name>.rozie` — so the `.d.rozie.ts` sidecar does NOT shadow the runtime |
16 | | -// VALUE class the `imports: [...]` metadata needs (this closes the Plan-05 |
17 | | -// known-red TS2614 entry condition). The sidecar adds the named Props/handle |
18 | | -// type exports the disk-cache lacks; the disk-cache provides the value class. |
19 | | -// Do NOT re-add a broad wildcard — it reintroduces the shadowing. |
20 | | -export {}; |
| 12 | +// Why no sidecar: TS module resolution prefers an arbitrary-extension |
| 13 | +// declaration file (`Counter.d.rozie.ts`) over the appended-extension |
| 14 | +// implementation (`Counter.rozie.ts`) — regardless of |
| 15 | +// `allowArbitraryExtensions`. ngtsc (inside @analogjs/vite-plugin-angular) uses |
| 16 | +// that same resolution to validate standalone `imports: [...]` entries; a |
| 17 | +// type-only `declare class` has no ɵcmp metadata, so ngtsc silently skips AOT |
| 18 | +// for every class importing a `.rozie` module → runtime "JIT compiler |
| 19 | +// unavailable" (the 2026-06-02 Angular + VR matrix regression). See |
| 20 | +// packages/unplugin/src/emitSidecar.ts ANGULAR EXCEPTION. |
| 21 | +// |
| 22 | +// This wildcard is the FRESH-CHECKOUT FALLBACK only: before the demo's first |
| 23 | +// build (no disk-cache on disk yet; sidecars are never written for Angular), |
| 24 | +// `tsc --noEmit` still needs `.rozie` imports to resolve. Once the disk-cache |
| 25 | +// exists, file resolution wins over the ambient wildcard and imports get the |
| 26 | +// real class types. |
| 27 | +// |
| 28 | +// Known limitation (accepted): unlike the other 5 targets, Angular consumers |
| 29 | +// have no named `<Name>Props` type export to import. A future ngtsc-valid |
| 30 | +// sidecar (declaring `static ɵcmp: ɵɵComponentDeclaration<...>` the way |
| 31 | +// compiled Angular libraries do) can restore it. |
| 32 | +declare module '*.rozie' { |
| 33 | + import type { Type } from '@angular/core'; |
| 34 | + const component: Type<unknown>; |
| 35 | + export default component; |
| 36 | +} |
0 commit comments