You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 3d03819
Browse filesBrowse the repository at this point in the historyBrowse files
fix(dts): resolve import-equals aliases in computed property names
A computed name in a transform's parameter type (`{ [Core.ɵSIGNAL]: string }`)
skipped the alias resolution type names get, so an alias of
`@angular/core` (`import Core = require('@angular/core')`, `import C = ng`,
`import S = Core.ɵSIGNAL`, or one declared in a namespace) was written as
is, another module's alias didn't make the type `unknown`, and a global's
alias wasn't written as its target. Computed names now resolve aliases
the way type names do: `i0.ɵSIGNAL`, `unknown`, and `G.k`. ngtsc 22.1.7
copies all of these as written, which doesn't resolve in its `.d.ts`. An
alias of a name the file declares stays as written, like ngtsc.
The snapshot's `scope-typeOnly-*` probes (added earlier in the stack,
before `.d.ts` transform types) now also compare ngtsc's
`ngAcceptInputType_*` types, including `typeof name` for a helper's
parameter used as a type.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
/// A computed property name through an import-equals alias (top level, in a
507
+
/// namespace, or of an alias) resolves it the way a type name does. ngtsc
508
+
/// 22.1.7 copies every one of these as written. An alias of a name the file
509
+
/// declares stays as written, as ngtsc wrote it (the last group). The rest
510
+
/// follow oxc's rules for imports and globals, since type-checking ngtsc's
511
+
/// `.d.ts` reports "Cannot find name" for each (except `Ex`, which is
512
+
/// exported): an alias of `@angular/core` gives `i0.X`, one of another module
513
+
/// makes the type `unknown`, and one of a global (`G`, declared in a separate
514
+
/// `.d.ts` for ngtsc) is written as its target.
515
+
#[test]
516
+
fncomputed_names_through_import_equals_aliases(){
517
+
let cases:[(&str,&[&str],&[&str]);4] = [
518
+
(
519
+
"import Core = require('@angular/core');\nimport S = Core.ɵSIGNAL;\nimport C2 = Core;\nexport import Ex = require('@angular/core');\nimport * as ng from '@angular/core';\nimport C = ng;\nimport S2 = ng.ɵSIGNAL;\nnamespace W { export import C3 = Core; export import S3 = Core.ɵSIGNAL; }\n",
520
+
&[
521
+
"{ [Core.ɵSIGNAL]: string }",
522
+
"{ [Core.ɵSIGNAL](): void }",
523
+
"{ [S]: string }",
524
+
"{ [C2.ɵSIGNAL]: string }",
525
+
"{ [Ex.ɵSIGNAL]: string }",
526
+
"{ [C.ɵSIGNAL]: string }",
527
+
"{ [S2]: string }",
528
+
"{ [W.C3.ɵSIGNAL]: string }",
529
+
"{ [W.S3]: string }",
530
+
],
531
+
&[
532
+
"{ [i0.ɵSIGNAL]: string; }",
533
+
"{ [i0.ɵSIGNAL](): void; }",
534
+
"{ [i0.ɵSIGNAL]: string; }",
535
+
"{ [i0.ɵSIGNAL]: string; }",
536
+
"{ [i0.ɵSIGNAL]: string; }",
537
+
"{ [i0.ɵSIGNAL]: string; }",
538
+
"{ [i0.ɵSIGNAL]: string; }",
539
+
"{ [i0.ɵSIGNAL]: string; }",
540
+
"{ [i0.ɵSIGNAL]: string; }",
541
+
],
542
+
),
543
+
(
544
+
"import R = require('./other');\nimport * as o from './other';\nimport O = o;\nimport T = o.token;\nimport {Inner} from './other';\nimport I = Inner;\nnamespace W { export import O2 = o; }\n",
0 commit comments