|
| 1 | +=== tests/cases/compiler/declarationNoDanglingGenerics.ts === |
| 2 | +const kindCache: { [kind: string]: boolean } = {}; |
| 3 | +>kindCache : Symbol(kindCache, Decl(declarationNoDanglingGenerics.ts, 0, 5)) |
| 4 | +>kind : Symbol(kind, Decl(declarationNoDanglingGenerics.ts, 0, 20)) |
| 5 | + |
| 6 | +function register(kind: string): void | never { |
| 7 | +>register : Symbol(register, Decl(declarationNoDanglingGenerics.ts, 0, 50)) |
| 8 | +>kind : Symbol(kind, Decl(declarationNoDanglingGenerics.ts, 2, 18)) |
| 9 | + |
| 10 | + if (kindCache[kind]) { |
| 11 | +>kindCache : Symbol(kindCache, Decl(declarationNoDanglingGenerics.ts, 0, 5)) |
| 12 | +>kind : Symbol(kind, Decl(declarationNoDanglingGenerics.ts, 2, 18)) |
| 13 | + |
| 14 | + throw new Error(`Class with kind "${kind}" is already registered.`); |
| 15 | +>Error : Symbol(Error, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) |
| 16 | +>kind : Symbol(kind, Decl(declarationNoDanglingGenerics.ts, 2, 18)) |
| 17 | + } |
| 18 | + kindCache[kind] = true; |
| 19 | +>kindCache : Symbol(kindCache, Decl(declarationNoDanglingGenerics.ts, 0, 5)) |
| 20 | +>kind : Symbol(kind, Decl(declarationNoDanglingGenerics.ts, 2, 18)) |
| 21 | +} |
| 22 | + |
| 23 | +function ClassFactory<TKind extends string>(kind: TKind) { |
| 24 | +>ClassFactory : Symbol(ClassFactory, Decl(declarationNoDanglingGenerics.ts, 7, 1)) |
| 25 | +>TKind : Symbol(TKind, Decl(declarationNoDanglingGenerics.ts, 9, 22)) |
| 26 | +>kind : Symbol(kind, Decl(declarationNoDanglingGenerics.ts, 9, 44)) |
| 27 | +>TKind : Symbol(TKind, Decl(declarationNoDanglingGenerics.ts, 9, 22)) |
| 28 | + |
| 29 | + register(kind); |
| 30 | +>register : Symbol(register, Decl(declarationNoDanglingGenerics.ts, 0, 50)) |
| 31 | +>kind : Symbol(kind, Decl(declarationNoDanglingGenerics.ts, 9, 44)) |
| 32 | + |
| 33 | + return class { |
| 34 | + static readonly THE_KIND: TKind = kind; |
| 35 | +>THE_KIND : Symbol((Anonymous class).THE_KIND, Decl(declarationNoDanglingGenerics.ts, 12, 16)) |
| 36 | +>TKind : Symbol(TKind, Decl(declarationNoDanglingGenerics.ts, 9, 22)) |
| 37 | +>kind : Symbol(kind, Decl(declarationNoDanglingGenerics.ts, 9, 44)) |
| 38 | + |
| 39 | + readonly kind: TKind = kind; |
| 40 | +>kind : Symbol((Anonymous class).kind, Decl(declarationNoDanglingGenerics.ts, 13, 43)) |
| 41 | +>TKind : Symbol(TKind, Decl(declarationNoDanglingGenerics.ts, 9, 22)) |
| 42 | +>kind : Symbol(kind, Decl(declarationNoDanglingGenerics.ts, 9, 44)) |
| 43 | + |
| 44 | + }; |
| 45 | +} |
| 46 | + |
| 47 | +class Kinds { |
| 48 | +>Kinds : Symbol(Kinds, Decl(declarationNoDanglingGenerics.ts, 16, 1)) |
| 49 | + |
| 50 | + static readonly A = "A"; |
| 51 | +>A : Symbol(Kinds.A, Decl(declarationNoDanglingGenerics.ts, 18, 13)) |
| 52 | + |
| 53 | + static readonly B = "B"; |
| 54 | +>B : Symbol(Kinds.B, Decl(declarationNoDanglingGenerics.ts, 19, 26)) |
| 55 | + |
| 56 | + static readonly C = "C"; |
| 57 | +>C : Symbol(Kinds.C, Decl(declarationNoDanglingGenerics.ts, 20, 26)) |
| 58 | +} |
| 59 | + |
| 60 | +export class AKind extends ClassFactory(Kinds.A) { |
| 61 | +>AKind : Symbol(AKind, Decl(declarationNoDanglingGenerics.ts, 22, 1)) |
| 62 | +>ClassFactory : Symbol(ClassFactory, Decl(declarationNoDanglingGenerics.ts, 7, 1)) |
| 63 | +>Kinds.A : Symbol(Kinds.A, Decl(declarationNoDanglingGenerics.ts, 18, 13)) |
| 64 | +>Kinds : Symbol(Kinds, Decl(declarationNoDanglingGenerics.ts, 16, 1)) |
| 65 | +>A : Symbol(Kinds.A, Decl(declarationNoDanglingGenerics.ts, 18, 13)) |
| 66 | +} |
| 67 | + |
| 68 | +export class BKind extends ClassFactory(Kinds.B) { |
| 69 | +>BKind : Symbol(BKind, Decl(declarationNoDanglingGenerics.ts, 25, 1)) |
| 70 | +>ClassFactory : Symbol(ClassFactory, Decl(declarationNoDanglingGenerics.ts, 7, 1)) |
| 71 | +>Kinds.B : Symbol(Kinds.B, Decl(declarationNoDanglingGenerics.ts, 19, 26)) |
| 72 | +>Kinds : Symbol(Kinds, Decl(declarationNoDanglingGenerics.ts, 16, 1)) |
| 73 | +>B : Symbol(Kinds.B, Decl(declarationNoDanglingGenerics.ts, 19, 26)) |
| 74 | +} |
| 75 | + |
| 76 | +export class CKind extends ClassFactory(Kinds.C) { |
| 77 | +>CKind : Symbol(CKind, Decl(declarationNoDanglingGenerics.ts, 28, 1)) |
| 78 | +>ClassFactory : Symbol(ClassFactory, Decl(declarationNoDanglingGenerics.ts, 7, 1)) |
| 79 | +>Kinds.C : Symbol(Kinds.C, Decl(declarationNoDanglingGenerics.ts, 20, 26)) |
| 80 | +>Kinds : Symbol(Kinds, Decl(declarationNoDanglingGenerics.ts, 16, 1)) |
| 81 | +>C : Symbol(Kinds.C, Decl(declarationNoDanglingGenerics.ts, 20, 26)) |
| 82 | +} |
0 commit comments