From d919f2c113da9a18140577d1278508fe522ba0f7 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Wed, 17 Apr 2019 15:13:09 -0700 Subject: [PATCH] Add test for #28334 --- ...olAssignmentOnGlobalAugmentationSuceeds.js | 18 ++++++++++++ ...ignmentOnGlobalAugmentationSuceeds.symbols | 29 +++++++++++++++++++ ...ssignmentOnGlobalAugmentationSuceeds.types | 28 ++++++++++++++++++ ...olAssignmentOnGlobalAugmentationSuceeds.ts | 13 +++++++++ 4 files changed, 88 insertions(+) create mode 100644 tests/baselines/reference/uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.js create mode 100644 tests/baselines/reference/uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.symbols create mode 100644 tests/baselines/reference/uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.types create mode 100644 tests/cases/compiler/uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts diff --git a/tests/baselines/reference/uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.js b/tests/baselines/reference/uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.js new file mode 100644 index 00000000000..bfb6f0a29c7 --- /dev/null +++ b/tests/baselines/reference/uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.js @@ -0,0 +1,18 @@ +//// [uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts] +const FOO_SYMBOL = Symbol('Foo'); + +declare global { + interface Promise { + [FOO_SYMBOL]?: number; + } +} + +export function foo(p: Promise) { + p[FOO_SYMBOL] = 3; +} + +//// [uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.js] +const FOO_SYMBOL = Symbol('Foo'); +export function foo(p) { + p[FOO_SYMBOL] = 3; +} diff --git a/tests/baselines/reference/uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.symbols b/tests/baselines/reference/uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.symbols new file mode 100644 index 00000000000..17af30e8fac --- /dev/null +++ b/tests/baselines/reference/uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.symbols @@ -0,0 +1,29 @@ +=== tests/cases/compiler/uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts === +const FOO_SYMBOL = Symbol('Foo'); +>FOO_SYMBOL : Symbol(FOO_SYMBOL, Decl(uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts, 0, 5)) +>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) + +declare global { +>global : Symbol(global, Decl(uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts, 0, 33)) + + interface Promise { +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts, 2, 16)) +>T : Symbol(T, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts, 3, 22)) + + [FOO_SYMBOL]?: number; +>[FOO_SYMBOL] : Symbol(Promise[FOO_SYMBOL], Decl(uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts, 3, 26)) +>FOO_SYMBOL : Symbol(FOO_SYMBOL, Decl(uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts, 0, 5)) + } +} + +export function foo(p: Promise) { +>foo : Symbol(foo, Decl(uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts, 6, 1)) +>T : Symbol(T, Decl(uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts, 8, 20)) +>p : Symbol(p, Decl(uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts, 8, 23)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts, 2, 16)) +>T : Symbol(T, Decl(uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts, 8, 20)) + + p[FOO_SYMBOL] = 3; +>p : Symbol(p, Decl(uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts, 8, 23)) +>FOO_SYMBOL : Symbol(FOO_SYMBOL, Decl(uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts, 0, 5)) +} diff --git a/tests/baselines/reference/uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.types b/tests/baselines/reference/uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.types new file mode 100644 index 00000000000..62dcc0607ae --- /dev/null +++ b/tests/baselines/reference/uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.types @@ -0,0 +1,28 @@ +=== tests/cases/compiler/uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts === +const FOO_SYMBOL = Symbol('Foo'); +>FOO_SYMBOL : unique symbol +>Symbol('Foo') : unique symbol +>Symbol : SymbolConstructor +>'Foo' : "Foo" + +declare global { +>global : any + + interface Promise { + [FOO_SYMBOL]?: number; +>[FOO_SYMBOL] : number | undefined +>FOO_SYMBOL : unique symbol + } +} + +export function foo(p: Promise) { +>foo : (p: Promise) => void +>p : Promise + + p[FOO_SYMBOL] = 3; +>p[FOO_SYMBOL] = 3 : 3 +>p[FOO_SYMBOL] : number | undefined +>p : Promise +>FOO_SYMBOL : unique symbol +>3 : 3 +} diff --git a/tests/cases/compiler/uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts b/tests/cases/compiler/uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts new file mode 100644 index 00000000000..f79c2a36e86 --- /dev/null +++ b/tests/cases/compiler/uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts @@ -0,0 +1,13 @@ +// @strict: true +// @target: es6 +const FOO_SYMBOL = Symbol('Foo'); + +declare global { + interface Promise { + [FOO_SYMBOL]?: number; + } +} + +export function foo(p: Promise) { + p[FOO_SYMBOL] = 3; +} \ No newline at end of file