Skip to content

Commit d919f2c

Browse files
committed
Add test for microsoft#28334
1 parent 3af78ae commit d919f2c

4 files changed

+88
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//// [uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts]
2+
const FOO_SYMBOL = Symbol('Foo');
3+
4+
declare global {
5+
interface Promise<T> {
6+
[FOO_SYMBOL]?: number;
7+
}
8+
}
9+
10+
export function foo<T>(p: Promise<T>) {
11+
p[FOO_SYMBOL] = 3;
12+
}
13+
14+
//// [uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.js]
15+
const FOO_SYMBOL = Symbol('Foo');
16+
export function foo(p) {
17+
p[FOO_SYMBOL] = 3;
18+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
=== tests/cases/compiler/uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts ===
2+
const FOO_SYMBOL = Symbol('Foo');
3+
>FOO_SYMBOL : Symbol(FOO_SYMBOL, Decl(uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts, 0, 5))
4+
>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
5+
6+
declare global {
7+
>global : Symbol(global, Decl(uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts, 0, 33))
8+
9+
interface Promise<T> {
10+
>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))
11+
>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))
12+
13+
[FOO_SYMBOL]?: number;
14+
>[FOO_SYMBOL] : Symbol(Promise[FOO_SYMBOL], Decl(uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts, 3, 26))
15+
>FOO_SYMBOL : Symbol(FOO_SYMBOL, Decl(uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts, 0, 5))
16+
}
17+
}
18+
19+
export function foo<T>(p: Promise<T>) {
20+
>foo : Symbol(foo, Decl(uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts, 6, 1))
21+
>T : Symbol(T, Decl(uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts, 8, 20))
22+
>p : Symbol(p, Decl(uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts, 8, 23))
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))
24+
>T : Symbol(T, Decl(uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts, 8, 20))
25+
26+
p[FOO_SYMBOL] = 3;
27+
>p : Symbol(p, Decl(uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts, 8, 23))
28+
>FOO_SYMBOL : Symbol(FOO_SYMBOL, Decl(uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts, 0, 5))
29+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
=== tests/cases/compiler/uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts ===
2+
const FOO_SYMBOL = Symbol('Foo');
3+
>FOO_SYMBOL : unique symbol
4+
>Symbol('Foo') : unique symbol
5+
>Symbol : SymbolConstructor
6+
>'Foo' : "Foo"
7+
8+
declare global {
9+
>global : any
10+
11+
interface Promise<T> {
12+
[FOO_SYMBOL]?: number;
13+
>[FOO_SYMBOL] : number | undefined
14+
>FOO_SYMBOL : unique symbol
15+
}
16+
}
17+
18+
export function foo<T>(p: Promise<T>) {
19+
>foo : <T>(p: Promise<T>) => void
20+
>p : Promise<T>
21+
22+
p[FOO_SYMBOL] = 3;
23+
>p[FOO_SYMBOL] = 3 : 3
24+
>p[FOO_SYMBOL] : number | undefined
25+
>p : Promise<T>
26+
>FOO_SYMBOL : unique symbol
27+
>3 : 3
28+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// @strict: true
2+
// @target: es6
3+
const FOO_SYMBOL = Symbol('Foo');
4+
5+
declare global {
6+
interface Promise<T> {
7+
[FOO_SYMBOL]?: number;
8+
}
9+
}
10+
11+
export function foo<T>(p: Promise<T>) {
12+
p[FOO_SYMBOL] = 3;
13+
}

0 commit comments

Comments
 (0)