From 5c491333823d59d48d4f6376cfd59a68176c8553 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 29 Mar 2018 11:01:05 -0700 Subject: [PATCH] Add regression tests documenting current behavior of #14121 (#22748) --- ...tAssignmentMembersVisibleInAugmentation.js | 39 +++++++++++++++++++ ...gnmentMembersVisibleInAugmentation.symbols | 36 +++++++++++++++++ ...signmentMembersVisibleInAugmentation.types | 36 +++++++++++++++++ ...tAssignmentMembersVisibleInAugmentation.ts | 19 +++++++++ 4 files changed, 130 insertions(+) create mode 100644 tests/baselines/reference/exportAssignmentMembersVisibleInAugmentation.js create mode 100644 tests/baselines/reference/exportAssignmentMembersVisibleInAugmentation.symbols create mode 100644 tests/baselines/reference/exportAssignmentMembersVisibleInAugmentation.types create mode 100644 tests/cases/compiler/exportAssignmentMembersVisibleInAugmentation.ts diff --git a/tests/baselines/reference/exportAssignmentMembersVisibleInAugmentation.js b/tests/baselines/reference/exportAssignmentMembersVisibleInAugmentation.js new file mode 100644 index 00000000000..8690fecc969 --- /dev/null +++ b/tests/baselines/reference/exportAssignmentMembersVisibleInAugmentation.js @@ -0,0 +1,39 @@ +//// [tests/cases/compiler/exportAssignmentMembersVisibleInAugmentation.ts] //// + +//// [index.d.ts] +export = foo; +declare namespace foo { + export type T = number; +} + +//// [a.ts] +import * as foo from "foo"; +declare module "foo" { + export function f(): T; // OK +} + +//// [b.ts] +import * as foo from "foo"; +declare module "foo" { + export function g(): foo.T; // OK +} + + +//// [a.js] +"use strict"; +exports.__esModule = true; +//// [b.js] +"use strict"; +exports.__esModule = true; + + +//// [a.d.ts] +declare module "foo" { + function f(): T; +} +export {}; +//// [b.d.ts] +import * as foo from "foo"; +declare module "foo" { + function g(): foo.T; +} diff --git a/tests/baselines/reference/exportAssignmentMembersVisibleInAugmentation.symbols b/tests/baselines/reference/exportAssignmentMembersVisibleInAugmentation.symbols new file mode 100644 index 00000000000..a5cf5aa514c --- /dev/null +++ b/tests/baselines/reference/exportAssignmentMembersVisibleInAugmentation.symbols @@ -0,0 +1,36 @@ +=== /node_modules/foo/index.d.ts === +export = foo; +>foo : Symbol(foo, Decl(index.d.ts, 0, 13)) + +declare namespace foo { +>foo : Symbol(foo, Decl(index.d.ts, 0, 13), Decl(a.ts, 0, 27), Decl(b.ts, 0, 27)) + + export type T = number; +>T : Symbol(T, Decl(index.d.ts, 1, 23)) +} + +=== /a.ts === +import * as foo from "foo"; +>foo : Symbol(foo, Decl(a.ts, 0, 6)) + +declare module "foo" { +>"foo" : Symbol(foo, Decl(index.d.ts, 0, 13), Decl(a.ts, 0, 27), Decl(b.ts, 0, 27)) + + export function f(): T; // OK +>f : Symbol(f, Decl(a.ts, 1, 22)) +>T : Symbol(T, Decl(index.d.ts, 1, 23)) +} + +=== /b.ts === +import * as foo from "foo"; +>foo : Symbol(foo, Decl(b.ts, 0, 6)) + +declare module "foo" { +>"foo" : Symbol(foo, Decl(index.d.ts, 0, 13), Decl(a.ts, 0, 27), Decl(b.ts, 0, 27)) + + export function g(): foo.T; // OK +>g : Symbol(g, Decl(b.ts, 1, 22)) +>foo : Symbol(foo, Decl(b.ts, 0, 6)) +>T : Symbol(T, Decl(index.d.ts, 1, 23)) +} + diff --git a/tests/baselines/reference/exportAssignmentMembersVisibleInAugmentation.types b/tests/baselines/reference/exportAssignmentMembersVisibleInAugmentation.types new file mode 100644 index 00000000000..74efa10e4d2 --- /dev/null +++ b/tests/baselines/reference/exportAssignmentMembersVisibleInAugmentation.types @@ -0,0 +1,36 @@ +=== /node_modules/foo/index.d.ts === +export = foo; +>foo : any + +declare namespace foo { +>foo : typeof foo + + export type T = number; +>T : number +} + +=== /a.ts === +import * as foo from "foo"; +>foo : typeof foo + +declare module "foo" { +>"foo" : typeof foo + + export function f(): T; // OK +>f : () => number +>T : number +} + +=== /b.ts === +import * as foo from "foo"; +>foo : typeof foo + +declare module "foo" { +>"foo" : typeof foo + + export function g(): foo.T; // OK +>g : () => number +>foo : any +>T : number +} + diff --git a/tests/cases/compiler/exportAssignmentMembersVisibleInAugmentation.ts b/tests/cases/compiler/exportAssignmentMembersVisibleInAugmentation.ts new file mode 100644 index 00000000000..72ac174b044 --- /dev/null +++ b/tests/cases/compiler/exportAssignmentMembersVisibleInAugmentation.ts @@ -0,0 +1,19 @@ +// @declaration: true + +// @Filename: /node_modules/foo/index.d.ts +export = foo; +declare namespace foo { + export type T = number; +} + +// @Filename: /a.ts +import * as foo from "foo"; +declare module "foo" { + export function f(): T; // OK +} + +// @Filename: /b.ts +import * as foo from "foo"; +declare module "foo" { + export function g(): foo.T; // OK +}