From 1fa1f307750330c331a082f37e494ffc23c132d3 Mon Sep 17 00:00:00 2001 From: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com> Date: Fri, 20 Nov 2026 16:14:20 +0000 Subject: [PATCH 01/14] Initial plan From 5a0ac4b3c6d4541611ff8fab595b3e3e61263476 Mon Sep 17 00:00:00 2001 From: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com> Date: Fri, 20 Nov 2026 16:20:45 +0000 Subject: [PATCH 02/14] Add test for expando property merged with type-only namespace member Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --- ...FunctionTypeOnlyNamespaceMember.errors.txt | 97 +++++++++ .../expandoFunctionTypeOnlyNamespaceMember.js | 143 ++++++++++++++ ...ndoFunctionTypeOnlyNamespaceMember.symbols | 154 +++++++++++++++ ...pandoFunctionTypeOnlyNamespaceMember.types | 187 ++++++++++++++++++ .../expandoFunctionTypeOnlyNamespaceMember.ts | 53 +++++ 5 files changed, 634 insertions(+) create mode 100644 tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.errors.txt create mode 100644 tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.js create mode 100644 tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.symbols create mode 100644 tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.types create mode 100644 tsc/testdata/tests/cases/compiler/expandoFunctionTypeOnlyNamespaceMember.ts diff --git a/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.errors.txt b/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.errors.txt new file mode 100644 index 0000000000000..915e267b4a5d4 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.errors.txt @@ -0,0 +1,97 @@ +popover.ts(2,9): error TS2339: Property 'Target' does not exist on type '{ (): null; displayName: string; }'. +popover.ts(11,9): error TS2339: Property 'Target' does not exist on type '{ (): null; displayName: string; }'. +variants.ts(2,4): error TS2339: Property 'a' does not exist on type '() => void'. +variants.ts(4,23): error TS2339: Property 'a' does not exist on type '() => void'. +variants.ts(5,23): error TS2339: Property 'a' does not exist on type '() => void'. +variants.ts(9,4): error TS2339: Property 'a' does not exist on type '() => void'. +variants.ts(11,23): error TS2339: Property 'a' does not exist on type '() => void'. +variants.ts(15,4): error TS2339: Property 'a' does not exist on type '() => void'. +variants.ts(17,23): error TS2339: Property 'a' does not exist on type '() => void'. +variants.ts(20,4): error TS2339: Property 'a' does not exist on type '() => void'. +variants.ts(22,23): error TS2339: Property 'a' does not exist on type '() => void'. +variants.ts(27,4): error TS2339: Property 'a' does not exist on type '() => void'. +variants.ts(28,23): error TS2339: Property 'a' does not exist on type '() => void'. +variants.ts(31,1): error TS2322: Type 'number' is not assignable to type 'typeof a'. +variants.ts(33,7): error TS2322: Type 'typeof a' is not assignable to type 'number'. + + +==== variants.ts (13 errors) ==== + function f1() {} + f1.a = 0; + ~ +!!! error TS2339: Property 'a' does not exist on type '() => void'. + namespace f1 { export type a = 0; } + const n1: number = f1.a; + ~ +!!! error TS2339: Property 'a' does not exist on type '() => void'. + const s1: string = f1.a; // error + ~ +!!! error TS2339: Property 'a' does not exist on type '() => void'. + const t1: f1.a = 0; + + function f2() {} + f2.a = 0; + ~ +!!! error TS2339: Property 'a' does not exist on type '() => void'. + namespace f2 { export interface a { x: string } } + const n2: number = f2.a; + ~ +!!! error TS2339: Property 'a' does not exist on type '() => void'. + const t2: f2.a = { x: "" }; + + function f3() {} + f3.a = 0; + ~ +!!! error TS2339: Property 'a' does not exist on type '() => void'. + namespace f3 { export namespace a {} } + const n3: number = f3.a; + ~ +!!! error TS2339: Property 'a' does not exist on type '() => void'. + + function f4() {} + f4.a = 0; + ~ +!!! error TS2339: Property 'a' does not exist on type '() => void'. + namespace f4 { export namespace a { export type T = string; } } + const n4: number = f4.a; + ~ +!!! error TS2339: Property 'a' does not exist on type '() => void'. + const t4: f4.a.T = ""; + + namespace f5 { export type a = 0; } + function f5() {} + f5.a = 0; + ~ +!!! error TS2339: Property 'a' does not exist on type '() => void'. + const n5: number = f5.a; + ~ +!!! error TS2339: Property 'a' does not exist on type '() => void'. + + function f6() {} + f6.a = 0; + ~~~~ +!!! error TS2322: Type 'number' is not assignable to type 'typeof a'. + namespace f6 { export namespace a { export const kind = 0; } } + const n6: number = f6.a; // error + ~~ +!!! error TS2322: Type 'typeof a' is not assignable to type 'number'. + +==== popover.ts (2 errors) ==== + export function Popover() { return null; } + Popover.Target = (x: number) => x; + ~~~~~~ +!!! error TS2339: Property 'Target' does not exist on type '{ (): null; displayName: string; }'. + Popover.displayName = "Popover"; + + export namespace Popover { + export namespace Target { + export type Props = number; + } + } + + Popover.Target(1); + ~~~~~~ +!!! error TS2339: Property 'Target' does not exist on type '{ (): null; displayName: string; }'. + Popover.displayName; + const props: Popover.Target.Props = 1; + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.js b/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.js new file mode 100644 index 0000000000000..cc7edd3418d7a --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.js @@ -0,0 +1,143 @@ +//// [tests/cases/compiler/expandoFunctionTypeOnlyNamespaceMember.ts] //// + +//// [variants.ts] +function f1() {} +f1.a = 0; +namespace f1 { export type a = 0; } +const n1: number = f1.a; +const s1: string = f1.a; // error +const t1: f1.a = 0; + +function f2() {} +f2.a = 0; +namespace f2 { export interface a { x: string } } +const n2: number = f2.a; +const t2: f2.a = { x: "" }; + +function f3() {} +f3.a = 0; +namespace f3 { export namespace a {} } +const n3: number = f3.a; + +function f4() {} +f4.a = 0; +namespace f4 { export namespace a { export type T = string; } } +const n4: number = f4.a; +const t4: f4.a.T = ""; + +namespace f5 { export type a = 0; } +function f5() {} +f5.a = 0; +const n5: number = f5.a; + +function f6() {} +f6.a = 0; +namespace f6 { export namespace a { export const kind = 0; } } +const n6: number = f6.a; // error + +//// [popover.ts] +export function Popover() { return null; } +Popover.Target = (x: number) => x; +Popover.displayName = "Popover"; + +export namespace Popover { + export namespace Target { + export type Props = number; + } +} + +Popover.Target(1); +Popover.displayName; +const props: Popover.Target.Props = 1; + + +//// [variants.js] +"use strict"; +function f1() { } +f1.a = 0; +const n1 = f1.a; +const s1 = f1.a; // error +const t1 = 0; +function f2() { } +f2.a = 0; +const n2 = f2.a; +const t2 = { x: "" }; +function f3() { } +f3.a = 0; +const n3 = f3.a; +function f4() { } +f4.a = 0; +const n4 = f4.a; +const t4 = ""; +function f5() { } +f5.a = 0; +const n5 = f5.a; +function f6() { } +f6.a = 0; +(function (f6) { + let a; + (function (a) { + a.kind = 0; + })(a = f6.a || (f6.a = {})); +})(f6 || (f6 = {})); +const n6 = f6.a; // error +//// [popover.js] +export function Popover() { return null; } +Popover.Target = (x) => x; +Popover.displayName = "Popover"; +Popover.Target(1); +Popover.displayName; +const props = 1; + + +//// [variants.d.ts] +declare function f1(): void; +declare namespace f1 { + type a = 0; +} +declare const n1: number; +declare const s1: string; +declare const t1: f1.a; +declare function f2(): void; +declare namespace f2 { + interface a { + x: string; + } +} +declare const n2: number; +declare const t2: f2.a; +declare function f3(): void; +declare namespace f3 { + namespace a { } +} +declare const n3: number; +declare function f4(): void; +declare namespace f4 { + namespace a { + type T = string; + } +} +declare const n4: number; +declare const t4: f4.a.T; +declare namespace f5 { + type a = 0; +} +declare function f5(): void; +declare const n5: number; +declare function f6(): void; +declare namespace f6 { + namespace a { + const kind = 0; + } +} +declare const n6: number; +//// [popover.d.ts] +export declare function Popover(): null; +export declare namespace Popover { + var displayName: string; +} +export declare namespace Popover { + namespace Target { + type Props = number; + } +} diff --git a/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.symbols b/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.symbols new file mode 100644 index 0000000000000..a99662e664892 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.symbols @@ -0,0 +1,154 @@ +//// [tests/cases/compiler/expandoFunctionTypeOnlyNamespaceMember.ts] //// + +=== variants.ts === +function f1() {} +>f1 : Symbol(f1, Decl(variants.ts, 0, 0), Decl(variants.ts, 1, 9)) + +f1.a = 0; +>f1 : Symbol(f1, Decl(variants.ts, 0, 0), Decl(variants.ts, 1, 9)) + +namespace f1 { export type a = 0; } +>f1 : Symbol(f1, Decl(variants.ts, 0, 0), Decl(variants.ts, 1, 9)) +>a : Symbol(a, Decl(variants.ts, 2, 14)) + +const n1: number = f1.a; +>n1 : Symbol(n1, Decl(variants.ts, 3, 5)) +>f1 : Symbol(f1, Decl(variants.ts, 0, 0), Decl(variants.ts, 1, 9)) + +const s1: string = f1.a; // error +>s1 : Symbol(s1, Decl(variants.ts, 4, 5)) +>f1 : Symbol(f1, Decl(variants.ts, 0, 0), Decl(variants.ts, 1, 9)) + +const t1: f1.a = 0; +>t1 : Symbol(t1, Decl(variants.ts, 5, 5)) +>f1 : Symbol(f1, Decl(variants.ts, 0, 0), Decl(variants.ts, 1, 9)) +>a : Symbol(f1.a, Decl(variants.ts, 2, 14)) + +function f2() {} +>f2 : Symbol(f2, Decl(variants.ts, 5, 19), Decl(variants.ts, 8, 9)) + +f2.a = 0; +>f2 : Symbol(f2, Decl(variants.ts, 5, 19), Decl(variants.ts, 8, 9)) + +namespace f2 { export interface a { x: string } } +>f2 : Symbol(f2, Decl(variants.ts, 5, 19), Decl(variants.ts, 8, 9)) +>a : Symbol(a, Decl(variants.ts, 9, 14)) +>x : Symbol(a.x, Decl(variants.ts, 9, 35)) + +const n2: number = f2.a; +>n2 : Symbol(n2, Decl(variants.ts, 10, 5)) +>f2 : Symbol(f2, Decl(variants.ts, 5, 19), Decl(variants.ts, 8, 9)) + +const t2: f2.a = { x: "" }; +>t2 : Symbol(t2, Decl(variants.ts, 11, 5)) +>f2 : Symbol(f2, Decl(variants.ts, 5, 19), Decl(variants.ts, 8, 9)) +>a : Symbol(f2.a, Decl(variants.ts, 9, 14)) +>x : Symbol(x, Decl(variants.ts, 11, 18)) + +function f3() {} +>f3 : Symbol(f3, Decl(variants.ts, 11, 27), Decl(variants.ts, 14, 9)) + +f3.a = 0; +>f3 : Symbol(f3, Decl(variants.ts, 11, 27), Decl(variants.ts, 14, 9)) + +namespace f3 { export namespace a {} } +>f3 : Symbol(f3, Decl(variants.ts, 11, 27), Decl(variants.ts, 14, 9)) +>a : Symbol(a, Decl(variants.ts, 15, 14)) + +const n3: number = f3.a; +>n3 : Symbol(n3, Decl(variants.ts, 16, 5)) +>f3 : Symbol(f3, Decl(variants.ts, 11, 27), Decl(variants.ts, 14, 9)) + +function f4() {} +>f4 : Symbol(f4, Decl(variants.ts, 16, 24), Decl(variants.ts, 19, 9)) + +f4.a = 0; +>f4 : Symbol(f4, Decl(variants.ts, 16, 24), Decl(variants.ts, 19, 9)) + +namespace f4 { export namespace a { export type T = string; } } +>f4 : Symbol(f4, Decl(variants.ts, 16, 24), Decl(variants.ts, 19, 9)) +>a : Symbol(a, Decl(variants.ts, 20, 14)) +>T : Symbol(T, Decl(variants.ts, 20, 35)) + +const n4: number = f4.a; +>n4 : Symbol(n4, Decl(variants.ts, 21, 5)) +>f4 : Symbol(f4, Decl(variants.ts, 16, 24), Decl(variants.ts, 19, 9)) + +const t4: f4.a.T = ""; +>t4 : Symbol(t4, Decl(variants.ts, 22, 5)) +>f4 : Symbol(f4, Decl(variants.ts, 16, 24), Decl(variants.ts, 19, 9)) +>a : Symbol(f4.a, Decl(variants.ts, 20, 14)) +>T : Symbol(f4.a.T, Decl(variants.ts, 20, 35)) + +namespace f5 { export type a = 0; } +>f5 : Symbol(f5, Decl(variants.ts, 24, 35), Decl(variants.ts, 22, 22)) +>a : Symbol(a, Decl(variants.ts, 24, 14)) + +function f5() {} +>f5 : Symbol(f5, Decl(variants.ts, 24, 35), Decl(variants.ts, 22, 22)) + +f5.a = 0; +>f5 : Symbol(f5, Decl(variants.ts, 24, 35), Decl(variants.ts, 22, 22)) + +const n5: number = f5.a; +>n5 : Symbol(n5, Decl(variants.ts, 27, 5)) +>f5 : Symbol(f5, Decl(variants.ts, 24, 35), Decl(variants.ts, 22, 22)) + +function f6() {} +>f6 : Symbol(f6, Decl(variants.ts, 27, 24), Decl(variants.ts, 30, 9)) + +f6.a = 0; +>f6.a : Symbol(f6.a, Decl(variants.ts, 31, 14)) +>f6 : Symbol(f6, Decl(variants.ts, 27, 24), Decl(variants.ts, 30, 9)) +>a : Symbol(f6.a, Decl(variants.ts, 31, 14)) + +namespace f6 { export namespace a { export const kind = 0; } } +>f6 : Symbol(f6, Decl(variants.ts, 27, 24), Decl(variants.ts, 30, 9)) +>a : Symbol(a, Decl(variants.ts, 31, 14)) +>kind : Symbol(kind, Decl(variants.ts, 31, 48)) + +const n6: number = f6.a; // error +>n6 : Symbol(n6, Decl(variants.ts, 32, 5)) +>f6.a : Symbol(f6.a, Decl(variants.ts, 31, 14)) +>f6 : Symbol(f6, Decl(variants.ts, 27, 24), Decl(variants.ts, 30, 9)) +>a : Symbol(f6.a, Decl(variants.ts, 31, 14)) + +=== popover.ts === +export function Popover() { return null; } +>Popover : Symbol(Popover, Decl(popover.ts, 0, 0), Decl(popover.ts, 2, 32)) + +Popover.Target = (x: number) => x; +>Popover : Symbol(Popover, Decl(popover.ts, 0, 0), Decl(popover.ts, 2, 32)) +>x : Symbol(x, Decl(popover.ts, 1, 18)) +>x : Symbol(x, Decl(popover.ts, 1, 18)) + +Popover.displayName = "Popover"; +>Popover.displayName : Symbol(Popover.displayName, Decl(popover.ts, 1, 34)) +>Popover : Symbol(Popover, Decl(popover.ts, 0, 0), Decl(popover.ts, 2, 32)) +>displayName : Symbol(Popover.displayName, Decl(popover.ts, 1, 34)) + +export namespace Popover { +>Popover : Symbol(Popover, Decl(popover.ts, 0, 0), Decl(popover.ts, 2, 32)) + + export namespace Target { +>Target : Symbol(Target, Decl(popover.ts, 4, 26)) + + export type Props = number; +>Props : Symbol(Props, Decl(popover.ts, 5, 27)) + } +} + +Popover.Target(1); +>Popover : Symbol(Popover, Decl(popover.ts, 0, 0), Decl(popover.ts, 2, 32)) + +Popover.displayName; +>Popover.displayName : Symbol(Popover.displayName, Decl(popover.ts, 1, 34)) +>Popover : Symbol(Popover, Decl(popover.ts, 0, 0), Decl(popover.ts, 2, 32)) +>displayName : Symbol(Popover.displayName, Decl(popover.ts, 1, 34)) + +const props: Popover.Target.Props = 1; +>props : Symbol(props, Decl(popover.ts, 12, 5)) +>Popover : Symbol(Popover, Decl(popover.ts, 0, 0), Decl(popover.ts, 2, 32)) +>Target : Symbol(Popover.Target, Decl(popover.ts, 4, 26)) +>Props : Symbol(Popover.Target.Props, Decl(popover.ts, 5, 27)) + diff --git a/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.types b/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.types new file mode 100644 index 0000000000000..24b8335fc2798 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.types @@ -0,0 +1,187 @@ +//// [tests/cases/compiler/expandoFunctionTypeOnlyNamespaceMember.ts] //// + +=== variants.ts === +function f1() {} +>f1 : () => void + +f1.a = 0; +>f1.a = 0 : 0 +>f1.a : any +>f1 : () => void +>a : any +>0 : 0 + +namespace f1 { export type a = 0; } +>a : 0 + +const n1: number = f1.a; +>n1 : number +>f1.a : any +>f1 : () => void +>a : any + +const s1: string = f1.a; // error +>s1 : string +>f1.a : any +>f1 : () => void +>a : any + +const t1: f1.a = 0; +>t1 : 0 +>f1 : any +>0 : 0 + +function f2() {} +>f2 : () => void + +f2.a = 0; +>f2.a = 0 : 0 +>f2.a : any +>f2 : () => void +>a : any +>0 : 0 + +namespace f2 { export interface a { x: string } } +>x : string + +const n2: number = f2.a; +>n2 : number +>f2.a : any +>f2 : () => void +>a : any + +const t2: f2.a = { x: "" }; +>t2 : f2.a +>f2 : any +>{ x: "" } : { x: string; } +>x : string +>"" : "" + +function f3() {} +>f3 : () => void + +f3.a = 0; +>f3.a = 0 : 0 +>f3.a : any +>f3 : () => void +>a : any +>0 : 0 + +namespace f3 { export namespace a {} } +const n3: number = f3.a; +>n3 : number +>f3.a : any +>f3 : () => void +>a : any + +function f4() {} +>f4 : () => void + +f4.a = 0; +>f4.a = 0 : 0 +>f4.a : any +>f4 : () => void +>a : any +>0 : 0 + +namespace f4 { export namespace a { export type T = string; } } +>T : string + +const n4: number = f4.a; +>n4 : number +>f4.a : any +>f4 : () => void +>a : any + +const t4: f4.a.T = ""; +>t4 : string +>f4 : any +>a : any +>"" : "" + +namespace f5 { export type a = 0; } +>a : 0 + +function f5() {} +>f5 : () => void + +f5.a = 0; +>f5.a = 0 : 0 +>f5.a : any +>f5 : () => void +>a : any +>0 : 0 + +const n5: number = f5.a; +>n5 : number +>f5.a : any +>f5 : () => void +>a : any + +function f6() {} +>f6 : typeof f6 + +f6.a = 0; +>f6.a = 0 : 0 +>f6.a : typeof f6.a +>f6 : typeof f6 +>a : typeof f6.a +>0 : 0 + +namespace f6 { export namespace a { export const kind = 0; } } +>f6 : typeof f6 +>a : typeof a +>kind : 0 +>0 : 0 + +const n6: number = f6.a; // error +>n6 : number +>f6.a : typeof f6.a +>f6 : typeof f6 +>a : typeof f6.a + +=== popover.ts === +export function Popover() { return null; } +>Popover : { (): null; displayName: string; } + +Popover.Target = (x: number) => x; +>Popover.Target = (x: number) => x : (x: number) => number +>Popover.Target : any +>Popover : { (): null; displayName: string; } +>Target : any +>(x: number) => x : (x: number) => number +>x : number +>x : number + +Popover.displayName = "Popover"; +>Popover.displayName = "Popover" : "Popover" +>Popover.displayName : string +>Popover : { (): null; displayName: string; } +>displayName : string +>"Popover" : "Popover" + +export namespace Popover { + export namespace Target { + export type Props = number; +>Props : number + } +} + +Popover.Target(1); +>Popover.Target(1) : any +>Popover.Target : any +>Popover : { (): null; displayName: string; } +>Target : any +>1 : 1 + +Popover.displayName; +>Popover.displayName : string +>Popover : { (): null; displayName: string; } +>displayName : string + +const props: Popover.Target.Props = 1; +>props : number +>Popover : any +>Target : any +>1 : 1 + diff --git a/tsc/testdata/tests/cases/compiler/expandoFunctionTypeOnlyNamespaceMember.ts b/tsc/testdata/tests/cases/compiler/expandoFunctionTypeOnlyNamespaceMember.ts new file mode 100644 index 0000000000000..88b4103735fa1 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/expandoFunctionTypeOnlyNamespaceMember.ts @@ -0,0 +1,53 @@ +// @strict: true +// @target: es2022 +// @declaration: true + +// @filename: variants.ts +function f1() {} +f1.a = 0; +namespace f1 { export type a = 0; } +const n1: number = f1.a; +const s1: string = f1.a; // error +const t1: f1.a = 0; + +function f2() {} +f2.a = 0; +namespace f2 { export interface a { x: string } } +const n2: number = f2.a; +const t2: f2.a = { x: "" }; + +function f3() {} +f3.a = 0; +namespace f3 { export namespace a {} } +const n3: number = f3.a; + +function f4() {} +f4.a = 0; +namespace f4 { export namespace a { export type T = string; } } +const n4: number = f4.a; +const t4: f4.a.T = ""; + +namespace f5 { export type a = 0; } +function f5() {} +f5.a = 0; +const n5: number = f5.a; + +function f6() {} +f6.a = 0; +namespace f6 { export namespace a { export const kind = 0; } } +const n6: number = f6.a; // error + +// @filename: popover.ts +export function Popover() { return null; } +Popover.Target = (x: number) => x; +Popover.displayName = "Popover"; + +export namespace Popover { + export namespace Target { + export type Props = number; + } +} + +Popover.Target(1); +Popover.displayName; +const props: Popover.Target.Props = 1; From d7686cff6d573fea88d574fc3e125890c60281af Mon Sep 17 00:00:00 2001 From: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com> Date: Fri, 20 Nov 2026 16:31:39 +0000 Subject: [PATCH 03/14] Add alias variants to expando/namespace merge test Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --- ...FunctionTypeOnlyNamespaceMember.errors.txt | 24 ++++++++- .../expandoFunctionTypeOnlyNamespaceMember.js | 44 ++++++++++++++++ ...ndoFunctionTypeOnlyNamespaceMember.symbols | 42 ++++++++++++++++ ...pandoFunctionTypeOnlyNamespaceMember.types | 50 +++++++++++++++++++ .../expandoFunctionTypeOnlyNamespaceMember.ts | 13 +++++ 5 files changed, 172 insertions(+), 1 deletion(-) diff --git a/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.errors.txt b/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.errors.txt index 915e267b4a5d4..e098bfacba6a8 100644 --- a/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.errors.txt +++ b/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.errors.txt @@ -13,9 +13,12 @@ variants.ts(27,4): error TS2339: Property 'a' does not exist on type '() => void variants.ts(28,23): error TS2339: Property 'a' does not exist on type '() => void'. variants.ts(31,1): error TS2322: Type 'number' is not assignable to type 'typeof a'. variants.ts(33,7): error TS2322: Type 'typeof a' is not assignable to type 'number'. +variants.ts(39,4): error TS2339: Property 'a' does not exist on type 'typeof f7'. +variants.ts(41,23): error TS2339: Property 'a' does not exist on type 'typeof f7'. +variants.ts(45,1): error TS2322: Type 'number' is not assignable to type 'typeof Values'. -==== variants.ts (13 errors) ==== +==== variants.ts (16 errors) ==== function f1() {} f1.a = 0; ~ @@ -76,6 +79,25 @@ variants.ts(33,7): error TS2322: Type 'typeof a' is not assignable to type 'numb ~~ !!! error TS2322: Type 'typeof a' is not assignable to type 'number'. + namespace TypesOnly { export type T = number; } + namespace Values { export const v = 1; } + + function f7() {} + f7.a = 0; + ~ +!!! error TS2339: Property 'a' does not exist on type 'typeof f7'. + namespace f7 { export import a = TypesOnly; } + const n7: number = f7.a; + ~ +!!! error TS2339: Property 'a' does not exist on type 'typeof f7'. + const t7: f7.a.T = 0; + + function f8() {} + f8.a = 0; + ~~~~ +!!! error TS2322: Type 'number' is not assignable to type 'typeof Values'. + namespace f8 { export import a = Values; } // error + ==== popover.ts (2 errors) ==== export function Popover() { return null; } Popover.Target = (x: number) => x; diff --git a/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.js b/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.js index cc7edd3418d7a..aeccd4b73bf8b 100644 --- a/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.js +++ b/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.js @@ -34,6 +34,19 @@ function f6() {} f6.a = 0; namespace f6 { export namespace a { export const kind = 0; } } const n6: number = f6.a; // error + +namespace TypesOnly { export type T = number; } +namespace Values { export const v = 1; } + +function f7() {} +f7.a = 0; +namespace f7 { export import a = TypesOnly; } +const n7: number = f7.a; +const t7: f7.a.T = 0; + +function f8() {} +f8.a = 0; +namespace f8 { export import a = Values; } // error //// [popover.ts] export function Popover() { return null; } @@ -81,6 +94,21 @@ f6.a = 0; })(a = f6.a || (f6.a = {})); })(f6 || (f6 = {})); const n6 = f6.a; // error +var Values; +(function (Values) { + Values.v = 1; +})(Values || (Values = {})); +function f7() { } +f7.a = 0; +(function (f7) { +})(f7 || (f7 = {})); +const n7 = f7.a; +const t7 = 0; +function f8() { } +f8.a = 0; +(function (f8) { + f8.a = Values; +})(f8 || (f8 = {})); // error //// [popover.js] export function Popover() { return null; } Popover.Target = (x) => x; @@ -131,6 +159,22 @@ declare namespace f6 { } } declare const n6: number; +declare namespace TypesOnly { + type T = number; +} +declare namespace Values { + const v = 1; +} +declare function f7(): void; +declare namespace f7 { + export import a = TypesOnly; +} +declare const n7: number; +declare const t7: f7.a.T; +declare function f8(): void; +declare namespace f8 { + export import a = Values; +} //// [popover.d.ts] export declare function Popover(): null; export declare namespace Popover { diff --git a/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.symbols b/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.symbols index a99662e664892..d06b27d9a2b02 100644 --- a/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.symbols +++ b/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.symbols @@ -113,6 +113,48 @@ const n6: number = f6.a; // error >f6 : Symbol(f6, Decl(variants.ts, 27, 24), Decl(variants.ts, 30, 9)) >a : Symbol(f6.a, Decl(variants.ts, 31, 14)) +namespace TypesOnly { export type T = number; } +>TypesOnly : Symbol(TypesOnly, Decl(variants.ts, 32, 24)) +>T : Symbol(T, Decl(variants.ts, 34, 21)) + +namespace Values { export const v = 1; } +>Values : Symbol(Values, Decl(variants.ts, 34, 47)) +>v : Symbol(v, Decl(variants.ts, 35, 31)) + +function f7() {} +>f7 : Symbol(f7, Decl(variants.ts, 35, 40), Decl(variants.ts, 38, 9)) + +f7.a = 0; +>f7 : Symbol(f7, Decl(variants.ts, 35, 40), Decl(variants.ts, 38, 9)) + +namespace f7 { export import a = TypesOnly; } +>f7 : Symbol(f7, Decl(variants.ts, 35, 40), Decl(variants.ts, 38, 9)) +>a : Symbol(a, Decl(variants.ts, 39, 14)) +>TypesOnly : Symbol(a, Decl(variants.ts, 32, 24)) + +const n7: number = f7.a; +>n7 : Symbol(n7, Decl(variants.ts, 40, 5)) +>f7 : Symbol(f7, Decl(variants.ts, 35, 40), Decl(variants.ts, 38, 9)) + +const t7: f7.a.T = 0; +>t7 : Symbol(t7, Decl(variants.ts, 41, 5)) +>f7 : Symbol(f7, Decl(variants.ts, 35, 40), Decl(variants.ts, 38, 9)) +>a : Symbol(f7.a, Decl(variants.ts, 39, 14)) +>T : Symbol(TypesOnly.T, Decl(variants.ts, 34, 21)) + +function f8() {} +>f8 : Symbol(f8, Decl(variants.ts, 41, 21), Decl(variants.ts, 44, 9)) + +f8.a = 0; +>f8.a : Symbol(f8.a, Decl(variants.ts, 45, 14)) +>f8 : Symbol(f8, Decl(variants.ts, 41, 21), Decl(variants.ts, 44, 9)) +>a : Symbol(f8.a, Decl(variants.ts, 45, 14)) + +namespace f8 { export import a = Values; } // error +>f8 : Symbol(f8, Decl(variants.ts, 41, 21), Decl(variants.ts, 44, 9)) +>a : Symbol(a, Decl(variants.ts, 45, 14)) +>Values : Symbol(a, Decl(variants.ts, 34, 47)) + === popover.ts === export function Popover() { return null; } >Popover : Symbol(Popover, Decl(popover.ts, 0, 0), Decl(popover.ts, 2, 32)) diff --git a/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.types b/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.types index 24b8335fc2798..def0a1a98c6b4 100644 --- a/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.types +++ b/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.types @@ -140,6 +140,56 @@ const n6: number = f6.a; // error >f6 : typeof f6 >a : typeof f6.a +namespace TypesOnly { export type T = number; } +>T : number + +namespace Values { export const v = 1; } +>Values : typeof Values +>v : 1 +>1 : 1 + +function f7() {} +>f7 : typeof f7 + +f7.a = 0; +>f7.a = 0 : 0 +>f7.a : any +>f7 : typeof f7 +>a : any +>0 : 0 + +namespace f7 { export import a = TypesOnly; } +>f7 : typeof f7 +>a : any +>TypesOnly : any + +const n7: number = f7.a; +>n7 : number +>f7.a : any +>f7 : typeof f7 +>a : any + +const t7: f7.a.T = 0; +>t7 : number +>f7 : any +>a : any +>0 : 0 + +function f8() {} +>f8 : typeof f8 + +f8.a = 0; +>f8.a = 0 : 0 +>f8.a : typeof Values +>f8 : typeof f8 +>a : typeof Values +>0 : 0 + +namespace f8 { export import a = Values; } // error +>f8 : typeof f8 +>a : typeof a +>Values : typeof a + === popover.ts === export function Popover() { return null; } >Popover : { (): null; displayName: string; } diff --git a/tsc/testdata/tests/cases/compiler/expandoFunctionTypeOnlyNamespaceMember.ts b/tsc/testdata/tests/cases/compiler/expandoFunctionTypeOnlyNamespaceMember.ts index 88b4103735fa1..86718deea46d6 100644 --- a/tsc/testdata/tests/cases/compiler/expandoFunctionTypeOnlyNamespaceMember.ts +++ b/tsc/testdata/tests/cases/compiler/expandoFunctionTypeOnlyNamespaceMember.ts @@ -37,6 +37,19 @@ f6.a = 0; namespace f6 { export namespace a { export const kind = 0; } } const n6: number = f6.a; // error +namespace TypesOnly { export type T = number; } +namespace Values { export const v = 1; } + +function f7() {} +f7.a = 0; +namespace f7 { export import a = TypesOnly; } +const n7: number = f7.a; +const t7: f7.a.T = 0; + +function f8() {} +f8.a = 0; +namespace f8 { export import a = Values; } // error + // @filename: popover.ts export function Popover() { return null; } Popover.Target = (x: number) => x; From 0d6341e52b0c237a5b7aafaf8851f3f9482d212f Mon Sep 17 00:00:00 2001 From: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com> Date: Fri, 20 Nov 2026 16:35:58 +0000 Subject: [PATCH 04/14] Allow expando assignments to merge with type-only declarations of the same name Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --- tsc/internal/binder/binder.go | 6 +- ...FunctionTypeOnlyNamespaceMember.errors.txt | 53 ++-------- .../expandoFunctionTypeOnlyNamespaceMember.js | 18 ++++ ...ndoFunctionTypeOnlyNamespaceMember.symbols | 77 ++++++++++----- ...pandoFunctionTypeOnlyNamespaceMember.types | 97 ++++++++++--------- .../expandoFunctionTypeOnlyNamespaceMember.ts | 1 + 6 files changed, 133 insertions(+), 119 deletions(-) diff --git a/tsc/internal/binder/binder.go b/tsc/internal/binder/binder.go index e1058bc33b043..082a83bc326de 100644 --- a/tsc/internal/binder/binder.go +++ b/tsc/internal/binder/binder.go @@ -1081,9 +1081,11 @@ func (b *Binder) bindDeferredExpandoAssignment(node *ast.Node) { b.bindAnonymousDeclaration(node, ast.SymbolFlagsProperty|ast.SymbolFlagsAssignment, ast.InternalSymbolNameComputed) b.addLateBoundAssignmentDeclarationToSymbol(node, symbol) } else { - // We declare expandos only when there are no non-expando declarations for that name. + // We declare expandos only when there are no non-expando declarations for that name that might have + // a value meaning. Expandos merge with type-only declarations (type aliases, interfaces, and + // uninstantiated namespaces), but not with aliases since those might resolve to values. exports := ast.GetExports(symbol, &b.symbolExtraArena) - if existing := exports.Get(b.getDeclarationName(node)); existing == nil || existing.Flags()&ast.SymbolFlagsAssignment != 0 { + if existing := exports.Get(b.getDeclarationName(node)); existing == nil || existing.Flags()&ast.SymbolFlagsAssignment != 0 || existing.Flags()&(ast.SymbolFlagsValue|ast.SymbolFlagsAlias) == 0 { b.declareSymbol(exports, symbol, node, ast.SymbolFlagsProperty|ast.SymbolFlagsAssignment, ast.SymbolFlagsPropertyExcludes) } } diff --git a/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.errors.txt b/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.errors.txt index e098bfacba6a8..744788c289e4a 100644 --- a/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.errors.txt +++ b/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.errors.txt @@ -1,74 +1,42 @@ -popover.ts(2,9): error TS2339: Property 'Target' does not exist on type '{ (): null; displayName: string; }'. -popover.ts(11,9): error TS2339: Property 'Target' does not exist on type '{ (): null; displayName: string; }'. -variants.ts(2,4): error TS2339: Property 'a' does not exist on type '() => void'. -variants.ts(4,23): error TS2339: Property 'a' does not exist on type '() => void'. -variants.ts(5,23): error TS2339: Property 'a' does not exist on type '() => void'. -variants.ts(9,4): error TS2339: Property 'a' does not exist on type '() => void'. -variants.ts(11,23): error TS2339: Property 'a' does not exist on type '() => void'. -variants.ts(15,4): error TS2339: Property 'a' does not exist on type '() => void'. -variants.ts(17,23): error TS2339: Property 'a' does not exist on type '() => void'. -variants.ts(20,4): error TS2339: Property 'a' does not exist on type '() => void'. -variants.ts(22,23): error TS2339: Property 'a' does not exist on type '() => void'. -variants.ts(27,4): error TS2339: Property 'a' does not exist on type '() => void'. -variants.ts(28,23): error TS2339: Property 'a' does not exist on type '() => void'. +variants.ts(5,7): error TS2322: Type 'number' is not assignable to type 'string'. variants.ts(31,1): error TS2322: Type 'number' is not assignable to type 'typeof a'. variants.ts(33,7): error TS2322: Type 'typeof a' is not assignable to type 'number'. -variants.ts(39,4): error TS2339: Property 'a' does not exist on type 'typeof f7'. -variants.ts(41,23): error TS2339: Property 'a' does not exist on type 'typeof f7'. -variants.ts(45,1): error TS2322: Type 'number' is not assignable to type 'typeof Values'. +variants.ts(40,4): error TS2339: Property 'a' does not exist on type 'typeof f7'. +variants.ts(42,23): error TS2339: Property 'a' does not exist on type 'typeof f7'. +variants.ts(46,1): error TS2322: Type 'number' is not assignable to type 'typeof Values'. -==== variants.ts (16 errors) ==== +==== variants.ts (6 errors) ==== function f1() {} f1.a = 0; - ~ -!!! error TS2339: Property 'a' does not exist on type '() => void'. namespace f1 { export type a = 0; } const n1: number = f1.a; - ~ -!!! error TS2339: Property 'a' does not exist on type '() => void'. const s1: string = f1.a; // error - ~ -!!! error TS2339: Property 'a' does not exist on type '() => void'. + ~~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. const t1: f1.a = 0; function f2() {} f2.a = 0; - ~ -!!! error TS2339: Property 'a' does not exist on type '() => void'. namespace f2 { export interface a { x: string } } const n2: number = f2.a; - ~ -!!! error TS2339: Property 'a' does not exist on type '() => void'. const t2: f2.a = { x: "" }; function f3() {} f3.a = 0; - ~ -!!! error TS2339: Property 'a' does not exist on type '() => void'. namespace f3 { export namespace a {} } const n3: number = f3.a; - ~ -!!! error TS2339: Property 'a' does not exist on type '() => void'. function f4() {} f4.a = 0; - ~ -!!! error TS2339: Property 'a' does not exist on type '() => void'. namespace f4 { export namespace a { export type T = string; } } const n4: number = f4.a; - ~ -!!! error TS2339: Property 'a' does not exist on type '() => void'. const t4: f4.a.T = ""; namespace f5 { export type a = 0; } function f5() {} f5.a = 0; - ~ -!!! error TS2339: Property 'a' does not exist on type '() => void'. const n5: number = f5.a; - ~ -!!! error TS2339: Property 'a' does not exist on type '() => void'. function f6() {} f6.a = 0; @@ -82,6 +50,7 @@ variants.ts(45,1): error TS2322: Type 'number' is not assignable to type 'typeof namespace TypesOnly { export type T = number; } namespace Values { export const v = 1; } + // Aliases might resolve to values, so they take precedence over expandos function f7() {} f7.a = 0; ~ @@ -98,11 +67,9 @@ variants.ts(45,1): error TS2322: Type 'number' is not assignable to type 'typeof !!! error TS2322: Type 'number' is not assignable to type 'typeof Values'. namespace f8 { export import a = Values; } // error -==== popover.ts (2 errors) ==== +==== popover.ts (0 errors) ==== export function Popover() { return null; } Popover.Target = (x: number) => x; - ~~~~~~ -!!! error TS2339: Property 'Target' does not exist on type '{ (): null; displayName: string; }'. Popover.displayName = "Popover"; export namespace Popover { @@ -112,8 +79,6 @@ variants.ts(45,1): error TS2322: Type 'number' is not assignable to type 'typeof } Popover.Target(1); - ~~~~~~ -!!! error TS2339: Property 'Target' does not exist on type '{ (): null; displayName: string; }'. Popover.displayName; const props: Popover.Target.Props = 1; \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.js b/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.js index aeccd4b73bf8b..bb158110142b4 100644 --- a/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.js +++ b/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.js @@ -38,6 +38,7 @@ const n6: number = f6.a; // error namespace TypesOnly { export type T = number; } namespace Values { export const v = 1; } +// Aliases might resolve to values, so they take precedence over expandos function f7() {} f7.a = 0; namespace f7 { export import a = TypesOnly; } @@ -98,6 +99,7 @@ var Values; (function (Values) { Values.v = 1; })(Values || (Values = {})); +// Aliases might resolve to values, so they take precedence over expandos function f7() { } f7.a = 0; (function (f7) { @@ -120,6 +122,9 @@ const props = 1; //// [variants.d.ts] declare function f1(): void; +declare namespace f1 { + var a: number; +} declare namespace f1 { type a = 0; } @@ -127,6 +132,9 @@ declare const n1: number; declare const s1: string; declare const t1: f1.a; declare function f2(): void; +declare namespace f2 { + var a: number; +} declare namespace f2 { interface a { x: string; @@ -135,11 +143,17 @@ declare namespace f2 { declare const n2: number; declare const t2: f2.a; declare function f3(): void; +declare namespace f3 { + var a: number; +} declare namespace f3 { namespace a { } } declare const n3: number; declare function f4(): void; +declare namespace f4 { + var a: number; +} declare namespace f4 { namespace a { type T = string; @@ -151,6 +165,9 @@ declare namespace f5 { type a = 0; } declare function f5(): void; +declare namespace f5 { + var a: number; +} declare const n5: number; declare function f6(): void; declare namespace f6 { @@ -178,6 +195,7 @@ declare namespace f8 { //// [popover.d.ts] export declare function Popover(): null; export declare namespace Popover { + var Target: (x: number) => number; var displayName: string; } export declare namespace Popover { diff --git a/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.symbols b/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.symbols index d06b27d9a2b02..8b37d2d0ea777 100644 --- a/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.symbols +++ b/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.symbols @@ -5,94 +5,116 @@ function f1() {} >f1 : Symbol(f1, Decl(variants.ts, 0, 0), Decl(variants.ts, 1, 9)) f1.a = 0; +>f1.a : Symbol(f1.a, Decl(variants.ts, 2, 14), Decl(variants.ts, 0, 16)) >f1 : Symbol(f1, Decl(variants.ts, 0, 0), Decl(variants.ts, 1, 9)) +>a : Symbol(f1.a, Decl(variants.ts, 2, 14), Decl(variants.ts, 0, 16)) namespace f1 { export type a = 0; } >f1 : Symbol(f1, Decl(variants.ts, 0, 0), Decl(variants.ts, 1, 9)) ->a : Symbol(a, Decl(variants.ts, 2, 14)) +>a : Symbol(a, Decl(variants.ts, 2, 14), Decl(variants.ts, 0, 16)) const n1: number = f1.a; >n1 : Symbol(n1, Decl(variants.ts, 3, 5)) +>f1.a : Symbol(f1.a, Decl(variants.ts, 2, 14), Decl(variants.ts, 0, 16)) >f1 : Symbol(f1, Decl(variants.ts, 0, 0), Decl(variants.ts, 1, 9)) +>a : Symbol(f1.a, Decl(variants.ts, 2, 14), Decl(variants.ts, 0, 16)) const s1: string = f1.a; // error >s1 : Symbol(s1, Decl(variants.ts, 4, 5)) +>f1.a : Symbol(f1.a, Decl(variants.ts, 2, 14), Decl(variants.ts, 0, 16)) >f1 : Symbol(f1, Decl(variants.ts, 0, 0), Decl(variants.ts, 1, 9)) +>a : Symbol(f1.a, Decl(variants.ts, 2, 14), Decl(variants.ts, 0, 16)) const t1: f1.a = 0; >t1 : Symbol(t1, Decl(variants.ts, 5, 5)) >f1 : Symbol(f1, Decl(variants.ts, 0, 0), Decl(variants.ts, 1, 9)) ->a : Symbol(f1.a, Decl(variants.ts, 2, 14)) +>a : Symbol(f1.a, Decl(variants.ts, 2, 14), Decl(variants.ts, 0, 16)) function f2() {} >f2 : Symbol(f2, Decl(variants.ts, 5, 19), Decl(variants.ts, 8, 9)) f2.a = 0; +>f2.a : Symbol(f2.a, Decl(variants.ts, 9, 14), Decl(variants.ts, 7, 16)) >f2 : Symbol(f2, Decl(variants.ts, 5, 19), Decl(variants.ts, 8, 9)) +>a : Symbol(f2.a, Decl(variants.ts, 9, 14), Decl(variants.ts, 7, 16)) namespace f2 { export interface a { x: string } } >f2 : Symbol(f2, Decl(variants.ts, 5, 19), Decl(variants.ts, 8, 9)) ->a : Symbol(a, Decl(variants.ts, 9, 14)) +>a : Symbol(a, Decl(variants.ts, 9, 14), Decl(variants.ts, 7, 16)) >x : Symbol(a.x, Decl(variants.ts, 9, 35)) const n2: number = f2.a; >n2 : Symbol(n2, Decl(variants.ts, 10, 5)) +>f2.a : Symbol(f2.a, Decl(variants.ts, 9, 14), Decl(variants.ts, 7, 16)) >f2 : Symbol(f2, Decl(variants.ts, 5, 19), Decl(variants.ts, 8, 9)) +>a : Symbol(f2.a, Decl(variants.ts, 9, 14), Decl(variants.ts, 7, 16)) const t2: f2.a = { x: "" }; >t2 : Symbol(t2, Decl(variants.ts, 11, 5)) >f2 : Symbol(f2, Decl(variants.ts, 5, 19), Decl(variants.ts, 8, 9)) ->a : Symbol(f2.a, Decl(variants.ts, 9, 14)) +>a : Symbol(f2.a, Decl(variants.ts, 9, 14), Decl(variants.ts, 7, 16)) >x : Symbol(x, Decl(variants.ts, 11, 18)) function f3() {} >f3 : Symbol(f3, Decl(variants.ts, 11, 27), Decl(variants.ts, 14, 9)) f3.a = 0; +>f3.a : Symbol(f3.a, Decl(variants.ts, 15, 14), Decl(variants.ts, 13, 16)) >f3 : Symbol(f3, Decl(variants.ts, 11, 27), Decl(variants.ts, 14, 9)) +>a : Symbol(f3.a, Decl(variants.ts, 15, 14), Decl(variants.ts, 13, 16)) namespace f3 { export namespace a {} } >f3 : Symbol(f3, Decl(variants.ts, 11, 27), Decl(variants.ts, 14, 9)) ->a : Symbol(a, Decl(variants.ts, 15, 14)) +>a : Symbol(a, Decl(variants.ts, 15, 14), Decl(variants.ts, 13, 16)) const n3: number = f3.a; >n3 : Symbol(n3, Decl(variants.ts, 16, 5)) +>f3.a : Symbol(f3.a, Decl(variants.ts, 15, 14), Decl(variants.ts, 13, 16)) >f3 : Symbol(f3, Decl(variants.ts, 11, 27), Decl(variants.ts, 14, 9)) +>a : Symbol(f3.a, Decl(variants.ts, 15, 14), Decl(variants.ts, 13, 16)) function f4() {} >f4 : Symbol(f4, Decl(variants.ts, 16, 24), Decl(variants.ts, 19, 9)) f4.a = 0; +>f4.a : Symbol(f4.a, Decl(variants.ts, 20, 14), Decl(variants.ts, 18, 16)) >f4 : Symbol(f4, Decl(variants.ts, 16, 24), Decl(variants.ts, 19, 9)) +>a : Symbol(f4.a, Decl(variants.ts, 20, 14), Decl(variants.ts, 18, 16)) namespace f4 { export namespace a { export type T = string; } } >f4 : Symbol(f4, Decl(variants.ts, 16, 24), Decl(variants.ts, 19, 9)) ->a : Symbol(a, Decl(variants.ts, 20, 14)) +>a : Symbol(a, Decl(variants.ts, 20, 14), Decl(variants.ts, 18, 16)) >T : Symbol(T, Decl(variants.ts, 20, 35)) const n4: number = f4.a; >n4 : Symbol(n4, Decl(variants.ts, 21, 5)) +>f4.a : Symbol(f4.a, Decl(variants.ts, 20, 14), Decl(variants.ts, 18, 16)) >f4 : Symbol(f4, Decl(variants.ts, 16, 24), Decl(variants.ts, 19, 9)) +>a : Symbol(f4.a, Decl(variants.ts, 20, 14), Decl(variants.ts, 18, 16)) const t4: f4.a.T = ""; >t4 : Symbol(t4, Decl(variants.ts, 22, 5)) >f4 : Symbol(f4, Decl(variants.ts, 16, 24), Decl(variants.ts, 19, 9)) ->a : Symbol(f4.a, Decl(variants.ts, 20, 14)) +>a : Symbol(f4.a, Decl(variants.ts, 20, 14), Decl(variants.ts, 18, 16)) >T : Symbol(f4.a.T, Decl(variants.ts, 20, 35)) namespace f5 { export type a = 0; } >f5 : Symbol(f5, Decl(variants.ts, 24, 35), Decl(variants.ts, 22, 22)) ->a : Symbol(a, Decl(variants.ts, 24, 14)) +>a : Symbol(a, Decl(variants.ts, 24, 14), Decl(variants.ts, 25, 16)) function f5() {} >f5 : Symbol(f5, Decl(variants.ts, 24, 35), Decl(variants.ts, 22, 22)) f5.a = 0; +>f5.a : Symbol(f5.a, Decl(variants.ts, 24, 14), Decl(variants.ts, 25, 16)) >f5 : Symbol(f5, Decl(variants.ts, 24, 35), Decl(variants.ts, 22, 22)) +>a : Symbol(f5.a, Decl(variants.ts, 24, 14), Decl(variants.ts, 25, 16)) const n5: number = f5.a; >n5 : Symbol(n5, Decl(variants.ts, 27, 5)) +>f5.a : Symbol(f5.a, Decl(variants.ts, 24, 14), Decl(variants.ts, 25, 16)) >f5 : Symbol(f5, Decl(variants.ts, 24, 35), Decl(variants.ts, 22, 22)) +>a : Symbol(f5.a, Decl(variants.ts, 24, 14), Decl(variants.ts, 25, 16)) function f6() {} >f6 : Symbol(f6, Decl(variants.ts, 27, 24), Decl(variants.ts, 30, 9)) @@ -121,38 +143,39 @@ namespace Values { export const v = 1; } >Values : Symbol(Values, Decl(variants.ts, 34, 47)) >v : Symbol(v, Decl(variants.ts, 35, 31)) +// Aliases might resolve to values, so they take precedence over expandos function f7() {} ->f7 : Symbol(f7, Decl(variants.ts, 35, 40), Decl(variants.ts, 38, 9)) +>f7 : Symbol(f7, Decl(variants.ts, 35, 40), Decl(variants.ts, 39, 9)) f7.a = 0; ->f7 : Symbol(f7, Decl(variants.ts, 35, 40), Decl(variants.ts, 38, 9)) +>f7 : Symbol(f7, Decl(variants.ts, 35, 40), Decl(variants.ts, 39, 9)) namespace f7 { export import a = TypesOnly; } ->f7 : Symbol(f7, Decl(variants.ts, 35, 40), Decl(variants.ts, 38, 9)) ->a : Symbol(a, Decl(variants.ts, 39, 14)) +>f7 : Symbol(f7, Decl(variants.ts, 35, 40), Decl(variants.ts, 39, 9)) +>a : Symbol(a, Decl(variants.ts, 40, 14)) >TypesOnly : Symbol(a, Decl(variants.ts, 32, 24)) const n7: number = f7.a; ->n7 : Symbol(n7, Decl(variants.ts, 40, 5)) ->f7 : Symbol(f7, Decl(variants.ts, 35, 40), Decl(variants.ts, 38, 9)) +>n7 : Symbol(n7, Decl(variants.ts, 41, 5)) +>f7 : Symbol(f7, Decl(variants.ts, 35, 40), Decl(variants.ts, 39, 9)) const t7: f7.a.T = 0; ->t7 : Symbol(t7, Decl(variants.ts, 41, 5)) ->f7 : Symbol(f7, Decl(variants.ts, 35, 40), Decl(variants.ts, 38, 9)) ->a : Symbol(f7.a, Decl(variants.ts, 39, 14)) +>t7 : Symbol(t7, Decl(variants.ts, 42, 5)) +>f7 : Symbol(f7, Decl(variants.ts, 35, 40), Decl(variants.ts, 39, 9)) +>a : Symbol(f7.a, Decl(variants.ts, 40, 14)) >T : Symbol(TypesOnly.T, Decl(variants.ts, 34, 21)) function f8() {} ->f8 : Symbol(f8, Decl(variants.ts, 41, 21), Decl(variants.ts, 44, 9)) +>f8 : Symbol(f8, Decl(variants.ts, 42, 21), Decl(variants.ts, 45, 9)) f8.a = 0; ->f8.a : Symbol(f8.a, Decl(variants.ts, 45, 14)) ->f8 : Symbol(f8, Decl(variants.ts, 41, 21), Decl(variants.ts, 44, 9)) ->a : Symbol(f8.a, Decl(variants.ts, 45, 14)) +>f8.a : Symbol(f8.a, Decl(variants.ts, 46, 14)) +>f8 : Symbol(f8, Decl(variants.ts, 42, 21), Decl(variants.ts, 45, 9)) +>a : Symbol(f8.a, Decl(variants.ts, 46, 14)) namespace f8 { export import a = Values; } // error ->f8 : Symbol(f8, Decl(variants.ts, 41, 21), Decl(variants.ts, 44, 9)) ->a : Symbol(a, Decl(variants.ts, 45, 14)) +>f8 : Symbol(f8, Decl(variants.ts, 42, 21), Decl(variants.ts, 45, 9)) +>a : Symbol(a, Decl(variants.ts, 46, 14)) >Values : Symbol(a, Decl(variants.ts, 34, 47)) === popover.ts === @@ -160,7 +183,9 @@ export function Popover() { return null; } >Popover : Symbol(Popover, Decl(popover.ts, 0, 0), Decl(popover.ts, 2, 32)) Popover.Target = (x: number) => x; +>Popover.Target : Symbol(Popover.Target, Decl(popover.ts, 4, 26), Decl(popover.ts, 0, 42)) >Popover : Symbol(Popover, Decl(popover.ts, 0, 0), Decl(popover.ts, 2, 32)) +>Target : Symbol(Popover.Target, Decl(popover.ts, 4, 26), Decl(popover.ts, 0, 42)) >x : Symbol(x, Decl(popover.ts, 1, 18)) >x : Symbol(x, Decl(popover.ts, 1, 18)) @@ -173,7 +198,7 @@ export namespace Popover { >Popover : Symbol(Popover, Decl(popover.ts, 0, 0), Decl(popover.ts, 2, 32)) export namespace Target { ->Target : Symbol(Target, Decl(popover.ts, 4, 26)) +>Target : Symbol(Target, Decl(popover.ts, 4, 26), Decl(popover.ts, 0, 42)) export type Props = number; >Props : Symbol(Props, Decl(popover.ts, 5, 27)) @@ -181,7 +206,9 @@ export namespace Popover { } Popover.Target(1); +>Popover.Target : Symbol(Popover.Target, Decl(popover.ts, 4, 26), Decl(popover.ts, 0, 42)) >Popover : Symbol(Popover, Decl(popover.ts, 0, 0), Decl(popover.ts, 2, 32)) +>Target : Symbol(Popover.Target, Decl(popover.ts, 4, 26), Decl(popover.ts, 0, 42)) Popover.displayName; >Popover.displayName : Symbol(Popover.displayName, Decl(popover.ts, 1, 34)) @@ -191,6 +218,6 @@ Popover.displayName; const props: Popover.Target.Props = 1; >props : Symbol(props, Decl(popover.ts, 12, 5)) >Popover : Symbol(Popover, Decl(popover.ts, 0, 0), Decl(popover.ts, 2, 32)) ->Target : Symbol(Popover.Target, Decl(popover.ts, 4, 26)) +>Target : Symbol(Popover.Target, Decl(popover.ts, 4, 26), Decl(popover.ts, 0, 42)) >Props : Symbol(Popover.Target.Props, Decl(popover.ts, 5, 27)) diff --git a/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.types b/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.types index def0a1a98c6b4..20a00bfdb9817 100644 --- a/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.types +++ b/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.types @@ -2,13 +2,13 @@ === variants.ts === function f1() {} ->f1 : () => void +>f1 : { (): void; a: number; } f1.a = 0; >f1.a = 0 : 0 ->f1.a : any ->f1 : () => void ->a : any +>f1.a : number +>f1 : { (): void; a: number; } +>a : number >0 : 0 namespace f1 { export type a = 0; } @@ -16,15 +16,15 @@ namespace f1 { export type a = 0; } const n1: number = f1.a; >n1 : number ->f1.a : any ->f1 : () => void ->a : any +>f1.a : number +>f1 : { (): void; a: number; } +>a : number const s1: string = f1.a; // error >s1 : string ->f1.a : any ->f1 : () => void ->a : any +>f1.a : number +>f1 : { (): void; a: number; } +>a : number const t1: f1.a = 0; >t1 : 0 @@ -32,13 +32,13 @@ const t1: f1.a = 0; >0 : 0 function f2() {} ->f2 : () => void +>f2 : { (): void; a: number; } f2.a = 0; >f2.a = 0 : 0 ->f2.a : any ->f2 : () => void ->a : any +>f2.a : number +>f2 : { (): void; a: number; } +>a : number >0 : 0 namespace f2 { export interface a { x: string } } @@ -46,9 +46,9 @@ namespace f2 { export interface a { x: string } } const n2: number = f2.a; >n2 : number ->f2.a : any ->f2 : () => void ->a : any +>f2.a : number +>f2 : { (): void; a: number; } +>a : number const t2: f2.a = { x: "" }; >t2 : f2.a @@ -58,30 +58,30 @@ const t2: f2.a = { x: "" }; >"" : "" function f3() {} ->f3 : () => void +>f3 : { (): void; a: number; } f3.a = 0; >f3.a = 0 : 0 ->f3.a : any ->f3 : () => void ->a : any +>f3.a : number +>f3 : { (): void; a: number; } +>a : number >0 : 0 namespace f3 { export namespace a {} } const n3: number = f3.a; >n3 : number ->f3.a : any ->f3 : () => void ->a : any +>f3.a : number +>f3 : { (): void; a: number; } +>a : number function f4() {} ->f4 : () => void +>f4 : { (): void; a: number; } f4.a = 0; >f4.a = 0 : 0 ->f4.a : any ->f4 : () => void ->a : any +>f4.a : number +>f4 : { (): void; a: number; } +>a : number >0 : 0 namespace f4 { export namespace a { export type T = string; } } @@ -89,9 +89,9 @@ namespace f4 { export namespace a { export type T = string; } } const n4: number = f4.a; >n4 : number ->f4.a : any ->f4 : () => void ->a : any +>f4.a : number +>f4 : { (): void; a: number; } +>a : number const t4: f4.a.T = ""; >t4 : string @@ -103,20 +103,20 @@ namespace f5 { export type a = 0; } >a : 0 function f5() {} ->f5 : () => void +>f5 : { (): void; a: number; } f5.a = 0; >f5.a = 0 : 0 ->f5.a : any ->f5 : () => void ->a : any +>f5.a : number +>f5 : { (): void; a: number; } +>a : number >0 : 0 const n5: number = f5.a; >n5 : number ->f5.a : any ->f5 : () => void ->a : any +>f5.a : number +>f5 : { (): void; a: number; } +>a : number function f6() {} >f6 : typeof f6 @@ -148,6 +148,7 @@ namespace Values { export const v = 1; } >v : 1 >1 : 1 +// Aliases might resolve to values, so they take precedence over expandos function f7() {} >f7 : typeof f7 @@ -192,13 +193,13 @@ namespace f8 { export import a = Values; } // error === popover.ts === export function Popover() { return null; } ->Popover : { (): null; displayName: string; } +>Popover : { (): null; displayName: string; Target: (x: number) => number; } Popover.Target = (x: number) => x; >Popover.Target = (x: number) => x : (x: number) => number ->Popover.Target : any ->Popover : { (): null; displayName: string; } ->Target : any +>Popover.Target : (x: number) => number +>Popover : { (): null; displayName: string; Target: (x: number) => number; } +>Target : (x: number) => number >(x: number) => x : (x: number) => number >x : number >x : number @@ -206,7 +207,7 @@ Popover.Target = (x: number) => x; Popover.displayName = "Popover"; >Popover.displayName = "Popover" : "Popover" >Popover.displayName : string ->Popover : { (): null; displayName: string; } +>Popover : { (): null; displayName: string; Target: (x: number) => number; } >displayName : string >"Popover" : "Popover" @@ -218,15 +219,15 @@ export namespace Popover { } Popover.Target(1); ->Popover.Target(1) : any ->Popover.Target : any ->Popover : { (): null; displayName: string; } ->Target : any +>Popover.Target(1) : number +>Popover.Target : (x: number) => number +>Popover : { (): null; displayName: string; Target: (x: number) => number; } +>Target : (x: number) => number >1 : 1 Popover.displayName; >Popover.displayName : string ->Popover : { (): null; displayName: string; } +>Popover : { (): null; displayName: string; Target: (x: number) => number; } >displayName : string const props: Popover.Target.Props = 1; diff --git a/tsc/testdata/tests/cases/compiler/expandoFunctionTypeOnlyNamespaceMember.ts b/tsc/testdata/tests/cases/compiler/expandoFunctionTypeOnlyNamespaceMember.ts index 86718deea46d6..5360710c33db2 100644 --- a/tsc/testdata/tests/cases/compiler/expandoFunctionTypeOnlyNamespaceMember.ts +++ b/tsc/testdata/tests/cases/compiler/expandoFunctionTypeOnlyNamespaceMember.ts @@ -40,6 +40,7 @@ const n6: number = f6.a; // error namespace TypesOnly { export type T = number; } namespace Values { export const v = 1; } +// Aliases might resolve to values, so they take precedence over expandos function f7() {} f7.a = 0; namespace f7 { export import a = TypesOnly; } From a815cce6e6898b2b956ff85e7e0ff964000dd0f5 Mon Sep 17 00:00:00 2001 From: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com> Date: Fri, 20 Nov 2026 16:49:26 +0000 Subject: [PATCH 05/14] Add declaration emit test for identifier expandos merged with type-only members Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --- ...ationEmitExpandoTypeOnlyNamespaceMember.js | 160 ++++++++++++++++++ ...EmitExpandoTypeOnlyNamespaceMember.symbols | 87 ++++++++++ ...onEmitExpandoTypeOnlyNamespaceMember.types | 82 +++++++++ ...ationEmitExpandoTypeOnlyNamespaceMember.ts | 30 ++++ 4 files changed, 359 insertions(+) create mode 100644 tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.js create mode 100644 tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.symbols create mode 100644 tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.types create mode 100644 tsc/testdata/tests/cases/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.ts diff --git a/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.js b/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.js new file mode 100644 index 0000000000000..a634a1026bec0 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.js @@ -0,0 +1,160 @@ +//// [tests/cases/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.ts] //// + +//// [declarationEmitExpandoTypeOnlyNamespaceMember.ts] +export class C {} +export function f1() {} +f1.a = C; +f1.b = C; +export namespace f1 { export type a = 0; } + +export enum E { A } +export function f2() {} +f2.a = E; +export namespace f2 { export interface a { x: string } } + +export function g() {} +export function f3() {} +f3.a = g; +export namespace f3 { export namespace a { export type T = string; } } + +export function Target() { return null; } +export namespace Target { export type Props = number; } + +export function Popover() { return null; } +Popover.Target = Target; +export namespace Popover { + export namespace Target { + export type Extra = string; + } +} + + +//// [declarationEmitExpandoTypeOnlyNamespaceMember.js] +export class C { +} +export function f1() { } +f1.a = C; +f1.b = C; +export var E; +(function (E) { + E[E["A"] = 0] = "A"; +})(E || (E = {})); +export function f2() { } +f2.a = E; +export function g() { } +export function f3() { } +f3.a = g; +export function Target() { return null; } +export function Popover() { return null; } +Popover.Target = Target; + + +//// [declarationEmitExpandoTypeOnlyNamespaceMember.d.ts] +export declare class C { +} +export declare function f1(): void; +export declare namespace f1 { + export { C as a }; + export { C as b }; +} +export declare namespace f1 { + type a = 0; +} +export declare enum E { + A = 0 +} +export declare function f2(): void; +export declare namespace f2 { + export { E as a }; +} +export declare namespace f2 { + interface a { + x: string; + } +} +export declare function g(): void; +export declare function f3(): void; +export declare namespace f3 { + export { g as a }; +} +export declare namespace f3 { + namespace a { + type T = string; + } +} +export declare function Target(): null; +export declare namespace Target { + type Props = number; +} +export declare function Popover(): null; +export declare namespace Popover { + export { Target }; +} +export declare namespace Popover { + namespace Target { + type Extra = string; + } +} + + +//// [DtsFileErrors] + + +declarationEmitExpandoTypeOnlyNamespaceMember.d.ts(5,14): error TS2484: Export declaration conflicts with exported declaration of 'a'. +declarationEmitExpandoTypeOnlyNamespaceMember.d.ts(16,14): error TS2484: Export declaration conflicts with exported declaration of 'a'. +declarationEmitExpandoTypeOnlyNamespaceMember.d.ts(39,14): error TS2484: Export declaration conflicts with exported declaration of 'Target'. + + +==== declarationEmitExpandoTypeOnlyNamespaceMember.d.ts (3 errors) ==== + export declare class C { + } + export declare function f1(): void; + export declare namespace f1 { + export { C as a }; + ~~~~~~ +!!! error TS2484: Export declaration conflicts with exported declaration of 'a'. + export { C as b }; + } + export declare namespace f1 { + type a = 0; + } + export declare enum E { + A = 0 + } + export declare function f2(): void; + export declare namespace f2 { + export { E as a }; + ~~~~~~ +!!! error TS2484: Export declaration conflicts with exported declaration of 'a'. + } + export declare namespace f2 { + interface a { + x: string; + } + } + export declare function g(): void; + export declare function f3(): void; + export declare namespace f3 { + export { g as a }; + } + export declare namespace f3 { + namespace a { + type T = string; + } + } + export declare function Target(): null; + export declare namespace Target { + type Props = number; + } + export declare function Popover(): null; + export declare namespace Popover { + export { Target }; + ~~~~~~ +!!! error TS2484: Export declaration conflicts with exported declaration of 'Target'. + } + export declare namespace Popover { + namespace Target { + type Extra = string; + } + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.symbols b/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.symbols new file mode 100644 index 0000000000000..d096962a87e0d --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.symbols @@ -0,0 +1,87 @@ +//// [tests/cases/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.ts] //// + +=== declarationEmitExpandoTypeOnlyNamespaceMember.ts === +export class C {} +>C : Symbol(C, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 0, 0)) + +export function f1() {} +>f1 : Symbol(f1, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 0, 17), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 3, 9)) + +f1.a = C; +>f1.a : Symbol(f1.a, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 4, 21), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 1, 23)) +>f1 : Symbol(f1, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 0, 17), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 3, 9)) +>a : Symbol(f1.a, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 4, 21), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 1, 23)) +>C : Symbol(C, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 0, 0)) + +f1.b = C; +>f1.b : Symbol(f1.b, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 2, 9)) +>f1 : Symbol(f1, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 0, 17), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 3, 9)) +>b : Symbol(f1.b, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 2, 9)) +>C : Symbol(C, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 0, 0)) + +export namespace f1 { export type a = 0; } +>f1 : Symbol(f1, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 0, 17), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 3, 9)) +>a : Symbol(a, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 4, 21), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 1, 23)) + +export enum E { A } +>E : Symbol(E, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 4, 42)) +>A : Symbol(E.A, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 6, 15)) + +export function f2() {} +>f2 : Symbol(f2, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 6, 19), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 8, 9)) + +f2.a = E; +>f2.a : Symbol(f2.a, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 9, 21), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 7, 23)) +>f2 : Symbol(f2, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 6, 19), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 8, 9)) +>a : Symbol(f2.a, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 9, 21), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 7, 23)) +>E : Symbol(E, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 4, 42)) + +export namespace f2 { export interface a { x: string } } +>f2 : Symbol(f2, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 6, 19), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 8, 9)) +>a : Symbol(a, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 9, 21), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 7, 23)) +>x : Symbol(a.x, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 9, 42)) + +export function g() {} +>g : Symbol(g, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 9, 56)) + +export function f3() {} +>f3 : Symbol(f3, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 11, 22), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 13, 9)) + +f3.a = g; +>f3.a : Symbol(f3.a, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 14, 21), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 12, 23)) +>f3 : Symbol(f3, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 11, 22), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 13, 9)) +>a : Symbol(f3.a, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 14, 21), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 12, 23)) +>g : Symbol(g, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 9, 56)) + +export namespace f3 { export namespace a { export type T = string; } } +>f3 : Symbol(f3, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 11, 22), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 13, 9)) +>a : Symbol(a, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 14, 21), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 12, 23)) +>T : Symbol(T, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 14, 42)) + +export function Target() { return null; } +>Target : Symbol(Target, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 14, 70), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 16, 41)) + +export namespace Target { export type Props = number; } +>Target : Symbol(Target, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 14, 70), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 16, 41)) +>Props : Symbol(Props, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 17, 25)) + +export function Popover() { return null; } +>Popover : Symbol(Popover, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 17, 55), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 20, 24)) + +Popover.Target = Target; +>Popover.Target : Symbol(Popover.Target, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 21, 26), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 19, 42)) +>Popover : Symbol(Popover, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 17, 55), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 20, 24)) +>Target : Symbol(Popover.Target, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 21, 26), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 19, 42)) +>Target : Symbol(Target, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 14, 70), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 16, 41)) + +export namespace Popover { +>Popover : Symbol(Popover, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 17, 55), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 20, 24)) + + export namespace Target { +>Target : Symbol(Target, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 21, 26), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 19, 42)) + + export type Extra = string; +>Extra : Symbol(Extra, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 22, 27)) + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.types b/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.types new file mode 100644 index 0000000000000..64a68ece3091e --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.types @@ -0,0 +1,82 @@ +//// [tests/cases/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.ts] //// + +=== declarationEmitExpandoTypeOnlyNamespaceMember.ts === +export class C {} +>C : C + +export function f1() {} +>f1 : { (): void; b: typeof C; a: typeof C; } + +f1.a = C; +>f1.a = C : typeof C +>f1.a : typeof C +>f1 : { (): void; b: typeof C; a: typeof C; } +>a : typeof C +>C : typeof C + +f1.b = C; +>f1.b = C : typeof C +>f1.b : typeof C +>f1 : { (): void; b: typeof C; a: typeof C; } +>b : typeof C +>C : typeof C + +export namespace f1 { export type a = 0; } +>a : 0 + +export enum E { A } +>E : E +>A : E.A + +export function f2() {} +>f2 : { (): void; a: typeof E; } + +f2.a = E; +>f2.a = E : typeof E +>f2.a : typeof E +>f2 : { (): void; a: typeof E; } +>a : typeof E +>E : typeof E + +export namespace f2 { export interface a { x: string } } +>x : string + +export function g() {} +>g : () => void + +export function f3() {} +>f3 : { (): void; a: () => void; } + +f3.a = g; +>f3.a = g : () => void +>f3.a : () => void +>f3 : { (): void; a: () => void; } +>a : () => void +>g : () => void + +export namespace f3 { export namespace a { export type T = string; } } +>T : string + +export function Target() { return null; } +>Target : () => null + +export namespace Target { export type Props = number; } +>Props : number + +export function Popover() { return null; } +>Popover : { (): null; Target: () => null; } + +Popover.Target = Target; +>Popover.Target = Target : () => null +>Popover.Target : () => null +>Popover : { (): null; Target: () => null; } +>Target : () => null +>Target : () => null + +export namespace Popover { + export namespace Target { + export type Extra = string; +>Extra : string + } +} + diff --git a/tsc/testdata/tests/cases/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.ts b/tsc/testdata/tests/cases/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.ts new file mode 100644 index 0000000000000..7baf8b5fc4196 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.ts @@ -0,0 +1,30 @@ +// @strict: true +// @target: es2022 +// @declaration: true + +export class C {} +export function f1() {} +f1.a = C; +f1.b = C; +export namespace f1 { export type a = 0; } + +export enum E { A } +export function f2() {} +f2.a = E; +export namespace f2 { export interface a { x: string } } + +export function g() {} +export function f3() {} +f3.a = g; +export namespace f3 { export namespace a { export type T = string; } } + +export function Target() { return null; } +export namespace Target { export type Props = number; } + +export function Popover() { return null; } +Popover.Target = Target; +export namespace Popover { + export namespace Target { + export type Extra = string; + } +} From 1c69c0ceaeeae6fc4993b619d71818973f9a4e96 Mon Sep 17 00:00:00 2001 From: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com> Date: Fri, 20 Nov 2026 16:55:23 +0000 Subject: [PATCH 06/14] Avoid alias-like declaration emit for expandos merged with type-only declarations Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --- .../transformers/declarations/transform.go | 4 +- ...ationEmitExpandoTypeOnlyNamespaceMember.js | 72 ++----------------- 2 files changed, 8 insertions(+), 68 deletions(-) diff --git a/tsc/internal/transformers/declarations/transform.go b/tsc/internal/transformers/declarations/transform.go index 9538225ed249f..5ccfcec334992 100644 --- a/tsc/internal/transformers/declarations/transform.go +++ b/tsc/internal/transformers/declarations/transform.go @@ -2908,7 +2908,9 @@ func (tx *DeclarationTransformer) transformExpandoAssignment(node *ast.BinaryExp preexistingExpandoHasExport := core.Some(tx.expandoMembers[hostId], ast.IsExportDeclaration) - if ast.IsIdentifier(node.Right) { + // When the expando is merged with a type-only declaration (e.g. a type alias or uninstantiated namespace + // of the same name), an alias-like export would conflict with it, so we emit a variable declaration instead. + if ast.IsIdentifier(node.Right) && symbol.Flags()&(ast.SymbolFlagsType|ast.SymbolFlagsNamespace) == 0 { if !preexistingExpandoHasExport { tx.addExportModifierToExpandoMembers(hostId) } diff --git a/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.js b/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.js index a634a1026bec0..d8c71efcd8d7a 100644 --- a/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.js +++ b/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.js @@ -54,7 +54,7 @@ export declare class C { } export declare function f1(): void; export declare namespace f1 { - export { C as a }; + export var a: typeof C; export { C as b }; } export declare namespace f1 { @@ -65,7 +65,7 @@ export declare enum E { } export declare function f2(): void; export declare namespace f2 { - export { E as a }; + var a: typeof E; } export declare namespace f2 { interface a { @@ -75,7 +75,7 @@ export declare namespace f2 { export declare function g(): void; export declare function f3(): void; export declare namespace f3 { - export { g as a }; + var a: typeof g; } export declare namespace f3 { namespace a { @@ -88,73 +88,11 @@ export declare namespace Target { } export declare function Popover(): null; export declare namespace Popover { - export { Target }; + var _a: typeof import("./declarationEmitExpandoTypeOnlyNamespaceMember").Target; + export { _a as Target }; } export declare namespace Popover { namespace Target { type Extra = string; } } - - -//// [DtsFileErrors] - - -declarationEmitExpandoTypeOnlyNamespaceMember.d.ts(5,14): error TS2484: Export declaration conflicts with exported declaration of 'a'. -declarationEmitExpandoTypeOnlyNamespaceMember.d.ts(16,14): error TS2484: Export declaration conflicts with exported declaration of 'a'. -declarationEmitExpandoTypeOnlyNamespaceMember.d.ts(39,14): error TS2484: Export declaration conflicts with exported declaration of 'Target'. - - -==== declarationEmitExpandoTypeOnlyNamespaceMember.d.ts (3 errors) ==== - export declare class C { - } - export declare function f1(): void; - export declare namespace f1 { - export { C as a }; - ~~~~~~ -!!! error TS2484: Export declaration conflicts with exported declaration of 'a'. - export { C as b }; - } - export declare namespace f1 { - type a = 0; - } - export declare enum E { - A = 0 - } - export declare function f2(): void; - export declare namespace f2 { - export { E as a }; - ~~~~~~ -!!! error TS2484: Export declaration conflicts with exported declaration of 'a'. - } - export declare namespace f2 { - interface a { - x: string; - } - } - export declare function g(): void; - export declare function f3(): void; - export declare namespace f3 { - export { g as a }; - } - export declare namespace f3 { - namespace a { - type T = string; - } - } - export declare function Target(): null; - export declare namespace Target { - type Props = number; - } - export declare function Popover(): null; - export declare namespace Popover { - export { Target }; - ~~~~~~ -!!! error TS2484: Export declaration conflicts with exported declaration of 'Target'. - } - export declare namespace Popover { - namespace Target { - type Extra = string; - } - } - \ No newline at end of file From b763203fbd4322edfc5eb92464f3ba06e8fde90b Mon Sep 17 00:00:00 2001 From: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com> Date: Fri, 20 Nov 2026 17:04:04 +0000 Subject: [PATCH 07/14] Add declaration emit test for renamed expando local leaking as a public export Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --- ...ationEmitExpandoTypeOnlyNamespaceMember.js | 23 ++++++++++++++++ ...EmitExpandoTypeOnlyNamespaceMember.symbols | 26 +++++++++++++++++++ ...onEmitExpandoTypeOnlyNamespaceMember.types | 24 +++++++++++++++++ ...ationEmitExpandoTypeOnlyNamespaceMember.ts | 9 +++++++ 4 files changed, 82 insertions(+) diff --git a/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.js b/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.js index d8c71efcd8d7a..be708fc1a0ac9 100644 --- a/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.js +++ b/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.js @@ -27,6 +27,15 @@ export namespace Popover { export type Extra = string; } } + +export function Popover2() { return null; } +Popover2.b = C; +Popover2.Target = Target; +export namespace Popover2 { + export namespace Target { + export type Extra = string; + } +} //// [declarationEmitExpandoTypeOnlyNamespaceMember.js] @@ -47,6 +56,9 @@ f3.a = g; export function Target() { return null; } export function Popover() { return null; } Popover.Target = Target; +export function Popover2() { return null; } +Popover2.b = C; +Popover2.Target = Target; //// [declarationEmitExpandoTypeOnlyNamespaceMember.d.ts] @@ -96,3 +108,14 @@ export declare namespace Popover { type Extra = string; } } +export declare function Popover2(): null; +export declare namespace Popover2 { + export { C as b }; + export var _b: typeof import("./declarationEmitExpandoTypeOnlyNamespaceMember").Target; + export { _b as Target }; +} +export declare namespace Popover2 { + namespace Target { + type Extra = string; + } +} diff --git a/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.symbols b/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.symbols index d096962a87e0d..68521a0615125 100644 --- a/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.symbols +++ b/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.symbols @@ -85,3 +85,29 @@ export namespace Popover { } } +export function Popover2() { return null; } +>Popover2 : Symbol(Popover2, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 25, 1), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 29, 25)) + +Popover2.b = C; +>Popover2.b : Symbol(Popover2.b, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 27, 43)) +>Popover2 : Symbol(Popover2, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 25, 1), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 29, 25)) +>b : Symbol(Popover2.b, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 27, 43)) +>C : Symbol(C, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 0, 0)) + +Popover2.Target = Target; +>Popover2.Target : Symbol(Popover2.Target, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 30, 27), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 28, 15)) +>Popover2 : Symbol(Popover2, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 25, 1), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 29, 25)) +>Target : Symbol(Popover2.Target, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 30, 27), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 28, 15)) +>Target : Symbol(Target, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 14, 70), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 16, 41)) + +export namespace Popover2 { +>Popover2 : Symbol(Popover2, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 25, 1), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 29, 25)) + + export namespace Target { +>Target : Symbol(Target, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 30, 27), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 28, 15)) + + export type Extra = string; +>Extra : Symbol(Extra, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 31, 27)) + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.types b/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.types index 64a68ece3091e..49b2596939db0 100644 --- a/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.types +++ b/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.types @@ -80,3 +80,27 @@ export namespace Popover { } } +export function Popover2() { return null; } +>Popover2 : { (): null; b: typeof C; Target: () => null; } + +Popover2.b = C; +>Popover2.b = C : typeof C +>Popover2.b : typeof C +>Popover2 : { (): null; b: typeof C; Target: () => null; } +>b : typeof C +>C : typeof C + +Popover2.Target = Target; +>Popover2.Target = Target : () => null +>Popover2.Target : () => null +>Popover2 : { (): null; b: typeof C; Target: () => null; } +>Target : () => null +>Target : () => null + +export namespace Popover2 { + export namespace Target { + export type Extra = string; +>Extra : string + } +} + diff --git a/tsc/testdata/tests/cases/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.ts b/tsc/testdata/tests/cases/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.ts index 7baf8b5fc4196..e78e31df19cd5 100644 --- a/tsc/testdata/tests/cases/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.ts +++ b/tsc/testdata/tests/cases/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.ts @@ -28,3 +28,12 @@ export namespace Popover { export type Extra = string; } } + +export function Popover2() { return null; } +Popover2.b = C; +Popover2.Target = Target; +export namespace Popover2 { + export namespace Target { + export type Extra = string; + } +} From cb2e41a520a7a6122e63d9e34107c17208f88ab9 Mon Sep 17 00:00:00 2001 From: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com> Date: Fri, 20 Nov 2026 17:05:16 +0000 Subject: [PATCH 08/14] Keep renamed expando locals private in declaration emit Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --- tsc/internal/transformers/declarations/transform.go | 3 ++- .../compiler/declarationEmitExpandoTypeOnlyNamespaceMember.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tsc/internal/transformers/declarations/transform.go b/tsc/internal/transformers/declarations/transform.go index 5ccfcec334992..895e36b37faea 100644 --- a/tsc/internal/transformers/declarations/transform.go +++ b/tsc/internal/transformers/declarations/transform.go @@ -2922,7 +2922,8 @@ func (tx *DeclarationTransformer) transformExpandoAssignment(node *ast.BinaryExp var varModifiers *ast.ModifierList - if preexistingExpandoHasExport { + // A renamed local stays private, since it's exported under the property name by the `export {}` added below + if preexistingExpandoHasExport && localName.Text() == exportName.Text() { varModifiers = tx.Factory().NewModifierList(ast.CreateModifiersFromModifierFlags(ast.ModifierFlagsExport, tx.Factory().NewModifier)) } diff --git a/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.js b/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.js index be708fc1a0ac9..12675e56bcac2 100644 --- a/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.js +++ b/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.js @@ -111,7 +111,7 @@ export declare namespace Popover { export declare function Popover2(): null; export declare namespace Popover2 { export { C as b }; - export var _b: typeof import("./declarationEmitExpandoTypeOnlyNamespaceMember").Target; + var _b: typeof import("./declarationEmitExpandoTypeOnlyNamespaceMember").Target; export { _b as Target }; } export declare namespace Popover2 { From 5ac41ac457bab3d79e0c0554243840271cb13d77 Mon Sep 17 00:00:00 2001 From: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com> Date: Fri, 20 Nov 2026 17:10:06 +0000 Subject: [PATCH 09/14] Revert prior changes to restack commits Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --- tsc/internal/binder/binder.go | 6 +- .../transformers/declarations/transform.go | 7 +- ...ationEmitExpandoTypeOnlyNamespaceMember.js | 121 --------- ...EmitExpandoTypeOnlyNamespaceMember.symbols | 113 --------- ...onEmitExpandoTypeOnlyNamespaceMember.types | 106 -------- ...FunctionTypeOnlyNamespaceMember.errors.txt | 84 ------- .../expandoFunctionTypeOnlyNamespaceMember.js | 205 --------------- ...ndoFunctionTypeOnlyNamespaceMember.symbols | 223 ---------------- ...pandoFunctionTypeOnlyNamespaceMember.types | 238 ------------------ ...ationEmitExpandoTypeOnlyNamespaceMember.ts | 39 --- .../expandoFunctionTypeOnlyNamespaceMember.ts | 67 ----- 11 files changed, 4 insertions(+), 1205 deletions(-) delete mode 100644 tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.js delete mode 100644 tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.symbols delete mode 100644 tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.types delete mode 100644 tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.errors.txt delete mode 100644 tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.js delete mode 100644 tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.symbols delete mode 100644 tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.types delete mode 100644 tsc/testdata/tests/cases/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.ts delete mode 100644 tsc/testdata/tests/cases/compiler/expandoFunctionTypeOnlyNamespaceMember.ts diff --git a/tsc/internal/binder/binder.go b/tsc/internal/binder/binder.go index 082a83bc326de..e1058bc33b043 100644 --- a/tsc/internal/binder/binder.go +++ b/tsc/internal/binder/binder.go @@ -1081,11 +1081,9 @@ func (b *Binder) bindDeferredExpandoAssignment(node *ast.Node) { b.bindAnonymousDeclaration(node, ast.SymbolFlagsProperty|ast.SymbolFlagsAssignment, ast.InternalSymbolNameComputed) b.addLateBoundAssignmentDeclarationToSymbol(node, symbol) } else { - // We declare expandos only when there are no non-expando declarations for that name that might have - // a value meaning. Expandos merge with type-only declarations (type aliases, interfaces, and - // uninstantiated namespaces), but not with aliases since those might resolve to values. + // We declare expandos only when there are no non-expando declarations for that name. exports := ast.GetExports(symbol, &b.symbolExtraArena) - if existing := exports.Get(b.getDeclarationName(node)); existing == nil || existing.Flags()&ast.SymbolFlagsAssignment != 0 || existing.Flags()&(ast.SymbolFlagsValue|ast.SymbolFlagsAlias) == 0 { + if existing := exports.Get(b.getDeclarationName(node)); existing == nil || existing.Flags()&ast.SymbolFlagsAssignment != 0 { b.declareSymbol(exports, symbol, node, ast.SymbolFlagsProperty|ast.SymbolFlagsAssignment, ast.SymbolFlagsPropertyExcludes) } } diff --git a/tsc/internal/transformers/declarations/transform.go b/tsc/internal/transformers/declarations/transform.go index 895e36b37faea..9538225ed249f 100644 --- a/tsc/internal/transformers/declarations/transform.go +++ b/tsc/internal/transformers/declarations/transform.go @@ -2908,9 +2908,7 @@ func (tx *DeclarationTransformer) transformExpandoAssignment(node *ast.BinaryExp preexistingExpandoHasExport := core.Some(tx.expandoMembers[hostId], ast.IsExportDeclaration) - // When the expando is merged with a type-only declaration (e.g. a type alias or uninstantiated namespace - // of the same name), an alias-like export would conflict with it, so we emit a variable declaration instead. - if ast.IsIdentifier(node.Right) && symbol.Flags()&(ast.SymbolFlagsType|ast.SymbolFlagsNamespace) == 0 { + if ast.IsIdentifier(node.Right) { if !preexistingExpandoHasExport { tx.addExportModifierToExpandoMembers(hostId) } @@ -2922,8 +2920,7 @@ func (tx *DeclarationTransformer) transformExpandoAssignment(node *ast.BinaryExp var varModifiers *ast.ModifierList - // A renamed local stays private, since it's exported under the property name by the `export {}` added below - if preexistingExpandoHasExport && localName.Text() == exportName.Text() { + if preexistingExpandoHasExport { varModifiers = tx.Factory().NewModifierList(ast.CreateModifiersFromModifierFlags(ast.ModifierFlagsExport, tx.Factory().NewModifier)) } diff --git a/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.js b/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.js deleted file mode 100644 index 12675e56bcac2..0000000000000 --- a/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.js +++ /dev/null @@ -1,121 +0,0 @@ -//// [tests/cases/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.ts] //// - -//// [declarationEmitExpandoTypeOnlyNamespaceMember.ts] -export class C {} -export function f1() {} -f1.a = C; -f1.b = C; -export namespace f1 { export type a = 0; } - -export enum E { A } -export function f2() {} -f2.a = E; -export namespace f2 { export interface a { x: string } } - -export function g() {} -export function f3() {} -f3.a = g; -export namespace f3 { export namespace a { export type T = string; } } - -export function Target() { return null; } -export namespace Target { export type Props = number; } - -export function Popover() { return null; } -Popover.Target = Target; -export namespace Popover { - export namespace Target { - export type Extra = string; - } -} - -export function Popover2() { return null; } -Popover2.b = C; -Popover2.Target = Target; -export namespace Popover2 { - export namespace Target { - export type Extra = string; - } -} - - -//// [declarationEmitExpandoTypeOnlyNamespaceMember.js] -export class C { -} -export function f1() { } -f1.a = C; -f1.b = C; -export var E; -(function (E) { - E[E["A"] = 0] = "A"; -})(E || (E = {})); -export function f2() { } -f2.a = E; -export function g() { } -export function f3() { } -f3.a = g; -export function Target() { return null; } -export function Popover() { return null; } -Popover.Target = Target; -export function Popover2() { return null; } -Popover2.b = C; -Popover2.Target = Target; - - -//// [declarationEmitExpandoTypeOnlyNamespaceMember.d.ts] -export declare class C { -} -export declare function f1(): void; -export declare namespace f1 { - export var a: typeof C; - export { C as b }; -} -export declare namespace f1 { - type a = 0; -} -export declare enum E { - A = 0 -} -export declare function f2(): void; -export declare namespace f2 { - var a: typeof E; -} -export declare namespace f2 { - interface a { - x: string; - } -} -export declare function g(): void; -export declare function f3(): void; -export declare namespace f3 { - var a: typeof g; -} -export declare namespace f3 { - namespace a { - type T = string; - } -} -export declare function Target(): null; -export declare namespace Target { - type Props = number; -} -export declare function Popover(): null; -export declare namespace Popover { - var _a: typeof import("./declarationEmitExpandoTypeOnlyNamespaceMember").Target; - export { _a as Target }; -} -export declare namespace Popover { - namespace Target { - type Extra = string; - } -} -export declare function Popover2(): null; -export declare namespace Popover2 { - export { C as b }; - var _b: typeof import("./declarationEmitExpandoTypeOnlyNamespaceMember").Target; - export { _b as Target }; -} -export declare namespace Popover2 { - namespace Target { - type Extra = string; - } -} diff --git a/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.symbols b/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.symbols deleted file mode 100644 index 68521a0615125..0000000000000 --- a/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.symbols +++ /dev/null @@ -1,113 +0,0 @@ -//// [tests/cases/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.ts] //// - -=== declarationEmitExpandoTypeOnlyNamespaceMember.ts === -export class C {} ->C : Symbol(C, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 0, 0)) - -export function f1() {} ->f1 : Symbol(f1, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 0, 17), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 3, 9)) - -f1.a = C; ->f1.a : Symbol(f1.a, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 4, 21), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 1, 23)) ->f1 : Symbol(f1, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 0, 17), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 3, 9)) ->a : Symbol(f1.a, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 4, 21), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 1, 23)) ->C : Symbol(C, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 0, 0)) - -f1.b = C; ->f1.b : Symbol(f1.b, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 2, 9)) ->f1 : Symbol(f1, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 0, 17), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 3, 9)) ->b : Symbol(f1.b, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 2, 9)) ->C : Symbol(C, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 0, 0)) - -export namespace f1 { export type a = 0; } ->f1 : Symbol(f1, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 0, 17), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 3, 9)) ->a : Symbol(a, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 4, 21), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 1, 23)) - -export enum E { A } ->E : Symbol(E, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 4, 42)) ->A : Symbol(E.A, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 6, 15)) - -export function f2() {} ->f2 : Symbol(f2, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 6, 19), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 8, 9)) - -f2.a = E; ->f2.a : Symbol(f2.a, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 9, 21), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 7, 23)) ->f2 : Symbol(f2, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 6, 19), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 8, 9)) ->a : Symbol(f2.a, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 9, 21), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 7, 23)) ->E : Symbol(E, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 4, 42)) - -export namespace f2 { export interface a { x: string } } ->f2 : Symbol(f2, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 6, 19), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 8, 9)) ->a : Symbol(a, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 9, 21), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 7, 23)) ->x : Symbol(a.x, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 9, 42)) - -export function g() {} ->g : Symbol(g, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 9, 56)) - -export function f3() {} ->f3 : Symbol(f3, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 11, 22), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 13, 9)) - -f3.a = g; ->f3.a : Symbol(f3.a, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 14, 21), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 12, 23)) ->f3 : Symbol(f3, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 11, 22), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 13, 9)) ->a : Symbol(f3.a, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 14, 21), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 12, 23)) ->g : Symbol(g, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 9, 56)) - -export namespace f3 { export namespace a { export type T = string; } } ->f3 : Symbol(f3, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 11, 22), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 13, 9)) ->a : Symbol(a, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 14, 21), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 12, 23)) ->T : Symbol(T, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 14, 42)) - -export function Target() { return null; } ->Target : Symbol(Target, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 14, 70), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 16, 41)) - -export namespace Target { export type Props = number; } ->Target : Symbol(Target, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 14, 70), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 16, 41)) ->Props : Symbol(Props, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 17, 25)) - -export function Popover() { return null; } ->Popover : Symbol(Popover, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 17, 55), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 20, 24)) - -Popover.Target = Target; ->Popover.Target : Symbol(Popover.Target, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 21, 26), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 19, 42)) ->Popover : Symbol(Popover, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 17, 55), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 20, 24)) ->Target : Symbol(Popover.Target, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 21, 26), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 19, 42)) ->Target : Symbol(Target, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 14, 70), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 16, 41)) - -export namespace Popover { ->Popover : Symbol(Popover, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 17, 55), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 20, 24)) - - export namespace Target { ->Target : Symbol(Target, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 21, 26), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 19, 42)) - - export type Extra = string; ->Extra : Symbol(Extra, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 22, 27)) - } -} - -export function Popover2() { return null; } ->Popover2 : Symbol(Popover2, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 25, 1), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 29, 25)) - -Popover2.b = C; ->Popover2.b : Symbol(Popover2.b, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 27, 43)) ->Popover2 : Symbol(Popover2, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 25, 1), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 29, 25)) ->b : Symbol(Popover2.b, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 27, 43)) ->C : Symbol(C, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 0, 0)) - -Popover2.Target = Target; ->Popover2.Target : Symbol(Popover2.Target, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 30, 27), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 28, 15)) ->Popover2 : Symbol(Popover2, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 25, 1), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 29, 25)) ->Target : Symbol(Popover2.Target, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 30, 27), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 28, 15)) ->Target : Symbol(Target, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 14, 70), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 16, 41)) - -export namespace Popover2 { ->Popover2 : Symbol(Popover2, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 25, 1), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 29, 25)) - - export namespace Target { ->Target : Symbol(Target, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 30, 27), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 28, 15)) - - export type Extra = string; ->Extra : Symbol(Extra, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 31, 27)) - } -} - diff --git a/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.types b/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.types deleted file mode 100644 index 49b2596939db0..0000000000000 --- a/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.types +++ /dev/null @@ -1,106 +0,0 @@ -//// [tests/cases/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.ts] //// - -=== declarationEmitExpandoTypeOnlyNamespaceMember.ts === -export class C {} ->C : C - -export function f1() {} ->f1 : { (): void; b: typeof C; a: typeof C; } - -f1.a = C; ->f1.a = C : typeof C ->f1.a : typeof C ->f1 : { (): void; b: typeof C; a: typeof C; } ->a : typeof C ->C : typeof C - -f1.b = C; ->f1.b = C : typeof C ->f1.b : typeof C ->f1 : { (): void; b: typeof C; a: typeof C; } ->b : typeof C ->C : typeof C - -export namespace f1 { export type a = 0; } ->a : 0 - -export enum E { A } ->E : E ->A : E.A - -export function f2() {} ->f2 : { (): void; a: typeof E; } - -f2.a = E; ->f2.a = E : typeof E ->f2.a : typeof E ->f2 : { (): void; a: typeof E; } ->a : typeof E ->E : typeof E - -export namespace f2 { export interface a { x: string } } ->x : string - -export function g() {} ->g : () => void - -export function f3() {} ->f3 : { (): void; a: () => void; } - -f3.a = g; ->f3.a = g : () => void ->f3.a : () => void ->f3 : { (): void; a: () => void; } ->a : () => void ->g : () => void - -export namespace f3 { export namespace a { export type T = string; } } ->T : string - -export function Target() { return null; } ->Target : () => null - -export namespace Target { export type Props = number; } ->Props : number - -export function Popover() { return null; } ->Popover : { (): null; Target: () => null; } - -Popover.Target = Target; ->Popover.Target = Target : () => null ->Popover.Target : () => null ->Popover : { (): null; Target: () => null; } ->Target : () => null ->Target : () => null - -export namespace Popover { - export namespace Target { - export type Extra = string; ->Extra : string - } -} - -export function Popover2() { return null; } ->Popover2 : { (): null; b: typeof C; Target: () => null; } - -Popover2.b = C; ->Popover2.b = C : typeof C ->Popover2.b : typeof C ->Popover2 : { (): null; b: typeof C; Target: () => null; } ->b : typeof C ->C : typeof C - -Popover2.Target = Target; ->Popover2.Target = Target : () => null ->Popover2.Target : () => null ->Popover2 : { (): null; b: typeof C; Target: () => null; } ->Target : () => null ->Target : () => null - -export namespace Popover2 { - export namespace Target { - export type Extra = string; ->Extra : string - } -} - diff --git a/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.errors.txt b/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.errors.txt deleted file mode 100644 index 744788c289e4a..0000000000000 --- a/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.errors.txt +++ /dev/null @@ -1,84 +0,0 @@ -variants.ts(5,7): error TS2322: Type 'number' is not assignable to type 'string'. -variants.ts(31,1): error TS2322: Type 'number' is not assignable to type 'typeof a'. -variants.ts(33,7): error TS2322: Type 'typeof a' is not assignable to type 'number'. -variants.ts(40,4): error TS2339: Property 'a' does not exist on type 'typeof f7'. -variants.ts(42,23): error TS2339: Property 'a' does not exist on type 'typeof f7'. -variants.ts(46,1): error TS2322: Type 'number' is not assignable to type 'typeof Values'. - - -==== variants.ts (6 errors) ==== - function f1() {} - f1.a = 0; - namespace f1 { export type a = 0; } - const n1: number = f1.a; - const s1: string = f1.a; // error - ~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. - const t1: f1.a = 0; - - function f2() {} - f2.a = 0; - namespace f2 { export interface a { x: string } } - const n2: number = f2.a; - const t2: f2.a = { x: "" }; - - function f3() {} - f3.a = 0; - namespace f3 { export namespace a {} } - const n3: number = f3.a; - - function f4() {} - f4.a = 0; - namespace f4 { export namespace a { export type T = string; } } - const n4: number = f4.a; - const t4: f4.a.T = ""; - - namespace f5 { export type a = 0; } - function f5() {} - f5.a = 0; - const n5: number = f5.a; - - function f6() {} - f6.a = 0; - ~~~~ -!!! error TS2322: Type 'number' is not assignable to type 'typeof a'. - namespace f6 { export namespace a { export const kind = 0; } } - const n6: number = f6.a; // error - ~~ -!!! error TS2322: Type 'typeof a' is not assignable to type 'number'. - - namespace TypesOnly { export type T = number; } - namespace Values { export const v = 1; } - - // Aliases might resolve to values, so they take precedence over expandos - function f7() {} - f7.a = 0; - ~ -!!! error TS2339: Property 'a' does not exist on type 'typeof f7'. - namespace f7 { export import a = TypesOnly; } - const n7: number = f7.a; - ~ -!!! error TS2339: Property 'a' does not exist on type 'typeof f7'. - const t7: f7.a.T = 0; - - function f8() {} - f8.a = 0; - ~~~~ -!!! error TS2322: Type 'number' is not assignable to type 'typeof Values'. - namespace f8 { export import a = Values; } // error - -==== popover.ts (0 errors) ==== - export function Popover() { return null; } - Popover.Target = (x: number) => x; - Popover.displayName = "Popover"; - - export namespace Popover { - export namespace Target { - export type Props = number; - } - } - - Popover.Target(1); - Popover.displayName; - const props: Popover.Target.Props = 1; - \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.js b/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.js deleted file mode 100644 index bb158110142b4..0000000000000 --- a/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.js +++ /dev/null @@ -1,205 +0,0 @@ -//// [tests/cases/compiler/expandoFunctionTypeOnlyNamespaceMember.ts] //// - -//// [variants.ts] -function f1() {} -f1.a = 0; -namespace f1 { export type a = 0; } -const n1: number = f1.a; -const s1: string = f1.a; // error -const t1: f1.a = 0; - -function f2() {} -f2.a = 0; -namespace f2 { export interface a { x: string } } -const n2: number = f2.a; -const t2: f2.a = { x: "" }; - -function f3() {} -f3.a = 0; -namespace f3 { export namespace a {} } -const n3: number = f3.a; - -function f4() {} -f4.a = 0; -namespace f4 { export namespace a { export type T = string; } } -const n4: number = f4.a; -const t4: f4.a.T = ""; - -namespace f5 { export type a = 0; } -function f5() {} -f5.a = 0; -const n5: number = f5.a; - -function f6() {} -f6.a = 0; -namespace f6 { export namespace a { export const kind = 0; } } -const n6: number = f6.a; // error - -namespace TypesOnly { export type T = number; } -namespace Values { export const v = 1; } - -// Aliases might resolve to values, so they take precedence over expandos -function f7() {} -f7.a = 0; -namespace f7 { export import a = TypesOnly; } -const n7: number = f7.a; -const t7: f7.a.T = 0; - -function f8() {} -f8.a = 0; -namespace f8 { export import a = Values; } // error - -//// [popover.ts] -export function Popover() { return null; } -Popover.Target = (x: number) => x; -Popover.displayName = "Popover"; - -export namespace Popover { - export namespace Target { - export type Props = number; - } -} - -Popover.Target(1); -Popover.displayName; -const props: Popover.Target.Props = 1; - - -//// [variants.js] -"use strict"; -function f1() { } -f1.a = 0; -const n1 = f1.a; -const s1 = f1.a; // error -const t1 = 0; -function f2() { } -f2.a = 0; -const n2 = f2.a; -const t2 = { x: "" }; -function f3() { } -f3.a = 0; -const n3 = f3.a; -function f4() { } -f4.a = 0; -const n4 = f4.a; -const t4 = ""; -function f5() { } -f5.a = 0; -const n5 = f5.a; -function f6() { } -f6.a = 0; -(function (f6) { - let a; - (function (a) { - a.kind = 0; - })(a = f6.a || (f6.a = {})); -})(f6 || (f6 = {})); -const n6 = f6.a; // error -var Values; -(function (Values) { - Values.v = 1; -})(Values || (Values = {})); -// Aliases might resolve to values, so they take precedence over expandos -function f7() { } -f7.a = 0; -(function (f7) { -})(f7 || (f7 = {})); -const n7 = f7.a; -const t7 = 0; -function f8() { } -f8.a = 0; -(function (f8) { - f8.a = Values; -})(f8 || (f8 = {})); // error -//// [popover.js] -export function Popover() { return null; } -Popover.Target = (x) => x; -Popover.displayName = "Popover"; -Popover.Target(1); -Popover.displayName; -const props = 1; - - -//// [variants.d.ts] -declare function f1(): void; -declare namespace f1 { - var a: number; -} -declare namespace f1 { - type a = 0; -} -declare const n1: number; -declare const s1: string; -declare const t1: f1.a; -declare function f2(): void; -declare namespace f2 { - var a: number; -} -declare namespace f2 { - interface a { - x: string; - } -} -declare const n2: number; -declare const t2: f2.a; -declare function f3(): void; -declare namespace f3 { - var a: number; -} -declare namespace f3 { - namespace a { } -} -declare const n3: number; -declare function f4(): void; -declare namespace f4 { - var a: number; -} -declare namespace f4 { - namespace a { - type T = string; - } -} -declare const n4: number; -declare const t4: f4.a.T; -declare namespace f5 { - type a = 0; -} -declare function f5(): void; -declare namespace f5 { - var a: number; -} -declare const n5: number; -declare function f6(): void; -declare namespace f6 { - namespace a { - const kind = 0; - } -} -declare const n6: number; -declare namespace TypesOnly { - type T = number; -} -declare namespace Values { - const v = 1; -} -declare function f7(): void; -declare namespace f7 { - export import a = TypesOnly; -} -declare const n7: number; -declare const t7: f7.a.T; -declare function f8(): void; -declare namespace f8 { - export import a = Values; -} -//// [popover.d.ts] -export declare function Popover(): null; -export declare namespace Popover { - var Target: (x: number) => number; - var displayName: string; -} -export declare namespace Popover { - namespace Target { - type Props = number; - } -} diff --git a/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.symbols b/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.symbols deleted file mode 100644 index 8b37d2d0ea777..0000000000000 --- a/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.symbols +++ /dev/null @@ -1,223 +0,0 @@ -//// [tests/cases/compiler/expandoFunctionTypeOnlyNamespaceMember.ts] //// - -=== variants.ts === -function f1() {} ->f1 : Symbol(f1, Decl(variants.ts, 0, 0), Decl(variants.ts, 1, 9)) - -f1.a = 0; ->f1.a : Symbol(f1.a, Decl(variants.ts, 2, 14), Decl(variants.ts, 0, 16)) ->f1 : Symbol(f1, Decl(variants.ts, 0, 0), Decl(variants.ts, 1, 9)) ->a : Symbol(f1.a, Decl(variants.ts, 2, 14), Decl(variants.ts, 0, 16)) - -namespace f1 { export type a = 0; } ->f1 : Symbol(f1, Decl(variants.ts, 0, 0), Decl(variants.ts, 1, 9)) ->a : Symbol(a, Decl(variants.ts, 2, 14), Decl(variants.ts, 0, 16)) - -const n1: number = f1.a; ->n1 : Symbol(n1, Decl(variants.ts, 3, 5)) ->f1.a : Symbol(f1.a, Decl(variants.ts, 2, 14), Decl(variants.ts, 0, 16)) ->f1 : Symbol(f1, Decl(variants.ts, 0, 0), Decl(variants.ts, 1, 9)) ->a : Symbol(f1.a, Decl(variants.ts, 2, 14), Decl(variants.ts, 0, 16)) - -const s1: string = f1.a; // error ->s1 : Symbol(s1, Decl(variants.ts, 4, 5)) ->f1.a : Symbol(f1.a, Decl(variants.ts, 2, 14), Decl(variants.ts, 0, 16)) ->f1 : Symbol(f1, Decl(variants.ts, 0, 0), Decl(variants.ts, 1, 9)) ->a : Symbol(f1.a, Decl(variants.ts, 2, 14), Decl(variants.ts, 0, 16)) - -const t1: f1.a = 0; ->t1 : Symbol(t1, Decl(variants.ts, 5, 5)) ->f1 : Symbol(f1, Decl(variants.ts, 0, 0), Decl(variants.ts, 1, 9)) ->a : Symbol(f1.a, Decl(variants.ts, 2, 14), Decl(variants.ts, 0, 16)) - -function f2() {} ->f2 : Symbol(f2, Decl(variants.ts, 5, 19), Decl(variants.ts, 8, 9)) - -f2.a = 0; ->f2.a : Symbol(f2.a, Decl(variants.ts, 9, 14), Decl(variants.ts, 7, 16)) ->f2 : Symbol(f2, Decl(variants.ts, 5, 19), Decl(variants.ts, 8, 9)) ->a : Symbol(f2.a, Decl(variants.ts, 9, 14), Decl(variants.ts, 7, 16)) - -namespace f2 { export interface a { x: string } } ->f2 : Symbol(f2, Decl(variants.ts, 5, 19), Decl(variants.ts, 8, 9)) ->a : Symbol(a, Decl(variants.ts, 9, 14), Decl(variants.ts, 7, 16)) ->x : Symbol(a.x, Decl(variants.ts, 9, 35)) - -const n2: number = f2.a; ->n2 : Symbol(n2, Decl(variants.ts, 10, 5)) ->f2.a : Symbol(f2.a, Decl(variants.ts, 9, 14), Decl(variants.ts, 7, 16)) ->f2 : Symbol(f2, Decl(variants.ts, 5, 19), Decl(variants.ts, 8, 9)) ->a : Symbol(f2.a, Decl(variants.ts, 9, 14), Decl(variants.ts, 7, 16)) - -const t2: f2.a = { x: "" }; ->t2 : Symbol(t2, Decl(variants.ts, 11, 5)) ->f2 : Symbol(f2, Decl(variants.ts, 5, 19), Decl(variants.ts, 8, 9)) ->a : Symbol(f2.a, Decl(variants.ts, 9, 14), Decl(variants.ts, 7, 16)) ->x : Symbol(x, Decl(variants.ts, 11, 18)) - -function f3() {} ->f3 : Symbol(f3, Decl(variants.ts, 11, 27), Decl(variants.ts, 14, 9)) - -f3.a = 0; ->f3.a : Symbol(f3.a, Decl(variants.ts, 15, 14), Decl(variants.ts, 13, 16)) ->f3 : Symbol(f3, Decl(variants.ts, 11, 27), Decl(variants.ts, 14, 9)) ->a : Symbol(f3.a, Decl(variants.ts, 15, 14), Decl(variants.ts, 13, 16)) - -namespace f3 { export namespace a {} } ->f3 : Symbol(f3, Decl(variants.ts, 11, 27), Decl(variants.ts, 14, 9)) ->a : Symbol(a, Decl(variants.ts, 15, 14), Decl(variants.ts, 13, 16)) - -const n3: number = f3.a; ->n3 : Symbol(n3, Decl(variants.ts, 16, 5)) ->f3.a : Symbol(f3.a, Decl(variants.ts, 15, 14), Decl(variants.ts, 13, 16)) ->f3 : Symbol(f3, Decl(variants.ts, 11, 27), Decl(variants.ts, 14, 9)) ->a : Symbol(f3.a, Decl(variants.ts, 15, 14), Decl(variants.ts, 13, 16)) - -function f4() {} ->f4 : Symbol(f4, Decl(variants.ts, 16, 24), Decl(variants.ts, 19, 9)) - -f4.a = 0; ->f4.a : Symbol(f4.a, Decl(variants.ts, 20, 14), Decl(variants.ts, 18, 16)) ->f4 : Symbol(f4, Decl(variants.ts, 16, 24), Decl(variants.ts, 19, 9)) ->a : Symbol(f4.a, Decl(variants.ts, 20, 14), Decl(variants.ts, 18, 16)) - -namespace f4 { export namespace a { export type T = string; } } ->f4 : Symbol(f4, Decl(variants.ts, 16, 24), Decl(variants.ts, 19, 9)) ->a : Symbol(a, Decl(variants.ts, 20, 14), Decl(variants.ts, 18, 16)) ->T : Symbol(T, Decl(variants.ts, 20, 35)) - -const n4: number = f4.a; ->n4 : Symbol(n4, Decl(variants.ts, 21, 5)) ->f4.a : Symbol(f4.a, Decl(variants.ts, 20, 14), Decl(variants.ts, 18, 16)) ->f4 : Symbol(f4, Decl(variants.ts, 16, 24), Decl(variants.ts, 19, 9)) ->a : Symbol(f4.a, Decl(variants.ts, 20, 14), Decl(variants.ts, 18, 16)) - -const t4: f4.a.T = ""; ->t4 : Symbol(t4, Decl(variants.ts, 22, 5)) ->f4 : Symbol(f4, Decl(variants.ts, 16, 24), Decl(variants.ts, 19, 9)) ->a : Symbol(f4.a, Decl(variants.ts, 20, 14), Decl(variants.ts, 18, 16)) ->T : Symbol(f4.a.T, Decl(variants.ts, 20, 35)) - -namespace f5 { export type a = 0; } ->f5 : Symbol(f5, Decl(variants.ts, 24, 35), Decl(variants.ts, 22, 22)) ->a : Symbol(a, Decl(variants.ts, 24, 14), Decl(variants.ts, 25, 16)) - -function f5() {} ->f5 : Symbol(f5, Decl(variants.ts, 24, 35), Decl(variants.ts, 22, 22)) - -f5.a = 0; ->f5.a : Symbol(f5.a, Decl(variants.ts, 24, 14), Decl(variants.ts, 25, 16)) ->f5 : Symbol(f5, Decl(variants.ts, 24, 35), Decl(variants.ts, 22, 22)) ->a : Symbol(f5.a, Decl(variants.ts, 24, 14), Decl(variants.ts, 25, 16)) - -const n5: number = f5.a; ->n5 : Symbol(n5, Decl(variants.ts, 27, 5)) ->f5.a : Symbol(f5.a, Decl(variants.ts, 24, 14), Decl(variants.ts, 25, 16)) ->f5 : Symbol(f5, Decl(variants.ts, 24, 35), Decl(variants.ts, 22, 22)) ->a : Symbol(f5.a, Decl(variants.ts, 24, 14), Decl(variants.ts, 25, 16)) - -function f6() {} ->f6 : Symbol(f6, Decl(variants.ts, 27, 24), Decl(variants.ts, 30, 9)) - -f6.a = 0; ->f6.a : Symbol(f6.a, Decl(variants.ts, 31, 14)) ->f6 : Symbol(f6, Decl(variants.ts, 27, 24), Decl(variants.ts, 30, 9)) ->a : Symbol(f6.a, Decl(variants.ts, 31, 14)) - -namespace f6 { export namespace a { export const kind = 0; } } ->f6 : Symbol(f6, Decl(variants.ts, 27, 24), Decl(variants.ts, 30, 9)) ->a : Symbol(a, Decl(variants.ts, 31, 14)) ->kind : Symbol(kind, Decl(variants.ts, 31, 48)) - -const n6: number = f6.a; // error ->n6 : Symbol(n6, Decl(variants.ts, 32, 5)) ->f6.a : Symbol(f6.a, Decl(variants.ts, 31, 14)) ->f6 : Symbol(f6, Decl(variants.ts, 27, 24), Decl(variants.ts, 30, 9)) ->a : Symbol(f6.a, Decl(variants.ts, 31, 14)) - -namespace TypesOnly { export type T = number; } ->TypesOnly : Symbol(TypesOnly, Decl(variants.ts, 32, 24)) ->T : Symbol(T, Decl(variants.ts, 34, 21)) - -namespace Values { export const v = 1; } ->Values : Symbol(Values, Decl(variants.ts, 34, 47)) ->v : Symbol(v, Decl(variants.ts, 35, 31)) - -// Aliases might resolve to values, so they take precedence over expandos -function f7() {} ->f7 : Symbol(f7, Decl(variants.ts, 35, 40), Decl(variants.ts, 39, 9)) - -f7.a = 0; ->f7 : Symbol(f7, Decl(variants.ts, 35, 40), Decl(variants.ts, 39, 9)) - -namespace f7 { export import a = TypesOnly; } ->f7 : Symbol(f7, Decl(variants.ts, 35, 40), Decl(variants.ts, 39, 9)) ->a : Symbol(a, Decl(variants.ts, 40, 14)) ->TypesOnly : Symbol(a, Decl(variants.ts, 32, 24)) - -const n7: number = f7.a; ->n7 : Symbol(n7, Decl(variants.ts, 41, 5)) ->f7 : Symbol(f7, Decl(variants.ts, 35, 40), Decl(variants.ts, 39, 9)) - -const t7: f7.a.T = 0; ->t7 : Symbol(t7, Decl(variants.ts, 42, 5)) ->f7 : Symbol(f7, Decl(variants.ts, 35, 40), Decl(variants.ts, 39, 9)) ->a : Symbol(f7.a, Decl(variants.ts, 40, 14)) ->T : Symbol(TypesOnly.T, Decl(variants.ts, 34, 21)) - -function f8() {} ->f8 : Symbol(f8, Decl(variants.ts, 42, 21), Decl(variants.ts, 45, 9)) - -f8.a = 0; ->f8.a : Symbol(f8.a, Decl(variants.ts, 46, 14)) ->f8 : Symbol(f8, Decl(variants.ts, 42, 21), Decl(variants.ts, 45, 9)) ->a : Symbol(f8.a, Decl(variants.ts, 46, 14)) - -namespace f8 { export import a = Values; } // error ->f8 : Symbol(f8, Decl(variants.ts, 42, 21), Decl(variants.ts, 45, 9)) ->a : Symbol(a, Decl(variants.ts, 46, 14)) ->Values : Symbol(a, Decl(variants.ts, 34, 47)) - -=== popover.ts === -export function Popover() { return null; } ->Popover : Symbol(Popover, Decl(popover.ts, 0, 0), Decl(popover.ts, 2, 32)) - -Popover.Target = (x: number) => x; ->Popover.Target : Symbol(Popover.Target, Decl(popover.ts, 4, 26), Decl(popover.ts, 0, 42)) ->Popover : Symbol(Popover, Decl(popover.ts, 0, 0), Decl(popover.ts, 2, 32)) ->Target : Symbol(Popover.Target, Decl(popover.ts, 4, 26), Decl(popover.ts, 0, 42)) ->x : Symbol(x, Decl(popover.ts, 1, 18)) ->x : Symbol(x, Decl(popover.ts, 1, 18)) - -Popover.displayName = "Popover"; ->Popover.displayName : Symbol(Popover.displayName, Decl(popover.ts, 1, 34)) ->Popover : Symbol(Popover, Decl(popover.ts, 0, 0), Decl(popover.ts, 2, 32)) ->displayName : Symbol(Popover.displayName, Decl(popover.ts, 1, 34)) - -export namespace Popover { ->Popover : Symbol(Popover, Decl(popover.ts, 0, 0), Decl(popover.ts, 2, 32)) - - export namespace Target { ->Target : Symbol(Target, Decl(popover.ts, 4, 26), Decl(popover.ts, 0, 42)) - - export type Props = number; ->Props : Symbol(Props, Decl(popover.ts, 5, 27)) - } -} - -Popover.Target(1); ->Popover.Target : Symbol(Popover.Target, Decl(popover.ts, 4, 26), Decl(popover.ts, 0, 42)) ->Popover : Symbol(Popover, Decl(popover.ts, 0, 0), Decl(popover.ts, 2, 32)) ->Target : Symbol(Popover.Target, Decl(popover.ts, 4, 26), Decl(popover.ts, 0, 42)) - -Popover.displayName; ->Popover.displayName : Symbol(Popover.displayName, Decl(popover.ts, 1, 34)) ->Popover : Symbol(Popover, Decl(popover.ts, 0, 0), Decl(popover.ts, 2, 32)) ->displayName : Symbol(Popover.displayName, Decl(popover.ts, 1, 34)) - -const props: Popover.Target.Props = 1; ->props : Symbol(props, Decl(popover.ts, 12, 5)) ->Popover : Symbol(Popover, Decl(popover.ts, 0, 0), Decl(popover.ts, 2, 32)) ->Target : Symbol(Popover.Target, Decl(popover.ts, 4, 26), Decl(popover.ts, 0, 42)) ->Props : Symbol(Popover.Target.Props, Decl(popover.ts, 5, 27)) - diff --git a/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.types b/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.types deleted file mode 100644 index 20a00bfdb9817..0000000000000 --- a/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.types +++ /dev/null @@ -1,238 +0,0 @@ -//// [tests/cases/compiler/expandoFunctionTypeOnlyNamespaceMember.ts] //// - -=== variants.ts === -function f1() {} ->f1 : { (): void; a: number; } - -f1.a = 0; ->f1.a = 0 : 0 ->f1.a : number ->f1 : { (): void; a: number; } ->a : number ->0 : 0 - -namespace f1 { export type a = 0; } ->a : 0 - -const n1: number = f1.a; ->n1 : number ->f1.a : number ->f1 : { (): void; a: number; } ->a : number - -const s1: string = f1.a; // error ->s1 : string ->f1.a : number ->f1 : { (): void; a: number; } ->a : number - -const t1: f1.a = 0; ->t1 : 0 ->f1 : any ->0 : 0 - -function f2() {} ->f2 : { (): void; a: number; } - -f2.a = 0; ->f2.a = 0 : 0 ->f2.a : number ->f2 : { (): void; a: number; } ->a : number ->0 : 0 - -namespace f2 { export interface a { x: string } } ->x : string - -const n2: number = f2.a; ->n2 : number ->f2.a : number ->f2 : { (): void; a: number; } ->a : number - -const t2: f2.a = { x: "" }; ->t2 : f2.a ->f2 : any ->{ x: "" } : { x: string; } ->x : string ->"" : "" - -function f3() {} ->f3 : { (): void; a: number; } - -f3.a = 0; ->f3.a = 0 : 0 ->f3.a : number ->f3 : { (): void; a: number; } ->a : number ->0 : 0 - -namespace f3 { export namespace a {} } -const n3: number = f3.a; ->n3 : number ->f3.a : number ->f3 : { (): void; a: number; } ->a : number - -function f4() {} ->f4 : { (): void; a: number; } - -f4.a = 0; ->f4.a = 0 : 0 ->f4.a : number ->f4 : { (): void; a: number; } ->a : number ->0 : 0 - -namespace f4 { export namespace a { export type T = string; } } ->T : string - -const n4: number = f4.a; ->n4 : number ->f4.a : number ->f4 : { (): void; a: number; } ->a : number - -const t4: f4.a.T = ""; ->t4 : string ->f4 : any ->a : any ->"" : "" - -namespace f5 { export type a = 0; } ->a : 0 - -function f5() {} ->f5 : { (): void; a: number; } - -f5.a = 0; ->f5.a = 0 : 0 ->f5.a : number ->f5 : { (): void; a: number; } ->a : number ->0 : 0 - -const n5: number = f5.a; ->n5 : number ->f5.a : number ->f5 : { (): void; a: number; } ->a : number - -function f6() {} ->f6 : typeof f6 - -f6.a = 0; ->f6.a = 0 : 0 ->f6.a : typeof f6.a ->f6 : typeof f6 ->a : typeof f6.a ->0 : 0 - -namespace f6 { export namespace a { export const kind = 0; } } ->f6 : typeof f6 ->a : typeof a ->kind : 0 ->0 : 0 - -const n6: number = f6.a; // error ->n6 : number ->f6.a : typeof f6.a ->f6 : typeof f6 ->a : typeof f6.a - -namespace TypesOnly { export type T = number; } ->T : number - -namespace Values { export const v = 1; } ->Values : typeof Values ->v : 1 ->1 : 1 - -// Aliases might resolve to values, so they take precedence over expandos -function f7() {} ->f7 : typeof f7 - -f7.a = 0; ->f7.a = 0 : 0 ->f7.a : any ->f7 : typeof f7 ->a : any ->0 : 0 - -namespace f7 { export import a = TypesOnly; } ->f7 : typeof f7 ->a : any ->TypesOnly : any - -const n7: number = f7.a; ->n7 : number ->f7.a : any ->f7 : typeof f7 ->a : any - -const t7: f7.a.T = 0; ->t7 : number ->f7 : any ->a : any ->0 : 0 - -function f8() {} ->f8 : typeof f8 - -f8.a = 0; ->f8.a = 0 : 0 ->f8.a : typeof Values ->f8 : typeof f8 ->a : typeof Values ->0 : 0 - -namespace f8 { export import a = Values; } // error ->f8 : typeof f8 ->a : typeof a ->Values : typeof a - -=== popover.ts === -export function Popover() { return null; } ->Popover : { (): null; displayName: string; Target: (x: number) => number; } - -Popover.Target = (x: number) => x; ->Popover.Target = (x: number) => x : (x: number) => number ->Popover.Target : (x: number) => number ->Popover : { (): null; displayName: string; Target: (x: number) => number; } ->Target : (x: number) => number ->(x: number) => x : (x: number) => number ->x : number ->x : number - -Popover.displayName = "Popover"; ->Popover.displayName = "Popover" : "Popover" ->Popover.displayName : string ->Popover : { (): null; displayName: string; Target: (x: number) => number; } ->displayName : string ->"Popover" : "Popover" - -export namespace Popover { - export namespace Target { - export type Props = number; ->Props : number - } -} - -Popover.Target(1); ->Popover.Target(1) : number ->Popover.Target : (x: number) => number ->Popover : { (): null; displayName: string; Target: (x: number) => number; } ->Target : (x: number) => number ->1 : 1 - -Popover.displayName; ->Popover.displayName : string ->Popover : { (): null; displayName: string; Target: (x: number) => number; } ->displayName : string - -const props: Popover.Target.Props = 1; ->props : number ->Popover : any ->Target : any ->1 : 1 - diff --git a/tsc/testdata/tests/cases/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.ts b/tsc/testdata/tests/cases/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.ts deleted file mode 100644 index e78e31df19cd5..0000000000000 --- a/tsc/testdata/tests/cases/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.ts +++ /dev/null @@ -1,39 +0,0 @@ -// @strict: true -// @target: es2022 -// @declaration: true - -export class C {} -export function f1() {} -f1.a = C; -f1.b = C; -export namespace f1 { export type a = 0; } - -export enum E { A } -export function f2() {} -f2.a = E; -export namespace f2 { export interface a { x: string } } - -export function g() {} -export function f3() {} -f3.a = g; -export namespace f3 { export namespace a { export type T = string; } } - -export function Target() { return null; } -export namespace Target { export type Props = number; } - -export function Popover() { return null; } -Popover.Target = Target; -export namespace Popover { - export namespace Target { - export type Extra = string; - } -} - -export function Popover2() { return null; } -Popover2.b = C; -Popover2.Target = Target; -export namespace Popover2 { - export namespace Target { - export type Extra = string; - } -} diff --git a/tsc/testdata/tests/cases/compiler/expandoFunctionTypeOnlyNamespaceMember.ts b/tsc/testdata/tests/cases/compiler/expandoFunctionTypeOnlyNamespaceMember.ts deleted file mode 100644 index 5360710c33db2..0000000000000 --- a/tsc/testdata/tests/cases/compiler/expandoFunctionTypeOnlyNamespaceMember.ts +++ /dev/null @@ -1,67 +0,0 @@ -// @strict: true -// @target: es2022 -// @declaration: true - -// @filename: variants.ts -function f1() {} -f1.a = 0; -namespace f1 { export type a = 0; } -const n1: number = f1.a; -const s1: string = f1.a; // error -const t1: f1.a = 0; - -function f2() {} -f2.a = 0; -namespace f2 { export interface a { x: string } } -const n2: number = f2.a; -const t2: f2.a = { x: "" }; - -function f3() {} -f3.a = 0; -namespace f3 { export namespace a {} } -const n3: number = f3.a; - -function f4() {} -f4.a = 0; -namespace f4 { export namespace a { export type T = string; } } -const n4: number = f4.a; -const t4: f4.a.T = ""; - -namespace f5 { export type a = 0; } -function f5() {} -f5.a = 0; -const n5: number = f5.a; - -function f6() {} -f6.a = 0; -namespace f6 { export namespace a { export const kind = 0; } } -const n6: number = f6.a; // error - -namespace TypesOnly { export type T = number; } -namespace Values { export const v = 1; } - -// Aliases might resolve to values, so they take precedence over expandos -function f7() {} -f7.a = 0; -namespace f7 { export import a = TypesOnly; } -const n7: number = f7.a; -const t7: f7.a.T = 0; - -function f8() {} -f8.a = 0; -namespace f8 { export import a = Values; } // error - -// @filename: popover.ts -export function Popover() { return null; } -Popover.Target = (x: number) => x; -Popover.displayName = "Popover"; - -export namespace Popover { - export namespace Target { - export type Props = number; - } -} - -Popover.Target(1); -Popover.displayName; -const props: Popover.Target.Props = 1; From 4e199c41fac2746a4505c5329a678be622d02429 Mon Sep 17 00:00:00 2001 From: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com> Date: Fri, 20 Nov 2026 17:12:35 +0000 Subject: [PATCH 10/14] Add tests for expando properties merged with type-only namespace members Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --- ...tExpandoTypeOnlyNamespaceMember.errors.txt | 54 ++++ ...ationEmitExpandoTypeOnlyNamespaceMember.js | 108 ++++++++ ...EmitExpandoTypeOnlyNamespaceMember.symbols | 103 ++++++++ ...onEmitExpandoTypeOnlyNamespaceMember.types | 106 ++++++++ ...FunctionTypeOnlyNamespaceMember.errors.txt | 120 +++++++++ .../expandoFunctionTypeOnlyNamespaceMember.js | 189 ++++++++++++++ ...ndoFunctionTypeOnlyNamespaceMember.symbols | 197 +++++++++++++++ ...pandoFunctionTypeOnlyNamespaceMember.types | 238 ++++++++++++++++++ ...ationEmitExpandoTypeOnlyNamespaceMember.ts | 39 +++ .../expandoFunctionTypeOnlyNamespaceMember.ts | 67 +++++ 10 files changed, 1221 insertions(+) create mode 100644 tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.errors.txt create mode 100644 tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.js create mode 100644 tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.symbols create mode 100644 tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.types create mode 100644 tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.errors.txt create mode 100644 tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.js create mode 100644 tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.symbols create mode 100644 tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.types create mode 100644 tsc/testdata/tests/cases/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.ts create mode 100644 tsc/testdata/tests/cases/compiler/expandoFunctionTypeOnlyNamespaceMember.ts diff --git a/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.errors.txt b/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.errors.txt new file mode 100644 index 0000000000000..617872d016d3c --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.errors.txt @@ -0,0 +1,54 @@ +declarationEmitExpandoTypeOnlyNamespaceMember.ts(3,4): error TS2339: Property 'a' does not exist on type '{ (): void; b: typeof C; }'. +declarationEmitExpandoTypeOnlyNamespaceMember.ts(9,4): error TS2339: Property 'a' does not exist on type '() => void'. +declarationEmitExpandoTypeOnlyNamespaceMember.ts(14,4): error TS2339: Property 'a' does not exist on type '() => void'. +declarationEmitExpandoTypeOnlyNamespaceMember.ts(21,9): error TS2339: Property 'Target' does not exist on type '() => null'. +declarationEmitExpandoTypeOnlyNamespaceMember.ts(30,10): error TS2339: Property 'Target' does not exist on type '{ (): null; b: typeof C; }'. + + +==== declarationEmitExpandoTypeOnlyNamespaceMember.ts (5 errors) ==== + export class C {} + export function f1() {} + f1.a = C; + ~ +!!! error TS2339: Property 'a' does not exist on type '{ (): void; b: typeof C; }'. + f1.b = C; + export namespace f1 { export type a = 0; } + + export enum E { A } + export function f2() {} + f2.a = E; + ~ +!!! error TS2339: Property 'a' does not exist on type '() => void'. + export namespace f2 { export interface a { x: string } } + + export function g() {} + export function f3() {} + f3.a = g; + ~ +!!! error TS2339: Property 'a' does not exist on type '() => void'. + export namespace f3 { export namespace a { export type T = string; } } + + export function Target() { return null; } + export namespace Target { export type Props = number; } + + export function Popover() { return null; } + Popover.Target = Target; + ~~~~~~ +!!! error TS2339: Property 'Target' does not exist on type '() => null'. + export namespace Popover { + export namespace Target { + export type Extra = string; + } + } + + export function Popover2() { return null; } + Popover2.b = C; + Popover2.Target = Target; + ~~~~~~ +!!! error TS2339: Property 'Target' does not exist on type '{ (): null; b: typeof C; }'. + export namespace Popover2 { + export namespace Target { + export type Extra = string; + } + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.js b/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.js new file mode 100644 index 0000000000000..f2d8d74ea1830 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.js @@ -0,0 +1,108 @@ +//// [tests/cases/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.ts] //// + +//// [declarationEmitExpandoTypeOnlyNamespaceMember.ts] +export class C {} +export function f1() {} +f1.a = C; +f1.b = C; +export namespace f1 { export type a = 0; } + +export enum E { A } +export function f2() {} +f2.a = E; +export namespace f2 { export interface a { x: string } } + +export function g() {} +export function f3() {} +f3.a = g; +export namespace f3 { export namespace a { export type T = string; } } + +export function Target() { return null; } +export namespace Target { export type Props = number; } + +export function Popover() { return null; } +Popover.Target = Target; +export namespace Popover { + export namespace Target { + export type Extra = string; + } +} + +export function Popover2() { return null; } +Popover2.b = C; +Popover2.Target = Target; +export namespace Popover2 { + export namespace Target { + export type Extra = string; + } +} + + +//// [declarationEmitExpandoTypeOnlyNamespaceMember.js] +export class C { +} +export function f1() { } +f1.a = C; +f1.b = C; +export var E; +(function (E) { + E[E["A"] = 0] = "A"; +})(E || (E = {})); +export function f2() { } +f2.a = E; +export function g() { } +export function f3() { } +f3.a = g; +export function Target() { return null; } +export function Popover() { return null; } +Popover.Target = Target; +export function Popover2() { return null; } +Popover2.b = C; +Popover2.Target = Target; + + +//// [declarationEmitExpandoTypeOnlyNamespaceMember.d.ts] +export declare class C { +} +export declare function f1(): void; +export declare namespace f1 { + export { C as b }; +} +export declare namespace f1 { + type a = 0; +} +export declare enum E { + A = 0 +} +export declare function f2(): void; +export declare namespace f2 { + interface a { + x: string; + } +} +export declare function g(): void; +export declare function f3(): void; +export declare namespace f3 { + namespace a { + type T = string; + } +} +export declare function Target(): null; +export declare namespace Target { + type Props = number; +} +export declare function Popover(): null; +export declare namespace Popover { + namespace Target { + type Extra = string; + } +} +export declare function Popover2(): null; +export declare namespace Popover2 { + export { C as b }; +} +export declare namespace Popover2 { + namespace Target { + type Extra = string; + } +} diff --git a/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.symbols b/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.symbols new file mode 100644 index 0000000000000..948cb8cab1c45 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.symbols @@ -0,0 +1,103 @@ +//// [tests/cases/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.ts] //// + +=== declarationEmitExpandoTypeOnlyNamespaceMember.ts === +export class C {} +>C : Symbol(C, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 0, 0)) + +export function f1() {} +>f1 : Symbol(f1, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 0, 17), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 3, 9)) + +f1.a = C; +>f1 : Symbol(f1, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 0, 17), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 3, 9)) +>C : Symbol(C, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 0, 0)) + +f1.b = C; +>f1.b : Symbol(f1.b, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 2, 9)) +>f1 : Symbol(f1, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 0, 17), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 3, 9)) +>b : Symbol(f1.b, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 2, 9)) +>C : Symbol(C, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 0, 0)) + +export namespace f1 { export type a = 0; } +>f1 : Symbol(f1, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 0, 17), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 3, 9)) +>a : Symbol(a, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 4, 21)) + +export enum E { A } +>E : Symbol(E, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 4, 42)) +>A : Symbol(E.A, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 6, 15)) + +export function f2() {} +>f2 : Symbol(f2, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 6, 19), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 8, 9)) + +f2.a = E; +>f2 : Symbol(f2, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 6, 19), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 8, 9)) +>E : Symbol(E, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 4, 42)) + +export namespace f2 { export interface a { x: string } } +>f2 : Symbol(f2, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 6, 19), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 8, 9)) +>a : Symbol(a, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 9, 21)) +>x : Symbol(a.x, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 9, 42)) + +export function g() {} +>g : Symbol(g, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 9, 56)) + +export function f3() {} +>f3 : Symbol(f3, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 11, 22), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 13, 9)) + +f3.a = g; +>f3 : Symbol(f3, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 11, 22), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 13, 9)) +>g : Symbol(g, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 9, 56)) + +export namespace f3 { export namespace a { export type T = string; } } +>f3 : Symbol(f3, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 11, 22), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 13, 9)) +>a : Symbol(a, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 14, 21)) +>T : Symbol(T, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 14, 42)) + +export function Target() { return null; } +>Target : Symbol(Target, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 14, 70), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 16, 41)) + +export namespace Target { export type Props = number; } +>Target : Symbol(Target, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 14, 70), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 16, 41)) +>Props : Symbol(Props, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 17, 25)) + +export function Popover() { return null; } +>Popover : Symbol(Popover, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 17, 55), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 20, 24)) + +Popover.Target = Target; +>Popover : Symbol(Popover, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 17, 55), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 20, 24)) +>Target : Symbol(Target, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 14, 70), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 16, 41)) + +export namespace Popover { +>Popover : Symbol(Popover, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 17, 55), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 20, 24)) + + export namespace Target { +>Target : Symbol(Target, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 21, 26)) + + export type Extra = string; +>Extra : Symbol(Extra, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 22, 27)) + } +} + +export function Popover2() { return null; } +>Popover2 : Symbol(Popover2, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 25, 1), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 29, 25)) + +Popover2.b = C; +>Popover2.b : Symbol(Popover2.b, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 27, 43)) +>Popover2 : Symbol(Popover2, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 25, 1), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 29, 25)) +>b : Symbol(Popover2.b, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 27, 43)) +>C : Symbol(C, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 0, 0)) + +Popover2.Target = Target; +>Popover2 : Symbol(Popover2, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 25, 1), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 29, 25)) +>Target : Symbol(Target, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 14, 70), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 16, 41)) + +export namespace Popover2 { +>Popover2 : Symbol(Popover2, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 25, 1), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 29, 25)) + + export namespace Target { +>Target : Symbol(Target, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 30, 27)) + + export type Extra = string; +>Extra : Symbol(Extra, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 31, 27)) + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.types b/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.types new file mode 100644 index 0000000000000..c666e4babcecc --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.types @@ -0,0 +1,106 @@ +//// [tests/cases/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.ts] //// + +=== declarationEmitExpandoTypeOnlyNamespaceMember.ts === +export class C {} +>C : C + +export function f1() {} +>f1 : { (): void; b: typeof C; } + +f1.a = C; +>f1.a = C : typeof C +>f1.a : any +>f1 : { (): void; b: typeof C; } +>a : any +>C : typeof C + +f1.b = C; +>f1.b = C : typeof C +>f1.b : typeof C +>f1 : { (): void; b: typeof C; } +>b : typeof C +>C : typeof C + +export namespace f1 { export type a = 0; } +>a : 0 + +export enum E { A } +>E : E +>A : E.A + +export function f2() {} +>f2 : () => void + +f2.a = E; +>f2.a = E : typeof E +>f2.a : any +>f2 : () => void +>a : any +>E : typeof E + +export namespace f2 { export interface a { x: string } } +>x : string + +export function g() {} +>g : () => void + +export function f3() {} +>f3 : () => void + +f3.a = g; +>f3.a = g : () => void +>f3.a : any +>f3 : () => void +>a : any +>g : () => void + +export namespace f3 { export namespace a { export type T = string; } } +>T : string + +export function Target() { return null; } +>Target : () => null + +export namespace Target { export type Props = number; } +>Props : number + +export function Popover() { return null; } +>Popover : () => null + +Popover.Target = Target; +>Popover.Target = Target : () => null +>Popover.Target : any +>Popover : () => null +>Target : any +>Target : () => null + +export namespace Popover { + export namespace Target { + export type Extra = string; +>Extra : string + } +} + +export function Popover2() { return null; } +>Popover2 : { (): null; b: typeof C; } + +Popover2.b = C; +>Popover2.b = C : typeof C +>Popover2.b : typeof C +>Popover2 : { (): null; b: typeof C; } +>b : typeof C +>C : typeof C + +Popover2.Target = Target; +>Popover2.Target = Target : () => null +>Popover2.Target : any +>Popover2 : { (): null; b: typeof C; } +>Target : any +>Target : () => null + +export namespace Popover2 { + export namespace Target { + export type Extra = string; +>Extra : string + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.errors.txt b/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.errors.txt new file mode 100644 index 0000000000000..f788db1980816 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.errors.txt @@ -0,0 +1,120 @@ +popover.ts(2,9): error TS2339: Property 'Target' does not exist on type '{ (): null; displayName: string; }'. +popover.ts(11,9): error TS2339: Property 'Target' does not exist on type '{ (): null; displayName: string; }'. +variants.ts(2,4): error TS2339: Property 'a' does not exist on type '() => void'. +variants.ts(4,23): error TS2339: Property 'a' does not exist on type '() => void'. +variants.ts(5,23): error TS2339: Property 'a' does not exist on type '() => void'. +variants.ts(9,4): error TS2339: Property 'a' does not exist on type '() => void'. +variants.ts(11,23): error TS2339: Property 'a' does not exist on type '() => void'. +variants.ts(15,4): error TS2339: Property 'a' does not exist on type '() => void'. +variants.ts(17,23): error TS2339: Property 'a' does not exist on type '() => void'. +variants.ts(20,4): error TS2339: Property 'a' does not exist on type '() => void'. +variants.ts(22,23): error TS2339: Property 'a' does not exist on type '() => void'. +variants.ts(27,4): error TS2339: Property 'a' does not exist on type '() => void'. +variants.ts(28,23): error TS2339: Property 'a' does not exist on type '() => void'. +variants.ts(31,1): error TS2322: Type 'number' is not assignable to type 'typeof a'. +variants.ts(33,7): error TS2322: Type 'typeof a' is not assignable to type 'number'. +variants.ts(40,4): error TS2339: Property 'a' does not exist on type 'typeof f7'. +variants.ts(42,23): error TS2339: Property 'a' does not exist on type 'typeof f7'. +variants.ts(46,1): error TS2322: Type 'number' is not assignable to type 'typeof Values'. + + +==== variants.ts (16 errors) ==== + function f1() {} + f1.a = 0; + ~ +!!! error TS2339: Property 'a' does not exist on type '() => void'. + namespace f1 { export type a = 0; } + const n1: number = f1.a; + ~ +!!! error TS2339: Property 'a' does not exist on type '() => void'. + const s1: string = f1.a; // error + ~ +!!! error TS2339: Property 'a' does not exist on type '() => void'. + const t1: f1.a = 0; + + function f2() {} + f2.a = 0; + ~ +!!! error TS2339: Property 'a' does not exist on type '() => void'. + namespace f2 { export interface a { x: string } } + const n2: number = f2.a; + ~ +!!! error TS2339: Property 'a' does not exist on type '() => void'. + const t2: f2.a = { x: "" }; + + function f3() {} + f3.a = 0; + ~ +!!! error TS2339: Property 'a' does not exist on type '() => void'. + namespace f3 { export namespace a {} } + const n3: number = f3.a; + ~ +!!! error TS2339: Property 'a' does not exist on type '() => void'. + + function f4() {} + f4.a = 0; + ~ +!!! error TS2339: Property 'a' does not exist on type '() => void'. + namespace f4 { export namespace a { export type T = string; } } + const n4: number = f4.a; + ~ +!!! error TS2339: Property 'a' does not exist on type '() => void'. + const t4: f4.a.T = ""; + + namespace f5 { export type a = 0; } + function f5() {} + f5.a = 0; + ~ +!!! error TS2339: Property 'a' does not exist on type '() => void'. + const n5: number = f5.a; + ~ +!!! error TS2339: Property 'a' does not exist on type '() => void'. + + function f6() {} + f6.a = 0; + ~~~~ +!!! error TS2322: Type 'number' is not assignable to type 'typeof a'. + namespace f6 { export namespace a { export const kind = 0; } } + const n6: number = f6.a; // error + ~~ +!!! error TS2322: Type 'typeof a' is not assignable to type 'number'. + + namespace TypesOnly { export type T = number; } + namespace Values { export const v = 1; } + + // Aliases might resolve to values, so they take precedence over expandos + function f7() {} + f7.a = 0; + ~ +!!! error TS2339: Property 'a' does not exist on type 'typeof f7'. + namespace f7 { export import a = TypesOnly; } + const n7: number = f7.a; + ~ +!!! error TS2339: Property 'a' does not exist on type 'typeof f7'. + const t7: f7.a.T = 0; + + function f8() {} + f8.a = 0; + ~~~~ +!!! error TS2322: Type 'number' is not assignable to type 'typeof Values'. + namespace f8 { export import a = Values; } // error + +==== popover.ts (2 errors) ==== + export function Popover() { return null; } + Popover.Target = (x: number) => x; + ~~~~~~ +!!! error TS2339: Property 'Target' does not exist on type '{ (): null; displayName: string; }'. + Popover.displayName = "Popover"; + + export namespace Popover { + export namespace Target { + export type Props = number; + } + } + + Popover.Target(1); + ~~~~~~ +!!! error TS2339: Property 'Target' does not exist on type '{ (): null; displayName: string; }'. + Popover.displayName; + const props: Popover.Target.Props = 1; + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.js b/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.js new file mode 100644 index 0000000000000..19f673ed02a83 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.js @@ -0,0 +1,189 @@ +//// [tests/cases/compiler/expandoFunctionTypeOnlyNamespaceMember.ts] //// + +//// [variants.ts] +function f1() {} +f1.a = 0; +namespace f1 { export type a = 0; } +const n1: number = f1.a; +const s1: string = f1.a; // error +const t1: f1.a = 0; + +function f2() {} +f2.a = 0; +namespace f2 { export interface a { x: string } } +const n2: number = f2.a; +const t2: f2.a = { x: "" }; + +function f3() {} +f3.a = 0; +namespace f3 { export namespace a {} } +const n3: number = f3.a; + +function f4() {} +f4.a = 0; +namespace f4 { export namespace a { export type T = string; } } +const n4: number = f4.a; +const t4: f4.a.T = ""; + +namespace f5 { export type a = 0; } +function f5() {} +f5.a = 0; +const n5: number = f5.a; + +function f6() {} +f6.a = 0; +namespace f6 { export namespace a { export const kind = 0; } } +const n6: number = f6.a; // error + +namespace TypesOnly { export type T = number; } +namespace Values { export const v = 1; } + +// Aliases might resolve to values, so they take precedence over expandos +function f7() {} +f7.a = 0; +namespace f7 { export import a = TypesOnly; } +const n7: number = f7.a; +const t7: f7.a.T = 0; + +function f8() {} +f8.a = 0; +namespace f8 { export import a = Values; } // error + +//// [popover.ts] +export function Popover() { return null; } +Popover.Target = (x: number) => x; +Popover.displayName = "Popover"; + +export namespace Popover { + export namespace Target { + export type Props = number; + } +} + +Popover.Target(1); +Popover.displayName; +const props: Popover.Target.Props = 1; + + +//// [variants.js] +"use strict"; +function f1() { } +f1.a = 0; +const n1 = f1.a; +const s1 = f1.a; // error +const t1 = 0; +function f2() { } +f2.a = 0; +const n2 = f2.a; +const t2 = { x: "" }; +function f3() { } +f3.a = 0; +const n3 = f3.a; +function f4() { } +f4.a = 0; +const n4 = f4.a; +const t4 = ""; +function f5() { } +f5.a = 0; +const n5 = f5.a; +function f6() { } +f6.a = 0; +(function (f6) { + let a; + (function (a) { + a.kind = 0; + })(a = f6.a || (f6.a = {})); +})(f6 || (f6 = {})); +const n6 = f6.a; // error +var Values; +(function (Values) { + Values.v = 1; +})(Values || (Values = {})); +// Aliases might resolve to values, so they take precedence over expandos +function f7() { } +f7.a = 0; +(function (f7) { +})(f7 || (f7 = {})); +const n7 = f7.a; +const t7 = 0; +function f8() { } +f8.a = 0; +(function (f8) { + f8.a = Values; +})(f8 || (f8 = {})); // error +//// [popover.js] +export function Popover() { return null; } +Popover.Target = (x) => x; +Popover.displayName = "Popover"; +Popover.Target(1); +Popover.displayName; +const props = 1; + + +//// [variants.d.ts] +declare function f1(): void; +declare namespace f1 { + type a = 0; +} +declare const n1: number; +declare const s1: string; +declare const t1: f1.a; +declare function f2(): void; +declare namespace f2 { + interface a { + x: string; + } +} +declare const n2: number; +declare const t2: f2.a; +declare function f3(): void; +declare namespace f3 { + namespace a { } +} +declare const n3: number; +declare function f4(): void; +declare namespace f4 { + namespace a { + type T = string; + } +} +declare const n4: number; +declare const t4: f4.a.T; +declare namespace f5 { + type a = 0; +} +declare function f5(): void; +declare const n5: number; +declare function f6(): void; +declare namespace f6 { + namespace a { + const kind = 0; + } +} +declare const n6: number; +declare namespace TypesOnly { + type T = number; +} +declare namespace Values { + const v = 1; +} +declare function f7(): void; +declare namespace f7 { + export import a = TypesOnly; +} +declare const n7: number; +declare const t7: f7.a.T; +declare function f8(): void; +declare namespace f8 { + export import a = Values; +} +//// [popover.d.ts] +export declare function Popover(): null; +export declare namespace Popover { + var displayName: string; +} +export declare namespace Popover { + namespace Target { + type Props = number; + } +} diff --git a/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.symbols b/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.symbols new file mode 100644 index 0000000000000..dc4c1bc6d0daa --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.symbols @@ -0,0 +1,197 @@ +//// [tests/cases/compiler/expandoFunctionTypeOnlyNamespaceMember.ts] //// + +=== variants.ts === +function f1() {} +>f1 : Symbol(f1, Decl(variants.ts, 0, 0), Decl(variants.ts, 1, 9)) + +f1.a = 0; +>f1 : Symbol(f1, Decl(variants.ts, 0, 0), Decl(variants.ts, 1, 9)) + +namespace f1 { export type a = 0; } +>f1 : Symbol(f1, Decl(variants.ts, 0, 0), Decl(variants.ts, 1, 9)) +>a : Symbol(a, Decl(variants.ts, 2, 14)) + +const n1: number = f1.a; +>n1 : Symbol(n1, Decl(variants.ts, 3, 5)) +>f1 : Symbol(f1, Decl(variants.ts, 0, 0), Decl(variants.ts, 1, 9)) + +const s1: string = f1.a; // error +>s1 : Symbol(s1, Decl(variants.ts, 4, 5)) +>f1 : Symbol(f1, Decl(variants.ts, 0, 0), Decl(variants.ts, 1, 9)) + +const t1: f1.a = 0; +>t1 : Symbol(t1, Decl(variants.ts, 5, 5)) +>f1 : Symbol(f1, Decl(variants.ts, 0, 0), Decl(variants.ts, 1, 9)) +>a : Symbol(f1.a, Decl(variants.ts, 2, 14)) + +function f2() {} +>f2 : Symbol(f2, Decl(variants.ts, 5, 19), Decl(variants.ts, 8, 9)) + +f2.a = 0; +>f2 : Symbol(f2, Decl(variants.ts, 5, 19), Decl(variants.ts, 8, 9)) + +namespace f2 { export interface a { x: string } } +>f2 : Symbol(f2, Decl(variants.ts, 5, 19), Decl(variants.ts, 8, 9)) +>a : Symbol(a, Decl(variants.ts, 9, 14)) +>x : Symbol(a.x, Decl(variants.ts, 9, 35)) + +const n2: number = f2.a; +>n2 : Symbol(n2, Decl(variants.ts, 10, 5)) +>f2 : Symbol(f2, Decl(variants.ts, 5, 19), Decl(variants.ts, 8, 9)) + +const t2: f2.a = { x: "" }; +>t2 : Symbol(t2, Decl(variants.ts, 11, 5)) +>f2 : Symbol(f2, Decl(variants.ts, 5, 19), Decl(variants.ts, 8, 9)) +>a : Symbol(f2.a, Decl(variants.ts, 9, 14)) +>x : Symbol(x, Decl(variants.ts, 11, 18)) + +function f3() {} +>f3 : Symbol(f3, Decl(variants.ts, 11, 27), Decl(variants.ts, 14, 9)) + +f3.a = 0; +>f3 : Symbol(f3, Decl(variants.ts, 11, 27), Decl(variants.ts, 14, 9)) + +namespace f3 { export namespace a {} } +>f3 : Symbol(f3, Decl(variants.ts, 11, 27), Decl(variants.ts, 14, 9)) +>a : Symbol(a, Decl(variants.ts, 15, 14)) + +const n3: number = f3.a; +>n3 : Symbol(n3, Decl(variants.ts, 16, 5)) +>f3 : Symbol(f3, Decl(variants.ts, 11, 27), Decl(variants.ts, 14, 9)) + +function f4() {} +>f4 : Symbol(f4, Decl(variants.ts, 16, 24), Decl(variants.ts, 19, 9)) + +f4.a = 0; +>f4 : Symbol(f4, Decl(variants.ts, 16, 24), Decl(variants.ts, 19, 9)) + +namespace f4 { export namespace a { export type T = string; } } +>f4 : Symbol(f4, Decl(variants.ts, 16, 24), Decl(variants.ts, 19, 9)) +>a : Symbol(a, Decl(variants.ts, 20, 14)) +>T : Symbol(T, Decl(variants.ts, 20, 35)) + +const n4: number = f4.a; +>n4 : Symbol(n4, Decl(variants.ts, 21, 5)) +>f4 : Symbol(f4, Decl(variants.ts, 16, 24), Decl(variants.ts, 19, 9)) + +const t4: f4.a.T = ""; +>t4 : Symbol(t4, Decl(variants.ts, 22, 5)) +>f4 : Symbol(f4, Decl(variants.ts, 16, 24), Decl(variants.ts, 19, 9)) +>a : Symbol(f4.a, Decl(variants.ts, 20, 14)) +>T : Symbol(f4.a.T, Decl(variants.ts, 20, 35)) + +namespace f5 { export type a = 0; } +>f5 : Symbol(f5, Decl(variants.ts, 24, 35), Decl(variants.ts, 22, 22)) +>a : Symbol(a, Decl(variants.ts, 24, 14)) + +function f5() {} +>f5 : Symbol(f5, Decl(variants.ts, 24, 35), Decl(variants.ts, 22, 22)) + +f5.a = 0; +>f5 : Symbol(f5, Decl(variants.ts, 24, 35), Decl(variants.ts, 22, 22)) + +const n5: number = f5.a; +>n5 : Symbol(n5, Decl(variants.ts, 27, 5)) +>f5 : Symbol(f5, Decl(variants.ts, 24, 35), Decl(variants.ts, 22, 22)) + +function f6() {} +>f6 : Symbol(f6, Decl(variants.ts, 27, 24), Decl(variants.ts, 30, 9)) + +f6.a = 0; +>f6.a : Symbol(f6.a, Decl(variants.ts, 31, 14)) +>f6 : Symbol(f6, Decl(variants.ts, 27, 24), Decl(variants.ts, 30, 9)) +>a : Symbol(f6.a, Decl(variants.ts, 31, 14)) + +namespace f6 { export namespace a { export const kind = 0; } } +>f6 : Symbol(f6, Decl(variants.ts, 27, 24), Decl(variants.ts, 30, 9)) +>a : Symbol(a, Decl(variants.ts, 31, 14)) +>kind : Symbol(kind, Decl(variants.ts, 31, 48)) + +const n6: number = f6.a; // error +>n6 : Symbol(n6, Decl(variants.ts, 32, 5)) +>f6.a : Symbol(f6.a, Decl(variants.ts, 31, 14)) +>f6 : Symbol(f6, Decl(variants.ts, 27, 24), Decl(variants.ts, 30, 9)) +>a : Symbol(f6.a, Decl(variants.ts, 31, 14)) + +namespace TypesOnly { export type T = number; } +>TypesOnly : Symbol(TypesOnly, Decl(variants.ts, 32, 24)) +>T : Symbol(T, Decl(variants.ts, 34, 21)) + +namespace Values { export const v = 1; } +>Values : Symbol(Values, Decl(variants.ts, 34, 47)) +>v : Symbol(v, Decl(variants.ts, 35, 31)) + +// Aliases might resolve to values, so they take precedence over expandos +function f7() {} +>f7 : Symbol(f7, Decl(variants.ts, 35, 40), Decl(variants.ts, 39, 9)) + +f7.a = 0; +>f7 : Symbol(f7, Decl(variants.ts, 35, 40), Decl(variants.ts, 39, 9)) + +namespace f7 { export import a = TypesOnly; } +>f7 : Symbol(f7, Decl(variants.ts, 35, 40), Decl(variants.ts, 39, 9)) +>a : Symbol(a, Decl(variants.ts, 40, 14)) +>TypesOnly : Symbol(a, Decl(variants.ts, 32, 24)) + +const n7: number = f7.a; +>n7 : Symbol(n7, Decl(variants.ts, 41, 5)) +>f7 : Symbol(f7, Decl(variants.ts, 35, 40), Decl(variants.ts, 39, 9)) + +const t7: f7.a.T = 0; +>t7 : Symbol(t7, Decl(variants.ts, 42, 5)) +>f7 : Symbol(f7, Decl(variants.ts, 35, 40), Decl(variants.ts, 39, 9)) +>a : Symbol(f7.a, Decl(variants.ts, 40, 14)) +>T : Symbol(TypesOnly.T, Decl(variants.ts, 34, 21)) + +function f8() {} +>f8 : Symbol(f8, Decl(variants.ts, 42, 21), Decl(variants.ts, 45, 9)) + +f8.a = 0; +>f8.a : Symbol(f8.a, Decl(variants.ts, 46, 14)) +>f8 : Symbol(f8, Decl(variants.ts, 42, 21), Decl(variants.ts, 45, 9)) +>a : Symbol(f8.a, Decl(variants.ts, 46, 14)) + +namespace f8 { export import a = Values; } // error +>f8 : Symbol(f8, Decl(variants.ts, 42, 21), Decl(variants.ts, 45, 9)) +>a : Symbol(a, Decl(variants.ts, 46, 14)) +>Values : Symbol(a, Decl(variants.ts, 34, 47)) + +=== popover.ts === +export function Popover() { return null; } +>Popover : Symbol(Popover, Decl(popover.ts, 0, 0), Decl(popover.ts, 2, 32)) + +Popover.Target = (x: number) => x; +>Popover : Symbol(Popover, Decl(popover.ts, 0, 0), Decl(popover.ts, 2, 32)) +>x : Symbol(x, Decl(popover.ts, 1, 18)) +>x : Symbol(x, Decl(popover.ts, 1, 18)) + +Popover.displayName = "Popover"; +>Popover.displayName : Symbol(Popover.displayName, Decl(popover.ts, 1, 34)) +>Popover : Symbol(Popover, Decl(popover.ts, 0, 0), Decl(popover.ts, 2, 32)) +>displayName : Symbol(Popover.displayName, Decl(popover.ts, 1, 34)) + +export namespace Popover { +>Popover : Symbol(Popover, Decl(popover.ts, 0, 0), Decl(popover.ts, 2, 32)) + + export namespace Target { +>Target : Symbol(Target, Decl(popover.ts, 4, 26)) + + export type Props = number; +>Props : Symbol(Props, Decl(popover.ts, 5, 27)) + } +} + +Popover.Target(1); +>Popover : Symbol(Popover, Decl(popover.ts, 0, 0), Decl(popover.ts, 2, 32)) + +Popover.displayName; +>Popover.displayName : Symbol(Popover.displayName, Decl(popover.ts, 1, 34)) +>Popover : Symbol(Popover, Decl(popover.ts, 0, 0), Decl(popover.ts, 2, 32)) +>displayName : Symbol(Popover.displayName, Decl(popover.ts, 1, 34)) + +const props: Popover.Target.Props = 1; +>props : Symbol(props, Decl(popover.ts, 12, 5)) +>Popover : Symbol(Popover, Decl(popover.ts, 0, 0), Decl(popover.ts, 2, 32)) +>Target : Symbol(Popover.Target, Decl(popover.ts, 4, 26)) +>Props : Symbol(Popover.Target.Props, Decl(popover.ts, 5, 27)) + diff --git a/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.types b/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.types new file mode 100644 index 0000000000000..2480eb1eacffe --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.types @@ -0,0 +1,238 @@ +//// [tests/cases/compiler/expandoFunctionTypeOnlyNamespaceMember.ts] //// + +=== variants.ts === +function f1() {} +>f1 : () => void + +f1.a = 0; +>f1.a = 0 : 0 +>f1.a : any +>f1 : () => void +>a : any +>0 : 0 + +namespace f1 { export type a = 0; } +>a : 0 + +const n1: number = f1.a; +>n1 : number +>f1.a : any +>f1 : () => void +>a : any + +const s1: string = f1.a; // error +>s1 : string +>f1.a : any +>f1 : () => void +>a : any + +const t1: f1.a = 0; +>t1 : 0 +>f1 : any +>0 : 0 + +function f2() {} +>f2 : () => void + +f2.a = 0; +>f2.a = 0 : 0 +>f2.a : any +>f2 : () => void +>a : any +>0 : 0 + +namespace f2 { export interface a { x: string } } +>x : string + +const n2: number = f2.a; +>n2 : number +>f2.a : any +>f2 : () => void +>a : any + +const t2: f2.a = { x: "" }; +>t2 : f2.a +>f2 : any +>{ x: "" } : { x: string; } +>x : string +>"" : "" + +function f3() {} +>f3 : () => void + +f3.a = 0; +>f3.a = 0 : 0 +>f3.a : any +>f3 : () => void +>a : any +>0 : 0 + +namespace f3 { export namespace a {} } +const n3: number = f3.a; +>n3 : number +>f3.a : any +>f3 : () => void +>a : any + +function f4() {} +>f4 : () => void + +f4.a = 0; +>f4.a = 0 : 0 +>f4.a : any +>f4 : () => void +>a : any +>0 : 0 + +namespace f4 { export namespace a { export type T = string; } } +>T : string + +const n4: number = f4.a; +>n4 : number +>f4.a : any +>f4 : () => void +>a : any + +const t4: f4.a.T = ""; +>t4 : string +>f4 : any +>a : any +>"" : "" + +namespace f5 { export type a = 0; } +>a : 0 + +function f5() {} +>f5 : () => void + +f5.a = 0; +>f5.a = 0 : 0 +>f5.a : any +>f5 : () => void +>a : any +>0 : 0 + +const n5: number = f5.a; +>n5 : number +>f5.a : any +>f5 : () => void +>a : any + +function f6() {} +>f6 : typeof f6 + +f6.a = 0; +>f6.a = 0 : 0 +>f6.a : typeof f6.a +>f6 : typeof f6 +>a : typeof f6.a +>0 : 0 + +namespace f6 { export namespace a { export const kind = 0; } } +>f6 : typeof f6 +>a : typeof a +>kind : 0 +>0 : 0 + +const n6: number = f6.a; // error +>n6 : number +>f6.a : typeof f6.a +>f6 : typeof f6 +>a : typeof f6.a + +namespace TypesOnly { export type T = number; } +>T : number + +namespace Values { export const v = 1; } +>Values : typeof Values +>v : 1 +>1 : 1 + +// Aliases might resolve to values, so they take precedence over expandos +function f7() {} +>f7 : typeof f7 + +f7.a = 0; +>f7.a = 0 : 0 +>f7.a : any +>f7 : typeof f7 +>a : any +>0 : 0 + +namespace f7 { export import a = TypesOnly; } +>f7 : typeof f7 +>a : any +>TypesOnly : any + +const n7: number = f7.a; +>n7 : number +>f7.a : any +>f7 : typeof f7 +>a : any + +const t7: f7.a.T = 0; +>t7 : number +>f7 : any +>a : any +>0 : 0 + +function f8() {} +>f8 : typeof f8 + +f8.a = 0; +>f8.a = 0 : 0 +>f8.a : typeof Values +>f8 : typeof f8 +>a : typeof Values +>0 : 0 + +namespace f8 { export import a = Values; } // error +>f8 : typeof f8 +>a : typeof a +>Values : typeof a + +=== popover.ts === +export function Popover() { return null; } +>Popover : { (): null; displayName: string; } + +Popover.Target = (x: number) => x; +>Popover.Target = (x: number) => x : (x: number) => number +>Popover.Target : any +>Popover : { (): null; displayName: string; } +>Target : any +>(x: number) => x : (x: number) => number +>x : number +>x : number + +Popover.displayName = "Popover"; +>Popover.displayName = "Popover" : "Popover" +>Popover.displayName : string +>Popover : { (): null; displayName: string; } +>displayName : string +>"Popover" : "Popover" + +export namespace Popover { + export namespace Target { + export type Props = number; +>Props : number + } +} + +Popover.Target(1); +>Popover.Target(1) : any +>Popover.Target : any +>Popover : { (): null; displayName: string; } +>Target : any +>1 : 1 + +Popover.displayName; +>Popover.displayName : string +>Popover : { (): null; displayName: string; } +>displayName : string + +const props: Popover.Target.Props = 1; +>props : number +>Popover : any +>Target : any +>1 : 1 + diff --git a/tsc/testdata/tests/cases/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.ts b/tsc/testdata/tests/cases/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.ts new file mode 100644 index 0000000000000..e78e31df19cd5 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.ts @@ -0,0 +1,39 @@ +// @strict: true +// @target: es2022 +// @declaration: true + +export class C {} +export function f1() {} +f1.a = C; +f1.b = C; +export namespace f1 { export type a = 0; } + +export enum E { A } +export function f2() {} +f2.a = E; +export namespace f2 { export interface a { x: string } } + +export function g() {} +export function f3() {} +f3.a = g; +export namespace f3 { export namespace a { export type T = string; } } + +export function Target() { return null; } +export namespace Target { export type Props = number; } + +export function Popover() { return null; } +Popover.Target = Target; +export namespace Popover { + export namespace Target { + export type Extra = string; + } +} + +export function Popover2() { return null; } +Popover2.b = C; +Popover2.Target = Target; +export namespace Popover2 { + export namespace Target { + export type Extra = string; + } +} diff --git a/tsc/testdata/tests/cases/compiler/expandoFunctionTypeOnlyNamespaceMember.ts b/tsc/testdata/tests/cases/compiler/expandoFunctionTypeOnlyNamespaceMember.ts new file mode 100644 index 0000000000000..5360710c33db2 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/expandoFunctionTypeOnlyNamespaceMember.ts @@ -0,0 +1,67 @@ +// @strict: true +// @target: es2022 +// @declaration: true + +// @filename: variants.ts +function f1() {} +f1.a = 0; +namespace f1 { export type a = 0; } +const n1: number = f1.a; +const s1: string = f1.a; // error +const t1: f1.a = 0; + +function f2() {} +f2.a = 0; +namespace f2 { export interface a { x: string } } +const n2: number = f2.a; +const t2: f2.a = { x: "" }; + +function f3() {} +f3.a = 0; +namespace f3 { export namespace a {} } +const n3: number = f3.a; + +function f4() {} +f4.a = 0; +namespace f4 { export namespace a { export type T = string; } } +const n4: number = f4.a; +const t4: f4.a.T = ""; + +namespace f5 { export type a = 0; } +function f5() {} +f5.a = 0; +const n5: number = f5.a; + +function f6() {} +f6.a = 0; +namespace f6 { export namespace a { export const kind = 0; } } +const n6: number = f6.a; // error + +namespace TypesOnly { export type T = number; } +namespace Values { export const v = 1; } + +// Aliases might resolve to values, so they take precedence over expandos +function f7() {} +f7.a = 0; +namespace f7 { export import a = TypesOnly; } +const n7: number = f7.a; +const t7: f7.a.T = 0; + +function f8() {} +f8.a = 0; +namespace f8 { export import a = Values; } // error + +// @filename: popover.ts +export function Popover() { return null; } +Popover.Target = (x: number) => x; +Popover.displayName = "Popover"; + +export namespace Popover { + export namespace Target { + export type Props = number; + } +} + +Popover.Target(1); +Popover.displayName; +const props: Popover.Target.Props = 1; From 0a106deedf4d0145caa1d51f44cbfcae3485f88a Mon Sep 17 00:00:00 2001 From: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com> Date: Fri, 20 Nov 2026 17:12:39 +0000 Subject: [PATCH 11/14] Allow expando assignments to merge with type-only declarations of the same name Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --- tsc/internal/binder/binder.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tsc/internal/binder/binder.go b/tsc/internal/binder/binder.go index e1058bc33b043..082a83bc326de 100644 --- a/tsc/internal/binder/binder.go +++ b/tsc/internal/binder/binder.go @@ -1081,9 +1081,11 @@ func (b *Binder) bindDeferredExpandoAssignment(node *ast.Node) { b.bindAnonymousDeclaration(node, ast.SymbolFlagsProperty|ast.SymbolFlagsAssignment, ast.InternalSymbolNameComputed) b.addLateBoundAssignmentDeclarationToSymbol(node, symbol) } else { - // We declare expandos only when there are no non-expando declarations for that name. + // We declare expandos only when there are no non-expando declarations for that name that might have + // a value meaning. Expandos merge with type-only declarations (type aliases, interfaces, and + // uninstantiated namespaces), but not with aliases since those might resolve to values. exports := ast.GetExports(symbol, &b.symbolExtraArena) - if existing := exports.Get(b.getDeclarationName(node)); existing == nil || existing.Flags()&ast.SymbolFlagsAssignment != 0 { + if existing := exports.Get(b.getDeclarationName(node)); existing == nil || existing.Flags()&ast.SymbolFlagsAssignment != 0 || existing.Flags()&(ast.SymbolFlagsValue|ast.SymbolFlagsAlias) == 0 { b.declareSymbol(exports, symbol, node, ast.SymbolFlagsProperty|ast.SymbolFlagsAssignment, ast.SymbolFlagsPropertyExcludes) } } From 9806e09ea2f5517fb52a10c59eb0d8da6d527edd Mon Sep 17 00:00:00 2001 From: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com> Date: Fri, 20 Nov 2026 17:12:40 +0000 Subject: [PATCH 12/14] Fix declaration emit for expandos merged with type-only declarations Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --- tsc/internal/transformers/declarations/transform.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tsc/internal/transformers/declarations/transform.go b/tsc/internal/transformers/declarations/transform.go index 9538225ed249f..895e36b37faea 100644 --- a/tsc/internal/transformers/declarations/transform.go +++ b/tsc/internal/transformers/declarations/transform.go @@ -2908,7 +2908,9 @@ func (tx *DeclarationTransformer) transformExpandoAssignment(node *ast.BinaryExp preexistingExpandoHasExport := core.Some(tx.expandoMembers[hostId], ast.IsExportDeclaration) - if ast.IsIdentifier(node.Right) { + // When the expando is merged with a type-only declaration (e.g. a type alias or uninstantiated namespace + // of the same name), an alias-like export would conflict with it, so we emit a variable declaration instead. + if ast.IsIdentifier(node.Right) && symbol.Flags()&(ast.SymbolFlagsType|ast.SymbolFlagsNamespace) == 0 { if !preexistingExpandoHasExport { tx.addExportModifierToExpandoMembers(hostId) } @@ -2920,7 +2922,8 @@ func (tx *DeclarationTransformer) transformExpandoAssignment(node *ast.BinaryExp var varModifiers *ast.ModifierList - if preexistingExpandoHasExport { + // A renamed local stays private, since it's exported under the property name by the `export {}` added below + if preexistingExpandoHasExport && localName.Text() == exportName.Text() { varModifiers = tx.Factory().NewModifierList(ast.CreateModifiersFromModifierFlags(ast.ModifierFlagsExport, tx.Factory().NewModifier)) } From 1f6b26f019f511a38a0d6650cf87300ad5daada6 Mon Sep 17 00:00:00 2001 From: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com> Date: Fri, 20 Nov 2026 17:14:18 +0000 Subject: [PATCH 13/14] Accept baselines for expando/type-only namespace member fix Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --- ...tExpandoTypeOnlyNamespaceMember.errors.txt | 54 ----------- ...ationEmitExpandoTypeOnlyNamespaceMember.js | 13 +++ ...EmitExpandoTypeOnlyNamespaceMember.symbols | 20 +++- ...onEmitExpandoTypeOnlyNamespaceMember.types | 44 ++++----- ...FunctionTypeOnlyNamespaceMember.errors.txt | 46 +-------- .../expandoFunctionTypeOnlyNamespaceMember.js | 16 ++++ ...ndoFunctionTypeOnlyNamespaceMember.symbols | 46 +++++++-- ...pandoFunctionTypeOnlyNamespaceMember.types | 96 +++++++++---------- 8 files changed, 155 insertions(+), 180 deletions(-) delete mode 100644 tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.errors.txt diff --git a/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.errors.txt b/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.errors.txt deleted file mode 100644 index 617872d016d3c..0000000000000 --- a/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.errors.txt +++ /dev/null @@ -1,54 +0,0 @@ -declarationEmitExpandoTypeOnlyNamespaceMember.ts(3,4): error TS2339: Property 'a' does not exist on type '{ (): void; b: typeof C; }'. -declarationEmitExpandoTypeOnlyNamespaceMember.ts(9,4): error TS2339: Property 'a' does not exist on type '() => void'. -declarationEmitExpandoTypeOnlyNamespaceMember.ts(14,4): error TS2339: Property 'a' does not exist on type '() => void'. -declarationEmitExpandoTypeOnlyNamespaceMember.ts(21,9): error TS2339: Property 'Target' does not exist on type '() => null'. -declarationEmitExpandoTypeOnlyNamespaceMember.ts(30,10): error TS2339: Property 'Target' does not exist on type '{ (): null; b: typeof C; }'. - - -==== declarationEmitExpandoTypeOnlyNamespaceMember.ts (5 errors) ==== - export class C {} - export function f1() {} - f1.a = C; - ~ -!!! error TS2339: Property 'a' does not exist on type '{ (): void; b: typeof C; }'. - f1.b = C; - export namespace f1 { export type a = 0; } - - export enum E { A } - export function f2() {} - f2.a = E; - ~ -!!! error TS2339: Property 'a' does not exist on type '() => void'. - export namespace f2 { export interface a { x: string } } - - export function g() {} - export function f3() {} - f3.a = g; - ~ -!!! error TS2339: Property 'a' does not exist on type '() => void'. - export namespace f3 { export namespace a { export type T = string; } } - - export function Target() { return null; } - export namespace Target { export type Props = number; } - - export function Popover() { return null; } - Popover.Target = Target; - ~~~~~~ -!!! error TS2339: Property 'Target' does not exist on type '() => null'. - export namespace Popover { - export namespace Target { - export type Extra = string; - } - } - - export function Popover2() { return null; } - Popover2.b = C; - Popover2.Target = Target; - ~~~~~~ -!!! error TS2339: Property 'Target' does not exist on type '{ (): null; b: typeof C; }'. - export namespace Popover2 { - export namespace Target { - export type Extra = string; - } - } - \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.js b/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.js index f2d8d74ea1830..12675e56bcac2 100644 --- a/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.js +++ b/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.js @@ -66,6 +66,7 @@ export declare class C { } export declare function f1(): void; export declare namespace f1 { + export var a: typeof C; export { C as b }; } export declare namespace f1 { @@ -75,6 +76,9 @@ export declare enum E { A = 0 } export declare function f2(): void; +export declare namespace f2 { + var a: typeof E; +} export declare namespace f2 { interface a { x: string; @@ -82,6 +86,9 @@ export declare namespace f2 { } export declare function g(): void; export declare function f3(): void; +export declare namespace f3 { + var a: typeof g; +} export declare namespace f3 { namespace a { type T = string; @@ -92,6 +99,10 @@ export declare namespace Target { type Props = number; } export declare function Popover(): null; +export declare namespace Popover { + var _a: typeof import("./declarationEmitExpandoTypeOnlyNamespaceMember").Target; + export { _a as Target }; +} export declare namespace Popover { namespace Target { type Extra = string; @@ -100,6 +111,8 @@ export declare namespace Popover { export declare function Popover2(): null; export declare namespace Popover2 { export { C as b }; + var _b: typeof import("./declarationEmitExpandoTypeOnlyNamespaceMember").Target; + export { _b as Target }; } export declare namespace Popover2 { namespace Target { diff --git a/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.symbols b/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.symbols index 948cb8cab1c45..68521a0615125 100644 --- a/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.symbols +++ b/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.symbols @@ -8,7 +8,9 @@ export function f1() {} >f1 : Symbol(f1, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 0, 17), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 3, 9)) f1.a = C; +>f1.a : Symbol(f1.a, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 4, 21), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 1, 23)) >f1 : Symbol(f1, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 0, 17), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 3, 9)) +>a : Symbol(f1.a, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 4, 21), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 1, 23)) >C : Symbol(C, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 0, 0)) f1.b = C; @@ -19,7 +21,7 @@ f1.b = C; export namespace f1 { export type a = 0; } >f1 : Symbol(f1, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 0, 17), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 3, 9)) ->a : Symbol(a, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 4, 21)) +>a : Symbol(a, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 4, 21), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 1, 23)) export enum E { A } >E : Symbol(E, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 4, 42)) @@ -29,12 +31,14 @@ export function f2() {} >f2 : Symbol(f2, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 6, 19), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 8, 9)) f2.a = E; +>f2.a : Symbol(f2.a, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 9, 21), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 7, 23)) >f2 : Symbol(f2, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 6, 19), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 8, 9)) +>a : Symbol(f2.a, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 9, 21), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 7, 23)) >E : Symbol(E, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 4, 42)) export namespace f2 { export interface a { x: string } } >f2 : Symbol(f2, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 6, 19), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 8, 9)) ->a : Symbol(a, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 9, 21)) +>a : Symbol(a, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 9, 21), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 7, 23)) >x : Symbol(a.x, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 9, 42)) export function g() {} @@ -44,12 +48,14 @@ export function f3() {} >f3 : Symbol(f3, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 11, 22), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 13, 9)) f3.a = g; +>f3.a : Symbol(f3.a, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 14, 21), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 12, 23)) >f3 : Symbol(f3, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 11, 22), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 13, 9)) +>a : Symbol(f3.a, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 14, 21), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 12, 23)) >g : Symbol(g, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 9, 56)) export namespace f3 { export namespace a { export type T = string; } } >f3 : Symbol(f3, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 11, 22), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 13, 9)) ->a : Symbol(a, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 14, 21)) +>a : Symbol(a, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 14, 21), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 12, 23)) >T : Symbol(T, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 14, 42)) export function Target() { return null; } @@ -63,14 +69,16 @@ export function Popover() { return null; } >Popover : Symbol(Popover, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 17, 55), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 20, 24)) Popover.Target = Target; +>Popover.Target : Symbol(Popover.Target, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 21, 26), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 19, 42)) >Popover : Symbol(Popover, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 17, 55), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 20, 24)) +>Target : Symbol(Popover.Target, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 21, 26), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 19, 42)) >Target : Symbol(Target, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 14, 70), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 16, 41)) export namespace Popover { >Popover : Symbol(Popover, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 17, 55), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 20, 24)) export namespace Target { ->Target : Symbol(Target, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 21, 26)) +>Target : Symbol(Target, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 21, 26), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 19, 42)) export type Extra = string; >Extra : Symbol(Extra, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 22, 27)) @@ -87,14 +95,16 @@ Popover2.b = C; >C : Symbol(C, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 0, 0)) Popover2.Target = Target; +>Popover2.Target : Symbol(Popover2.Target, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 30, 27), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 28, 15)) >Popover2 : Symbol(Popover2, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 25, 1), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 29, 25)) +>Target : Symbol(Popover2.Target, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 30, 27), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 28, 15)) >Target : Symbol(Target, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 14, 70), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 16, 41)) export namespace Popover2 { >Popover2 : Symbol(Popover2, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 25, 1), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 29, 25)) export namespace Target { ->Target : Symbol(Target, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 30, 27)) +>Target : Symbol(Target, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 30, 27), Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 28, 15)) export type Extra = string; >Extra : Symbol(Extra, Decl(declarationEmitExpandoTypeOnlyNamespaceMember.ts, 31, 27)) diff --git a/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.types b/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.types index c666e4babcecc..49b2596939db0 100644 --- a/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.types +++ b/tsc/testdata/baselines/reference/compiler/declarationEmitExpandoTypeOnlyNamespaceMember.types @@ -5,19 +5,19 @@ export class C {} >C : C export function f1() {} ->f1 : { (): void; b: typeof C; } +>f1 : { (): void; b: typeof C; a: typeof C; } f1.a = C; >f1.a = C : typeof C ->f1.a : any ->f1 : { (): void; b: typeof C; } ->a : any +>f1.a : typeof C +>f1 : { (): void; b: typeof C; a: typeof C; } +>a : typeof C >C : typeof C f1.b = C; >f1.b = C : typeof C >f1.b : typeof C ->f1 : { (): void; b: typeof C; } +>f1 : { (): void; b: typeof C; a: typeof C; } >b : typeof C >C : typeof C @@ -29,13 +29,13 @@ export enum E { A } >A : E.A export function f2() {} ->f2 : () => void +>f2 : { (): void; a: typeof E; } f2.a = E; >f2.a = E : typeof E ->f2.a : any ->f2 : () => void ->a : any +>f2.a : typeof E +>f2 : { (): void; a: typeof E; } +>a : typeof E >E : typeof E export namespace f2 { export interface a { x: string } } @@ -45,13 +45,13 @@ export function g() {} >g : () => void export function f3() {} ->f3 : () => void +>f3 : { (): void; a: () => void; } f3.a = g; >f3.a = g : () => void ->f3.a : any ->f3 : () => void ->a : any +>f3.a : () => void +>f3 : { (): void; a: () => void; } +>a : () => void >g : () => void export namespace f3 { export namespace a { export type T = string; } } @@ -64,13 +64,13 @@ export namespace Target { export type Props = number; } >Props : number export function Popover() { return null; } ->Popover : () => null +>Popover : { (): null; Target: () => null; } Popover.Target = Target; >Popover.Target = Target : () => null ->Popover.Target : any ->Popover : () => null ->Target : any +>Popover.Target : () => null +>Popover : { (): null; Target: () => null; } +>Target : () => null >Target : () => null export namespace Popover { @@ -81,20 +81,20 @@ export namespace Popover { } export function Popover2() { return null; } ->Popover2 : { (): null; b: typeof C; } +>Popover2 : { (): null; b: typeof C; Target: () => null; } Popover2.b = C; >Popover2.b = C : typeof C >Popover2.b : typeof C ->Popover2 : { (): null; b: typeof C; } +>Popover2 : { (): null; b: typeof C; Target: () => null; } >b : typeof C >C : typeof C Popover2.Target = Target; >Popover2.Target = Target : () => null ->Popover2.Target : any ->Popover2 : { (): null; b: typeof C; } ->Target : any +>Popover2.Target : () => null +>Popover2 : { (): null; b: typeof C; Target: () => null; } +>Target : () => null >Target : () => null export namespace Popover2 { diff --git a/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.errors.txt b/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.errors.txt index f788db1980816..744788c289e4a 100644 --- a/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.errors.txt +++ b/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.errors.txt @@ -1,16 +1,4 @@ -popover.ts(2,9): error TS2339: Property 'Target' does not exist on type '{ (): null; displayName: string; }'. -popover.ts(11,9): error TS2339: Property 'Target' does not exist on type '{ (): null; displayName: string; }'. -variants.ts(2,4): error TS2339: Property 'a' does not exist on type '() => void'. -variants.ts(4,23): error TS2339: Property 'a' does not exist on type '() => void'. -variants.ts(5,23): error TS2339: Property 'a' does not exist on type '() => void'. -variants.ts(9,4): error TS2339: Property 'a' does not exist on type '() => void'. -variants.ts(11,23): error TS2339: Property 'a' does not exist on type '() => void'. -variants.ts(15,4): error TS2339: Property 'a' does not exist on type '() => void'. -variants.ts(17,23): error TS2339: Property 'a' does not exist on type '() => void'. -variants.ts(20,4): error TS2339: Property 'a' does not exist on type '() => void'. -variants.ts(22,23): error TS2339: Property 'a' does not exist on type '() => void'. -variants.ts(27,4): error TS2339: Property 'a' does not exist on type '() => void'. -variants.ts(28,23): error TS2339: Property 'a' does not exist on type '() => void'. +variants.ts(5,7): error TS2322: Type 'number' is not assignable to type 'string'. variants.ts(31,1): error TS2322: Type 'number' is not assignable to type 'typeof a'. variants.ts(33,7): error TS2322: Type 'typeof a' is not assignable to type 'number'. variants.ts(40,4): error TS2339: Property 'a' does not exist on type 'typeof f7'. @@ -18,57 +6,37 @@ variants.ts(42,23): error TS2339: Property 'a' does not exist on type 'typeof f7 variants.ts(46,1): error TS2322: Type 'number' is not assignable to type 'typeof Values'. -==== variants.ts (16 errors) ==== +==== variants.ts (6 errors) ==== function f1() {} f1.a = 0; - ~ -!!! error TS2339: Property 'a' does not exist on type '() => void'. namespace f1 { export type a = 0; } const n1: number = f1.a; - ~ -!!! error TS2339: Property 'a' does not exist on type '() => void'. const s1: string = f1.a; // error - ~ -!!! error TS2339: Property 'a' does not exist on type '() => void'. + ~~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. const t1: f1.a = 0; function f2() {} f2.a = 0; - ~ -!!! error TS2339: Property 'a' does not exist on type '() => void'. namespace f2 { export interface a { x: string } } const n2: number = f2.a; - ~ -!!! error TS2339: Property 'a' does not exist on type '() => void'. const t2: f2.a = { x: "" }; function f3() {} f3.a = 0; - ~ -!!! error TS2339: Property 'a' does not exist on type '() => void'. namespace f3 { export namespace a {} } const n3: number = f3.a; - ~ -!!! error TS2339: Property 'a' does not exist on type '() => void'. function f4() {} f4.a = 0; - ~ -!!! error TS2339: Property 'a' does not exist on type '() => void'. namespace f4 { export namespace a { export type T = string; } } const n4: number = f4.a; - ~ -!!! error TS2339: Property 'a' does not exist on type '() => void'. const t4: f4.a.T = ""; namespace f5 { export type a = 0; } function f5() {} f5.a = 0; - ~ -!!! error TS2339: Property 'a' does not exist on type '() => void'. const n5: number = f5.a; - ~ -!!! error TS2339: Property 'a' does not exist on type '() => void'. function f6() {} f6.a = 0; @@ -99,11 +67,9 @@ variants.ts(46,1): error TS2322: Type 'number' is not assignable to type 'typeof !!! error TS2322: Type 'number' is not assignable to type 'typeof Values'. namespace f8 { export import a = Values; } // error -==== popover.ts (2 errors) ==== +==== popover.ts (0 errors) ==== export function Popover() { return null; } Popover.Target = (x: number) => x; - ~~~~~~ -!!! error TS2339: Property 'Target' does not exist on type '{ (): null; displayName: string; }'. Popover.displayName = "Popover"; export namespace Popover { @@ -113,8 +79,6 @@ variants.ts(46,1): error TS2322: Type 'number' is not assignable to type 'typeof } Popover.Target(1); - ~~~~~~ -!!! error TS2339: Property 'Target' does not exist on type '{ (): null; displayName: string; }'. Popover.displayName; const props: Popover.Target.Props = 1; \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.js b/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.js index 19f673ed02a83..bb158110142b4 100644 --- a/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.js +++ b/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.js @@ -122,6 +122,9 @@ const props = 1; //// [variants.d.ts] declare function f1(): void; +declare namespace f1 { + var a: number; +} declare namespace f1 { type a = 0; } @@ -129,6 +132,9 @@ declare const n1: number; declare const s1: string; declare const t1: f1.a; declare function f2(): void; +declare namespace f2 { + var a: number; +} declare namespace f2 { interface a { x: string; @@ -137,11 +143,17 @@ declare namespace f2 { declare const n2: number; declare const t2: f2.a; declare function f3(): void; +declare namespace f3 { + var a: number; +} declare namespace f3 { namespace a { } } declare const n3: number; declare function f4(): void; +declare namespace f4 { + var a: number; +} declare namespace f4 { namespace a { type T = string; @@ -153,6 +165,9 @@ declare namespace f5 { type a = 0; } declare function f5(): void; +declare namespace f5 { + var a: number; +} declare const n5: number; declare function f6(): void; declare namespace f6 { @@ -180,6 +195,7 @@ declare namespace f8 { //// [popover.d.ts] export declare function Popover(): null; export declare namespace Popover { + var Target: (x: number) => number; var displayName: string; } export declare namespace Popover { diff --git a/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.symbols b/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.symbols index dc4c1bc6d0daa..8b37d2d0ea777 100644 --- a/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.symbols +++ b/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.symbols @@ -5,94 +5,116 @@ function f1() {} >f1 : Symbol(f1, Decl(variants.ts, 0, 0), Decl(variants.ts, 1, 9)) f1.a = 0; +>f1.a : Symbol(f1.a, Decl(variants.ts, 2, 14), Decl(variants.ts, 0, 16)) >f1 : Symbol(f1, Decl(variants.ts, 0, 0), Decl(variants.ts, 1, 9)) +>a : Symbol(f1.a, Decl(variants.ts, 2, 14), Decl(variants.ts, 0, 16)) namespace f1 { export type a = 0; } >f1 : Symbol(f1, Decl(variants.ts, 0, 0), Decl(variants.ts, 1, 9)) ->a : Symbol(a, Decl(variants.ts, 2, 14)) +>a : Symbol(a, Decl(variants.ts, 2, 14), Decl(variants.ts, 0, 16)) const n1: number = f1.a; >n1 : Symbol(n1, Decl(variants.ts, 3, 5)) +>f1.a : Symbol(f1.a, Decl(variants.ts, 2, 14), Decl(variants.ts, 0, 16)) >f1 : Symbol(f1, Decl(variants.ts, 0, 0), Decl(variants.ts, 1, 9)) +>a : Symbol(f1.a, Decl(variants.ts, 2, 14), Decl(variants.ts, 0, 16)) const s1: string = f1.a; // error >s1 : Symbol(s1, Decl(variants.ts, 4, 5)) +>f1.a : Symbol(f1.a, Decl(variants.ts, 2, 14), Decl(variants.ts, 0, 16)) >f1 : Symbol(f1, Decl(variants.ts, 0, 0), Decl(variants.ts, 1, 9)) +>a : Symbol(f1.a, Decl(variants.ts, 2, 14), Decl(variants.ts, 0, 16)) const t1: f1.a = 0; >t1 : Symbol(t1, Decl(variants.ts, 5, 5)) >f1 : Symbol(f1, Decl(variants.ts, 0, 0), Decl(variants.ts, 1, 9)) ->a : Symbol(f1.a, Decl(variants.ts, 2, 14)) +>a : Symbol(f1.a, Decl(variants.ts, 2, 14), Decl(variants.ts, 0, 16)) function f2() {} >f2 : Symbol(f2, Decl(variants.ts, 5, 19), Decl(variants.ts, 8, 9)) f2.a = 0; +>f2.a : Symbol(f2.a, Decl(variants.ts, 9, 14), Decl(variants.ts, 7, 16)) >f2 : Symbol(f2, Decl(variants.ts, 5, 19), Decl(variants.ts, 8, 9)) +>a : Symbol(f2.a, Decl(variants.ts, 9, 14), Decl(variants.ts, 7, 16)) namespace f2 { export interface a { x: string } } >f2 : Symbol(f2, Decl(variants.ts, 5, 19), Decl(variants.ts, 8, 9)) ->a : Symbol(a, Decl(variants.ts, 9, 14)) +>a : Symbol(a, Decl(variants.ts, 9, 14), Decl(variants.ts, 7, 16)) >x : Symbol(a.x, Decl(variants.ts, 9, 35)) const n2: number = f2.a; >n2 : Symbol(n2, Decl(variants.ts, 10, 5)) +>f2.a : Symbol(f2.a, Decl(variants.ts, 9, 14), Decl(variants.ts, 7, 16)) >f2 : Symbol(f2, Decl(variants.ts, 5, 19), Decl(variants.ts, 8, 9)) +>a : Symbol(f2.a, Decl(variants.ts, 9, 14), Decl(variants.ts, 7, 16)) const t2: f2.a = { x: "" }; >t2 : Symbol(t2, Decl(variants.ts, 11, 5)) >f2 : Symbol(f2, Decl(variants.ts, 5, 19), Decl(variants.ts, 8, 9)) ->a : Symbol(f2.a, Decl(variants.ts, 9, 14)) +>a : Symbol(f2.a, Decl(variants.ts, 9, 14), Decl(variants.ts, 7, 16)) >x : Symbol(x, Decl(variants.ts, 11, 18)) function f3() {} >f3 : Symbol(f3, Decl(variants.ts, 11, 27), Decl(variants.ts, 14, 9)) f3.a = 0; +>f3.a : Symbol(f3.a, Decl(variants.ts, 15, 14), Decl(variants.ts, 13, 16)) >f3 : Symbol(f3, Decl(variants.ts, 11, 27), Decl(variants.ts, 14, 9)) +>a : Symbol(f3.a, Decl(variants.ts, 15, 14), Decl(variants.ts, 13, 16)) namespace f3 { export namespace a {} } >f3 : Symbol(f3, Decl(variants.ts, 11, 27), Decl(variants.ts, 14, 9)) ->a : Symbol(a, Decl(variants.ts, 15, 14)) +>a : Symbol(a, Decl(variants.ts, 15, 14), Decl(variants.ts, 13, 16)) const n3: number = f3.a; >n3 : Symbol(n3, Decl(variants.ts, 16, 5)) +>f3.a : Symbol(f3.a, Decl(variants.ts, 15, 14), Decl(variants.ts, 13, 16)) >f3 : Symbol(f3, Decl(variants.ts, 11, 27), Decl(variants.ts, 14, 9)) +>a : Symbol(f3.a, Decl(variants.ts, 15, 14), Decl(variants.ts, 13, 16)) function f4() {} >f4 : Symbol(f4, Decl(variants.ts, 16, 24), Decl(variants.ts, 19, 9)) f4.a = 0; +>f4.a : Symbol(f4.a, Decl(variants.ts, 20, 14), Decl(variants.ts, 18, 16)) >f4 : Symbol(f4, Decl(variants.ts, 16, 24), Decl(variants.ts, 19, 9)) +>a : Symbol(f4.a, Decl(variants.ts, 20, 14), Decl(variants.ts, 18, 16)) namespace f4 { export namespace a { export type T = string; } } >f4 : Symbol(f4, Decl(variants.ts, 16, 24), Decl(variants.ts, 19, 9)) ->a : Symbol(a, Decl(variants.ts, 20, 14)) +>a : Symbol(a, Decl(variants.ts, 20, 14), Decl(variants.ts, 18, 16)) >T : Symbol(T, Decl(variants.ts, 20, 35)) const n4: number = f4.a; >n4 : Symbol(n4, Decl(variants.ts, 21, 5)) +>f4.a : Symbol(f4.a, Decl(variants.ts, 20, 14), Decl(variants.ts, 18, 16)) >f4 : Symbol(f4, Decl(variants.ts, 16, 24), Decl(variants.ts, 19, 9)) +>a : Symbol(f4.a, Decl(variants.ts, 20, 14), Decl(variants.ts, 18, 16)) const t4: f4.a.T = ""; >t4 : Symbol(t4, Decl(variants.ts, 22, 5)) >f4 : Symbol(f4, Decl(variants.ts, 16, 24), Decl(variants.ts, 19, 9)) ->a : Symbol(f4.a, Decl(variants.ts, 20, 14)) +>a : Symbol(f4.a, Decl(variants.ts, 20, 14), Decl(variants.ts, 18, 16)) >T : Symbol(f4.a.T, Decl(variants.ts, 20, 35)) namespace f5 { export type a = 0; } >f5 : Symbol(f5, Decl(variants.ts, 24, 35), Decl(variants.ts, 22, 22)) ->a : Symbol(a, Decl(variants.ts, 24, 14)) +>a : Symbol(a, Decl(variants.ts, 24, 14), Decl(variants.ts, 25, 16)) function f5() {} >f5 : Symbol(f5, Decl(variants.ts, 24, 35), Decl(variants.ts, 22, 22)) f5.a = 0; +>f5.a : Symbol(f5.a, Decl(variants.ts, 24, 14), Decl(variants.ts, 25, 16)) >f5 : Symbol(f5, Decl(variants.ts, 24, 35), Decl(variants.ts, 22, 22)) +>a : Symbol(f5.a, Decl(variants.ts, 24, 14), Decl(variants.ts, 25, 16)) const n5: number = f5.a; >n5 : Symbol(n5, Decl(variants.ts, 27, 5)) +>f5.a : Symbol(f5.a, Decl(variants.ts, 24, 14), Decl(variants.ts, 25, 16)) >f5 : Symbol(f5, Decl(variants.ts, 24, 35), Decl(variants.ts, 22, 22)) +>a : Symbol(f5.a, Decl(variants.ts, 24, 14), Decl(variants.ts, 25, 16)) function f6() {} >f6 : Symbol(f6, Decl(variants.ts, 27, 24), Decl(variants.ts, 30, 9)) @@ -161,7 +183,9 @@ export function Popover() { return null; } >Popover : Symbol(Popover, Decl(popover.ts, 0, 0), Decl(popover.ts, 2, 32)) Popover.Target = (x: number) => x; +>Popover.Target : Symbol(Popover.Target, Decl(popover.ts, 4, 26), Decl(popover.ts, 0, 42)) >Popover : Symbol(Popover, Decl(popover.ts, 0, 0), Decl(popover.ts, 2, 32)) +>Target : Symbol(Popover.Target, Decl(popover.ts, 4, 26), Decl(popover.ts, 0, 42)) >x : Symbol(x, Decl(popover.ts, 1, 18)) >x : Symbol(x, Decl(popover.ts, 1, 18)) @@ -174,7 +198,7 @@ export namespace Popover { >Popover : Symbol(Popover, Decl(popover.ts, 0, 0), Decl(popover.ts, 2, 32)) export namespace Target { ->Target : Symbol(Target, Decl(popover.ts, 4, 26)) +>Target : Symbol(Target, Decl(popover.ts, 4, 26), Decl(popover.ts, 0, 42)) export type Props = number; >Props : Symbol(Props, Decl(popover.ts, 5, 27)) @@ -182,7 +206,9 @@ export namespace Popover { } Popover.Target(1); +>Popover.Target : Symbol(Popover.Target, Decl(popover.ts, 4, 26), Decl(popover.ts, 0, 42)) >Popover : Symbol(Popover, Decl(popover.ts, 0, 0), Decl(popover.ts, 2, 32)) +>Target : Symbol(Popover.Target, Decl(popover.ts, 4, 26), Decl(popover.ts, 0, 42)) Popover.displayName; >Popover.displayName : Symbol(Popover.displayName, Decl(popover.ts, 1, 34)) @@ -192,6 +218,6 @@ Popover.displayName; const props: Popover.Target.Props = 1; >props : Symbol(props, Decl(popover.ts, 12, 5)) >Popover : Symbol(Popover, Decl(popover.ts, 0, 0), Decl(popover.ts, 2, 32)) ->Target : Symbol(Popover.Target, Decl(popover.ts, 4, 26)) +>Target : Symbol(Popover.Target, Decl(popover.ts, 4, 26), Decl(popover.ts, 0, 42)) >Props : Symbol(Popover.Target.Props, Decl(popover.ts, 5, 27)) diff --git a/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.types b/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.types index 2480eb1eacffe..20a00bfdb9817 100644 --- a/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.types +++ b/tsc/testdata/baselines/reference/compiler/expandoFunctionTypeOnlyNamespaceMember.types @@ -2,13 +2,13 @@ === variants.ts === function f1() {} ->f1 : () => void +>f1 : { (): void; a: number; } f1.a = 0; >f1.a = 0 : 0 ->f1.a : any ->f1 : () => void ->a : any +>f1.a : number +>f1 : { (): void; a: number; } +>a : number >0 : 0 namespace f1 { export type a = 0; } @@ -16,15 +16,15 @@ namespace f1 { export type a = 0; } const n1: number = f1.a; >n1 : number ->f1.a : any ->f1 : () => void ->a : any +>f1.a : number +>f1 : { (): void; a: number; } +>a : number const s1: string = f1.a; // error >s1 : string ->f1.a : any ->f1 : () => void ->a : any +>f1.a : number +>f1 : { (): void; a: number; } +>a : number const t1: f1.a = 0; >t1 : 0 @@ -32,13 +32,13 @@ const t1: f1.a = 0; >0 : 0 function f2() {} ->f2 : () => void +>f2 : { (): void; a: number; } f2.a = 0; >f2.a = 0 : 0 ->f2.a : any ->f2 : () => void ->a : any +>f2.a : number +>f2 : { (): void; a: number; } +>a : number >0 : 0 namespace f2 { export interface a { x: string } } @@ -46,9 +46,9 @@ namespace f2 { export interface a { x: string } } const n2: number = f2.a; >n2 : number ->f2.a : any ->f2 : () => void ->a : any +>f2.a : number +>f2 : { (): void; a: number; } +>a : number const t2: f2.a = { x: "" }; >t2 : f2.a @@ -58,30 +58,30 @@ const t2: f2.a = { x: "" }; >"" : "" function f3() {} ->f3 : () => void +>f3 : { (): void; a: number; } f3.a = 0; >f3.a = 0 : 0 ->f3.a : any ->f3 : () => void ->a : any +>f3.a : number +>f3 : { (): void; a: number; } +>a : number >0 : 0 namespace f3 { export namespace a {} } const n3: number = f3.a; >n3 : number ->f3.a : any ->f3 : () => void ->a : any +>f3.a : number +>f3 : { (): void; a: number; } +>a : number function f4() {} ->f4 : () => void +>f4 : { (): void; a: number; } f4.a = 0; >f4.a = 0 : 0 ->f4.a : any ->f4 : () => void ->a : any +>f4.a : number +>f4 : { (): void; a: number; } +>a : number >0 : 0 namespace f4 { export namespace a { export type T = string; } } @@ -89,9 +89,9 @@ namespace f4 { export namespace a { export type T = string; } } const n4: number = f4.a; >n4 : number ->f4.a : any ->f4 : () => void ->a : any +>f4.a : number +>f4 : { (): void; a: number; } +>a : number const t4: f4.a.T = ""; >t4 : string @@ -103,20 +103,20 @@ namespace f5 { export type a = 0; } >a : 0 function f5() {} ->f5 : () => void +>f5 : { (): void; a: number; } f5.a = 0; >f5.a = 0 : 0 ->f5.a : any ->f5 : () => void ->a : any +>f5.a : number +>f5 : { (): void; a: number; } +>a : number >0 : 0 const n5: number = f5.a; >n5 : number ->f5.a : any ->f5 : () => void ->a : any +>f5.a : number +>f5 : { (): void; a: number; } +>a : number function f6() {} >f6 : typeof f6 @@ -193,13 +193,13 @@ namespace f8 { export import a = Values; } // error === popover.ts === export function Popover() { return null; } ->Popover : { (): null; displayName: string; } +>Popover : { (): null; displayName: string; Target: (x: number) => number; } Popover.Target = (x: number) => x; >Popover.Target = (x: number) => x : (x: number) => number ->Popover.Target : any ->Popover : { (): null; displayName: string; } ->Target : any +>Popover.Target : (x: number) => number +>Popover : { (): null; displayName: string; Target: (x: number) => number; } +>Target : (x: number) => number >(x: number) => x : (x: number) => number >x : number >x : number @@ -207,7 +207,7 @@ Popover.Target = (x: number) => x; Popover.displayName = "Popover"; >Popover.displayName = "Popover" : "Popover" >Popover.displayName : string ->Popover : { (): null; displayName: string; } +>Popover : { (): null; displayName: string; Target: (x: number) => number; } >displayName : string >"Popover" : "Popover" @@ -219,15 +219,15 @@ export namespace Popover { } Popover.Target(1); ->Popover.Target(1) : any ->Popover.Target : any ->Popover : { (): null; displayName: string; } ->Target : any +>Popover.Target(1) : number +>Popover.Target : (x: number) => number +>Popover : { (): null; displayName: string; Target: (x: number) => number; } +>Target : (x: number) => number >1 : 1 Popover.displayName; >Popover.displayName : string ->Popover : { (): null; displayName: string; } +>Popover : { (): null; displayName: string; Target: (x: number) => number; } >displayName : string const props: Popover.Target.Props = 1; From 1f870f8e0e9b3002c5387961dd7f1102745d9de7 Mon Sep 17 00:00:00 2001 From: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com> Date: Fri, 20 Nov 2026 20:19:37 +0000 Subject: [PATCH 14/14] Update expando declaration baselines Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --- ...ionKeywordPropExhaustive(target=es2015).js | 90 +++++++++---------- .../reference/conformance/nullPropertyName.js | 90 +++++++++---------- 2 files changed, 90 insertions(+), 90 deletions(-) diff --git a/tsc/testdata/baselines/reference/conformance/jsDeclarationsFunctionKeywordPropExhaustive(target=es2015).js b/tsc/testdata/baselines/reference/conformance/jsDeclarationsFunctionKeywordPropExhaustive(target=es2015).js index 26dfbafde270f..af46a2972e982 100644 --- a/tsc/testdata/baselines/reference/conformance/jsDeclarationsFunctionKeywordPropExhaustive(target=es2015).js +++ b/tsc/testdata/baselines/reference/conformance/jsDeclarationsFunctionKeywordPropExhaustive(target=es2015).js @@ -176,93 +176,93 @@ declare namespace foo { export var y: number; var _a: number; export { _a as break }; - export var _b: number; + var _b: number; export { _b as case }; - export var _c: number; + var _c: number; export { _c as catch }; - export var _d: number; + var _d: number; export { _d as class }; - export var _e: number; + var _e: number; export { _e as const }; - export var _f: number; + var _f: number; export { _f as continue }; - export var _g: number; + var _g: number; export { _g as debugger }; - export var _h: number; + var _h: number; export { _h as default }; - export var _j: number; + var _j: number; export { _j as delete }; - export var _k: number; + var _k: number; export { _k as do }; - export var _l: number; + var _l: number; export { _l as else }; - export var _m: number; + var _m: number; export { _m as enum }; - export var _o: number; + var _o: number; export { _o as export }; - export var _p: number; + var _p: number; export { _p as extends }; - export var _q: number; + var _q: number; export { _q as false }; - export var _r: number; + var _r: number; export { _r as finally }; - export var _s: number; + var _s: number; export { _s as for }; - export var _t: number; + var _t: number; export { _t as function }; - export var _u: number; + var _u: number; export { _u as if }; - export var _v: number; + var _v: number; export { _v as import }; - export var _w: number; + var _w: number; export { _w as in }; - export var _x: number; + var _x: number; export { _x as instanceof }; - export var _y: number; + var _y: number; export { _y as new }; - export var _z: number; + var _z: number; export { _z as null }; - export var _0: number; + var _0: number; export { _0 as return }; - export var _1: number; + var _1: number; export { _1 as super }; - export var _2: number; + var _2: number; export { _2 as switch }; - export var _3: number; + var _3: number; export { _3 as this }; - export var _4: number; + var _4: number; export { _4 as throw }; - export var _5: number; + var _5: number; export { _5 as true }; - export var _6: number; + var _6: number; export { _6 as try }; - export var _7: number; + var _7: number; export { _7 as typeof }; - export var _8: number; + var _8: number; export { _8 as var }; - export var _9: number; + var _9: number; export { _9 as void }; - export var _10: number; + var _10: number; export { _10 as while }; - export var _11: number; + var _11: number; export { _11 as with }; - export var _12: number; + var _12: number; export { _12 as implements }; - export var _13: number; + var _13: number; export { _13 as interface }; - export var _14: number; + var _14: number; export { _14 as let }; - export var _15: number; + var _15: number; export { _15 as package }; - export var _16: number; + var _16: number; export { _16 as private }; - export var _17: number; + var _17: number; export { _17 as protected }; - export var _18: number; + var _18: number; export { _18 as public }; - export var _19: number; + var _19: number; export { _19 as static }; - export var _20: number; + var _20: number; export { _20 as yield }; export var abstract: number; export var as: number; @@ -288,7 +288,7 @@ declare namespace foo { export var string: number; export var symbol: number; export var type: number; - export var _21: number; + var _21: number; export { _21 as undefined }; export var unique: number; export var unknown: number; diff --git a/tsc/testdata/baselines/reference/conformance/nullPropertyName.js b/tsc/testdata/baselines/reference/conformance/nullPropertyName.js index 2cf307d9ef807..2a1f9e50975e4 100644 --- a/tsc/testdata/baselines/reference/conformance/nullPropertyName.js +++ b/tsc/testdata/baselines/reference/conformance/nullPropertyName.js @@ -177,93 +177,93 @@ declare namespace foo { export var y: number; var _a: number; export { _a as break }; - export var _b: number; + var _b: number; export { _b as case }; - export var _c: number; + var _c: number; export { _c as catch }; - export var _d: number; + var _d: number; export { _d as class }; - export var _e: number; + var _e: number; export { _e as const }; - export var _f: number; + var _f: number; export { _f as continue }; - export var _g: number; + var _g: number; export { _g as debugger }; - export var _h: number; + var _h: number; export { _h as default }; - export var _j: number; + var _j: number; export { _j as delete }; - export var _k: number; + var _k: number; export { _k as do }; - export var _l: number; + var _l: number; export { _l as else }; - export var _m: number; + var _m: number; export { _m as enum }; - export var _o: number; + var _o: number; export { _o as export }; - export var _p: number; + var _p: number; export { _p as extends }; - export var _q: number; + var _q: number; export { _q as false }; - export var _r: number; + var _r: number; export { _r as finally }; - export var _s: number; + var _s: number; export { _s as for }; - export var _t: number; + var _t: number; export { _t as function }; - export var _u: number; + var _u: number; export { _u as if }; - export var _v: number; + var _v: number; export { _v as import }; - export var _w: number; + var _w: number; export { _w as in }; - export var _x: number; + var _x: number; export { _x as instanceof }; - export var _y: number; + var _y: number; export { _y as new }; - export var _z: number; + var _z: number; export { _z as null }; - export var _0: number; + var _0: number; export { _0 as return }; - export var _1: number; + var _1: number; export { _1 as super }; - export var _2: number; + var _2: number; export { _2 as switch }; - export var _3: number; + var _3: number; export { _3 as this }; - export var _4: number; + var _4: number; export { _4 as throw }; - export var _5: number; + var _5: number; export { _5 as true }; - export var _6: number; + var _6: number; export { _6 as try }; - export var _7: number; + var _7: number; export { _7 as typeof }; - export var _8: number; + var _8: number; export { _8 as var }; - export var _9: number; + var _9: number; export { _9 as void }; - export var _10: number; + var _10: number; export { _10 as while }; - export var _11: number; + var _11: number; export { _11 as with }; - export var _12: number; + var _12: number; export { _12 as implements }; - export var _13: number; + var _13: number; export { _13 as interface }; - export var _14: number; + var _14: number; export { _14 as let }; - export var _15: number; + var _15: number; export { _15 as package }; - export var _16: number; + var _16: number; export { _16 as private }; - export var _17: number; + var _17: number; export { _17 as protected }; - export var _18: number; + var _18: number; export { _18 as public }; - export var _19: number; + var _19: number; export { _19 as static }; - export var _20: number; + var _20: number; export { _20 as yield }; export var abstract: number; export var as: number; @@ -289,7 +289,7 @@ declare namespace foo { export var string: number; export var symbol: number; export var type: number; - export var _21: number; + var _21: number; export { _21 as undefined }; export var unique: number; export var unknown: number;