mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-11-18 20:11:14 +00:00
Fix getReturnTypeFromBody widening
This commit is contained in:
1 parent
b9dbf5d13b
commit
ae11ae55c5
60 files changed
+3865
-427
No files matched your search
+45
-28
@@ -3360,8 +3360,13 @@ namespace ts {
|
||||
writeAnonymousType(<ObjectType>type, nextFlags);
|
||||
}
|
||||
else if (type.flags & TypeFlags.UniqueESSymbol) {
|
||||
writeKeyword(writer, SyntaxKind.UniqueKeyword);
|
||||
writeSpace(writer);
|
||||
if (flags & TypeFormatFlags.AllowUniqueESSymbolType) {
|
||||
writeKeyword(writer, SyntaxKind.UniqueKeyword);
|
||||
writeSpace(writer);
|
||||
}
|
||||
else {
|
||||
writer.reportInaccessibleUniqueSymbolError();
|
||||
}
|
||||
writeKeyword(writer, SyntaxKind.SymbolKeyword);
|
||||
}
|
||||
else if (type.flags & TypeFlags.StringOrNumberLiteral) {
|
||||
@@ -8365,9 +8370,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getESSymbolLikeTypeForNode(node: Node) {
|
||||
if (isVariableDeclaration(node) ? isConst(node) && isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) :
|
||||
isPropertyDeclaration(node) ? hasReadonlyModifier(node) && hasStaticModifier(node) :
|
||||
isPropertySignature(node) && hasReadonlyModifier(node)) {
|
||||
if (isValidESSymbolDeclaration(node)) {
|
||||
const symbol = getSymbolOfNode(node);
|
||||
const links = getSymbolLinks(symbol);
|
||||
return links.type || (links.type = createUniqueESSymbolType(symbol));
|
||||
@@ -17694,9 +17697,6 @@ namespace ts {
|
||||
// the native Promise<T> type later in this function.
|
||||
type = checkAwaitedType(type, /*errorNode*/ func, Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member);
|
||||
}
|
||||
|
||||
// widen 'unique symbol' types when we infer the return type.
|
||||
type = getWidenedUniqueESSymbolType(type);
|
||||
}
|
||||
else {
|
||||
let types: Type[];
|
||||
@@ -17728,37 +17728,49 @@ namespace ts {
|
||||
: voidType; // Normal function
|
||||
}
|
||||
}
|
||||
|
||||
// Return a union of the return expression types.
|
||||
type = getUnionType(types, /*subtypeReduction*/ true);
|
||||
|
||||
// widen 'unique symbol' types when we infer the return type.
|
||||
type = getWidenedUniqueESSymbolType(type);
|
||||
|
||||
if (functionFlags & FunctionFlags.Generator) { // AsyncGenerator function or Generator function
|
||||
type = functionFlags & FunctionFlags.Async
|
||||
? createAsyncIterableIteratorType(type) // AsyncGenerator function
|
||||
: createIterableIteratorType(type); // Generator function
|
||||
}
|
||||
}
|
||||
|
||||
if (!contextualSignature) {
|
||||
reportErrorsFromWidening(func, type);
|
||||
}
|
||||
|
||||
if (isUnitType(type) &&
|
||||
!(contextualSignature &&
|
||||
isLiteralContextualType(
|
||||
contextualSignature === getSignatureFromDeclaration(func) ? type : getReturnTypeOfSignature(contextualSignature)))) {
|
||||
type = getWidenedLiteralType(type);
|
||||
if (isUnitType(type)) {
|
||||
let contextualType = !contextualSignature ? undefined :
|
||||
contextualSignature === getSignatureFromDeclaration(func) ? type :
|
||||
getReturnTypeOfSignature(contextualSignature);
|
||||
if (contextualType) {
|
||||
switch (functionFlags & FunctionFlags.AsyncGenerator) {
|
||||
case FunctionFlags.AsyncGenerator:
|
||||
contextualType = getIteratedTypeOfGenerator(contextualType, /*isAsyncGenerator*/ true);
|
||||
break;
|
||||
case FunctionFlags.Generator:
|
||||
contextualType = getIteratedTypeOfGenerator(contextualType, /*isAsyncGenerator*/ false);
|
||||
break;
|
||||
case FunctionFlags.Async:
|
||||
contextualType = getPromisedTypeOfPromise(contextualType);
|
||||
break;
|
||||
}
|
||||
}
|
||||
type = getWidenedLiteralLikeTypeForContextualType(type, contextualType);
|
||||
}
|
||||
|
||||
const widenedType = getWidenedType(type);
|
||||
// From within an async function you can return either a non-promise value or a promise. Any
|
||||
// Promise/A+ compatible implementation will always assimilate any foreign promise, so the
|
||||
// return type of the body is awaited type of the body, wrapped in a native Promise<T> type.
|
||||
return (functionFlags & FunctionFlags.AsyncGenerator) === FunctionFlags.Async
|
||||
? createPromiseReturnType(func, widenedType) // Async function
|
||||
: widenedType; // Generator function, AsyncGenerator function, or normal function
|
||||
switch (functionFlags & FunctionFlags.AsyncGenerator) {
|
||||
case FunctionFlags.AsyncGenerator:
|
||||
return createAsyncIterableIteratorType(widenedType);
|
||||
case FunctionFlags.Generator:
|
||||
return createIterableIteratorType(widenedType);
|
||||
case FunctionFlags.Async:
|
||||
// From within an async function you can return either a non-promise value or a promise. Any
|
||||
// Promise/A+ compatible implementation will always assimilate any foreign promise, so the
|
||||
// return type of the body is awaited type of the body, wrapped in a native Promise<T> type.
|
||||
return createPromiseType(widenedType);
|
||||
default:
|
||||
return widenedType;
|
||||
}
|
||||
}
|
||||
|
||||
function checkAndAggregateYieldOperandTypes(func: FunctionLikeDeclaration, checkMode: CheckMode): Type[] {
|
||||
@@ -24627,9 +24639,14 @@ namespace ts {
|
||||
let type = symbol && !(symbol.flags & (SymbolFlags.TypeLiteral | SymbolFlags.Signature))
|
||||
? getWidenedLiteralType(getTypeOfSymbol(symbol))
|
||||
: unknownType;
|
||||
if (type.flags & TypeFlags.UniqueESSymbol &&
|
||||
type.symbol === symbol) {
|
||||
flags |= TypeFormatFlags.AllowUniqueESSymbolType;
|
||||
}
|
||||
if (flags & TypeFormatFlags.AddUndefined) {
|
||||
type = getNullableType(type, TypeFlags.Undefined);
|
||||
}
|
||||
|
||||
getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags);
|
||||
}
|
||||
|
||||
|
||||
@@ -190,6 +190,7 @@ namespace ts {
|
||||
const writer = <EmitTextWriterWithSymbolWriter>createTextWriter(newLine);
|
||||
writer.trackSymbol = trackSymbol;
|
||||
writer.reportInaccessibleThisError = reportInaccessibleThisError;
|
||||
writer.reportInaccessibleUniqueSymbolError = reportInaccessibleUniqueSymbolError;
|
||||
writer.reportPrivateInBaseOfClassExpression = reportPrivateInBaseOfClassExpression;
|
||||
writer.writeKeyword = writer.write;
|
||||
writer.writeOperator = writer.write;
|
||||
@@ -322,11 +323,21 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function reportInaccessibleUniqueSymbolError() {
|
||||
if (errorNameNode) {
|
||||
reportedDeclarationError = true;
|
||||
emitterDiagnostics.add(createDiagnosticForNode(errorNameNode, Diagnostics.The_inferred_type_of_0_references_an_inaccessible_1_type_A_type_annotation_is_necessary,
|
||||
declarationNameToString(errorNameNode),
|
||||
"unique symbol"));
|
||||
}
|
||||
}
|
||||
|
||||
function reportInaccessibleThisError() {
|
||||
if (errorNameNode) {
|
||||
reportedDeclarationError = true;
|
||||
emitterDiagnostics.add(createDiagnosticForNode(errorNameNode, Diagnostics.The_inferred_type_of_0_references_an_inaccessible_this_type_A_type_annotation_is_necessary,
|
||||
declarationNameToString(errorNameNode)));
|
||||
emitterDiagnostics.add(createDiagnosticForNode(errorNameNode, Diagnostics.The_inferred_type_of_0_references_an_inaccessible_1_type_A_type_annotation_is_necessary,
|
||||
declarationNameToString(errorNameNode),
|
||||
"this"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1804,7 +1804,7 @@
|
||||
"category": "Error",
|
||||
"code": 2526
|
||||
},
|
||||
"The inferred type of '{0}' references an inaccessible 'this' type. A type annotation is necessary.": {
|
||||
"The inferred type of '{0}' references an inaccessible '{1}' type. A type annotation is necessary.": {
|
||||
"category": "Error",
|
||||
"code": 2527
|
||||
},
|
||||
|
||||
@@ -2857,6 +2857,7 @@ namespace ts {
|
||||
trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void;
|
||||
reportInaccessibleThisError(): void;
|
||||
reportPrivateInBaseOfClassExpression(propertyName: string): void;
|
||||
reportInaccessibleUniqueSymbolError(): void;
|
||||
}
|
||||
|
||||
export const enum TypeFormatFlags {
|
||||
@@ -2877,6 +2878,7 @@ namespace ts {
|
||||
InArrayType = 1 << 15, // Writing an array element type
|
||||
UseAliasDefinedOutsideCurrentScope = 1 << 16, // For a `type T = ... ` defined in a different file, write `T` instead of its value,
|
||||
// even though `T` can't be accessed in the current scope.
|
||||
AllowUniqueESSymbolType = 1 << 17,
|
||||
}
|
||||
|
||||
export const enum SymbolFormatFlags {
|
||||
|
||||
@@ -56,6 +56,7 @@ namespace ts {
|
||||
clear: () => str = "",
|
||||
trackSymbol: noop,
|
||||
reportInaccessibleThisError: noop,
|
||||
reportInaccessibleUniqueSymbolError: noop,
|
||||
reportPrivateInBaseOfClassExpression: noop,
|
||||
};
|
||||
}
|
||||
@@ -945,6 +946,12 @@ namespace ts {
|
||||
&& node.parent.parent.kind === SyntaxKind.VariableStatement;
|
||||
}
|
||||
|
||||
export function isValidESSymbolDeclaration(node: Node) {
|
||||
return isVariableDeclaration(node) ? isConst(node) && isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) :
|
||||
isPropertyDeclaration(node) ? hasReadonlyModifier(node) && hasStaticModifier(node) :
|
||||
isPropertySignature(node) && hasReadonlyModifier(node);
|
||||
}
|
||||
|
||||
export function introducesArgumentsExoticObject(node: Node) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
|
||||
@@ -246,6 +246,7 @@ namespace ts.codefix {
|
||||
},
|
||||
reportInaccessibleThisError: () => { typeIsAccessible = false; },
|
||||
reportPrivateInBaseOfClassExpression: () => { typeIsAccessible = false; },
|
||||
reportInaccessibleUniqueSymbolError: () => { typeIsAccessible = false; }
|
||||
};
|
||||
}
|
||||
writer.clear();
|
||||
|
||||
@@ -1130,6 +1130,7 @@ namespace ts {
|
||||
clear: resetWriter,
|
||||
trackSymbol: noop,
|
||||
reportInaccessibleThisError: noop,
|
||||
reportInaccessibleUniqueSymbolError: noop,
|
||||
reportPrivateInBaseOfClassExpression: noop,
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
=== tests/cases/conformance/es6/yieldExpressions/YieldStarExpression4_es6.ts ===
|
||||
function *g() {
|
||||
>g : () => IterableIterator<undefined>
|
||||
>g : () => IterableIterator<any>
|
||||
|
||||
yield * [];
|
||||
>yield * [] : any
|
||||
|
||||
@@ -1826,6 +1826,7 @@ declare namespace ts {
|
||||
trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void;
|
||||
reportInaccessibleThisError(): void;
|
||||
reportPrivateInBaseOfClassExpression(propertyName: string): void;
|
||||
reportInaccessibleUniqueSymbolError(): void;
|
||||
}
|
||||
enum TypeFormatFlags {
|
||||
None = 0,
|
||||
@@ -1844,6 +1845,7 @@ declare namespace ts {
|
||||
WriteClassExpressionAsTypeLiteral = 16384,
|
||||
InArrayType = 32768,
|
||||
UseAliasDefinedOutsideCurrentScope = 65536,
|
||||
AllowUniqueESSymbolType = 131072,
|
||||
}
|
||||
enum SymbolFormatFlags {
|
||||
None = 0,
|
||||
|
||||
@@ -1826,6 +1826,7 @@ declare namespace ts {
|
||||
trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void;
|
||||
reportInaccessibleThisError(): void;
|
||||
reportPrivateInBaseOfClassExpression(propertyName: string): void;
|
||||
reportInaccessibleUniqueSymbolError(): void;
|
||||
}
|
||||
enum TypeFormatFlags {
|
||||
None = 0,
|
||||
@@ -1844,6 +1845,7 @@ declare namespace ts {
|
||||
WriteClassExpressionAsTypeLiteral = 16384,
|
||||
InArrayType = 32768,
|
||||
UseAliasDefinedOutsideCurrentScope = 65536,
|
||||
AllowUniqueESSymbolType = 131072,
|
||||
}
|
||||
enum SymbolFormatFlags {
|
||||
None = 0,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
=== tests/cases/compiler/asyncImportNestedYield.ts ===
|
||||
async function* foo() {
|
||||
>foo : () => AsyncIterableIterator<"foo">
|
||||
>foo : () => AsyncIterableIterator<string>
|
||||
|
||||
import((await import(yield "foo")).default);
|
||||
>import((await import(yield "foo")).default) : Promise<any>
|
||||
|
||||
@@ -23,7 +23,7 @@ class C3 {
|
||||
>C3 : C3
|
||||
|
||||
async * f() {
|
||||
>f : () => AsyncIterableIterator<1>
|
||||
>f : () => AsyncIterableIterator<number>
|
||||
|
||||
const x = yield 1;
|
||||
>x : any
|
||||
@@ -50,14 +50,14 @@ class C5 {
|
||||
>C5 : C5
|
||||
|
||||
async * f() {
|
||||
>f : () => AsyncIterableIterator<1>
|
||||
>f : () => AsyncIterableIterator<number>
|
||||
|
||||
const x = yield* (async function*() { yield 1; })();
|
||||
>x : any
|
||||
>yield* (async function*() { yield 1; })() : any
|
||||
>(async function*() { yield 1; })() : AsyncIterableIterator<1>
|
||||
>(async function*() { yield 1; }) : () => AsyncIterableIterator<1>
|
||||
>async function*() { yield 1; } : () => AsyncIterableIterator<1>
|
||||
>(async function*() { yield 1; })() : AsyncIterableIterator<number>
|
||||
>(async function*() { yield 1; }) : () => AsyncIterableIterator<number>
|
||||
>async function*() { yield 1; } : () => AsyncIterableIterator<number>
|
||||
>yield 1 : any
|
||||
>1 : 1
|
||||
}
|
||||
@@ -80,7 +80,7 @@ class C7 {
|
||||
>C7 : C7
|
||||
|
||||
async * f() {
|
||||
>f : () => AsyncIterableIterator<1>
|
||||
>f : () => AsyncIterableIterator<number>
|
||||
|
||||
return 1;
|
||||
>1 : 1
|
||||
|
||||
@@ -23,7 +23,7 @@ class C3 {
|
||||
>C3 : C3
|
||||
|
||||
async * f() {
|
||||
>f : () => AsyncIterableIterator<1>
|
||||
>f : () => AsyncIterableIterator<number>
|
||||
|
||||
const x = yield 1;
|
||||
>x : any
|
||||
@@ -50,14 +50,14 @@ class C5 {
|
||||
>C5 : C5
|
||||
|
||||
async * f() {
|
||||
>f : () => AsyncIterableIterator<1>
|
||||
>f : () => AsyncIterableIterator<number>
|
||||
|
||||
const x = yield* (async function*() { yield 1; })();
|
||||
>x : any
|
||||
>yield* (async function*() { yield 1; })() : any
|
||||
>(async function*() { yield 1; })() : AsyncIterableIterator<1>
|
||||
>(async function*() { yield 1; }) : () => AsyncIterableIterator<1>
|
||||
>async function*() { yield 1; } : () => AsyncIterableIterator<1>
|
||||
>(async function*() { yield 1; })() : AsyncIterableIterator<number>
|
||||
>(async function*() { yield 1; }) : () => AsyncIterableIterator<number>
|
||||
>async function*() { yield 1; } : () => AsyncIterableIterator<number>
|
||||
>yield 1 : any
|
||||
>1 : 1
|
||||
}
|
||||
@@ -80,7 +80,7 @@ class C7 {
|
||||
>C7 : C7
|
||||
|
||||
async * f() {
|
||||
>f : () => AsyncIterableIterator<1>
|
||||
>f : () => AsyncIterableIterator<number>
|
||||
|
||||
return 1;
|
||||
>1 : 1
|
||||
|
||||
@@ -23,7 +23,7 @@ class C3 {
|
||||
>C3 : C3
|
||||
|
||||
async * f() {
|
||||
>f : () => AsyncIterableIterator<1>
|
||||
>f : () => AsyncIterableIterator<number>
|
||||
|
||||
const x = yield 1;
|
||||
>x : any
|
||||
@@ -50,14 +50,14 @@ class C5 {
|
||||
>C5 : C5
|
||||
|
||||
async * f() {
|
||||
>f : () => AsyncIterableIterator<1>
|
||||
>f : () => AsyncIterableIterator<number>
|
||||
|
||||
const x = yield* (async function*() { yield 1; })();
|
||||
>x : any
|
||||
>yield* (async function*() { yield 1; })() : any
|
||||
>(async function*() { yield 1; })() : AsyncIterableIterator<1>
|
||||
>(async function*() { yield 1; }) : () => AsyncIterableIterator<1>
|
||||
>async function*() { yield 1; } : () => AsyncIterableIterator<1>
|
||||
>(async function*() { yield 1; })() : AsyncIterableIterator<number>
|
||||
>(async function*() { yield 1; }) : () => AsyncIterableIterator<number>
|
||||
>async function*() { yield 1; } : () => AsyncIterableIterator<number>
|
||||
>yield 1 : any
|
||||
>1 : 1
|
||||
}
|
||||
@@ -80,7 +80,7 @@ class C7 {
|
||||
>C7 : C7
|
||||
|
||||
async * f() {
|
||||
>f : () => AsyncIterableIterator<1>
|
||||
>f : () => AsyncIterableIterator<number>
|
||||
|
||||
return 1;
|
||||
>1 : 1
|
||||
|
||||
@@ -12,7 +12,7 @@ async function * f2() {
|
||||
}
|
||||
=== tests/cases/conformance/emitter/es2015/asyncGenerators/F3.ts ===
|
||||
async function * f3() {
|
||||
>f3 : () => AsyncIterableIterator<1>
|
||||
>f3 : () => AsyncIterableIterator<number>
|
||||
|
||||
const x = yield 1;
|
||||
>x : any
|
||||
@@ -31,14 +31,14 @@ async function * f4() {
|
||||
}
|
||||
=== tests/cases/conformance/emitter/es2015/asyncGenerators/F5.ts ===
|
||||
async function * f5() {
|
||||
>f5 : () => AsyncIterableIterator<1>
|
||||
>f5 : () => AsyncIterableIterator<number>
|
||||
|
||||
const x = yield* (async function*() { yield 1; })();
|
||||
>x : any
|
||||
>yield* (async function*() { yield 1; })() : any
|
||||
>(async function*() { yield 1; })() : AsyncIterableIterator<1>
|
||||
>(async function*() { yield 1; }) : () => AsyncIterableIterator<1>
|
||||
>async function*() { yield 1; } : () => AsyncIterableIterator<1>
|
||||
>(async function*() { yield 1; })() : AsyncIterableIterator<number>
|
||||
>(async function*() { yield 1; }) : () => AsyncIterableIterator<number>
|
||||
>async function*() { yield 1; } : () => AsyncIterableIterator<number>
|
||||
>yield 1 : any
|
||||
>1 : 1
|
||||
}
|
||||
@@ -53,7 +53,7 @@ async function * f6() {
|
||||
}
|
||||
=== tests/cases/conformance/emitter/es2015/asyncGenerators/F7.ts ===
|
||||
async function * f7() {
|
||||
>f7 : () => AsyncIterableIterator<1>
|
||||
>f7 : () => AsyncIterableIterator<number>
|
||||
|
||||
return 1;
|
||||
>1 : 1
|
||||
|
||||
@@ -12,7 +12,7 @@ async function * f2() {
|
||||
}
|
||||
=== tests/cases/conformance/emitter/es5/asyncGenerators/F3.ts ===
|
||||
async function * f3() {
|
||||
>f3 : () => AsyncIterableIterator<1>
|
||||
>f3 : () => AsyncIterableIterator<number>
|
||||
|
||||
const x = yield 1;
|
||||
>x : any
|
||||
@@ -31,14 +31,14 @@ async function * f4() {
|
||||
}
|
||||
=== tests/cases/conformance/emitter/es5/asyncGenerators/F5.ts ===
|
||||
async function * f5() {
|
||||
>f5 : () => AsyncIterableIterator<1>
|
||||
>f5 : () => AsyncIterableIterator<number>
|
||||
|
||||
const x = yield* (async function*() { yield 1; })();
|
||||
>x : any
|
||||
>yield* (async function*() { yield 1; })() : any
|
||||
>(async function*() { yield 1; })() : AsyncIterableIterator<1>
|
||||
>(async function*() { yield 1; }) : () => AsyncIterableIterator<1>
|
||||
>async function*() { yield 1; } : () => AsyncIterableIterator<1>
|
||||
>(async function*() { yield 1; })() : AsyncIterableIterator<number>
|
||||
>(async function*() { yield 1; }) : () => AsyncIterableIterator<number>
|
||||
>async function*() { yield 1; } : () => AsyncIterableIterator<number>
|
||||
>yield 1 : any
|
||||
>1 : 1
|
||||
}
|
||||
@@ -53,7 +53,7 @@ async function * f6() {
|
||||
}
|
||||
=== tests/cases/conformance/emitter/es5/asyncGenerators/F7.ts ===
|
||||
async function * f7() {
|
||||
>f7 : () => AsyncIterableIterator<1>
|
||||
>f7 : () => AsyncIterableIterator<number>
|
||||
|
||||
return 1;
|
||||
>1 : 1
|
||||
|
||||
@@ -12,7 +12,7 @@ async function * f2() {
|
||||
}
|
||||
=== tests/cases/conformance/emitter/esnext/asyncGenerators/F3.ts ===
|
||||
async function * f3() {
|
||||
>f3 : () => AsyncIterableIterator<1>
|
||||
>f3 : () => AsyncIterableIterator<number>
|
||||
|
||||
const x = yield 1;
|
||||
>x : any
|
||||
@@ -31,14 +31,14 @@ async function * f4() {
|
||||
}
|
||||
=== tests/cases/conformance/emitter/esnext/asyncGenerators/F5.ts ===
|
||||
async function * f5() {
|
||||
>f5 : () => AsyncIterableIterator<1>
|
||||
>f5 : () => AsyncIterableIterator<number>
|
||||
|
||||
const x = yield* (async function*() { yield 1; })();
|
||||
>x : any
|
||||
>yield* (async function*() { yield 1; })() : any
|
||||
>(async function*() { yield 1; })() : AsyncIterableIterator<1>
|
||||
>(async function*() { yield 1; }) : () => AsyncIterableIterator<1>
|
||||
>async function*() { yield 1; } : () => AsyncIterableIterator<1>
|
||||
>(async function*() { yield 1; })() : AsyncIterableIterator<number>
|
||||
>(async function*() { yield 1; }) : () => AsyncIterableIterator<number>
|
||||
>async function*() { yield 1; } : () => AsyncIterableIterator<number>
|
||||
>yield 1 : any
|
||||
>1 : 1
|
||||
}
|
||||
@@ -53,7 +53,7 @@ async function * f6() {
|
||||
}
|
||||
=== tests/cases/conformance/emitter/esnext/asyncGenerators/F7.ts ===
|
||||
async function * f7() {
|
||||
>f7 : () => AsyncIterableIterator<1>
|
||||
>f7 : () => AsyncIterableIterator<number>
|
||||
|
||||
return 1;
|
||||
>1 : 1
|
||||
|
||||
@@ -14,8 +14,8 @@ const f2 = async function * () {
|
||||
}
|
||||
=== tests/cases/conformance/emitter/es2015/asyncGenerators/F3.ts ===
|
||||
const f3 = async function * () {
|
||||
>f3 : () => AsyncIterableIterator<1>
|
||||
>async function * () { const x = yield 1;} : () => AsyncIterableIterator<1>
|
||||
>f3 : () => AsyncIterableIterator<number>
|
||||
>async function * () { const x = yield 1;} : () => AsyncIterableIterator<number>
|
||||
|
||||
const x = yield 1;
|
||||
>x : any
|
||||
@@ -35,15 +35,15 @@ const f4 = async function * () {
|
||||
}
|
||||
=== tests/cases/conformance/emitter/es2015/asyncGenerators/F5.ts ===
|
||||
const f5 = async function * () {
|
||||
>f5 : () => AsyncIterableIterator<1>
|
||||
>async function * () { const x = yield* (async function*() { yield 1; })();} : () => AsyncIterableIterator<1>
|
||||
>f5 : () => AsyncIterableIterator<number>
|
||||
>async function * () { const x = yield* (async function*() { yield 1; })();} : () => AsyncIterableIterator<number>
|
||||
|
||||
const x = yield* (async function*() { yield 1; })();
|
||||
>x : any
|
||||
>yield* (async function*() { yield 1; })() : any
|
||||
>(async function*() { yield 1; })() : AsyncIterableIterator<1>
|
||||
>(async function*() { yield 1; }) : () => AsyncIterableIterator<1>
|
||||
>async function*() { yield 1; } : () => AsyncIterableIterator<1>
|
||||
>(async function*() { yield 1; })() : AsyncIterableIterator<number>
|
||||
>(async function*() { yield 1; }) : () => AsyncIterableIterator<number>
|
||||
>async function*() { yield 1; } : () => AsyncIterableIterator<number>
|
||||
>yield 1 : any
|
||||
>1 : 1
|
||||
}
|
||||
@@ -59,8 +59,8 @@ const f6 = async function * () {
|
||||
}
|
||||
=== tests/cases/conformance/emitter/es2015/asyncGenerators/F7.ts ===
|
||||
const f7 = async function * () {
|
||||
>f7 : () => AsyncIterableIterator<1>
|
||||
>async function * () { return 1;} : () => AsyncIterableIterator<1>
|
||||
>f7 : () => AsyncIterableIterator<number>
|
||||
>async function * () { return 1;} : () => AsyncIterableIterator<number>
|
||||
|
||||
return 1;
|
||||
>1 : 1
|
||||
|
||||
@@ -14,8 +14,8 @@ const f2 = async function * () {
|
||||
}
|
||||
=== tests/cases/conformance/emitter/es5/asyncGenerators/F3.ts ===
|
||||
const f3 = async function * () {
|
||||
>f3 : () => AsyncIterableIterator<1>
|
||||
>async function * () { const x = yield 1;} : () => AsyncIterableIterator<1>
|
||||
>f3 : () => AsyncIterableIterator<number>
|
||||
>async function * () { const x = yield 1;} : () => AsyncIterableIterator<number>
|
||||
|
||||
const x = yield 1;
|
||||
>x : any
|
||||
@@ -35,15 +35,15 @@ const f4 = async function * () {
|
||||
}
|
||||
=== tests/cases/conformance/emitter/es5/asyncGenerators/F5.ts ===
|
||||
const f5 = async function * () {
|
||||
>f5 : () => AsyncIterableIterator<1>
|
||||
>async function * () { const x = yield* (async function*() { yield 1; })();} : () => AsyncIterableIterator<1>
|
||||
>f5 : () => AsyncIterableIterator<number>
|
||||
>async function * () { const x = yield* (async function*() { yield 1; })();} : () => AsyncIterableIterator<number>
|
||||
|
||||
const x = yield* (async function*() { yield 1; })();
|
||||
>x : any
|
||||
>yield* (async function*() { yield 1; })() : any
|
||||
>(async function*() { yield 1; })() : AsyncIterableIterator<1>
|
||||
>(async function*() { yield 1; }) : () => AsyncIterableIterator<1>
|
||||
>async function*() { yield 1; } : () => AsyncIterableIterator<1>
|
||||
>(async function*() { yield 1; })() : AsyncIterableIterator<number>
|
||||
>(async function*() { yield 1; }) : () => AsyncIterableIterator<number>
|
||||
>async function*() { yield 1; } : () => AsyncIterableIterator<number>
|
||||
>yield 1 : any
|
||||
>1 : 1
|
||||
}
|
||||
@@ -59,8 +59,8 @@ const f6 = async function * () {
|
||||
}
|
||||
=== tests/cases/conformance/emitter/es5/asyncGenerators/F7.ts ===
|
||||
const f7 = async function * () {
|
||||
>f7 : () => AsyncIterableIterator<1>
|
||||
>async function * () { return 1;} : () => AsyncIterableIterator<1>
|
||||
>f7 : () => AsyncIterableIterator<number>
|
||||
>async function * () { return 1;} : () => AsyncIterableIterator<number>
|
||||
|
||||
return 1;
|
||||
>1 : 1
|
||||
|
||||
@@ -14,8 +14,8 @@ const f2 = async function * () {
|
||||
}
|
||||
=== tests/cases/conformance/emitter/esnext/asyncGenerators/F3.ts ===
|
||||
const f3 = async function * () {
|
||||
>f3 : () => AsyncIterableIterator<1>
|
||||
>async function * () { const x = yield 1;} : () => AsyncIterableIterator<1>
|
||||
>f3 : () => AsyncIterableIterator<number>
|
||||
>async function * () { const x = yield 1;} : () => AsyncIterableIterator<number>
|
||||
|
||||
const x = yield 1;
|
||||
>x : any
|
||||
@@ -35,15 +35,15 @@ const f4 = async function * () {
|
||||
}
|
||||
=== tests/cases/conformance/emitter/esnext/asyncGenerators/F5.ts ===
|
||||
const f5 = async function * () {
|
||||
>f5 : () => AsyncIterableIterator<1>
|
||||
>async function * () { const x = yield* (async function*() { yield 1; })();} : () => AsyncIterableIterator<1>
|
||||
>f5 : () => AsyncIterableIterator<number>
|
||||
>async function * () { const x = yield* (async function*() { yield 1; })();} : () => AsyncIterableIterator<number>
|
||||
|
||||
const x = yield* (async function*() { yield 1; })();
|
||||
>x : any
|
||||
>yield* (async function*() { yield 1; })() : any
|
||||
>(async function*() { yield 1; })() : AsyncIterableIterator<1>
|
||||
>(async function*() { yield 1; }) : () => AsyncIterableIterator<1>
|
||||
>async function*() { yield 1; } : () => AsyncIterableIterator<1>
|
||||
>(async function*() { yield 1; })() : AsyncIterableIterator<number>
|
||||
>(async function*() { yield 1; }) : () => AsyncIterableIterator<number>
|
||||
>async function*() { yield 1; } : () => AsyncIterableIterator<number>
|
||||
>yield 1 : any
|
||||
>1 : 1
|
||||
}
|
||||
@@ -59,8 +59,8 @@ const f6 = async function * () {
|
||||
}
|
||||
=== tests/cases/conformance/emitter/esnext/asyncGenerators/F7.ts ===
|
||||
const f7 = async function * () {
|
||||
>f7 : () => AsyncIterableIterator<1>
|
||||
>async function * () { return 1;} : () => AsyncIterableIterator<1>
|
||||
>f7 : () => AsyncIterableIterator<number>
|
||||
>async function * () { return 1;} : () => AsyncIterableIterator<number>
|
||||
|
||||
return 1;
|
||||
>1 : 1
|
||||
|
||||
+12
-12
@@ -22,11 +22,11 @@ const o2 = {
|
||||
}
|
||||
=== tests/cases/conformance/emitter/es2015/asyncGenerators/O3.ts ===
|
||||
const o3 = {
|
||||
>o3 : { f(): AsyncIterableIterator<1>; }
|
||||
>{ async * f() { const x = yield 1; }} : { f(): AsyncIterableIterator<1>; }
|
||||
>o3 : { f(): AsyncIterableIterator<number>; }
|
||||
>{ async * f() { const x = yield 1; }} : { f(): AsyncIterableIterator<number>; }
|
||||
|
||||
async * f() {
|
||||
>f : () => AsyncIterableIterator<1>
|
||||
>f : () => AsyncIterableIterator<number>
|
||||
|
||||
const x = yield 1;
|
||||
>x : any
|
||||
@@ -51,18 +51,18 @@ const o4 = {
|
||||
}
|
||||
=== tests/cases/conformance/emitter/es2015/asyncGenerators/O5.ts ===
|
||||
const o5 = {
|
||||
>o5 : { f(): AsyncIterableIterator<1>; }
|
||||
>{ async * f() { const x = yield* (async function*() { yield 1; })(); }} : { f(): AsyncIterableIterator<1>; }
|
||||
>o5 : { f(): AsyncIterableIterator<number>; }
|
||||
>{ async * f() { const x = yield* (async function*() { yield 1; })(); }} : { f(): AsyncIterableIterator<number>; }
|
||||
|
||||
async * f() {
|
||||
>f : () => AsyncIterableIterator<1>
|
||||
>f : () => AsyncIterableIterator<number>
|
||||
|
||||
const x = yield* (async function*() { yield 1; })();
|
||||
>x : any
|
||||
>yield* (async function*() { yield 1; })() : any
|
||||
>(async function*() { yield 1; })() : AsyncIterableIterator<1>
|
||||
>(async function*() { yield 1; }) : () => AsyncIterableIterator<1>
|
||||
>async function*() { yield 1; } : () => AsyncIterableIterator<1>
|
||||
>(async function*() { yield 1; })() : AsyncIterableIterator<number>
|
||||
>(async function*() { yield 1; }) : () => AsyncIterableIterator<number>
|
||||
>async function*() { yield 1; } : () => AsyncIterableIterator<number>
|
||||
>yield 1 : any
|
||||
>1 : 1
|
||||
}
|
||||
@@ -83,11 +83,11 @@ const o6 = {
|
||||
}
|
||||
=== tests/cases/conformance/emitter/es2015/asyncGenerators/O7.ts ===
|
||||
const o7 = {
|
||||
>o7 : { f(): AsyncIterableIterator<1>; }
|
||||
>{ async * f() { return 1; }} : { f(): AsyncIterableIterator<1>; }
|
||||
>o7 : { f(): AsyncIterableIterator<number>; }
|
||||
>{ async * f() { return 1; }} : { f(): AsyncIterableIterator<number>; }
|
||||
|
||||
async * f() {
|
||||
>f : () => AsyncIterableIterator<1>
|
||||
>f : () => AsyncIterableIterator<number>
|
||||
|
||||
return 1;
|
||||
>1 : 1
|
||||
|
||||
@@ -22,11 +22,11 @@ const o2 = {
|
||||
}
|
||||
=== tests/cases/conformance/emitter/es5/asyncGenerators/O3.ts ===
|
||||
const o3 = {
|
||||
>o3 : { f(): AsyncIterableIterator<1>; }
|
||||
>{ async * f() { const x = yield 1; }} : { f(): AsyncIterableIterator<1>; }
|
||||
>o3 : { f(): AsyncIterableIterator<number>; }
|
||||
>{ async * f() { const x = yield 1; }} : { f(): AsyncIterableIterator<number>; }
|
||||
|
||||
async * f() {
|
||||
>f : () => AsyncIterableIterator<1>
|
||||
>f : () => AsyncIterableIterator<number>
|
||||
|
||||
const x = yield 1;
|
||||
>x : any
|
||||
@@ -51,18 +51,18 @@ const o4 = {
|
||||
}
|
||||
=== tests/cases/conformance/emitter/es5/asyncGenerators/O5.ts ===
|
||||
const o5 = {
|
||||
>o5 : { f(): AsyncIterableIterator<1>; }
|
||||
>{ async * f() { const x = yield* (async function*() { yield 1; })(); }} : { f(): AsyncIterableIterator<1>; }
|
||||
>o5 : { f(): AsyncIterableIterator<number>; }
|
||||
>{ async * f() { const x = yield* (async function*() { yield 1; })(); }} : { f(): AsyncIterableIterator<number>; }
|
||||
|
||||
async * f() {
|
||||
>f : () => AsyncIterableIterator<1>
|
||||
>f : () => AsyncIterableIterator<number>
|
||||
|
||||
const x = yield* (async function*() { yield 1; })();
|
||||
>x : any
|
||||
>yield* (async function*() { yield 1; })() : any
|
||||
>(async function*() { yield 1; })() : AsyncIterableIterator<1>
|
||||
>(async function*() { yield 1; }) : () => AsyncIterableIterator<1>
|
||||
>async function*() { yield 1; } : () => AsyncIterableIterator<1>
|
||||
>(async function*() { yield 1; })() : AsyncIterableIterator<number>
|
||||
>(async function*() { yield 1; }) : () => AsyncIterableIterator<number>
|
||||
>async function*() { yield 1; } : () => AsyncIterableIterator<number>
|
||||
>yield 1 : any
|
||||
>1 : 1
|
||||
}
|
||||
@@ -83,11 +83,11 @@ const o6 = {
|
||||
}
|
||||
=== tests/cases/conformance/emitter/es5/asyncGenerators/O7.ts ===
|
||||
const o7 = {
|
||||
>o7 : { f(): AsyncIterableIterator<1>; }
|
||||
>{ async * f() { return 1; }} : { f(): AsyncIterableIterator<1>; }
|
||||
>o7 : { f(): AsyncIterableIterator<number>; }
|
||||
>{ async * f() { return 1; }} : { f(): AsyncIterableIterator<number>; }
|
||||
|
||||
async * f() {
|
||||
>f : () => AsyncIterableIterator<1>
|
||||
>f : () => AsyncIterableIterator<number>
|
||||
|
||||
return 1;
|
||||
>1 : 1
|
||||
|
||||
+12
-12
@@ -22,11 +22,11 @@ const o2 = {
|
||||
}
|
||||
=== tests/cases/conformance/emitter/esnext/asyncGenerators/O3.ts ===
|
||||
const o3 = {
|
||||
>o3 : { f(): AsyncIterableIterator<1>; }
|
||||
>{ async * f() { const x = yield 1; }} : { f(): AsyncIterableIterator<1>; }
|
||||
>o3 : { f(): AsyncIterableIterator<number>; }
|
||||
>{ async * f() { const x = yield 1; }} : { f(): AsyncIterableIterator<number>; }
|
||||
|
||||
async * f() {
|
||||
>f : () => AsyncIterableIterator<1>
|
||||
>f : () => AsyncIterableIterator<number>
|
||||
|
||||
const x = yield 1;
|
||||
>x : any
|
||||
@@ -51,18 +51,18 @@ const o4 = {
|
||||
}
|
||||
=== tests/cases/conformance/emitter/esnext/asyncGenerators/O5.ts ===
|
||||
const o5 = {
|
||||
>o5 : { f(): AsyncIterableIterator<1>; }
|
||||
>{ async * f() { const x = yield* (async function*() { yield 1; })(); }} : { f(): AsyncIterableIterator<1>; }
|
||||
>o5 : { f(): AsyncIterableIterator<number>; }
|
||||
>{ async * f() { const x = yield* (async function*() { yield 1; })(); }} : { f(): AsyncIterableIterator<number>; }
|
||||
|
||||
async * f() {
|
||||
>f : () => AsyncIterableIterator<1>
|
||||
>f : () => AsyncIterableIterator<number>
|
||||
|
||||
const x = yield* (async function*() { yield 1; })();
|
||||
>x : any
|
||||
>yield* (async function*() { yield 1; })() : any
|
||||
>(async function*() { yield 1; })() : AsyncIterableIterator<1>
|
||||
>(async function*() { yield 1; }) : () => AsyncIterableIterator<1>
|
||||
>async function*() { yield 1; } : () => AsyncIterableIterator<1>
|
||||
>(async function*() { yield 1; })() : AsyncIterableIterator<number>
|
||||
>(async function*() { yield 1; }) : () => AsyncIterableIterator<number>
|
||||
>async function*() { yield 1; } : () => AsyncIterableIterator<number>
|
||||
>yield 1 : any
|
||||
>1 : 1
|
||||
}
|
||||
@@ -83,11 +83,11 @@ const o6 = {
|
||||
}
|
||||
=== tests/cases/conformance/emitter/esnext/asyncGenerators/O7.ts ===
|
||||
const o7 = {
|
||||
>o7 : { f(): AsyncIterableIterator<1>; }
|
||||
>{ async * f() { return 1; }} : { f(): AsyncIterableIterator<1>; }
|
||||
>o7 : { f(): AsyncIterableIterator<number>; }
|
||||
>{ async * f() { return 1; }} : { f(): AsyncIterableIterator<number>; }
|
||||
|
||||
async * f() {
|
||||
>f : () => AsyncIterableIterator<1>
|
||||
>f : () => AsyncIterableIterator<number>
|
||||
|
||||
return 1;
|
||||
>1 : 1
|
||||
|
||||
@@ -3,7 +3,7 @@ class C {
|
||||
>C : C
|
||||
|
||||
public * foo() {
|
||||
>foo : () => IterableIterator<1>
|
||||
>foo : () => IterableIterator<number>
|
||||
|
||||
yield 1
|
||||
>yield 1 : any
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
=== tests/cases/compiler/generatorES6_3.ts ===
|
||||
var v = function*() {
|
||||
>v : () => IterableIterator<0>
|
||||
>function*() { yield 0} : () => IterableIterator<0>
|
||||
>v : () => IterableIterator<number>
|
||||
>function*() { yield 0} : () => IterableIterator<number>
|
||||
|
||||
yield 0
|
||||
>yield 0 : any
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
=== tests/cases/compiler/generatorES6_4.ts ===
|
||||
var v = {
|
||||
>v : { foo(): IterableIterator<0>; }
|
||||
>{ *foo() { yield 0 }} : { foo(): IterableIterator<0>; }
|
||||
>v : { foo(): IterableIterator<number>; }
|
||||
>{ *foo() { yield 0 }} : { foo(): IterableIterator<number>; }
|
||||
|
||||
*foo() {
|
||||
>foo : () => IterableIterator<0>
|
||||
>foo : () => IterableIterator<number>
|
||||
|
||||
yield 0
|
||||
>yield 0 : any
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck15.ts ===
|
||||
function* g() {
|
||||
>g : () => IterableIterator<"">
|
||||
>g : () => IterableIterator<string>
|
||||
|
||||
return "";
|
||||
>"" : ""
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck33.ts ===
|
||||
function* g() {
|
||||
>g : () => IterableIterator<0>
|
||||
>g : () => IterableIterator<number>
|
||||
|
||||
yield 0;
|
||||
>yield 0 : any
|
||||
>0 : 0
|
||||
|
||||
function* g2() {
|
||||
>g2 : () => IterableIterator<"">
|
||||
>g2 : () => IterableIterator<string>
|
||||
|
||||
yield "";
|
||||
>yield "" : any
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck34.ts ===
|
||||
function* g() {
|
||||
>g : () => IterableIterator<0>
|
||||
>g : () => IterableIterator<number>
|
||||
|
||||
yield 0;
|
||||
>yield 0 : any
|
||||
>0 : 0
|
||||
|
||||
function* g2() {
|
||||
>g2 : () => IterableIterator<"">
|
||||
>g2 : () => IterableIterator<string>
|
||||
|
||||
return "";
|
||||
>"" : ""
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck35.ts ===
|
||||
function* g() {
|
||||
>g : () => IterableIterator<0>
|
||||
>g : () => IterableIterator<number>
|
||||
|
||||
yield 0;
|
||||
>yield 0 : any
|
||||
|
||||
@@ -3,7 +3,7 @@ var yield;
|
||||
>yield : any
|
||||
|
||||
function* g() {
|
||||
>g : () => IterableIterator<0>
|
||||
>g : () => IterableIterator<number>
|
||||
|
||||
yield 0;
|
||||
>yield 0 : any
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck41.ts ===
|
||||
function* g() {
|
||||
>g : () => IterableIterator<0>
|
||||
>g : () => IterableIterator<number>
|
||||
|
||||
let x = {
|
||||
>x : { [x: number]: number; }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck42.ts ===
|
||||
function* g() {
|
||||
>g : () => IterableIterator<0>
|
||||
>g : () => IterableIterator<number>
|
||||
|
||||
let x = {
|
||||
>x : { [x: number]: () => void; }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck43.ts ===
|
||||
function* g() {
|
||||
>g : () => IterableIterator<0>
|
||||
>g : () => IterableIterator<number>
|
||||
|
||||
let x = {
|
||||
>x : { [x: number]: () => IterableIterator<any>; }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck44.ts ===
|
||||
function* g() {
|
||||
>g : () => IterableIterator<0>
|
||||
>g : () => IterableIterator<number>
|
||||
|
||||
let x = {
|
||||
>x : { [x: number]: number; }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck49.ts ===
|
||||
function* g() {
|
||||
>g : () => IterableIterator<0>
|
||||
>g : () => IterableIterator<number>
|
||||
|
||||
yield 0;
|
||||
>yield 0 : any
|
||||
|
||||
@@ -3,7 +3,7 @@ function* g() {
|
||||
>g : () => IterableIterator<any>
|
||||
|
||||
function* h() {
|
||||
>h : () => IterableIterator<0>
|
||||
>h : () => IterableIterator<number>
|
||||
|
||||
yield 0;
|
||||
>yield 0 : any
|
||||
|
||||
@@ -3,9 +3,9 @@ tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(24,61): err
|
||||
Type 'State | 1' is not assignable to type 'StrategicState'.
|
||||
Type '1' has no properties in common with type 'StrategicState'.
|
||||
tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(29,70): error TS7025: Generator implicitly has type 'IterableIterator<any>' because it does not yield any values. Consider supplying a return type.
|
||||
tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(32,62): error TS2345: Argument of type '(state: State) => IterableIterator<1>' is not assignable to parameter of type '(a: State) => IterableIterator<State>'.
|
||||
Type 'IterableIterator<1>' is not assignable to type 'IterableIterator<State>'.
|
||||
Type '1' is not assignable to type 'State'.
|
||||
tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(32,62): error TS2345: Argument of type '(state: State) => IterableIterator<number>' is not assignable to parameter of type '(a: State) => IterableIterator<State>'.
|
||||
Type 'IterableIterator<number>' is not assignable to type 'IterableIterator<State>'.
|
||||
Type 'number' is not assignable to type 'State'.
|
||||
tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(36,62): error TS2345: Argument of type '(state: State) => IterableIterator<State | 1>' is not assignable to parameter of type '(a: StrategicState) => IterableIterator<StrategicState>'.
|
||||
Type 'IterableIterator<State | 1>' is not assignable to type 'IterableIterator<StrategicState>'.
|
||||
|
||||
@@ -51,9 +51,9 @@ tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(36,62): err
|
||||
|
||||
export const Nothing2: Strategy<State> = strategy("Nothing", function* (state: State) {
|
||||
~~~~~~~~
|
||||
!!! error TS2345: Argument of type '(state: State) => IterableIterator<1>' is not assignable to parameter of type '(a: State) => IterableIterator<State>'.
|
||||
!!! error TS2345: Type 'IterableIterator<1>' is not assignable to type 'IterableIterator<State>'.
|
||||
!!! error TS2345: Type '1' is not assignable to type 'State'.
|
||||
!!! error TS2345: Argument of type '(state: State) => IterableIterator<number>' is not assignable to parameter of type '(a: State) => IterableIterator<State>'.
|
||||
!!! error TS2345: Type 'IterableIterator<number>' is not assignable to type 'IterableIterator<State>'.
|
||||
!!! error TS2345: Type 'number' is not assignable to type 'State'.
|
||||
return 1;
|
||||
});
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ export const Nothing2: Strategy<State> = strategy("Nothing", function* (state: S
|
||||
>strategy("Nothing", function* (state: State) { return 1;}) : any
|
||||
>strategy : <T extends StrategicState>(stratName: string, gen: (a: T) => IterableIterator<T>) => (a: T) => IterableIterator<T>
|
||||
>"Nothing" : "Nothing"
|
||||
>function* (state: State) { return 1;} : (state: State) => IterableIterator<1>
|
||||
>function* (state: State) { return 1;} : (state: State) => IterableIterator<number>
|
||||
>state : State
|
||||
>State : State
|
||||
|
||||
|
||||
@@ -151,7 +151,7 @@ class C14 {
|
||||
>C14 : C14
|
||||
|
||||
async * f() {
|
||||
>f : () => AsyncIterableIterator<1>
|
||||
>f : () => AsyncIterableIterator<number>
|
||||
|
||||
yield 1;
|
||||
>yield 1 : any
|
||||
@@ -175,7 +175,7 @@ class C16 {
|
||||
>C16 : C16
|
||||
|
||||
async * f() {
|
||||
>f : () => AsyncIterableIterator<undefined>
|
||||
>f : () => AsyncIterableIterator<any>
|
||||
|
||||
yield * [];
|
||||
>yield * [] : any
|
||||
|
||||
@@ -95,7 +95,7 @@ async function * f13() {
|
||||
}
|
||||
=== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldWithValueIsOk.ts ===
|
||||
async function * f14() {
|
||||
>f14 : () => AsyncIterableIterator<1>
|
||||
>f14 : () => AsyncIterableIterator<number>
|
||||
|
||||
yield 1;
|
||||
>yield 1 : any
|
||||
@@ -111,7 +111,7 @@ async function * f15() {
|
||||
}
|
||||
=== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldStarWithValueIsOk.ts ===
|
||||
async function * f16() {
|
||||
>f16 : () => AsyncIterableIterator<undefined>
|
||||
>f16 : () => AsyncIterableIterator<any>
|
||||
|
||||
yield * [];
|
||||
>yield * [] : any
|
||||
|
||||
@@ -122,8 +122,8 @@ const f13 = async function * () {
|
||||
};
|
||||
=== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldWithValueIsOk.ts ===
|
||||
const f14 = async function * () {
|
||||
>f14 : () => AsyncIterableIterator<1>
|
||||
>async function * () { yield 1;} : () => AsyncIterableIterator<1>
|
||||
>f14 : () => AsyncIterableIterator<number>
|
||||
>async function * () { yield 1;} : () => AsyncIterableIterator<number>
|
||||
|
||||
yield 1;
|
||||
>yield 1 : any
|
||||
@@ -142,8 +142,8 @@ const f15 = async function * () {
|
||||
};
|
||||
=== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldStarWithValueIsOk.ts ===
|
||||
const f16 = async function * () {
|
||||
>f16 : () => AsyncIterableIterator<undefined>
|
||||
>async function * () { yield * [];} : () => AsyncIterableIterator<undefined>
|
||||
>f16 : () => AsyncIterableIterator<any>
|
||||
>async function * () { yield * [];} : () => AsyncIterableIterator<any>
|
||||
|
||||
yield * [];
|
||||
>yield * [] : any
|
||||
|
||||
@@ -163,11 +163,11 @@ const o13 = {
|
||||
};
|
||||
=== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldWithValueIsOk.ts ===
|
||||
const o14 = {
|
||||
>o14 : { f(): AsyncIterableIterator<1>; }
|
||||
>{ async * f() { yield 1; }} : { f(): AsyncIterableIterator<1>; }
|
||||
>o14 : { f(): AsyncIterableIterator<number>; }
|
||||
>{ async * f() { yield 1; }} : { f(): AsyncIterableIterator<number>; }
|
||||
|
||||
async * f() {
|
||||
>f : () => AsyncIterableIterator<1>
|
||||
>f : () => AsyncIterableIterator<number>
|
||||
|
||||
yield 1;
|
||||
>yield 1 : any
|
||||
@@ -189,11 +189,11 @@ const o15 = {
|
||||
};
|
||||
=== tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldStarWithValueIsOk.ts ===
|
||||
const o16 = {
|
||||
>o16 : { f(): AsyncIterableIterator<undefined>; }
|
||||
>{ async * f() { yield * []; }} : { f(): AsyncIterableIterator<undefined>; }
|
||||
>o16 : { f(): AsyncIterableIterator<any>; }
|
||||
>{ async * f() { yield * []; }} : { f(): AsyncIterableIterator<any>; }
|
||||
|
||||
async * f() {
|
||||
>f : () => AsyncIterableIterator<undefined>
|
||||
>f : () => AsyncIterableIterator<any>
|
||||
|
||||
yield * [];
|
||||
>yield * [] : any
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
=== tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeywordES6.ts ===
|
||||
function* gen() {
|
||||
>gen : () => IterableIterator<10>
|
||||
>gen : () => IterableIterator<number>
|
||||
|
||||
// Once this is supported, yield *must* be parenthesized.
|
||||
var x = `abc${ yield 10 }def`;
|
||||
|
||||
@@ -9,7 +9,7 @@ async function * inferReturnType2() {
|
||||
>yield : any
|
||||
}
|
||||
async function * inferReturnType3() {
|
||||
>inferReturnType3 : () => AsyncIterableIterator<1>
|
||||
>inferReturnType3 : () => AsyncIterableIterator<number>
|
||||
|
||||
yield 1;
|
||||
>yield 1 : any
|
||||
@@ -63,20 +63,20 @@ async function * inferReturnType7() {
|
||||
>1 : 1
|
||||
}
|
||||
async function * inferReturnType8() {
|
||||
>inferReturnType8 : () => AsyncIterableIterator<1>
|
||||
>inferReturnType8 : () => AsyncIterableIterator<number>
|
||||
|
||||
yield* (async function * () { yield 1; })();
|
||||
>yield* (async function * () { yield 1; })() : any
|
||||
>(async function * () { yield 1; })() : AsyncIterableIterator<1>
|
||||
>(async function * () { yield 1; }) : () => AsyncIterableIterator<1>
|
||||
>async function * () { yield 1; } : () => AsyncIterableIterator<1>
|
||||
>(async function * () { yield 1; })() : AsyncIterableIterator<number>
|
||||
>(async function * () { yield 1; }) : () => AsyncIterableIterator<number>
|
||||
>async function * () { yield 1; } : () => AsyncIterableIterator<number>
|
||||
>yield 1 : any
|
||||
>1 : 1
|
||||
}
|
||||
const assignability1: () => AsyncIterableIterator<number> = async function * () {
|
||||
>assignability1 : () => AsyncIterableIterator<number>
|
||||
>AsyncIterableIterator : AsyncIterableIterator<T>
|
||||
>async function * () { yield 1;} : () => AsyncIterableIterator<1>
|
||||
>async function * () { yield 1;} : () => AsyncIterableIterator<number>
|
||||
|
||||
yield 1;
|
||||
>yield 1 : any
|
||||
@@ -127,13 +127,13 @@ const assignability4: () => AsyncIterableIterator<number> = async function * ()
|
||||
const assignability5: () => AsyncIterableIterator<number> = async function * () {
|
||||
>assignability5 : () => AsyncIterableIterator<number>
|
||||
>AsyncIterableIterator : AsyncIterableIterator<T>
|
||||
>async function * () { yield* (async function * () { yield 1; })();} : () => AsyncIterableIterator<1>
|
||||
>async function * () { yield* (async function * () { yield 1; })();} : () => AsyncIterableIterator<number>
|
||||
|
||||
yield* (async function * () { yield 1; })();
|
||||
>yield* (async function * () { yield 1; })() : any
|
||||
>(async function * () { yield 1; })() : AsyncIterableIterator<1>
|
||||
>(async function * () { yield 1; }) : () => AsyncIterableIterator<1>
|
||||
>async function * () { yield 1; } : () => AsyncIterableIterator<1>
|
||||
>(async function * () { yield 1; })() : AsyncIterableIterator<number>
|
||||
>(async function * () { yield 1; }) : () => AsyncIterableIterator<number>
|
||||
>async function * () { yield 1; } : () => AsyncIterableIterator<number>
|
||||
>yield 1 : any
|
||||
>1 : 1
|
||||
|
||||
@@ -141,7 +141,7 @@ const assignability5: () => AsyncIterableIterator<number> = async function * ()
|
||||
const assignability6: () => AsyncIterable<number> = async function * () {
|
||||
>assignability6 : () => AsyncIterable<number>
|
||||
>AsyncIterable : AsyncIterable<T>
|
||||
>async function * () { yield 1;} : () => AsyncIterableIterator<1>
|
||||
>async function * () { yield 1;} : () => AsyncIterableIterator<number>
|
||||
|
||||
yield 1;
|
||||
>yield 1 : any
|
||||
@@ -192,13 +192,13 @@ const assignability9: () => AsyncIterable<number> = async function * () {
|
||||
const assignability10: () => AsyncIterable<number> = async function * () {
|
||||
>assignability10 : () => AsyncIterable<number>
|
||||
>AsyncIterable : AsyncIterable<T>
|
||||
>async function * () { yield* (async function * () { yield 1; })();} : () => AsyncIterableIterator<1>
|
||||
>async function * () { yield* (async function * () { yield 1; })();} : () => AsyncIterableIterator<number>
|
||||
|
||||
yield* (async function * () { yield 1; })();
|
||||
>yield* (async function * () { yield 1; })() : any
|
||||
>(async function * () { yield 1; })() : AsyncIterableIterator<1>
|
||||
>(async function * () { yield 1; }) : () => AsyncIterableIterator<1>
|
||||
>async function * () { yield 1; } : () => AsyncIterableIterator<1>
|
||||
>(async function * () { yield 1; })() : AsyncIterableIterator<number>
|
||||
>(async function * () { yield 1; }) : () => AsyncIterableIterator<number>
|
||||
>async function * () { yield 1; } : () => AsyncIterableIterator<number>
|
||||
>yield 1 : any
|
||||
>1 : 1
|
||||
|
||||
@@ -206,7 +206,7 @@ const assignability10: () => AsyncIterable<number> = async function * () {
|
||||
const assignability11: () => AsyncIterator<number> = async function * () {
|
||||
>assignability11 : () => AsyncIterator<number>
|
||||
>AsyncIterator : AsyncIterator<T>
|
||||
>async function * () { yield 1;} : () => AsyncIterableIterator<1>
|
||||
>async function * () { yield 1;} : () => AsyncIterableIterator<number>
|
||||
|
||||
yield 1;
|
||||
>yield 1 : any
|
||||
@@ -257,13 +257,13 @@ const assignability14: () => AsyncIterator<number> = async function * () {
|
||||
const assignability15: () => AsyncIterator<number> = async function * () {
|
||||
>assignability15 : () => AsyncIterator<number>
|
||||
>AsyncIterator : AsyncIterator<T>
|
||||
>async function * () { yield* (async function * () { yield 1; })();} : () => AsyncIterableIterator<1>
|
||||
>async function * () { yield* (async function * () { yield 1; })();} : () => AsyncIterableIterator<number>
|
||||
|
||||
yield* (async function * () { yield 1; })();
|
||||
>yield* (async function * () { yield 1; })() : any
|
||||
>(async function * () { yield 1; })() : AsyncIterableIterator<1>
|
||||
>(async function * () { yield 1; }) : () => AsyncIterableIterator<1>
|
||||
>async function * () { yield 1; } : () => AsyncIterableIterator<1>
|
||||
>(async function * () { yield 1; })() : AsyncIterableIterator<number>
|
||||
>(async function * () { yield 1; }) : () => AsyncIterableIterator<number>
|
||||
>async function * () { yield 1; } : () => AsyncIterableIterator<number>
|
||||
>yield 1 : any
|
||||
>1 : 1
|
||||
|
||||
@@ -317,9 +317,9 @@ async function * explicitReturnType5(): AsyncIterableIterator<number> {
|
||||
|
||||
yield* (async function * () { yield 1; })();
|
||||
>yield* (async function * () { yield 1; })() : any
|
||||
>(async function * () { yield 1; })() : AsyncIterableIterator<1>
|
||||
>(async function * () { yield 1; }) : () => AsyncIterableIterator<1>
|
||||
>async function * () { yield 1; } : () => AsyncIterableIterator<1>
|
||||
>(async function * () { yield 1; })() : AsyncIterableIterator<number>
|
||||
>(async function * () { yield 1; }) : () => AsyncIterableIterator<number>
|
||||
>async function * () { yield 1; } : () => AsyncIterableIterator<number>
|
||||
>yield 1 : any
|
||||
>1 : 1
|
||||
}
|
||||
@@ -372,9 +372,9 @@ async function * explicitReturnType10(): AsyncIterable<number> {
|
||||
|
||||
yield* (async function * () { yield 1; })();
|
||||
>yield* (async function * () { yield 1; })() : any
|
||||
>(async function * () { yield 1; })() : AsyncIterableIterator<1>
|
||||
>(async function * () { yield 1; }) : () => AsyncIterableIterator<1>
|
||||
>async function * () { yield 1; } : () => AsyncIterableIterator<1>
|
||||
>(async function * () { yield 1; })() : AsyncIterableIterator<number>
|
||||
>(async function * () { yield 1; }) : () => AsyncIterableIterator<number>
|
||||
>async function * () { yield 1; } : () => AsyncIterableIterator<number>
|
||||
>yield 1 : any
|
||||
>1 : 1
|
||||
}
|
||||
@@ -427,9 +427,9 @@ async function * explicitReturnType15(): AsyncIterator<number> {
|
||||
|
||||
yield* (async function * () { yield 1; })();
|
||||
>yield* (async function * () { yield 1; })() : any
|
||||
>(async function * () { yield 1; })() : AsyncIterableIterator<1>
|
||||
>(async function * () { yield 1; }) : () => AsyncIterableIterator<1>
|
||||
>async function * () { yield 1; } : () => AsyncIterableIterator<1>
|
||||
>(async function * () { yield 1; })() : AsyncIterableIterator<number>
|
||||
>(async function * () { yield 1; }) : () => AsyncIterableIterator<number>
|
||||
>async function * () { yield 1; } : () => AsyncIterableIterator<number>
|
||||
>yield 1 : any
|
||||
>1 : 1
|
||||
}
|
||||
|
||||
@@ -1,24 +1,13 @@
|
||||
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(2,12): error TS2504: Type must have a '[Symbol.asyncIterator]()' method that returns an async iterator.
|
||||
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(8,12): error TS2504: Type must have a '[Symbol.asyncIterator]()' method that returns an async iterator.
|
||||
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(10,7): error TS2322: Type '() => AsyncIterableIterator<"a">' is not assignable to type '() => AsyncIterableIterator<number>'.
|
||||
Type 'AsyncIterableIterator<"a">' is not assignable to type 'AsyncIterableIterator<number>'.
|
||||
Type '"a"' is not assignable to type 'number'.
|
||||
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(13,7): error TS2322: Type '() => AsyncIterableIterator<string>' is not assignable to type '() => AsyncIterableIterator<number>'.
|
||||
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(10,7): error TS2322: Type '() => AsyncIterableIterator<string>' is not assignable to type '() => AsyncIterableIterator<number>'.
|
||||
Type 'AsyncIterableIterator<string>' is not assignable to type 'AsyncIterableIterator<number>'.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(16,7): error TS2322: Type '() => AsyncIterableIterator<"a">' is not assignable to type '() => AsyncIterableIterator<number>'.
|
||||
Type 'AsyncIterableIterator<"a">' is not assignable to type 'AsyncIterableIterator<number>'.
|
||||
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(19,7): error TS2322: Type '() => AsyncIterableIterator<"a">' is not assignable to type '() => AsyncIterable<number>'.
|
||||
Type 'AsyncIterableIterator<"a">' is not assignable to type 'AsyncIterable<number>'.
|
||||
Types of property '[Symbol.asyncIterator]' are incompatible.
|
||||
Type '() => AsyncIterableIterator<"a">' is not assignable to type '() => AsyncIterator<number>'.
|
||||
Type 'AsyncIterableIterator<"a">' is not assignable to type 'AsyncIterator<number>'.
|
||||
Types of property 'next' are incompatible.
|
||||
Type '(value?: any) => Promise<IteratorResult<"a">>' is not assignable to type '(value?: any) => Promise<IteratorResult<number>>'.
|
||||
Type 'Promise<IteratorResult<"a">>' is not assignable to type 'Promise<IteratorResult<number>>'.
|
||||
Type 'IteratorResult<"a">' is not assignable to type 'IteratorResult<number>'.
|
||||
Type '"a"' is not assignable to type 'number'.
|
||||
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(22,7): error TS2322: Type '() => AsyncIterableIterator<string>' is not assignable to type '() => AsyncIterable<number>'.
|
||||
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(13,7): error TS2322: Type '() => AsyncIterableIterator<string>' is not assignable to type '() => AsyncIterableIterator<number>'.
|
||||
Type 'AsyncIterableIterator<string>' is not assignable to type 'AsyncIterableIterator<number>'.
|
||||
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(16,7): error TS2322: Type '() => AsyncIterableIterator<string>' is not assignable to type '() => AsyncIterableIterator<number>'.
|
||||
Type 'AsyncIterableIterator<string>' is not assignable to type 'AsyncIterableIterator<number>'.
|
||||
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(19,7): error TS2322: Type '() => AsyncIterableIterator<string>' is not assignable to type '() => AsyncIterable<number>'.
|
||||
Type 'AsyncIterableIterator<string>' is not assignable to type 'AsyncIterable<number>'.
|
||||
Types of property '[Symbol.asyncIterator]' are incompatible.
|
||||
Type '() => AsyncIterableIterator<string>' is not assignable to type '() => AsyncIterator<number>'.
|
||||
@@ -28,23 +17,25 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(
|
||||
Type 'Promise<IteratorResult<string>>' is not assignable to type 'Promise<IteratorResult<number>>'.
|
||||
Type 'IteratorResult<string>' is not assignable to type 'IteratorResult<number>'.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(25,7): error TS2322: Type '() => AsyncIterableIterator<"a">' is not assignable to type '() => AsyncIterable<number>'.
|
||||
Type 'AsyncIterableIterator<"a">' is not assignable to type 'AsyncIterable<number>'.
|
||||
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(28,7): error TS2322: Type '() => AsyncIterableIterator<"a">' is not assignable to type '() => AsyncIterator<number>'.
|
||||
Type 'AsyncIterableIterator<"a">' is not assignable to type 'AsyncIterator<number>'.
|
||||
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(22,7): error TS2322: Type '() => AsyncIterableIterator<string>' is not assignable to type '() => AsyncIterable<number>'.
|
||||
Type 'AsyncIterableIterator<string>' is not assignable to type 'AsyncIterable<number>'.
|
||||
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(25,7): error TS2322: Type '() => AsyncIterableIterator<string>' is not assignable to type '() => AsyncIterable<number>'.
|
||||
Type 'AsyncIterableIterator<string>' is not assignable to type 'AsyncIterable<number>'.
|
||||
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(28,7): error TS2322: Type '() => AsyncIterableIterator<string>' is not assignable to type '() => AsyncIterator<number>'.
|
||||
Type 'AsyncIterableIterator<string>' is not assignable to type 'AsyncIterator<number>'.
|
||||
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(31,7): error TS2322: Type '() => AsyncIterableIterator<string>' is not assignable to type '() => AsyncIterator<number>'.
|
||||
Type 'AsyncIterableIterator<string>' is not assignable to type 'AsyncIterator<number>'.
|
||||
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(34,7): error TS2322: Type '() => AsyncIterableIterator<"a">' is not assignable to type '() => AsyncIterator<number>'.
|
||||
Type 'AsyncIterableIterator<"a">' is not assignable to type 'AsyncIterator<number>'.
|
||||
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(34,7): error TS2322: Type '() => AsyncIterableIterator<string>' is not assignable to type '() => AsyncIterator<number>'.
|
||||
Type 'AsyncIterableIterator<string>' is not assignable to type 'AsyncIterator<number>'.
|
||||
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(38,11): error TS2322: Type '"a"' is not assignable to type 'number'.
|
||||
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(41,12): error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(44,12): error TS2322: Type '"a"' is not assignable to type 'number'.
|
||||
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(44,12): error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(47,11): error TS2322: Type '"a"' is not assignable to type 'number'.
|
||||
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(50,12): error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(53,12): error TS2322: Type '"a"' is not assignable to type 'number'.
|
||||
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(53,12): error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(56,11): error TS2322: Type '"a"' is not assignable to type 'number'.
|
||||
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(59,12): error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(62,12): error TS2322: Type '"a"' is not assignable to type 'number'.
|
||||
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(62,12): error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(64,42): error TS2322: Type 'AsyncIterableIterator<any>' is not assignable to type 'IterableIterator<number>'.
|
||||
Property '[Symbol.iterator]' is missing in type 'AsyncIterableIterator<any>'.
|
||||
tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(67,42): error TS2322: Type 'AsyncIterableIterator<any>' is not assignable to type 'Iterable<number>'.
|
||||
@@ -73,40 +64,25 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(
|
||||
}
|
||||
const assignability1: () => AsyncIterableIterator<number> = async function * () {
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '() => AsyncIterableIterator<"a">' is not assignable to type '() => AsyncIterableIterator<number>'.
|
||||
!!! error TS2322: Type 'AsyncIterableIterator<"a">' is not assignable to type 'AsyncIterableIterator<number>'.
|
||||
!!! error TS2322: Type '"a"' is not assignable to type 'number'.
|
||||
!!! error TS2322: Type '() => AsyncIterableIterator<string>' is not assignable to type '() => AsyncIterableIterator<number>'.
|
||||
!!! error TS2322: Type 'AsyncIterableIterator<string>' is not assignable to type 'AsyncIterableIterator<number>'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
yield "a";
|
||||
};
|
||||
const assignability2: () => AsyncIterableIterator<number> = async function * () {
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '() => AsyncIterableIterator<string>' is not assignable to type '() => AsyncIterableIterator<number>'.
|
||||
!!! error TS2322: Type 'AsyncIterableIterator<string>' is not assignable to type 'AsyncIterableIterator<number>'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
yield* ["a", "b"];
|
||||
};
|
||||
const assignability3: () => AsyncIterableIterator<number> = async function * () {
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '() => AsyncIterableIterator<"a">' is not assignable to type '() => AsyncIterableIterator<number>'.
|
||||
!!! error TS2322: Type 'AsyncIterableIterator<"a">' is not assignable to type 'AsyncIterableIterator<number>'.
|
||||
!!! error TS2322: Type '() => AsyncIterableIterator<string>' is not assignable to type '() => AsyncIterableIterator<number>'.
|
||||
!!! error TS2322: Type 'AsyncIterableIterator<string>' is not assignable to type 'AsyncIterableIterator<number>'.
|
||||
yield* (async function * () { yield "a"; })();
|
||||
};
|
||||
const assignability4: () => AsyncIterable<number> = async function * () {
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '() => AsyncIterableIterator<"a">' is not assignable to type '() => AsyncIterable<number>'.
|
||||
!!! error TS2322: Type 'AsyncIterableIterator<"a">' is not assignable to type 'AsyncIterable<number>'.
|
||||
!!! error TS2322: Types of property '[Symbol.asyncIterator]' are incompatible.
|
||||
!!! error TS2322: Type '() => AsyncIterableIterator<"a">' is not assignable to type '() => AsyncIterator<number>'.
|
||||
!!! error TS2322: Type 'AsyncIterableIterator<"a">' is not assignable to type 'AsyncIterator<number>'.
|
||||
!!! error TS2322: Types of property 'next' are incompatible.
|
||||
!!! error TS2322: Type '(value?: any) => Promise<IteratorResult<"a">>' is not assignable to type '(value?: any) => Promise<IteratorResult<number>>'.
|
||||
!!! error TS2322: Type 'Promise<IteratorResult<"a">>' is not assignable to type 'Promise<IteratorResult<number>>'.
|
||||
!!! error TS2322: Type 'IteratorResult<"a">' is not assignable to type 'IteratorResult<number>'.
|
||||
!!! error TS2322: Type '"a"' is not assignable to type 'number'.
|
||||
yield "a";
|
||||
};
|
||||
const assignability5: () => AsyncIterable<number> = async function * () {
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '() => AsyncIterableIterator<string>' is not assignable to type '() => AsyncIterable<number>'.
|
||||
!!! error TS2322: Type 'AsyncIterableIterator<string>' is not assignable to type 'AsyncIterable<number>'.
|
||||
!!! error TS2322: Types of property '[Symbol.asyncIterator]' are incompatible.
|
||||
@@ -117,18 +93,24 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(
|
||||
!!! error TS2322: Type 'Promise<IteratorResult<string>>' is not assignable to type 'Promise<IteratorResult<number>>'.
|
||||
!!! error TS2322: Type 'IteratorResult<string>' is not assignable to type 'IteratorResult<number>'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
yield "a";
|
||||
};
|
||||
const assignability5: () => AsyncIterable<number> = async function * () {
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '() => AsyncIterableIterator<string>' is not assignable to type '() => AsyncIterable<number>'.
|
||||
!!! error TS2322: Type 'AsyncIterableIterator<string>' is not assignable to type 'AsyncIterable<number>'.
|
||||
yield* ["a", "b"];
|
||||
};
|
||||
const assignability6: () => AsyncIterable<number> = async function * () {
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '() => AsyncIterableIterator<"a">' is not assignable to type '() => AsyncIterable<number>'.
|
||||
!!! error TS2322: Type 'AsyncIterableIterator<"a">' is not assignable to type 'AsyncIterable<number>'.
|
||||
!!! error TS2322: Type '() => AsyncIterableIterator<string>' is not assignable to type '() => AsyncIterable<number>'.
|
||||
!!! error TS2322: Type 'AsyncIterableIterator<string>' is not assignable to type 'AsyncIterable<number>'.
|
||||
yield* (async function * () { yield "a"; })();
|
||||
};
|
||||
const assignability7: () => AsyncIterator<number> = async function * () {
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '() => AsyncIterableIterator<"a">' is not assignable to type '() => AsyncIterator<number>'.
|
||||
!!! error TS2322: Type 'AsyncIterableIterator<"a">' is not assignable to type 'AsyncIterator<number>'.
|
||||
!!! error TS2322: Type '() => AsyncIterableIterator<string>' is not assignable to type '() => AsyncIterator<number>'.
|
||||
!!! error TS2322: Type 'AsyncIterableIterator<string>' is not assignable to type 'AsyncIterator<number>'.
|
||||
yield "a";
|
||||
};
|
||||
const assignability8: () => AsyncIterator<number> = async function * () {
|
||||
@@ -139,8 +121,8 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(
|
||||
};
|
||||
const assignability9: () => AsyncIterator<number> = async function * () {
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '() => AsyncIterableIterator<"a">' is not assignable to type '() => AsyncIterator<number>'.
|
||||
!!! error TS2322: Type 'AsyncIterableIterator<"a">' is not assignable to type 'AsyncIterator<number>'.
|
||||
!!! error TS2322: Type '() => AsyncIterableIterator<string>' is not assignable to type '() => AsyncIterator<number>'.
|
||||
!!! error TS2322: Type 'AsyncIterableIterator<string>' is not assignable to type 'AsyncIterator<number>'.
|
||||
yield* (async function * () { yield "a"; })();
|
||||
};
|
||||
async function * explicitReturnType1(): AsyncIterableIterator<number> {
|
||||
@@ -156,7 +138,7 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(
|
||||
async function * explicitReturnType3(): AsyncIterableIterator<number> {
|
||||
yield* (async function * () { yield "a"; })();
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '"a"' is not assignable to type 'number'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
}
|
||||
async function * explicitReturnType4(): AsyncIterable<number> {
|
||||
yield "a";
|
||||
@@ -171,7 +153,7 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(
|
||||
async function * explicitReturnType6(): AsyncIterable<number> {
|
||||
yield* (async function * () { yield "a"; })();
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '"a"' is not assignable to type 'number'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
}
|
||||
async function * explicitReturnType7(): AsyncIterator<number> {
|
||||
yield "a";
|
||||
@@ -186,7 +168,7 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(
|
||||
async function * explicitReturnType9(): AsyncIterator<number> {
|
||||
yield* (async function * () { yield "a"; })();
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '"a"' is not assignable to type 'number'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
}
|
||||
async function * explicitReturnType10(): IterableIterator<number> {
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
@@ -30,7 +30,7 @@ async function * inferReturnType3() {
|
||||
const assignability1: () => AsyncIterableIterator<number> = async function * () {
|
||||
>assignability1 : () => AsyncIterableIterator<number>
|
||||
>AsyncIterableIterator : AsyncIterableIterator<T>
|
||||
>async function * () { yield "a";} : () => AsyncIterableIterator<"a">
|
||||
>async function * () { yield "a";} : () => AsyncIterableIterator<string>
|
||||
|
||||
yield "a";
|
||||
>yield "a" : any
|
||||
@@ -52,13 +52,13 @@ const assignability2: () => AsyncIterableIterator<number> = async function * ()
|
||||
const assignability3: () => AsyncIterableIterator<number> = async function * () {
|
||||
>assignability3 : () => AsyncIterableIterator<number>
|
||||
>AsyncIterableIterator : AsyncIterableIterator<T>
|
||||
>async function * () { yield* (async function * () { yield "a"; })();} : () => AsyncIterableIterator<"a">
|
||||
>async function * () { yield* (async function * () { yield "a"; })();} : () => AsyncIterableIterator<string>
|
||||
|
||||
yield* (async function * () { yield "a"; })();
|
||||
>yield* (async function * () { yield "a"; })() : any
|
||||
>(async function * () { yield "a"; })() : AsyncIterableIterator<"a">
|
||||
>(async function * () { yield "a"; }) : () => AsyncIterableIterator<"a">
|
||||
>async function * () { yield "a"; } : () => AsyncIterableIterator<"a">
|
||||
>(async function * () { yield "a"; })() : AsyncIterableIterator<string>
|
||||
>(async function * () { yield "a"; }) : () => AsyncIterableIterator<string>
|
||||
>async function * () { yield "a"; } : () => AsyncIterableIterator<string>
|
||||
>yield "a" : any
|
||||
>"a" : "a"
|
||||
|
||||
@@ -66,7 +66,7 @@ const assignability3: () => AsyncIterableIterator<number> = async function * ()
|
||||
const assignability4: () => AsyncIterable<number> = async function * () {
|
||||
>assignability4 : () => AsyncIterable<number>
|
||||
>AsyncIterable : AsyncIterable<T>
|
||||
>async function * () { yield "a";} : () => AsyncIterableIterator<"a">
|
||||
>async function * () { yield "a";} : () => AsyncIterableIterator<string>
|
||||
|
||||
yield "a";
|
||||
>yield "a" : any
|
||||
@@ -88,13 +88,13 @@ const assignability5: () => AsyncIterable<number> = async function * () {
|
||||
const assignability6: () => AsyncIterable<number> = async function * () {
|
||||
>assignability6 : () => AsyncIterable<number>
|
||||
>AsyncIterable : AsyncIterable<T>
|
||||
>async function * () { yield* (async function * () { yield "a"; })();} : () => AsyncIterableIterator<"a">
|
||||
>async function * () { yield* (async function * () { yield "a"; })();} : () => AsyncIterableIterator<string>
|
||||
|
||||
yield* (async function * () { yield "a"; })();
|
||||
>yield* (async function * () { yield "a"; })() : any
|
||||
>(async function * () { yield "a"; })() : AsyncIterableIterator<"a">
|
||||
>(async function * () { yield "a"; }) : () => AsyncIterableIterator<"a">
|
||||
>async function * () { yield "a"; } : () => AsyncIterableIterator<"a">
|
||||
>(async function * () { yield "a"; })() : AsyncIterableIterator<string>
|
||||
>(async function * () { yield "a"; }) : () => AsyncIterableIterator<string>
|
||||
>async function * () { yield "a"; } : () => AsyncIterableIterator<string>
|
||||
>yield "a" : any
|
||||
>"a" : "a"
|
||||
|
||||
@@ -102,7 +102,7 @@ const assignability6: () => AsyncIterable<number> = async function * () {
|
||||
const assignability7: () => AsyncIterator<number> = async function * () {
|
||||
>assignability7 : () => AsyncIterator<number>
|
||||
>AsyncIterator : AsyncIterator<T>
|
||||
>async function * () { yield "a";} : () => AsyncIterableIterator<"a">
|
||||
>async function * () { yield "a";} : () => AsyncIterableIterator<string>
|
||||
|
||||
yield "a";
|
||||
>yield "a" : any
|
||||
@@ -124,13 +124,13 @@ const assignability8: () => AsyncIterator<number> = async function * () {
|
||||
const assignability9: () => AsyncIterator<number> = async function * () {
|
||||
>assignability9 : () => AsyncIterator<number>
|
||||
>AsyncIterator : AsyncIterator<T>
|
||||
>async function * () { yield* (async function * () { yield "a"; })();} : () => AsyncIterableIterator<"a">
|
||||
>async function * () { yield* (async function * () { yield "a"; })();} : () => AsyncIterableIterator<string>
|
||||
|
||||
yield* (async function * () { yield "a"; })();
|
||||
>yield* (async function * () { yield "a"; })() : any
|
||||
>(async function * () { yield "a"; })() : AsyncIterableIterator<"a">
|
||||
>(async function * () { yield "a"; }) : () => AsyncIterableIterator<"a">
|
||||
>async function * () { yield "a"; } : () => AsyncIterableIterator<"a">
|
||||
>(async function * () { yield "a"; })() : AsyncIterableIterator<string>
|
||||
>(async function * () { yield "a"; }) : () => AsyncIterableIterator<string>
|
||||
>async function * () { yield "a"; } : () => AsyncIterableIterator<string>
|
||||
>yield "a" : any
|
||||
>"a" : "a"
|
||||
|
||||
@@ -159,9 +159,9 @@ async function * explicitReturnType3(): AsyncIterableIterator<number> {
|
||||
|
||||
yield* (async function * () { yield "a"; })();
|
||||
>yield* (async function * () { yield "a"; })() : any
|
||||
>(async function * () { yield "a"; })() : AsyncIterableIterator<"a">
|
||||
>(async function * () { yield "a"; }) : () => AsyncIterableIterator<"a">
|
||||
>async function * () { yield "a"; } : () => AsyncIterableIterator<"a">
|
||||
>(async function * () { yield "a"; })() : AsyncIterableIterator<string>
|
||||
>(async function * () { yield "a"; }) : () => AsyncIterableIterator<string>
|
||||
>async function * () { yield "a"; } : () => AsyncIterableIterator<string>
|
||||
>yield "a" : any
|
||||
>"a" : "a"
|
||||
}
|
||||
@@ -189,9 +189,9 @@ async function * explicitReturnType6(): AsyncIterable<number> {
|
||||
|
||||
yield* (async function * () { yield "a"; })();
|
||||
>yield* (async function * () { yield "a"; })() : any
|
||||
>(async function * () { yield "a"; })() : AsyncIterableIterator<"a">
|
||||
>(async function * () { yield "a"; }) : () => AsyncIterableIterator<"a">
|
||||
>async function * () { yield "a"; } : () => AsyncIterableIterator<"a">
|
||||
>(async function * () { yield "a"; })() : AsyncIterableIterator<string>
|
||||
>(async function * () { yield "a"; }) : () => AsyncIterableIterator<string>
|
||||
>async function * () { yield "a"; } : () => AsyncIterableIterator<string>
|
||||
>yield "a" : any
|
||||
>"a" : "a"
|
||||
}
|
||||
@@ -219,9 +219,9 @@ async function * explicitReturnType9(): AsyncIterator<number> {
|
||||
|
||||
yield* (async function * () { yield "a"; })();
|
||||
>yield* (async function * () { yield "a"; })() : any
|
||||
>(async function * () { yield "a"; })() : AsyncIterableIterator<"a">
|
||||
>(async function * () { yield "a"; }) : () => AsyncIterableIterator<"a">
|
||||
>async function * () { yield "a"; } : () => AsyncIterableIterator<"a">
|
||||
>(async function * () { yield "a"; })() : AsyncIterableIterator<string>
|
||||
>(async function * () { yield "a"; }) : () => AsyncIterableIterator<string>
|
||||
>async function * () { yield "a"; } : () => AsyncIterableIterator<string>
|
||||
>yield "a" : any
|
||||
>"a" : "a"
|
||||
}
|
||||
|
||||
@@ -122,6 +122,7 @@ declare function g(x: typeof s): void;
|
||||
declare function g(x: typeof N.s): void;
|
||||
|
||||
// widening positions
|
||||
|
||||
// argument inference
|
||||
f(s);
|
||||
f(N.s);
|
||||
@@ -132,11 +133,17 @@ f(N["s"]);
|
||||
[N.s];
|
||||
[N["s"]];
|
||||
|
||||
// property assignments
|
||||
// property assignments/methods
|
||||
const o2 = {
|
||||
a: s,
|
||||
b: N.s,
|
||||
c: N["s"]
|
||||
c: N["s"],
|
||||
|
||||
method1() { return s; },
|
||||
async method2() { return s; },
|
||||
async * method3() { yield s; },
|
||||
* method4() { yield s; },
|
||||
method5(p = s) { return p; },
|
||||
};
|
||||
|
||||
// property initializers
|
||||
@@ -156,6 +163,12 @@ class C0 {
|
||||
d = s;
|
||||
e = N.s;
|
||||
f = N["s"];
|
||||
|
||||
method1() { return s; }
|
||||
async method2() { return s; }
|
||||
async * method3() { yield s; }
|
||||
* method4() { yield s; }
|
||||
method5(p = s) { return p; }
|
||||
}
|
||||
|
||||
// non-widening positions
|
||||
@@ -195,7 +208,60 @@ class C1 {
|
||||
|
||||
[s]: "a";
|
||||
[N.s]: "b";
|
||||
}
|
||||
}
|
||||
|
||||
// contextual types
|
||||
|
||||
interface Context {
|
||||
method1(): typeof s;
|
||||
method2(): Promise<typeof s>;
|
||||
method3(): AsyncIterableIterator<typeof s>;
|
||||
method4(): IterableIterator<typeof s>;
|
||||
method5(p?: typeof s): typeof s;
|
||||
}
|
||||
|
||||
const o3: Context = {
|
||||
method1() {
|
||||
return s; // return type should not widen due to contextual type
|
||||
},
|
||||
async method2() {
|
||||
return s; // return type should not widen due to contextual type
|
||||
},
|
||||
async * method3() {
|
||||
yield s; // yield type should not widen due to contextual type
|
||||
},
|
||||
* method4() {
|
||||
yield s; // yield type should not widen due to contextual type
|
||||
},
|
||||
method5(p = s) { // parameter should not widen due to contextual type
|
||||
return p;
|
||||
},
|
||||
};
|
||||
|
||||
// allowed when not emitting declarations
|
||||
|
||||
const o4 = {
|
||||
method1(p: typeof s): typeof s {
|
||||
return p;
|
||||
},
|
||||
method2(p: I["readonlyType"]): I["readonlyType"] {
|
||||
return p;
|
||||
}
|
||||
};
|
||||
|
||||
const ce0 = class {
|
||||
method1(p: typeof s): typeof s {
|
||||
return p;
|
||||
}
|
||||
method2(p: I["readonlyType"]): I["readonlyType"] {
|
||||
return p;
|
||||
}
|
||||
};
|
||||
|
||||
function funcInferredReturnType(obj: { method(p: typeof s): void }) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
//// [uniqueSymbols.js]
|
||||
// declarations with call initializer
|
||||
@@ -285,11 +351,16 @@ f(N["s"]);
|
||||
[s];
|
||||
[N.s];
|
||||
[N["s"]];
|
||||
// property assignments
|
||||
// property assignments/methods
|
||||
const o2 = {
|
||||
a: s,
|
||||
b: N.s,
|
||||
c: N["s"]
|
||||
c: N["s"],
|
||||
method1() { return s; },
|
||||
async method2() { return s; },
|
||||
async *method3() { yield s; },
|
||||
*method4() { yield s; },
|
||||
method5(p = s) { return p; },
|
||||
};
|
||||
// property initializers
|
||||
class C0 {
|
||||
@@ -301,6 +372,11 @@ class C0 {
|
||||
this.e = N.s;
|
||||
this.f = N["s"];
|
||||
}
|
||||
method1() { return s; }
|
||||
async method2() { return s; }
|
||||
async *method3() { yield s; }
|
||||
*method4() { yield s; }
|
||||
method5(p = s) { return p; }
|
||||
}
|
||||
C0.a = s;
|
||||
C0.b = N.s;
|
||||
@@ -335,120 +411,40 @@ Math.random() * 2 ? N["s"] : "a";
|
||||
});
|
||||
class C1 {
|
||||
}
|
||||
|
||||
|
||||
//// [uniqueSymbols.d.ts]
|
||||
declare const constCall: unique symbol;
|
||||
declare let letCall: symbol;
|
||||
declare var varCall: symbol;
|
||||
declare const constType: unique symbol;
|
||||
declare const constTypeAndCall: unique symbol;
|
||||
declare const constInitToConstCall: symbol;
|
||||
declare const constInitToLetCall: symbol;
|
||||
declare const constInitToVarCall: symbol;
|
||||
declare const constInitToConstDeclAmbient: symbol;
|
||||
declare let letInitToConstCall: symbol;
|
||||
declare let letInitToLetCall: symbol;
|
||||
declare let letInitToVarCall: symbol;
|
||||
declare let letInitToConstDeclAmbient: symbol;
|
||||
declare var varInitToConstCall: symbol;
|
||||
declare var varInitToLetCall: symbol;
|
||||
declare var varInitToVarCall: symbol;
|
||||
declare var varInitToConstDeclAmbient: symbol;
|
||||
declare const constInitToConstCallWithTypeQuery: typeof constCall;
|
||||
declare const constInitToConstDeclAmbientWithTypeQuery: typeof constType;
|
||||
declare function funcReturnConstCall(): symbol;
|
||||
declare function funcReturnLetCall(): symbol;
|
||||
declare function funcReturnVarCall(): symbol;
|
||||
declare function funcReturnConstCallWithTypeQuery(): typeof constCall;
|
||||
declare function genFuncYieldConstCall(): IterableIterator<symbol>;
|
||||
declare function genFuncYieldLetCall(): IterableIterator<symbol>;
|
||||
declare function genFuncYieldVarCall(): IterableIterator<symbol>;
|
||||
declare function genFuncYieldConstCallWithTypeQuery(): IterableIterator<typeof constCall>;
|
||||
declare function asyncFuncReturnConstCall(): Promise<symbol>;
|
||||
declare function asyncFuncReturnLetCall(): Promise<symbol>;
|
||||
declare function asyncFuncReturnVarCall(): Promise<symbol>;
|
||||
declare function asyncGenFuncYieldConstCall(): AsyncIterableIterator<symbol>;
|
||||
declare function asyncGenFuncYieldLetCall(): AsyncIterableIterator<symbol>;
|
||||
declare function asyncGenFuncYieldVarCall(): AsyncIterableIterator<symbol>;
|
||||
declare class C {
|
||||
static readonly readonlyStaticCall: unique symbol;
|
||||
static readonly readonlyStaticType: unique symbol;
|
||||
static readonly readonlyStaticTypeAndCall: unique symbol;
|
||||
static readwriteStaticCall: symbol;
|
||||
readonly readonlyCall: symbol;
|
||||
readwriteCall: symbol;
|
||||
}
|
||||
declare const c: C;
|
||||
declare const constInitToCReadonlyStaticCall: symbol;
|
||||
declare const constInitToCReadonlyStaticType: symbol;
|
||||
declare const constInitToCReadonlyStaticTypeAndCall: symbol;
|
||||
declare const constInitToCReadwriteStaticCall: symbol;
|
||||
declare const constInitToCReadonlyStaticCallWithTypeQuery: typeof C.readonlyStaticCall;
|
||||
declare const constInitToCReadonlyStaticTypeWithTypeQuery: typeof C.readonlyStaticType;
|
||||
declare const constInitToCReadonlyStaticTypeAndCallWithTypeQuery: typeof C.readonlyStaticTypeAndCall;
|
||||
declare const constInitToCReadwriteStaticCallWithTypeQuery: typeof C.readwriteStaticCall;
|
||||
declare const constInitToCReadonlyCall: symbol;
|
||||
declare const constInitToCReadwriteCall: symbol;
|
||||
declare const constInitToCReadonlyCallWithTypeQuery: typeof c.readonlyCall;
|
||||
declare const constInitToCReadwriteCallWithTypeQuery: typeof c.readwriteCall;
|
||||
declare const constInitToCReadonlyCallWithIndexedAccess: C["readonlyCall"];
|
||||
declare const constInitToCReadwriteCallWithIndexedAccess: C["readwriteCall"];
|
||||
interface I {
|
||||
readonly readonlyType: unique symbol;
|
||||
}
|
||||
declare const i: I;
|
||||
declare const constInitToIReadonlyType: symbol;
|
||||
declare const constInitToIReadonlyTypeWithTypeQuery: typeof i.readonlyType;
|
||||
declare const constInitToIReadonlyTypeWithIndexedAccess: I["readonlyType"];
|
||||
declare type L = {
|
||||
readonly readonlyType: unique symbol;
|
||||
nested: {
|
||||
readonly readonlyNestedType: unique symbol;
|
||||
};
|
||||
const o3 = {
|
||||
method1() {
|
||||
return s; // return type should not widen due to contextual type
|
||||
},
|
||||
async method2() {
|
||||
return s; // return type should not widen due to contextual type
|
||||
},
|
||||
async *method3() {
|
||||
yield s; // yield type should not widen due to contextual type
|
||||
},
|
||||
*method4() {
|
||||
yield s; // yield type should not widen due to contextual type
|
||||
},
|
||||
method5(p = s) {
|
||||
return p;
|
||||
},
|
||||
};
|
||||
declare const l: L;
|
||||
declare const constInitToLReadonlyType: symbol;
|
||||
declare const constInitToLReadonlyNestedType: symbol;
|
||||
declare const constInitToLReadonlyTypeWithTypeQuery: typeof l.readonlyType;
|
||||
declare const constInitToLReadonlyNestedTypeWithTypeQuery: typeof l.nested.readonlyNestedType;
|
||||
declare const constInitToLReadonlyTypeWithIndexedAccess: L["readonlyType"];
|
||||
declare const constInitToLReadonlyNestedTypeWithIndexedAccess: L["nested"]["readonlyNestedType"];
|
||||
declare const promiseForConstCall: Promise<symbol>;
|
||||
declare const arrayOfConstCall: symbol[];
|
||||
declare const s: unique symbol;
|
||||
declare namespace N {
|
||||
const s: unique symbol;
|
||||
}
|
||||
declare const o: {
|
||||
[s]: "a";
|
||||
[N.s]: "b";
|
||||
// allowed when not emitting declarations
|
||||
const o4 = {
|
||||
method1(p) {
|
||||
return p;
|
||||
},
|
||||
method2(p) {
|
||||
return p;
|
||||
}
|
||||
};
|
||||
declare function f<T>(x: T): T;
|
||||
declare function g(x: typeof s): void;
|
||||
declare function g(x: typeof N.s): void;
|
||||
declare const o2: {
|
||||
a: symbol;
|
||||
b: symbol;
|
||||
c: symbol;
|
||||
const ce0 = class {
|
||||
method1(p) {
|
||||
return p;
|
||||
}
|
||||
method2(p) {
|
||||
return p;
|
||||
}
|
||||
};
|
||||
declare class C0 {
|
||||
static readonly a: symbol;
|
||||
static readonly b: symbol;
|
||||
static readonly c: symbol;
|
||||
static d: symbol;
|
||||
static e: symbol;
|
||||
static f: symbol;
|
||||
readonly a: symbol;
|
||||
readonly b: symbol;
|
||||
readonly c: symbol;
|
||||
d: symbol;
|
||||
e: symbol;
|
||||
f: symbol;
|
||||
}
|
||||
declare class C1 {
|
||||
static [s]: "a";
|
||||
static [N.s]: "b";
|
||||
[s]: "a";
|
||||
[N.s]: "b";
|
||||
function funcInferredReturnType(obj) {
|
||||
return obj;
|
||||
}
|
||||
@@ -431,6 +431,7 @@ declare function g(x: typeof N.s): void;
|
||||
>s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27))
|
||||
|
||||
// widening positions
|
||||
|
||||
// argument inference
|
||||
f(s);
|
||||
>f : Symbol(f, Decl(uniqueSymbols.ts, 117, 42))
|
||||
@@ -460,90 +461,134 @@ f(N["s"]);
|
||||
>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31))
|
||||
>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27))
|
||||
|
||||
// property assignments
|
||||
// property assignments/methods
|
||||
const o2 = {
|
||||
>o2 : Symbol(o2, Decl(uniqueSymbols.ts, 134, 5))
|
||||
>o2 : Symbol(o2, Decl(uniqueSymbols.ts, 135, 5))
|
||||
|
||||
a: s,
|
||||
>a : Symbol(a, Decl(uniqueSymbols.ts, 134, 12))
|
||||
>a : Symbol(a, Decl(uniqueSymbols.ts, 135, 12))
|
||||
>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13))
|
||||
|
||||
b: N.s,
|
||||
>b : Symbol(b, Decl(uniqueSymbols.ts, 135, 9))
|
||||
>b : Symbol(b, Decl(uniqueSymbols.ts, 136, 9))
|
||||
>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27))
|
||||
>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31))
|
||||
>s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27))
|
||||
|
||||
c: N["s"]
|
||||
>c : Symbol(c, Decl(uniqueSymbols.ts, 136, 11))
|
||||
c: N["s"],
|
||||
>c : Symbol(c, Decl(uniqueSymbols.ts, 137, 11))
|
||||
>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31))
|
||||
>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27))
|
||||
|
||||
method1() { return s; },
|
||||
>method1 : Symbol(method1, Decl(uniqueSymbols.ts, 138, 14))
|
||||
>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13))
|
||||
|
||||
async method2() { return s; },
|
||||
>method2 : Symbol(method2, Decl(uniqueSymbols.ts, 140, 28))
|
||||
>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13))
|
||||
|
||||
async * method3() { yield s; },
|
||||
>method3 : Symbol(method3, Decl(uniqueSymbols.ts, 141, 34))
|
||||
>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13))
|
||||
|
||||
* method4() { yield s; },
|
||||
>method4 : Symbol(method4, Decl(uniqueSymbols.ts, 142, 35))
|
||||
>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13))
|
||||
|
||||
method5(p = s) { return p; },
|
||||
>method5 : Symbol(method5, Decl(uniqueSymbols.ts, 143, 29))
|
||||
>p : Symbol(p, Decl(uniqueSymbols.ts, 144, 12))
|
||||
>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13))
|
||||
>p : Symbol(p, Decl(uniqueSymbols.ts, 144, 12))
|
||||
|
||||
};
|
||||
|
||||
// property initializers
|
||||
class C0 {
|
||||
>C0 : Symbol(C0, Decl(uniqueSymbols.ts, 138, 2))
|
||||
>C0 : Symbol(C0, Decl(uniqueSymbols.ts, 145, 2))
|
||||
|
||||
static readonly a = s;
|
||||
>a : Symbol(C0.a, Decl(uniqueSymbols.ts, 141, 10))
|
||||
>a : Symbol(C0.a, Decl(uniqueSymbols.ts, 148, 10))
|
||||
>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13))
|
||||
|
||||
static readonly b = N.s;
|
||||
>b : Symbol(C0.b, Decl(uniqueSymbols.ts, 142, 26))
|
||||
>b : Symbol(C0.b, Decl(uniqueSymbols.ts, 149, 26))
|
||||
>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27))
|
||||
>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31))
|
||||
>s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27))
|
||||
|
||||
static readonly c = N["s"];
|
||||
>c : Symbol(C0.c, Decl(uniqueSymbols.ts, 143, 28))
|
||||
>c : Symbol(C0.c, Decl(uniqueSymbols.ts, 150, 28))
|
||||
>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31))
|
||||
>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27))
|
||||
|
||||
static d = s;
|
||||
>d : Symbol(C0.d, Decl(uniqueSymbols.ts, 144, 31))
|
||||
>d : Symbol(C0.d, Decl(uniqueSymbols.ts, 151, 31))
|
||||
>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13))
|
||||
|
||||
static e = N.s;
|
||||
>e : Symbol(C0.e, Decl(uniqueSymbols.ts, 146, 17))
|
||||
>e : Symbol(C0.e, Decl(uniqueSymbols.ts, 153, 17))
|
||||
>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27))
|
||||
>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31))
|
||||
>s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27))
|
||||
|
||||
static f = N["s"];
|
||||
>f : Symbol(C0.f, Decl(uniqueSymbols.ts, 147, 19))
|
||||
>f : Symbol(C0.f, Decl(uniqueSymbols.ts, 154, 19))
|
||||
>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31))
|
||||
>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27))
|
||||
|
||||
readonly a = s;
|
||||
>a : Symbol(C0.a, Decl(uniqueSymbols.ts, 148, 22))
|
||||
>a : Symbol(C0.a, Decl(uniqueSymbols.ts, 155, 22))
|
||||
>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13))
|
||||
|
||||
readonly b = N.s;
|
||||
>b : Symbol(C0.b, Decl(uniqueSymbols.ts, 150, 19))
|
||||
>b : Symbol(C0.b, Decl(uniqueSymbols.ts, 157, 19))
|
||||
>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27))
|
||||
>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31))
|
||||
>s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27))
|
||||
|
||||
readonly c = N["s"];
|
||||
>c : Symbol(C0.c, Decl(uniqueSymbols.ts, 151, 21))
|
||||
>c : Symbol(C0.c, Decl(uniqueSymbols.ts, 158, 21))
|
||||
>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31))
|
||||
>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27))
|
||||
|
||||
d = s;
|
||||
>d : Symbol(C0.d, Decl(uniqueSymbols.ts, 152, 24))
|
||||
>d : Symbol(C0.d, Decl(uniqueSymbols.ts, 159, 24))
|
||||
>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13))
|
||||
|
||||
e = N.s;
|
||||
>e : Symbol(C0.e, Decl(uniqueSymbols.ts, 154, 10))
|
||||
>e : Symbol(C0.e, Decl(uniqueSymbols.ts, 161, 10))
|
||||
>N.s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27))
|
||||
>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31))
|
||||
>s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27))
|
||||
|
||||
f = N["s"];
|
||||
>f : Symbol(C0.f, Decl(uniqueSymbols.ts, 155, 12))
|
||||
>f : Symbol(C0.f, Decl(uniqueSymbols.ts, 162, 12))
|
||||
>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31))
|
||||
>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27))
|
||||
|
||||
method1() { return s; }
|
||||
>method1 : Symbol(C0.method1, Decl(uniqueSymbols.ts, 163, 15))
|
||||
>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13))
|
||||
|
||||
async method2() { return s; }
|
||||
>method2 : Symbol(C0.method2, Decl(uniqueSymbols.ts, 165, 27))
|
||||
>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13))
|
||||
|
||||
async * method3() { yield s; }
|
||||
>method3 : Symbol(C0.method3, Decl(uniqueSymbols.ts, 166, 33))
|
||||
>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13))
|
||||
|
||||
* method4() { yield s; }
|
||||
>method4 : Symbol(C0.method4, Decl(uniqueSymbols.ts, 167, 34))
|
||||
>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13))
|
||||
|
||||
method5(p = s) { return p; }
|
||||
>method5 : Symbol(C0.method5, Decl(uniqueSymbols.ts, 168, 28))
|
||||
>p : Symbol(p, Decl(uniqueSymbols.ts, 169, 12))
|
||||
>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13))
|
||||
>p : Symbol(p, Decl(uniqueSymbols.ts, 169, 12))
|
||||
}
|
||||
|
||||
// non-widening positions
|
||||
@@ -650,7 +695,7 @@ Math.random() * 2 ? N["s"] : "a";
|
||||
});
|
||||
|
||||
class C1 {
|
||||
>C1 : Symbol(C1, Decl(uniqueSymbols.ts, 188, 3))
|
||||
>C1 : Symbol(C1, Decl(uniqueSymbols.ts, 201, 3))
|
||||
|
||||
static [s]: "a";
|
||||
>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13))
|
||||
@@ -668,3 +713,138 @@ class C1 {
|
||||
>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31))
|
||||
>s : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27))
|
||||
}
|
||||
|
||||
// contextual types
|
||||
|
||||
interface Context {
|
||||
>Context : Symbol(Context, Decl(uniqueSymbols.ts, 209, 1))
|
||||
|
||||
method1(): typeof s;
|
||||
>method1 : Symbol(Context.method1, Decl(uniqueSymbols.ts, 213, 19))
|
||||
>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13))
|
||||
|
||||
method2(): Promise<typeof s>;
|
||||
>method2 : Symbol(Context.method2, Decl(uniqueSymbols.ts, 214, 24))
|
||||
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13))
|
||||
|
||||
method3(): AsyncIterableIterator<typeof s>;
|
||||
>method3 : Symbol(Context.method3, Decl(uniqueSymbols.ts, 215, 33))
|
||||
>AsyncIterableIterator : Symbol(AsyncIterableIterator, Decl(lib.esnext.asynciterable.d.ts, --, --))
|
||||
>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13))
|
||||
|
||||
method4(): IterableIterator<typeof s>;
|
||||
>method4 : Symbol(Context.method4, Decl(uniqueSymbols.ts, 216, 47))
|
||||
>IterableIterator : Symbol(IterableIterator, Decl(lib.es2015.iterable.d.ts, --, --))
|
||||
>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13))
|
||||
|
||||
method5(p?: typeof s): typeof s;
|
||||
>method5 : Symbol(Context.method5, Decl(uniqueSymbols.ts, 217, 42))
|
||||
>p : Symbol(p, Decl(uniqueSymbols.ts, 218, 12))
|
||||
>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13))
|
||||
>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13))
|
||||
}
|
||||
|
||||
const o3: Context = {
|
||||
>o3 : Symbol(o3, Decl(uniqueSymbols.ts, 221, 5))
|
||||
>Context : Symbol(Context, Decl(uniqueSymbols.ts, 209, 1))
|
||||
|
||||
method1() {
|
||||
>method1 : Symbol(method1, Decl(uniqueSymbols.ts, 221, 21))
|
||||
|
||||
return s; // return type should not widen due to contextual type
|
||||
>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13))
|
||||
|
||||
},
|
||||
async method2() {
|
||||
>method2 : Symbol(method2, Decl(uniqueSymbols.ts, 224, 6))
|
||||
|
||||
return s; // return type should not widen due to contextual type
|
||||
>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13))
|
||||
|
||||
},
|
||||
async * method3() {
|
||||
>method3 : Symbol(method3, Decl(uniqueSymbols.ts, 227, 6))
|
||||
|
||||
yield s; // yield type should not widen due to contextual type
|
||||
>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13))
|
||||
|
||||
},
|
||||
* method4() {
|
||||
>method4 : Symbol(method4, Decl(uniqueSymbols.ts, 230, 6))
|
||||
|
||||
yield s; // yield type should not widen due to contextual type
|
||||
>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13))
|
||||
|
||||
},
|
||||
method5(p = s) { // parameter should not widen due to contextual type
|
||||
>method5 : Symbol(method5, Decl(uniqueSymbols.ts, 233, 6))
|
||||
>p : Symbol(p, Decl(uniqueSymbols.ts, 234, 12))
|
||||
>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13))
|
||||
|
||||
return p;
|
||||
>p : Symbol(p, Decl(uniqueSymbols.ts, 234, 12))
|
||||
|
||||
},
|
||||
};
|
||||
|
||||
// allowed when not emitting declarations
|
||||
|
||||
const o4 = {
|
||||
>o4 : Symbol(o4, Decl(uniqueSymbols.ts, 241, 5))
|
||||
|
||||
method1(p: typeof s): typeof s {
|
||||
>method1 : Symbol(method1, Decl(uniqueSymbols.ts, 241, 12))
|
||||
>p : Symbol(p, Decl(uniqueSymbols.ts, 242, 12))
|
||||
>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13))
|
||||
>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13))
|
||||
|
||||
return p;
|
||||
>p : Symbol(p, Decl(uniqueSymbols.ts, 242, 12))
|
||||
|
||||
},
|
||||
method2(p: I["readonlyType"]): I["readonlyType"] {
|
||||
>method2 : Symbol(method2, Decl(uniqueSymbols.ts, 244, 6))
|
||||
>p : Symbol(p, Decl(uniqueSymbols.ts, 245, 12))
|
||||
>I : Symbol(I, Decl(uniqueSymbols.ts, 82, 87))
|
||||
>I : Symbol(I, Decl(uniqueSymbols.ts, 82, 87))
|
||||
|
||||
return p;
|
||||
>p : Symbol(p, Decl(uniqueSymbols.ts, 245, 12))
|
||||
}
|
||||
};
|
||||
|
||||
const ce0 = class {
|
||||
>ce0 : Symbol(ce0, Decl(uniqueSymbols.ts, 250, 5))
|
||||
|
||||
method1(p: typeof s): typeof s {
|
||||
>method1 : Symbol(ce0.method1, Decl(uniqueSymbols.ts, 250, 19))
|
||||
>p : Symbol(p, Decl(uniqueSymbols.ts, 251, 12))
|
||||
>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13))
|
||||
>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13))
|
||||
|
||||
return p;
|
||||
>p : Symbol(p, Decl(uniqueSymbols.ts, 251, 12))
|
||||
}
|
||||
method2(p: I["readonlyType"]): I["readonlyType"] {
|
||||
>method2 : Symbol(ce0.method2, Decl(uniqueSymbols.ts, 253, 5))
|
||||
>p : Symbol(p, Decl(uniqueSymbols.ts, 254, 12))
|
||||
>I : Symbol(I, Decl(uniqueSymbols.ts, 82, 87))
|
||||
>I : Symbol(I, Decl(uniqueSymbols.ts, 82, 87))
|
||||
|
||||
return p;
|
||||
>p : Symbol(p, Decl(uniqueSymbols.ts, 254, 12))
|
||||
}
|
||||
};
|
||||
|
||||
function funcInferredReturnType(obj: { method(p: typeof s): void }) {
|
||||
>funcInferredReturnType : Symbol(funcInferredReturnType, Decl(uniqueSymbols.ts, 257, 2))
|
||||
>obj : Symbol(obj, Decl(uniqueSymbols.ts, 259, 32))
|
||||
>method : Symbol(method, Decl(uniqueSymbols.ts, 259, 38))
|
||||
>p : Symbol(p, Decl(uniqueSymbols.ts, 259, 46))
|
||||
>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13))
|
||||
|
||||
return obj;
|
||||
>obj : Symbol(obj, Decl(uniqueSymbols.ts, 259, 32))
|
||||
}
|
||||
|
||||
@@ -449,6 +449,7 @@ declare function g(x: typeof N.s): void;
|
||||
>s : unique symbol
|
||||
|
||||
// widening positions
|
||||
|
||||
// argument inference
|
||||
f(s);
|
||||
>f(s) : symbol
|
||||
@@ -486,10 +487,10 @@ f(N["s"]);
|
||||
>N : typeof N
|
||||
>"s" : "s"
|
||||
|
||||
// property assignments
|
||||
// property assignments/methods
|
||||
const o2 = {
|
||||
>o2 : { a: symbol; b: symbol; c: symbol; }
|
||||
>{ a: s, b: N.s, c: N["s"]} : { a: symbol; b: symbol; c: symbol; }
|
||||
>o2 : { a: symbol; b: symbol; c: symbol; method1(): symbol; method2(): Promise<symbol>; method3(): AsyncIterableIterator<symbol>; method4(): IterableIterator<symbol>; method5(p?: symbol): symbol; }
|
||||
>{ a: s, b: N.s, c: N["s"], method1() { return s; }, async method2() { return s; }, async * method3() { yield s; }, * method4() { yield s; }, method5(p = s) { return p; },} : { a: symbol; b: symbol; c: symbol; method1(): symbol; method2(): Promise<symbol>; method3(): AsyncIterableIterator<symbol>; method4(): IterableIterator<symbol>; method5(p?: symbol): symbol; }
|
||||
|
||||
a: s,
|
||||
>a : symbol
|
||||
@@ -501,12 +502,36 @@ const o2 = {
|
||||
>N : typeof N
|
||||
>s : unique symbol
|
||||
|
||||
c: N["s"]
|
||||
c: N["s"],
|
||||
>c : symbol
|
||||
>N["s"] : unique symbol
|
||||
>N : typeof N
|
||||
>"s" : "s"
|
||||
|
||||
method1() { return s; },
|
||||
>method1 : () => symbol
|
||||
>s : unique symbol
|
||||
|
||||
async method2() { return s; },
|
||||
>method2 : () => Promise<symbol>
|
||||
>s : unique symbol
|
||||
|
||||
async * method3() { yield s; },
|
||||
>method3 : () => AsyncIterableIterator<symbol>
|
||||
>yield s : any
|
||||
>s : unique symbol
|
||||
|
||||
* method4() { yield s; },
|
||||
>method4 : () => IterableIterator<symbol>
|
||||
>yield s : any
|
||||
>s : unique symbol
|
||||
|
||||
method5(p = s) { return p; },
|
||||
>method5 : (p?: symbol) => symbol
|
||||
>p : symbol
|
||||
>s : unique symbol
|
||||
>p : symbol
|
||||
|
||||
};
|
||||
|
||||
// property initializers
|
||||
@@ -576,6 +601,30 @@ class C0 {
|
||||
>N["s"] : unique symbol
|
||||
>N : typeof N
|
||||
>"s" : "s"
|
||||
|
||||
method1() { return s; }
|
||||
>method1 : () => symbol
|
||||
>s : unique symbol
|
||||
|
||||
async method2() { return s; }
|
||||
>method2 : () => Promise<symbol>
|
||||
>s : unique symbol
|
||||
|
||||
async * method3() { yield s; }
|
||||
>method3 : () => AsyncIterableIterator<symbol>
|
||||
>yield s : any
|
||||
>s : unique symbol
|
||||
|
||||
* method4() { yield s; }
|
||||
>method4 : () => IterableIterator<symbol>
|
||||
>yield s : any
|
||||
>s : unique symbol
|
||||
|
||||
method5(p = s) { return p; }
|
||||
>method5 : (p?: symbol) => symbol
|
||||
>p : symbol
|
||||
>s : unique symbol
|
||||
>p : symbol
|
||||
}
|
||||
|
||||
// non-widening positions
|
||||
@@ -740,3 +789,143 @@ class C1 {
|
||||
>N : typeof N
|
||||
>s : unique symbol
|
||||
}
|
||||
|
||||
// contextual types
|
||||
|
||||
interface Context {
|
||||
>Context : Context
|
||||
|
||||
method1(): typeof s;
|
||||
>method1 : () => unique symbol
|
||||
>s : unique symbol
|
||||
|
||||
method2(): Promise<typeof s>;
|
||||
>method2 : () => Promise<unique symbol>
|
||||
>Promise : Promise<T>
|
||||
>s : unique symbol
|
||||
|
||||
method3(): AsyncIterableIterator<typeof s>;
|
||||
>method3 : () => AsyncIterableIterator<unique symbol>
|
||||
>AsyncIterableIterator : AsyncIterableIterator<T>
|
||||
>s : unique symbol
|
||||
|
||||
method4(): IterableIterator<typeof s>;
|
||||
>method4 : () => IterableIterator<unique symbol>
|
||||
>IterableIterator : IterableIterator<T>
|
||||
>s : unique symbol
|
||||
|
||||
method5(p?: typeof s): typeof s;
|
||||
>method5 : (p?: unique symbol) => unique symbol
|
||||
>p : unique symbol
|
||||
>s : unique symbol
|
||||
>s : unique symbol
|
||||
}
|
||||
|
||||
const o3: Context = {
|
||||
>o3 : Context
|
||||
>Context : Context
|
||||
>{ method1() { return s; // return type should not widen due to contextual type }, async method2() { return s; // return type should not widen due to contextual type }, async * method3() { yield s; // yield type should not widen due to contextual type }, * method4() { yield s; // yield type should not widen due to contextual type }, method5(p = s) { // parameter should not widen due to contextual type return p; },} : { method1(): unique symbol; method2(): Promise<unique symbol>; method3(): AsyncIterableIterator<unique symbol>; method4(): IterableIterator<unique symbol>; method5(p?: unique symbol): unique symbol; }
|
||||
|
||||
method1() {
|
||||
>method1 : () => unique symbol
|
||||
|
||||
return s; // return type should not widen due to contextual type
|
||||
>s : unique symbol
|
||||
|
||||
},
|
||||
async method2() {
|
||||
>method2 : () => Promise<unique symbol>
|
||||
|
||||
return s; // return type should not widen due to contextual type
|
||||
>s : unique symbol
|
||||
|
||||
},
|
||||
async * method3() {
|
||||
>method3 : () => AsyncIterableIterator<unique symbol>
|
||||
|
||||
yield s; // yield type should not widen due to contextual type
|
||||
>yield s : any
|
||||
>s : unique symbol
|
||||
|
||||
},
|
||||
* method4() {
|
||||
>method4 : () => IterableIterator<unique symbol>
|
||||
|
||||
yield s; // yield type should not widen due to contextual type
|
||||
>yield s : any
|
||||
>s : unique symbol
|
||||
|
||||
},
|
||||
method5(p = s) { // parameter should not widen due to contextual type
|
||||
>method5 : (p?: unique symbol) => unique symbol
|
||||
>p : unique symbol
|
||||
>s : unique symbol
|
||||
|
||||
return p;
|
||||
>p : unique symbol
|
||||
|
||||
},
|
||||
};
|
||||
|
||||
// allowed when not emitting declarations
|
||||
|
||||
const o4 = {
|
||||
>o4 : { method1(p: unique symbol): unique symbol; method2(p: unique symbol): unique symbol; }
|
||||
>{ method1(p: typeof s): typeof s { return p; }, method2(p: I["readonlyType"]): I["readonlyType"] { return p; }} : { method1(p: unique symbol): unique symbol; method2(p: unique symbol): unique symbol; }
|
||||
|
||||
method1(p: typeof s): typeof s {
|
||||
>method1 : (p: unique symbol) => unique symbol
|
||||
>p : unique symbol
|
||||
>s : unique symbol
|
||||
>s : unique symbol
|
||||
|
||||
return p;
|
||||
>p : unique symbol
|
||||
|
||||
},
|
||||
method2(p: I["readonlyType"]): I["readonlyType"] {
|
||||
>method2 : (p: unique symbol) => unique symbol
|
||||
>p : unique symbol
|
||||
>I : I
|
||||
>I : I
|
||||
|
||||
return p;
|
||||
>p : unique symbol
|
||||
}
|
||||
};
|
||||
|
||||
const ce0 = class {
|
||||
>ce0 : typeof ce0
|
||||
>class { method1(p: typeof s): typeof s { return p; } method2(p: I["readonlyType"]): I["readonlyType"] { return p; }} : typeof ce0
|
||||
|
||||
method1(p: typeof s): typeof s {
|
||||
>method1 : (p: unique symbol) => unique symbol
|
||||
>p : unique symbol
|
||||
>s : unique symbol
|
||||
>s : unique symbol
|
||||
|
||||
return p;
|
||||
>p : unique symbol
|
||||
}
|
||||
method2(p: I["readonlyType"]): I["readonlyType"] {
|
||||
>method2 : (p: unique symbol) => unique symbol
|
||||
>p : unique symbol
|
||||
>I : I
|
||||
>I : I
|
||||
|
||||
return p;
|
||||
>p : unique symbol
|
||||
}
|
||||
};
|
||||
|
||||
function funcInferredReturnType(obj: { method(p: typeof s): void }) {
|
||||
>funcInferredReturnType : (obj: { method(p: unique symbol): void; }) => { method(p: unique symbol): void; }
|
||||
>obj : { method(p: unique symbol): void; }
|
||||
>method : (p: unique symbol) => void
|
||||
>p : unique symbol
|
||||
>s : unique symbol
|
||||
|
||||
return obj;
|
||||
>obj : { method(p: unique symbol): void; }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,540 @@
|
||||
//// [uniqueSymbolsDeclarations.ts]
|
||||
// declarations with call initializer
|
||||
const constCall = Symbol();
|
||||
let letCall = Symbol();
|
||||
var varCall = Symbol();
|
||||
|
||||
// ambient declaration with type
|
||||
declare const constType: unique symbol;
|
||||
|
||||
// declaration with type and call initializer
|
||||
const constTypeAndCall: unique symbol = Symbol();
|
||||
|
||||
// declaration from initializer
|
||||
const constInitToConstCall = constCall;
|
||||
const constInitToLetCall = letCall;
|
||||
const constInitToVarCall = varCall;
|
||||
const constInitToConstDeclAmbient = constType;
|
||||
let letInitToConstCall = constCall;
|
||||
let letInitToLetCall = letCall;
|
||||
let letInitToVarCall = varCall;
|
||||
let letInitToConstDeclAmbient = constType;
|
||||
var varInitToConstCall = constCall;
|
||||
var varInitToLetCall = letCall;
|
||||
var varInitToVarCall = varCall;
|
||||
var varInitToConstDeclAmbient = constType;
|
||||
|
||||
// declaration from initializer with type query
|
||||
const constInitToConstCallWithTypeQuery: typeof constCall = constCall;
|
||||
const constInitToConstDeclAmbientWithTypeQuery: typeof constType = constType;
|
||||
|
||||
// function return inference
|
||||
function funcReturnConstCall() { return constCall; }
|
||||
function funcReturnLetCall() { return letCall; }
|
||||
function funcReturnVarCall() { return varCall; }
|
||||
|
||||
// function return value with type query
|
||||
function funcReturnConstCallWithTypeQuery(): typeof constCall { return constCall; }
|
||||
|
||||
// generator function yield inference
|
||||
function* genFuncYieldConstCall() { yield constCall; }
|
||||
function* genFuncYieldLetCall() { yield letCall; }
|
||||
function* genFuncYieldVarCall() { yield varCall; }
|
||||
|
||||
// generator function yield with return type query
|
||||
function* genFuncYieldConstCallWithTypeQuery(): IterableIterator<typeof constCall> { yield constCall; }
|
||||
|
||||
// async function return inference
|
||||
async function asyncFuncReturnConstCall() { return constCall; }
|
||||
async function asyncFuncReturnLetCall() { return letCall; }
|
||||
async function asyncFuncReturnVarCall() { return varCall; }
|
||||
|
||||
// async generator function yield inference
|
||||
async function* asyncGenFuncYieldConstCall() { yield constCall; }
|
||||
async function* asyncGenFuncYieldLetCall() { yield letCall; }
|
||||
async function* asyncGenFuncYieldVarCall() { yield varCall; }
|
||||
|
||||
// classes
|
||||
class C {
|
||||
static readonly readonlyStaticCall = Symbol();
|
||||
static readonly readonlyStaticType: unique symbol;
|
||||
static readonly readonlyStaticTypeAndCall: unique symbol = Symbol();
|
||||
static readwriteStaticCall = Symbol();
|
||||
|
||||
readonly readonlyCall = Symbol();
|
||||
readwriteCall = Symbol();
|
||||
}
|
||||
declare const c: C;
|
||||
|
||||
const constInitToCReadonlyStaticCall = C.readonlyStaticCall;
|
||||
const constInitToCReadonlyStaticType = C.readonlyStaticType;
|
||||
const constInitToCReadonlyStaticTypeAndCall = C.readonlyStaticTypeAndCall;
|
||||
const constInitToCReadwriteStaticCall = C.readwriteStaticCall;
|
||||
|
||||
const constInitToCReadonlyStaticCallWithTypeQuery: typeof C.readonlyStaticCall = C.readonlyStaticCall;
|
||||
const constInitToCReadonlyStaticTypeWithTypeQuery: typeof C.readonlyStaticType = C.readonlyStaticType;
|
||||
const constInitToCReadonlyStaticTypeAndCallWithTypeQuery: typeof C.readonlyStaticTypeAndCall = C.readonlyStaticTypeAndCall;
|
||||
const constInitToCReadwriteStaticCallWithTypeQuery: typeof C.readwriteStaticCall = C.readwriteStaticCall;
|
||||
|
||||
const constInitToCReadonlyCall = c.readonlyCall;
|
||||
const constInitToCReadwriteCall = c.readwriteCall;
|
||||
const constInitToCReadonlyCallWithTypeQuery: typeof c.readonlyCall = c.readonlyCall;
|
||||
const constInitToCReadwriteCallWithTypeQuery: typeof c.readwriteCall = c.readwriteCall;
|
||||
const constInitToCReadonlyCallWithIndexedAccess: C["readonlyCall"] = c.readonlyCall;
|
||||
const constInitToCReadwriteCallWithIndexedAccess: C["readwriteCall"] = c.readwriteCall;
|
||||
|
||||
// interfaces
|
||||
interface I {
|
||||
readonly readonlyType: unique symbol;
|
||||
}
|
||||
declare const i: I;
|
||||
|
||||
const constInitToIReadonlyType = i.readonlyType;
|
||||
const constInitToIReadonlyTypeWithTypeQuery: typeof i.readonlyType = i.readonlyType;
|
||||
const constInitToIReadonlyTypeWithIndexedAccess: I["readonlyType"] = i.readonlyType;
|
||||
|
||||
// type literals
|
||||
type L = {
|
||||
readonly readonlyType: unique symbol;
|
||||
nested: {
|
||||
readonly readonlyNestedType: unique symbol;
|
||||
}
|
||||
};
|
||||
declare const l: L;
|
||||
|
||||
const constInitToLReadonlyType = l.readonlyType;
|
||||
const constInitToLReadonlyNestedType = l.nested.readonlyNestedType;
|
||||
const constInitToLReadonlyTypeWithTypeQuery: typeof l.readonlyType = l.readonlyType;
|
||||
const constInitToLReadonlyNestedTypeWithTypeQuery: typeof l.nested.readonlyNestedType = l.nested.readonlyNestedType;
|
||||
const constInitToLReadonlyTypeWithIndexedAccess: L["readonlyType"] = l.readonlyType;
|
||||
const constInitToLReadonlyNestedTypeWithIndexedAccess: L["nested"]["readonlyNestedType"] = l.nested.readonlyNestedType;
|
||||
|
||||
// type argument inference
|
||||
const promiseForConstCall = Promise.resolve(constCall);
|
||||
const arrayOfConstCall = [constCall];
|
||||
|
||||
// unique symbol widening in expressions
|
||||
declare const s: unique symbol;
|
||||
declare namespace N { const s: unique symbol; }
|
||||
declare const o: { [s]: "a", [N.s]: "b" };
|
||||
declare function f<T>(x: T): T;
|
||||
declare function g(x: typeof s): void;
|
||||
declare function g(x: typeof N.s): void;
|
||||
|
||||
// widening positions
|
||||
|
||||
// argument inference
|
||||
f(s);
|
||||
f(N.s);
|
||||
f(N["s"]);
|
||||
|
||||
// array literal elements
|
||||
[s];
|
||||
[N.s];
|
||||
[N["s"]];
|
||||
|
||||
// property assignments/methods
|
||||
const o2 = {
|
||||
a: s,
|
||||
b: N.s,
|
||||
c: N["s"],
|
||||
|
||||
method1() { return s; },
|
||||
async method2() { return s; },
|
||||
async * method3() { yield s; },
|
||||
* method4() { yield s; },
|
||||
method5(p = s) { return p; }
|
||||
};
|
||||
|
||||
// property initializers
|
||||
class C0 {
|
||||
static readonly a = s;
|
||||
static readonly b = N.s;
|
||||
static readonly c = N["s"];
|
||||
|
||||
static d = s;
|
||||
static e = N.s;
|
||||
static f = N["s"];
|
||||
|
||||
readonly a = s;
|
||||
readonly b = N.s;
|
||||
readonly c = N["s"];
|
||||
|
||||
d = s;
|
||||
e = N.s;
|
||||
f = N["s"];
|
||||
|
||||
method1() { return s; }
|
||||
async method2() { return s; }
|
||||
async * method3() { yield s; }
|
||||
* method4() { yield s; }
|
||||
method5(p = s) { return p; }
|
||||
}
|
||||
|
||||
// non-widening positions
|
||||
|
||||
// element access
|
||||
o[s];
|
||||
o[N.s];
|
||||
o[N["s"]];
|
||||
|
||||
// arguments (no-inference)
|
||||
f<typeof s>(s);
|
||||
f<typeof N.s>(N.s);
|
||||
f<typeof N.s>(N["s"]);
|
||||
g(s);
|
||||
g(N.s);
|
||||
g(N["s"]);
|
||||
|
||||
// falsy expressions
|
||||
s || "";
|
||||
N.s || "";
|
||||
N["s"] || "";
|
||||
|
||||
// conditionals
|
||||
Math.random() * 2 ? s : "a";
|
||||
Math.random() * 2 ? N.s : "a";
|
||||
Math.random() * 2 ? N["s"] : "a";
|
||||
|
||||
// computed property names
|
||||
({
|
||||
[s]: "a",
|
||||
[N.s]: "b",
|
||||
});
|
||||
|
||||
class C1 {
|
||||
static [s]: "a";
|
||||
static [N.s]: "b";
|
||||
|
||||
[s]: "a";
|
||||
[N.s]: "b";
|
||||
}
|
||||
|
||||
// contextual types
|
||||
|
||||
interface Context {
|
||||
method1(): typeof s;
|
||||
method2(): Promise<typeof s>;
|
||||
method3(): AsyncIterableIterator<typeof s>;
|
||||
method4(): IterableIterator<typeof s>;
|
||||
method5(p?: typeof s): typeof s;
|
||||
}
|
||||
|
||||
const o4: Context = {
|
||||
method1() {
|
||||
return s; // return type should not widen due to contextual type
|
||||
},
|
||||
async method2() {
|
||||
return s; // return type should not widen due to contextual type
|
||||
},
|
||||
async * method3() {
|
||||
yield s; // yield type should not widen due to contextual type
|
||||
},
|
||||
* method4() {
|
||||
yield s; // yield type should not widen due to contextual type
|
||||
},
|
||||
method5(p = s) { // parameter should not widen due to contextual type
|
||||
return p;
|
||||
}
|
||||
};
|
||||
|
||||
//// [uniqueSymbolsDeclarations.js]
|
||||
// declarations with call initializer
|
||||
const constCall = Symbol();
|
||||
let letCall = Symbol();
|
||||
var varCall = Symbol();
|
||||
// declaration with type and call initializer
|
||||
const constTypeAndCall = Symbol();
|
||||
// declaration from initializer
|
||||
const constInitToConstCall = constCall;
|
||||
const constInitToLetCall = letCall;
|
||||
const constInitToVarCall = varCall;
|
||||
const constInitToConstDeclAmbient = constType;
|
||||
let letInitToConstCall = constCall;
|
||||
let letInitToLetCall = letCall;
|
||||
let letInitToVarCall = varCall;
|
||||
let letInitToConstDeclAmbient = constType;
|
||||
var varInitToConstCall = constCall;
|
||||
var varInitToLetCall = letCall;
|
||||
var varInitToVarCall = varCall;
|
||||
var varInitToConstDeclAmbient = constType;
|
||||
// declaration from initializer with type query
|
||||
const constInitToConstCallWithTypeQuery = constCall;
|
||||
const constInitToConstDeclAmbientWithTypeQuery = constType;
|
||||
// function return inference
|
||||
function funcReturnConstCall() { return constCall; }
|
||||
function funcReturnLetCall() { return letCall; }
|
||||
function funcReturnVarCall() { return varCall; }
|
||||
// function return value with type query
|
||||
function funcReturnConstCallWithTypeQuery() { return constCall; }
|
||||
// generator function yield inference
|
||||
function* genFuncYieldConstCall() { yield constCall; }
|
||||
function* genFuncYieldLetCall() { yield letCall; }
|
||||
function* genFuncYieldVarCall() { yield varCall; }
|
||||
// generator function yield with return type query
|
||||
function* genFuncYieldConstCallWithTypeQuery() { yield constCall; }
|
||||
// async function return inference
|
||||
async function asyncFuncReturnConstCall() { return constCall; }
|
||||
async function asyncFuncReturnLetCall() { return letCall; }
|
||||
async function asyncFuncReturnVarCall() { return varCall; }
|
||||
// async generator function yield inference
|
||||
async function* asyncGenFuncYieldConstCall() { yield constCall; }
|
||||
async function* asyncGenFuncYieldLetCall() { yield letCall; }
|
||||
async function* asyncGenFuncYieldVarCall() { yield varCall; }
|
||||
// classes
|
||||
class C {
|
||||
constructor() {
|
||||
this.readonlyCall = Symbol();
|
||||
this.readwriteCall = Symbol();
|
||||
}
|
||||
}
|
||||
C.readonlyStaticCall = Symbol();
|
||||
C.readonlyStaticTypeAndCall = Symbol();
|
||||
C.readwriteStaticCall = Symbol();
|
||||
const constInitToCReadonlyStaticCall = C.readonlyStaticCall;
|
||||
const constInitToCReadonlyStaticType = C.readonlyStaticType;
|
||||
const constInitToCReadonlyStaticTypeAndCall = C.readonlyStaticTypeAndCall;
|
||||
const constInitToCReadwriteStaticCall = C.readwriteStaticCall;
|
||||
const constInitToCReadonlyStaticCallWithTypeQuery = C.readonlyStaticCall;
|
||||
const constInitToCReadonlyStaticTypeWithTypeQuery = C.readonlyStaticType;
|
||||
const constInitToCReadonlyStaticTypeAndCallWithTypeQuery = C.readonlyStaticTypeAndCall;
|
||||
const constInitToCReadwriteStaticCallWithTypeQuery = C.readwriteStaticCall;
|
||||
const constInitToCReadonlyCall = c.readonlyCall;
|
||||
const constInitToCReadwriteCall = c.readwriteCall;
|
||||
const constInitToCReadonlyCallWithTypeQuery = c.readonlyCall;
|
||||
const constInitToCReadwriteCallWithTypeQuery = c.readwriteCall;
|
||||
const constInitToCReadonlyCallWithIndexedAccess = c.readonlyCall;
|
||||
const constInitToCReadwriteCallWithIndexedAccess = c.readwriteCall;
|
||||
const constInitToIReadonlyType = i.readonlyType;
|
||||
const constInitToIReadonlyTypeWithTypeQuery = i.readonlyType;
|
||||
const constInitToIReadonlyTypeWithIndexedAccess = i.readonlyType;
|
||||
const constInitToLReadonlyType = l.readonlyType;
|
||||
const constInitToLReadonlyNestedType = l.nested.readonlyNestedType;
|
||||
const constInitToLReadonlyTypeWithTypeQuery = l.readonlyType;
|
||||
const constInitToLReadonlyNestedTypeWithTypeQuery = l.nested.readonlyNestedType;
|
||||
const constInitToLReadonlyTypeWithIndexedAccess = l.readonlyType;
|
||||
const constInitToLReadonlyNestedTypeWithIndexedAccess = l.nested.readonlyNestedType;
|
||||
// type argument inference
|
||||
const promiseForConstCall = Promise.resolve(constCall);
|
||||
const arrayOfConstCall = [constCall];
|
||||
// widening positions
|
||||
// argument inference
|
||||
f(s);
|
||||
f(N.s);
|
||||
f(N["s"]);
|
||||
// array literal elements
|
||||
[s];
|
||||
[N.s];
|
||||
[N["s"]];
|
||||
// property assignments/methods
|
||||
const o2 = {
|
||||
a: s,
|
||||
b: N.s,
|
||||
c: N["s"],
|
||||
method1() { return s; },
|
||||
async method2() { return s; },
|
||||
async *method3() { yield s; },
|
||||
*method4() { yield s; },
|
||||
method5(p = s) { return p; }
|
||||
};
|
||||
// property initializers
|
||||
class C0 {
|
||||
constructor() {
|
||||
this.a = s;
|
||||
this.b = N.s;
|
||||
this.c = N["s"];
|
||||
this.d = s;
|
||||
this.e = N.s;
|
||||
this.f = N["s"];
|
||||
}
|
||||
method1() { return s; }
|
||||
async method2() { return s; }
|
||||
async *method3() { yield s; }
|
||||
*method4() { yield s; }
|
||||
method5(p = s) { return p; }
|
||||
}
|
||||
C0.a = s;
|
||||
C0.b = N.s;
|
||||
C0.c = N["s"];
|
||||
C0.d = s;
|
||||
C0.e = N.s;
|
||||
C0.f = N["s"];
|
||||
// non-widening positions
|
||||
// element access
|
||||
o[s];
|
||||
o[N.s];
|
||||
o[N["s"]];
|
||||
// arguments (no-inference)
|
||||
f(s);
|
||||
f(N.s);
|
||||
f(N["s"]);
|
||||
g(s);
|
||||
g(N.s);
|
||||
g(N["s"]);
|
||||
// falsy expressions
|
||||
s || "";
|
||||
N.s || "";
|
||||
N["s"] || "";
|
||||
// conditionals
|
||||
Math.random() * 2 ? s : "a";
|
||||
Math.random() * 2 ? N.s : "a";
|
||||
Math.random() * 2 ? N["s"] : "a";
|
||||
// computed property names
|
||||
({
|
||||
[s]: "a",
|
||||
[N.s]: "b",
|
||||
});
|
||||
class C1 {
|
||||
}
|
||||
const o4 = {
|
||||
method1() {
|
||||
return s; // return type should not widen due to contextual type
|
||||
},
|
||||
async method2() {
|
||||
return s; // return type should not widen due to contextual type
|
||||
},
|
||||
async *method3() {
|
||||
yield s; // yield type should not widen due to contextual type
|
||||
},
|
||||
*method4() {
|
||||
yield s; // yield type should not widen due to contextual type
|
||||
},
|
||||
method5(p = s) {
|
||||
return p;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//// [uniqueSymbolsDeclarations.d.ts]
|
||||
declare const constCall: unique symbol;
|
||||
declare let letCall: symbol;
|
||||
declare var varCall: symbol;
|
||||
declare const constType: unique symbol;
|
||||
declare const constTypeAndCall: unique symbol;
|
||||
declare const constInitToConstCall: symbol;
|
||||
declare const constInitToLetCall: symbol;
|
||||
declare const constInitToVarCall: symbol;
|
||||
declare const constInitToConstDeclAmbient: symbol;
|
||||
declare let letInitToConstCall: symbol;
|
||||
declare let letInitToLetCall: symbol;
|
||||
declare let letInitToVarCall: symbol;
|
||||
declare let letInitToConstDeclAmbient: symbol;
|
||||
declare var varInitToConstCall: symbol;
|
||||
declare var varInitToLetCall: symbol;
|
||||
declare var varInitToVarCall: symbol;
|
||||
declare var varInitToConstDeclAmbient: symbol;
|
||||
declare const constInitToConstCallWithTypeQuery: typeof constCall;
|
||||
declare const constInitToConstDeclAmbientWithTypeQuery: typeof constType;
|
||||
declare function funcReturnConstCall(): symbol;
|
||||
declare function funcReturnLetCall(): symbol;
|
||||
declare function funcReturnVarCall(): symbol;
|
||||
declare function funcReturnConstCallWithTypeQuery(): typeof constCall;
|
||||
declare function genFuncYieldConstCall(): IterableIterator<symbol>;
|
||||
declare function genFuncYieldLetCall(): IterableIterator<symbol>;
|
||||
declare function genFuncYieldVarCall(): IterableIterator<symbol>;
|
||||
declare function genFuncYieldConstCallWithTypeQuery(): IterableIterator<typeof constCall>;
|
||||
declare function asyncFuncReturnConstCall(): Promise<symbol>;
|
||||
declare function asyncFuncReturnLetCall(): Promise<symbol>;
|
||||
declare function asyncFuncReturnVarCall(): Promise<symbol>;
|
||||
declare function asyncGenFuncYieldConstCall(): AsyncIterableIterator<symbol>;
|
||||
declare function asyncGenFuncYieldLetCall(): AsyncIterableIterator<symbol>;
|
||||
declare function asyncGenFuncYieldVarCall(): AsyncIterableIterator<symbol>;
|
||||
declare class C {
|
||||
static readonly readonlyStaticCall: unique symbol;
|
||||
static readonly readonlyStaticType: unique symbol;
|
||||
static readonly readonlyStaticTypeAndCall: unique symbol;
|
||||
static readwriteStaticCall: symbol;
|
||||
readonly readonlyCall: symbol;
|
||||
readwriteCall: symbol;
|
||||
}
|
||||
declare const c: C;
|
||||
declare const constInitToCReadonlyStaticCall: symbol;
|
||||
declare const constInitToCReadonlyStaticType: symbol;
|
||||
declare const constInitToCReadonlyStaticTypeAndCall: symbol;
|
||||
declare const constInitToCReadwriteStaticCall: symbol;
|
||||
declare const constInitToCReadonlyStaticCallWithTypeQuery: typeof C.readonlyStaticCall;
|
||||
declare const constInitToCReadonlyStaticTypeWithTypeQuery: typeof C.readonlyStaticType;
|
||||
declare const constInitToCReadonlyStaticTypeAndCallWithTypeQuery: typeof C.readonlyStaticTypeAndCall;
|
||||
declare const constInitToCReadwriteStaticCallWithTypeQuery: typeof C.readwriteStaticCall;
|
||||
declare const constInitToCReadonlyCall: symbol;
|
||||
declare const constInitToCReadwriteCall: symbol;
|
||||
declare const constInitToCReadonlyCallWithTypeQuery: typeof c.readonlyCall;
|
||||
declare const constInitToCReadwriteCallWithTypeQuery: typeof c.readwriteCall;
|
||||
declare const constInitToCReadonlyCallWithIndexedAccess: C["readonlyCall"];
|
||||
declare const constInitToCReadwriteCallWithIndexedAccess: C["readwriteCall"];
|
||||
interface I {
|
||||
readonly readonlyType: unique symbol;
|
||||
}
|
||||
declare const i: I;
|
||||
declare const constInitToIReadonlyType: symbol;
|
||||
declare const constInitToIReadonlyTypeWithTypeQuery: typeof i.readonlyType;
|
||||
declare const constInitToIReadonlyTypeWithIndexedAccess: I["readonlyType"];
|
||||
declare type L = {
|
||||
readonly readonlyType: unique symbol;
|
||||
nested: {
|
||||
readonly readonlyNestedType: unique symbol;
|
||||
};
|
||||
};
|
||||
declare const l: L;
|
||||
declare const constInitToLReadonlyType: symbol;
|
||||
declare const constInitToLReadonlyNestedType: symbol;
|
||||
declare const constInitToLReadonlyTypeWithTypeQuery: typeof l.readonlyType;
|
||||
declare const constInitToLReadonlyNestedTypeWithTypeQuery: typeof l.nested.readonlyNestedType;
|
||||
declare const constInitToLReadonlyTypeWithIndexedAccess: L["readonlyType"];
|
||||
declare const constInitToLReadonlyNestedTypeWithIndexedAccess: L["nested"]["readonlyNestedType"];
|
||||
declare const promiseForConstCall: Promise<symbol>;
|
||||
declare const arrayOfConstCall: symbol[];
|
||||
declare const s: unique symbol;
|
||||
declare namespace N {
|
||||
const s: unique symbol;
|
||||
}
|
||||
declare const o: {
|
||||
[s]: "a";
|
||||
[N.s]: "b";
|
||||
};
|
||||
declare function f<T>(x: T): T;
|
||||
declare function g(x: typeof s): void;
|
||||
declare function g(x: typeof N.s): void;
|
||||
declare const o2: {
|
||||
a: symbol;
|
||||
b: symbol;
|
||||
c: symbol;
|
||||
method1(): symbol;
|
||||
method2(): Promise<symbol>;
|
||||
method3(): AsyncIterableIterator<symbol>;
|
||||
method4(): IterableIterator<symbol>;
|
||||
method5(p?: symbol): symbol;
|
||||
};
|
||||
declare class C0 {
|
||||
static readonly a: symbol;
|
||||
static readonly b: symbol;
|
||||
static readonly c: symbol;
|
||||
static d: symbol;
|
||||
static e: symbol;
|
||||
static f: symbol;
|
||||
readonly a: symbol;
|
||||
readonly b: symbol;
|
||||
readonly c: symbol;
|
||||
d: symbol;
|
||||
e: symbol;
|
||||
f: symbol;
|
||||
method1(): symbol;
|
||||
method2(): Promise<symbol>;
|
||||
method3(): AsyncIterableIterator<symbol>;
|
||||
method4(): IterableIterator<symbol>;
|
||||
method5(p?: symbol): symbol;
|
||||
}
|
||||
declare class C1 {
|
||||
static [s]: "a";
|
||||
static [N.s]: "b";
|
||||
[s]: "a";
|
||||
[N.s]: "b";
|
||||
}
|
||||
interface Context {
|
||||
method1(): typeof s;
|
||||
method2(): Promise<typeof s>;
|
||||
method3(): AsyncIterableIterator<typeof s>;
|
||||
method4(): IterableIterator<typeof s>;
|
||||
method5(p?: typeof s): typeof s;
|
||||
}
|
||||
declare const o4: Context;
|
||||
@@ -0,0 +1,788 @@
|
||||
=== tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarations.ts ===
|
||||
// declarations with call initializer
|
||||
const constCall = Symbol();
|
||||
>constCall : Symbol(constCall, Decl(uniqueSymbolsDeclarations.ts, 1, 5))
|
||||
>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --))
|
||||
|
||||
let letCall = Symbol();
|
||||
>letCall : Symbol(letCall, Decl(uniqueSymbolsDeclarations.ts, 2, 3))
|
||||
>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --))
|
||||
|
||||
var varCall = Symbol();
|
||||
>varCall : Symbol(varCall, Decl(uniqueSymbolsDeclarations.ts, 3, 3))
|
||||
>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --))
|
||||
|
||||
// ambient declaration with type
|
||||
declare const constType: unique symbol;
|
||||
>constType : Symbol(constType, Decl(uniqueSymbolsDeclarations.ts, 6, 13))
|
||||
|
||||
// declaration with type and call initializer
|
||||
const constTypeAndCall: unique symbol = Symbol();
|
||||
>constTypeAndCall : Symbol(constTypeAndCall, Decl(uniqueSymbolsDeclarations.ts, 9, 5))
|
||||
>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --))
|
||||
|
||||
// declaration from initializer
|
||||
const constInitToConstCall = constCall;
|
||||
>constInitToConstCall : Symbol(constInitToConstCall, Decl(uniqueSymbolsDeclarations.ts, 12, 5))
|
||||
>constCall : Symbol(constCall, Decl(uniqueSymbolsDeclarations.ts, 1, 5))
|
||||
|
||||
const constInitToLetCall = letCall;
|
||||
>constInitToLetCall : Symbol(constInitToLetCall, Decl(uniqueSymbolsDeclarations.ts, 13, 5))
|
||||
>letCall : Symbol(letCall, Decl(uniqueSymbolsDeclarations.ts, 2, 3))
|
||||
|
||||
const constInitToVarCall = varCall;
|
||||
>constInitToVarCall : Symbol(constInitToVarCall, Decl(uniqueSymbolsDeclarations.ts, 14, 5))
|
||||
>varCall : Symbol(varCall, Decl(uniqueSymbolsDeclarations.ts, 3, 3))
|
||||
|
||||
const constInitToConstDeclAmbient = constType;
|
||||
>constInitToConstDeclAmbient : Symbol(constInitToConstDeclAmbient, Decl(uniqueSymbolsDeclarations.ts, 15, 5))
|
||||
>constType : Symbol(constType, Decl(uniqueSymbolsDeclarations.ts, 6, 13))
|
||||
|
||||
let letInitToConstCall = constCall;
|
||||
>letInitToConstCall : Symbol(letInitToConstCall, Decl(uniqueSymbolsDeclarations.ts, 16, 3))
|
||||
>constCall : Symbol(constCall, Decl(uniqueSymbolsDeclarations.ts, 1, 5))
|
||||
|
||||
let letInitToLetCall = letCall;
|
||||
>letInitToLetCall : Symbol(letInitToLetCall, Decl(uniqueSymbolsDeclarations.ts, 17, 3))
|
||||
>letCall : Symbol(letCall, Decl(uniqueSymbolsDeclarations.ts, 2, 3))
|
||||
|
||||
let letInitToVarCall = varCall;
|
||||
>letInitToVarCall : Symbol(letInitToVarCall, Decl(uniqueSymbolsDeclarations.ts, 18, 3))
|
||||
>varCall : Symbol(varCall, Decl(uniqueSymbolsDeclarations.ts, 3, 3))
|
||||
|
||||
let letInitToConstDeclAmbient = constType;
|
||||
>letInitToConstDeclAmbient : Symbol(letInitToConstDeclAmbient, Decl(uniqueSymbolsDeclarations.ts, 19, 3))
|
||||
>constType : Symbol(constType, Decl(uniqueSymbolsDeclarations.ts, 6, 13))
|
||||
|
||||
var varInitToConstCall = constCall;
|
||||
>varInitToConstCall : Symbol(varInitToConstCall, Decl(uniqueSymbolsDeclarations.ts, 20, 3))
|
||||
>constCall : Symbol(constCall, Decl(uniqueSymbolsDeclarations.ts, 1, 5))
|
||||
|
||||
var varInitToLetCall = letCall;
|
||||
>varInitToLetCall : Symbol(varInitToLetCall, Decl(uniqueSymbolsDeclarations.ts, 21, 3))
|
||||
>letCall : Symbol(letCall, Decl(uniqueSymbolsDeclarations.ts, 2, 3))
|
||||
|
||||
var varInitToVarCall = varCall;
|
||||
>varInitToVarCall : Symbol(varInitToVarCall, Decl(uniqueSymbolsDeclarations.ts, 22, 3))
|
||||
>varCall : Symbol(varCall, Decl(uniqueSymbolsDeclarations.ts, 3, 3))
|
||||
|
||||
var varInitToConstDeclAmbient = constType;
|
||||
>varInitToConstDeclAmbient : Symbol(varInitToConstDeclAmbient, Decl(uniqueSymbolsDeclarations.ts, 23, 3))
|
||||
>constType : Symbol(constType, Decl(uniqueSymbolsDeclarations.ts, 6, 13))
|
||||
|
||||
// declaration from initializer with type query
|
||||
const constInitToConstCallWithTypeQuery: typeof constCall = constCall;
|
||||
>constInitToConstCallWithTypeQuery : Symbol(constInitToConstCallWithTypeQuery, Decl(uniqueSymbolsDeclarations.ts, 26, 5))
|
||||
>constCall : Symbol(constCall, Decl(uniqueSymbolsDeclarations.ts, 1, 5))
|
||||
>constCall : Symbol(constCall, Decl(uniqueSymbolsDeclarations.ts, 1, 5))
|
||||
|
||||
const constInitToConstDeclAmbientWithTypeQuery: typeof constType = constType;
|
||||
>constInitToConstDeclAmbientWithTypeQuery : Symbol(constInitToConstDeclAmbientWithTypeQuery, Decl(uniqueSymbolsDeclarations.ts, 27, 5))
|
||||
>constType : Symbol(constType, Decl(uniqueSymbolsDeclarations.ts, 6, 13))
|
||||
>constType : Symbol(constType, Decl(uniqueSymbolsDeclarations.ts, 6, 13))
|
||||
|
||||
// function return inference
|
||||
function funcReturnConstCall() { return constCall; }
|
||||
>funcReturnConstCall : Symbol(funcReturnConstCall, Decl(uniqueSymbolsDeclarations.ts, 27, 77))
|
||||
>constCall : Symbol(constCall, Decl(uniqueSymbolsDeclarations.ts, 1, 5))
|
||||
|
||||
function funcReturnLetCall() { return letCall; }
|
||||
>funcReturnLetCall : Symbol(funcReturnLetCall, Decl(uniqueSymbolsDeclarations.ts, 30, 52))
|
||||
>letCall : Symbol(letCall, Decl(uniqueSymbolsDeclarations.ts, 2, 3))
|
||||
|
||||
function funcReturnVarCall() { return varCall; }
|
||||
>funcReturnVarCall : Symbol(funcReturnVarCall, Decl(uniqueSymbolsDeclarations.ts, 31, 48))
|
||||
>varCall : Symbol(varCall, Decl(uniqueSymbolsDeclarations.ts, 3, 3))
|
||||
|
||||
// function return value with type query
|
||||
function funcReturnConstCallWithTypeQuery(): typeof constCall { return constCall; }
|
||||
>funcReturnConstCallWithTypeQuery : Symbol(funcReturnConstCallWithTypeQuery, Decl(uniqueSymbolsDeclarations.ts, 32, 48))
|
||||
>constCall : Symbol(constCall, Decl(uniqueSymbolsDeclarations.ts, 1, 5))
|
||||
>constCall : Symbol(constCall, Decl(uniqueSymbolsDeclarations.ts, 1, 5))
|
||||
|
||||
// generator function yield inference
|
||||
function* genFuncYieldConstCall() { yield constCall; }
|
||||
>genFuncYieldConstCall : Symbol(genFuncYieldConstCall, Decl(uniqueSymbolsDeclarations.ts, 35, 83))
|
||||
>constCall : Symbol(constCall, Decl(uniqueSymbolsDeclarations.ts, 1, 5))
|
||||
|
||||
function* genFuncYieldLetCall() { yield letCall; }
|
||||
>genFuncYieldLetCall : Symbol(genFuncYieldLetCall, Decl(uniqueSymbolsDeclarations.ts, 38, 54))
|
||||
>letCall : Symbol(letCall, Decl(uniqueSymbolsDeclarations.ts, 2, 3))
|
||||
|
||||
function* genFuncYieldVarCall() { yield varCall; }
|
||||
>genFuncYieldVarCall : Symbol(genFuncYieldVarCall, Decl(uniqueSymbolsDeclarations.ts, 39, 50))
|
||||
>varCall : Symbol(varCall, Decl(uniqueSymbolsDeclarations.ts, 3, 3))
|
||||
|
||||
// generator function yield with return type query
|
||||
function* genFuncYieldConstCallWithTypeQuery(): IterableIterator<typeof constCall> { yield constCall; }
|
||||
>genFuncYieldConstCallWithTypeQuery : Symbol(genFuncYieldConstCallWithTypeQuery, Decl(uniqueSymbolsDeclarations.ts, 40, 50))
|
||||
>IterableIterator : Symbol(IterableIterator, Decl(lib.es2015.iterable.d.ts, --, --))
|
||||
>constCall : Symbol(constCall, Decl(uniqueSymbolsDeclarations.ts, 1, 5))
|
||||
>constCall : Symbol(constCall, Decl(uniqueSymbolsDeclarations.ts, 1, 5))
|
||||
|
||||
// async function return inference
|
||||
async function asyncFuncReturnConstCall() { return constCall; }
|
||||
>asyncFuncReturnConstCall : Symbol(asyncFuncReturnConstCall, Decl(uniqueSymbolsDeclarations.ts, 43, 103))
|
||||
>constCall : Symbol(constCall, Decl(uniqueSymbolsDeclarations.ts, 1, 5))
|
||||
|
||||
async function asyncFuncReturnLetCall() { return letCall; }
|
||||
>asyncFuncReturnLetCall : Symbol(asyncFuncReturnLetCall, Decl(uniqueSymbolsDeclarations.ts, 46, 63))
|
||||
>letCall : Symbol(letCall, Decl(uniqueSymbolsDeclarations.ts, 2, 3))
|
||||
|
||||
async function asyncFuncReturnVarCall() { return varCall; }
|
||||
>asyncFuncReturnVarCall : Symbol(asyncFuncReturnVarCall, Decl(uniqueSymbolsDeclarations.ts, 47, 59))
|
||||
>varCall : Symbol(varCall, Decl(uniqueSymbolsDeclarations.ts, 3, 3))
|
||||
|
||||
// async generator function yield inference
|
||||
async function* asyncGenFuncYieldConstCall() { yield constCall; }
|
||||
>asyncGenFuncYieldConstCall : Symbol(asyncGenFuncYieldConstCall, Decl(uniqueSymbolsDeclarations.ts, 48, 59))
|
||||
>constCall : Symbol(constCall, Decl(uniqueSymbolsDeclarations.ts, 1, 5))
|
||||
|
||||
async function* asyncGenFuncYieldLetCall() { yield letCall; }
|
||||
>asyncGenFuncYieldLetCall : Symbol(asyncGenFuncYieldLetCall, Decl(uniqueSymbolsDeclarations.ts, 51, 65))
|
||||
>letCall : Symbol(letCall, Decl(uniqueSymbolsDeclarations.ts, 2, 3))
|
||||
|
||||
async function* asyncGenFuncYieldVarCall() { yield varCall; }
|
||||
>asyncGenFuncYieldVarCall : Symbol(asyncGenFuncYieldVarCall, Decl(uniqueSymbolsDeclarations.ts, 52, 61))
|
||||
>varCall : Symbol(varCall, Decl(uniqueSymbolsDeclarations.ts, 3, 3))
|
||||
|
||||
// classes
|
||||
class C {
|
||||
>C : Symbol(C, Decl(uniqueSymbolsDeclarations.ts, 53, 61))
|
||||
|
||||
static readonly readonlyStaticCall = Symbol();
|
||||
>readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbolsDeclarations.ts, 56, 9))
|
||||
>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --))
|
||||
|
||||
static readonly readonlyStaticType: unique symbol;
|
||||
>readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbolsDeclarations.ts, 57, 50))
|
||||
|
||||
static readonly readonlyStaticTypeAndCall: unique symbol = Symbol();
|
||||
>readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbolsDeclarations.ts, 58, 54))
|
||||
>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --))
|
||||
|
||||
static readwriteStaticCall = Symbol();
|
||||
>readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbolsDeclarations.ts, 59, 72))
|
||||
>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --))
|
||||
|
||||
readonly readonlyCall = Symbol();
|
||||
>readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbolsDeclarations.ts, 60, 42))
|
||||
>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --))
|
||||
|
||||
readwriteCall = Symbol();
|
||||
>readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbolsDeclarations.ts, 62, 37))
|
||||
>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --))
|
||||
}
|
||||
declare const c: C;
|
||||
>c : Symbol(c, Decl(uniqueSymbolsDeclarations.ts, 65, 13))
|
||||
>C : Symbol(C, Decl(uniqueSymbolsDeclarations.ts, 53, 61))
|
||||
|
||||
const constInitToCReadonlyStaticCall = C.readonlyStaticCall;
|
||||
>constInitToCReadonlyStaticCall : Symbol(constInitToCReadonlyStaticCall, Decl(uniqueSymbolsDeclarations.ts, 67, 5))
|
||||
>C.readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbolsDeclarations.ts, 56, 9))
|
||||
>C : Symbol(C, Decl(uniqueSymbolsDeclarations.ts, 53, 61))
|
||||
>readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbolsDeclarations.ts, 56, 9))
|
||||
|
||||
const constInitToCReadonlyStaticType = C.readonlyStaticType;
|
||||
>constInitToCReadonlyStaticType : Symbol(constInitToCReadonlyStaticType, Decl(uniqueSymbolsDeclarations.ts, 68, 5))
|
||||
>C.readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbolsDeclarations.ts, 57, 50))
|
||||
>C : Symbol(C, Decl(uniqueSymbolsDeclarations.ts, 53, 61))
|
||||
>readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbolsDeclarations.ts, 57, 50))
|
||||
|
||||
const constInitToCReadonlyStaticTypeAndCall = C.readonlyStaticTypeAndCall;
|
||||
>constInitToCReadonlyStaticTypeAndCall : Symbol(constInitToCReadonlyStaticTypeAndCall, Decl(uniqueSymbolsDeclarations.ts, 69, 5))
|
||||
>C.readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbolsDeclarations.ts, 58, 54))
|
||||
>C : Symbol(C, Decl(uniqueSymbolsDeclarations.ts, 53, 61))
|
||||
>readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbolsDeclarations.ts, 58, 54))
|
||||
|
||||
const constInitToCReadwriteStaticCall = C.readwriteStaticCall;
|
||||
>constInitToCReadwriteStaticCall : Symbol(constInitToCReadwriteStaticCall, Decl(uniqueSymbolsDeclarations.ts, 70, 5))
|
||||
>C.readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbolsDeclarations.ts, 59, 72))
|
||||
>C : Symbol(C, Decl(uniqueSymbolsDeclarations.ts, 53, 61))
|
||||
>readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbolsDeclarations.ts, 59, 72))
|
||||
|
||||
const constInitToCReadonlyStaticCallWithTypeQuery: typeof C.readonlyStaticCall = C.readonlyStaticCall;
|
||||
>constInitToCReadonlyStaticCallWithTypeQuery : Symbol(constInitToCReadonlyStaticCallWithTypeQuery, Decl(uniqueSymbolsDeclarations.ts, 72, 5))
|
||||
>C.readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbolsDeclarations.ts, 56, 9))
|
||||
>C : Symbol(C, Decl(uniqueSymbolsDeclarations.ts, 53, 61))
|
||||
>readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbolsDeclarations.ts, 56, 9))
|
||||
>C.readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbolsDeclarations.ts, 56, 9))
|
||||
>C : Symbol(C, Decl(uniqueSymbolsDeclarations.ts, 53, 61))
|
||||
>readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbolsDeclarations.ts, 56, 9))
|
||||
|
||||
const constInitToCReadonlyStaticTypeWithTypeQuery: typeof C.readonlyStaticType = C.readonlyStaticType;
|
||||
>constInitToCReadonlyStaticTypeWithTypeQuery : Symbol(constInitToCReadonlyStaticTypeWithTypeQuery, Decl(uniqueSymbolsDeclarations.ts, 73, 5))
|
||||
>C.readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbolsDeclarations.ts, 57, 50))
|
||||
>C : Symbol(C, Decl(uniqueSymbolsDeclarations.ts, 53, 61))
|
||||
>readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbolsDeclarations.ts, 57, 50))
|
||||
>C.readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbolsDeclarations.ts, 57, 50))
|
||||
>C : Symbol(C, Decl(uniqueSymbolsDeclarations.ts, 53, 61))
|
||||
>readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbolsDeclarations.ts, 57, 50))
|
||||
|
||||
const constInitToCReadonlyStaticTypeAndCallWithTypeQuery: typeof C.readonlyStaticTypeAndCall = C.readonlyStaticTypeAndCall;
|
||||
>constInitToCReadonlyStaticTypeAndCallWithTypeQuery : Symbol(constInitToCReadonlyStaticTypeAndCallWithTypeQuery, Decl(uniqueSymbolsDeclarations.ts, 74, 5))
|
||||
>C.readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbolsDeclarations.ts, 58, 54))
|
||||
>C : Symbol(C, Decl(uniqueSymbolsDeclarations.ts, 53, 61))
|
||||
>readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbolsDeclarations.ts, 58, 54))
|
||||
>C.readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbolsDeclarations.ts, 58, 54))
|
||||
>C : Symbol(C, Decl(uniqueSymbolsDeclarations.ts, 53, 61))
|
||||
>readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbolsDeclarations.ts, 58, 54))
|
||||
|
||||
const constInitToCReadwriteStaticCallWithTypeQuery: typeof C.readwriteStaticCall = C.readwriteStaticCall;
|
||||
>constInitToCReadwriteStaticCallWithTypeQuery : Symbol(constInitToCReadwriteStaticCallWithTypeQuery, Decl(uniqueSymbolsDeclarations.ts, 75, 5))
|
||||
>C.readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbolsDeclarations.ts, 59, 72))
|
||||
>C : Symbol(C, Decl(uniqueSymbolsDeclarations.ts, 53, 61))
|
||||
>readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbolsDeclarations.ts, 59, 72))
|
||||
>C.readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbolsDeclarations.ts, 59, 72))
|
||||
>C : Symbol(C, Decl(uniqueSymbolsDeclarations.ts, 53, 61))
|
||||
>readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbolsDeclarations.ts, 59, 72))
|
||||
|
||||
const constInitToCReadonlyCall = c.readonlyCall;
|
||||
>constInitToCReadonlyCall : Symbol(constInitToCReadonlyCall, Decl(uniqueSymbolsDeclarations.ts, 77, 5))
|
||||
>c.readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbolsDeclarations.ts, 60, 42))
|
||||
>c : Symbol(c, Decl(uniqueSymbolsDeclarations.ts, 65, 13))
|
||||
>readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbolsDeclarations.ts, 60, 42))
|
||||
|
||||
const constInitToCReadwriteCall = c.readwriteCall;
|
||||
>constInitToCReadwriteCall : Symbol(constInitToCReadwriteCall, Decl(uniqueSymbolsDeclarations.ts, 78, 5))
|
||||
>c.readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbolsDeclarations.ts, 62, 37))
|
||||
>c : Symbol(c, Decl(uniqueSymbolsDeclarations.ts, 65, 13))
|
||||
>readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbolsDeclarations.ts, 62, 37))
|
||||
|
||||
const constInitToCReadonlyCallWithTypeQuery: typeof c.readonlyCall = c.readonlyCall;
|
||||
>constInitToCReadonlyCallWithTypeQuery : Symbol(constInitToCReadonlyCallWithTypeQuery, Decl(uniqueSymbolsDeclarations.ts, 79, 5))
|
||||
>c.readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbolsDeclarations.ts, 60, 42))
|
||||
>c : Symbol(c, Decl(uniqueSymbolsDeclarations.ts, 65, 13))
|
||||
>readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbolsDeclarations.ts, 60, 42))
|
||||
>c.readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbolsDeclarations.ts, 60, 42))
|
||||
>c : Symbol(c, Decl(uniqueSymbolsDeclarations.ts, 65, 13))
|
||||
>readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbolsDeclarations.ts, 60, 42))
|
||||
|
||||
const constInitToCReadwriteCallWithTypeQuery: typeof c.readwriteCall = c.readwriteCall;
|
||||
>constInitToCReadwriteCallWithTypeQuery : Symbol(constInitToCReadwriteCallWithTypeQuery, Decl(uniqueSymbolsDeclarations.ts, 80, 5))
|
||||
>c.readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbolsDeclarations.ts, 62, 37))
|
||||
>c : Symbol(c, Decl(uniqueSymbolsDeclarations.ts, 65, 13))
|
||||
>readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbolsDeclarations.ts, 62, 37))
|
||||
>c.readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbolsDeclarations.ts, 62, 37))
|
||||
>c : Symbol(c, Decl(uniqueSymbolsDeclarations.ts, 65, 13))
|
||||
>readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbolsDeclarations.ts, 62, 37))
|
||||
|
||||
const constInitToCReadonlyCallWithIndexedAccess: C["readonlyCall"] = c.readonlyCall;
|
||||
>constInitToCReadonlyCallWithIndexedAccess : Symbol(constInitToCReadonlyCallWithIndexedAccess, Decl(uniqueSymbolsDeclarations.ts, 81, 5))
|
||||
>C : Symbol(C, Decl(uniqueSymbolsDeclarations.ts, 53, 61))
|
||||
>c.readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbolsDeclarations.ts, 60, 42))
|
||||
>c : Symbol(c, Decl(uniqueSymbolsDeclarations.ts, 65, 13))
|
||||
>readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbolsDeclarations.ts, 60, 42))
|
||||
|
||||
const constInitToCReadwriteCallWithIndexedAccess: C["readwriteCall"] = c.readwriteCall;
|
||||
>constInitToCReadwriteCallWithIndexedAccess : Symbol(constInitToCReadwriteCallWithIndexedAccess, Decl(uniqueSymbolsDeclarations.ts, 82, 5))
|
||||
>C : Symbol(C, Decl(uniqueSymbolsDeclarations.ts, 53, 61))
|
||||
>c.readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbolsDeclarations.ts, 62, 37))
|
||||
>c : Symbol(c, Decl(uniqueSymbolsDeclarations.ts, 65, 13))
|
||||
>readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbolsDeclarations.ts, 62, 37))
|
||||
|
||||
// interfaces
|
||||
interface I {
|
||||
>I : Symbol(I, Decl(uniqueSymbolsDeclarations.ts, 82, 87))
|
||||
|
||||
readonly readonlyType: unique symbol;
|
||||
>readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbolsDeclarations.ts, 85, 13))
|
||||
}
|
||||
declare const i: I;
|
||||
>i : Symbol(i, Decl(uniqueSymbolsDeclarations.ts, 88, 13))
|
||||
>I : Symbol(I, Decl(uniqueSymbolsDeclarations.ts, 82, 87))
|
||||
|
||||
const constInitToIReadonlyType = i.readonlyType;
|
||||
>constInitToIReadonlyType : Symbol(constInitToIReadonlyType, Decl(uniqueSymbolsDeclarations.ts, 90, 5))
|
||||
>i.readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbolsDeclarations.ts, 85, 13))
|
||||
>i : Symbol(i, Decl(uniqueSymbolsDeclarations.ts, 88, 13))
|
||||
>readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbolsDeclarations.ts, 85, 13))
|
||||
|
||||
const constInitToIReadonlyTypeWithTypeQuery: typeof i.readonlyType = i.readonlyType;
|
||||
>constInitToIReadonlyTypeWithTypeQuery : Symbol(constInitToIReadonlyTypeWithTypeQuery, Decl(uniqueSymbolsDeclarations.ts, 91, 5))
|
||||
>i.readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbolsDeclarations.ts, 85, 13))
|
||||
>i : Symbol(i, Decl(uniqueSymbolsDeclarations.ts, 88, 13))
|
||||
>readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbolsDeclarations.ts, 85, 13))
|
||||
>i.readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbolsDeclarations.ts, 85, 13))
|
||||
>i : Symbol(i, Decl(uniqueSymbolsDeclarations.ts, 88, 13))
|
||||
>readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbolsDeclarations.ts, 85, 13))
|
||||
|
||||
const constInitToIReadonlyTypeWithIndexedAccess: I["readonlyType"] = i.readonlyType;
|
||||
>constInitToIReadonlyTypeWithIndexedAccess : Symbol(constInitToIReadonlyTypeWithIndexedAccess, Decl(uniqueSymbolsDeclarations.ts, 92, 5))
|
||||
>I : Symbol(I, Decl(uniqueSymbolsDeclarations.ts, 82, 87))
|
||||
>i.readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbolsDeclarations.ts, 85, 13))
|
||||
>i : Symbol(i, Decl(uniqueSymbolsDeclarations.ts, 88, 13))
|
||||
>readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbolsDeclarations.ts, 85, 13))
|
||||
|
||||
// type literals
|
||||
type L = {
|
||||
>L : Symbol(L, Decl(uniqueSymbolsDeclarations.ts, 92, 84))
|
||||
|
||||
readonly readonlyType: unique symbol;
|
||||
>readonlyType : Symbol(readonlyType, Decl(uniqueSymbolsDeclarations.ts, 95, 10))
|
||||
|
||||
nested: {
|
||||
>nested : Symbol(nested, Decl(uniqueSymbolsDeclarations.ts, 96, 41))
|
||||
|
||||
readonly readonlyNestedType: unique symbol;
|
||||
>readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbolsDeclarations.ts, 97, 13))
|
||||
}
|
||||
};
|
||||
declare const l: L;
|
||||
>l : Symbol(l, Decl(uniqueSymbolsDeclarations.ts, 101, 13))
|
||||
>L : Symbol(L, Decl(uniqueSymbolsDeclarations.ts, 92, 84))
|
||||
|
||||
const constInitToLReadonlyType = l.readonlyType;
|
||||
>constInitToLReadonlyType : Symbol(constInitToLReadonlyType, Decl(uniqueSymbolsDeclarations.ts, 103, 5))
|
||||
>l.readonlyType : Symbol(readonlyType, Decl(uniqueSymbolsDeclarations.ts, 95, 10))
|
||||
>l : Symbol(l, Decl(uniqueSymbolsDeclarations.ts, 101, 13))
|
||||
>readonlyType : Symbol(readonlyType, Decl(uniqueSymbolsDeclarations.ts, 95, 10))
|
||||
|
||||
const constInitToLReadonlyNestedType = l.nested.readonlyNestedType;
|
||||
>constInitToLReadonlyNestedType : Symbol(constInitToLReadonlyNestedType, Decl(uniqueSymbolsDeclarations.ts, 104, 5))
|
||||
>l.nested.readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbolsDeclarations.ts, 97, 13))
|
||||
>l.nested : Symbol(nested, Decl(uniqueSymbolsDeclarations.ts, 96, 41))
|
||||
>l : Symbol(l, Decl(uniqueSymbolsDeclarations.ts, 101, 13))
|
||||
>nested : Symbol(nested, Decl(uniqueSymbolsDeclarations.ts, 96, 41))
|
||||
>readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbolsDeclarations.ts, 97, 13))
|
||||
|
||||
const constInitToLReadonlyTypeWithTypeQuery: typeof l.readonlyType = l.readonlyType;
|
||||
>constInitToLReadonlyTypeWithTypeQuery : Symbol(constInitToLReadonlyTypeWithTypeQuery, Decl(uniqueSymbolsDeclarations.ts, 105, 5))
|
||||
>l.readonlyType : Symbol(readonlyType, Decl(uniqueSymbolsDeclarations.ts, 95, 10))
|
||||
>l : Symbol(l, Decl(uniqueSymbolsDeclarations.ts, 101, 13))
|
||||
>readonlyType : Symbol(readonlyType, Decl(uniqueSymbolsDeclarations.ts, 95, 10))
|
||||
>l.readonlyType : Symbol(readonlyType, Decl(uniqueSymbolsDeclarations.ts, 95, 10))
|
||||
>l : Symbol(l, Decl(uniqueSymbolsDeclarations.ts, 101, 13))
|
||||
>readonlyType : Symbol(readonlyType, Decl(uniqueSymbolsDeclarations.ts, 95, 10))
|
||||
|
||||
const constInitToLReadonlyNestedTypeWithTypeQuery: typeof l.nested.readonlyNestedType = l.nested.readonlyNestedType;
|
||||
>constInitToLReadonlyNestedTypeWithTypeQuery : Symbol(constInitToLReadonlyNestedTypeWithTypeQuery, Decl(uniqueSymbolsDeclarations.ts, 106, 5))
|
||||
>l.nested.readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbolsDeclarations.ts, 97, 13))
|
||||
>l.nested : Symbol(nested, Decl(uniqueSymbolsDeclarations.ts, 96, 41))
|
||||
>l : Symbol(l, Decl(uniqueSymbolsDeclarations.ts, 101, 13))
|
||||
>nested : Symbol(nested, Decl(uniqueSymbolsDeclarations.ts, 96, 41))
|
||||
>readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbolsDeclarations.ts, 97, 13))
|
||||
>l.nested.readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbolsDeclarations.ts, 97, 13))
|
||||
>l.nested : Symbol(nested, Decl(uniqueSymbolsDeclarations.ts, 96, 41))
|
||||
>l : Symbol(l, Decl(uniqueSymbolsDeclarations.ts, 101, 13))
|
||||
>nested : Symbol(nested, Decl(uniqueSymbolsDeclarations.ts, 96, 41))
|
||||
>readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbolsDeclarations.ts, 97, 13))
|
||||
|
||||
const constInitToLReadonlyTypeWithIndexedAccess: L["readonlyType"] = l.readonlyType;
|
||||
>constInitToLReadonlyTypeWithIndexedAccess : Symbol(constInitToLReadonlyTypeWithIndexedAccess, Decl(uniqueSymbolsDeclarations.ts, 107, 5))
|
||||
>L : Symbol(L, Decl(uniqueSymbolsDeclarations.ts, 92, 84))
|
||||
>l.readonlyType : Symbol(readonlyType, Decl(uniqueSymbolsDeclarations.ts, 95, 10))
|
||||
>l : Symbol(l, Decl(uniqueSymbolsDeclarations.ts, 101, 13))
|
||||
>readonlyType : Symbol(readonlyType, Decl(uniqueSymbolsDeclarations.ts, 95, 10))
|
||||
|
||||
const constInitToLReadonlyNestedTypeWithIndexedAccess: L["nested"]["readonlyNestedType"] = l.nested.readonlyNestedType;
|
||||
>constInitToLReadonlyNestedTypeWithIndexedAccess : Symbol(constInitToLReadonlyNestedTypeWithIndexedAccess, Decl(uniqueSymbolsDeclarations.ts, 108, 5))
|
||||
>L : Symbol(L, Decl(uniqueSymbolsDeclarations.ts, 92, 84))
|
||||
>l.nested.readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbolsDeclarations.ts, 97, 13))
|
||||
>l.nested : Symbol(nested, Decl(uniqueSymbolsDeclarations.ts, 96, 41))
|
||||
>l : Symbol(l, Decl(uniqueSymbolsDeclarations.ts, 101, 13))
|
||||
>nested : Symbol(nested, Decl(uniqueSymbolsDeclarations.ts, 96, 41))
|
||||
>readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbolsDeclarations.ts, 97, 13))
|
||||
|
||||
// type argument inference
|
||||
const promiseForConstCall = Promise.resolve(constCall);
|
||||
>promiseForConstCall : Symbol(promiseForConstCall, Decl(uniqueSymbolsDeclarations.ts, 111, 5))
|
||||
>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>constCall : Symbol(constCall, Decl(uniqueSymbolsDeclarations.ts, 1, 5))
|
||||
|
||||
const arrayOfConstCall = [constCall];
|
||||
>arrayOfConstCall : Symbol(arrayOfConstCall, Decl(uniqueSymbolsDeclarations.ts, 112, 5))
|
||||
>constCall : Symbol(constCall, Decl(uniqueSymbolsDeclarations.ts, 1, 5))
|
||||
|
||||
// unique symbol widening in expressions
|
||||
declare const s: unique symbol;
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13))
|
||||
|
||||
declare namespace N { const s: unique symbol; }
|
||||
>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31))
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
|
||||
declare const o: { [s]: "a", [N.s]: "b" };
|
||||
>o : Symbol(o, Decl(uniqueSymbolsDeclarations.ts, 117, 13))
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13))
|
||||
>N.s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31))
|
||||
>s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
|
||||
declare function f<T>(x: T): T;
|
||||
>f : Symbol(f, Decl(uniqueSymbolsDeclarations.ts, 117, 42))
|
||||
>T : Symbol(T, Decl(uniqueSymbolsDeclarations.ts, 118, 19))
|
||||
>x : Symbol(x, Decl(uniqueSymbolsDeclarations.ts, 118, 22))
|
||||
>T : Symbol(T, Decl(uniqueSymbolsDeclarations.ts, 118, 19))
|
||||
>T : Symbol(T, Decl(uniqueSymbolsDeclarations.ts, 118, 19))
|
||||
|
||||
declare function g(x: typeof s): void;
|
||||
>g : Symbol(g, Decl(uniqueSymbolsDeclarations.ts, 118, 31), Decl(uniqueSymbolsDeclarations.ts, 119, 38))
|
||||
>x : Symbol(x, Decl(uniqueSymbolsDeclarations.ts, 119, 19))
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13))
|
||||
|
||||
declare function g(x: typeof N.s): void;
|
||||
>g : Symbol(g, Decl(uniqueSymbolsDeclarations.ts, 118, 31), Decl(uniqueSymbolsDeclarations.ts, 119, 38))
|
||||
>x : Symbol(x, Decl(uniqueSymbolsDeclarations.ts, 120, 19))
|
||||
>N.s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31))
|
||||
>s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
|
||||
// widening positions
|
||||
|
||||
// argument inference
|
||||
f(s);
|
||||
>f : Symbol(f, Decl(uniqueSymbolsDeclarations.ts, 117, 42))
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13))
|
||||
|
||||
f(N.s);
|
||||
>f : Symbol(f, Decl(uniqueSymbolsDeclarations.ts, 117, 42))
|
||||
>N.s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31))
|
||||
>s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
|
||||
f(N["s"]);
|
||||
>f : Symbol(f, Decl(uniqueSymbolsDeclarations.ts, 117, 42))
|
||||
>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31))
|
||||
>"s" : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
|
||||
// array literal elements
|
||||
[s];
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13))
|
||||
|
||||
[N.s];
|
||||
>N.s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31))
|
||||
>s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
|
||||
[N["s"]];
|
||||
>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31))
|
||||
>"s" : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
|
||||
// property assignments/methods
|
||||
const o2 = {
|
||||
>o2 : Symbol(o2, Decl(uniqueSymbolsDeclarations.ts, 135, 5))
|
||||
|
||||
a: s,
|
||||
>a : Symbol(a, Decl(uniqueSymbolsDeclarations.ts, 135, 12))
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13))
|
||||
|
||||
b: N.s,
|
||||
>b : Symbol(b, Decl(uniqueSymbolsDeclarations.ts, 136, 9))
|
||||
>N.s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31))
|
||||
>s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
|
||||
c: N["s"],
|
||||
>c : Symbol(c, Decl(uniqueSymbolsDeclarations.ts, 137, 11))
|
||||
>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31))
|
||||
>"s" : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
|
||||
method1() { return s; },
|
||||
>method1 : Symbol(method1, Decl(uniqueSymbolsDeclarations.ts, 138, 14))
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13))
|
||||
|
||||
async method2() { return s; },
|
||||
>method2 : Symbol(method2, Decl(uniqueSymbolsDeclarations.ts, 140, 28))
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13))
|
||||
|
||||
async * method3() { yield s; },
|
||||
>method3 : Symbol(method3, Decl(uniqueSymbolsDeclarations.ts, 141, 34))
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13))
|
||||
|
||||
* method4() { yield s; },
|
||||
>method4 : Symbol(method4, Decl(uniqueSymbolsDeclarations.ts, 142, 35))
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13))
|
||||
|
||||
method5(p = s) { return p; }
|
||||
>method5 : Symbol(method5, Decl(uniqueSymbolsDeclarations.ts, 143, 29))
|
||||
>p : Symbol(p, Decl(uniqueSymbolsDeclarations.ts, 144, 12))
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13))
|
||||
>p : Symbol(p, Decl(uniqueSymbolsDeclarations.ts, 144, 12))
|
||||
|
||||
};
|
||||
|
||||
// property initializers
|
||||
class C0 {
|
||||
>C0 : Symbol(C0, Decl(uniqueSymbolsDeclarations.ts, 145, 2))
|
||||
|
||||
static readonly a = s;
|
||||
>a : Symbol(C0.a, Decl(uniqueSymbolsDeclarations.ts, 148, 10))
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13))
|
||||
|
||||
static readonly b = N.s;
|
||||
>b : Symbol(C0.b, Decl(uniqueSymbolsDeclarations.ts, 149, 26))
|
||||
>N.s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31))
|
||||
>s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
|
||||
static readonly c = N["s"];
|
||||
>c : Symbol(C0.c, Decl(uniqueSymbolsDeclarations.ts, 150, 28))
|
||||
>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31))
|
||||
>"s" : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
|
||||
static d = s;
|
||||
>d : Symbol(C0.d, Decl(uniqueSymbolsDeclarations.ts, 151, 31))
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13))
|
||||
|
||||
static e = N.s;
|
||||
>e : Symbol(C0.e, Decl(uniqueSymbolsDeclarations.ts, 153, 17))
|
||||
>N.s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31))
|
||||
>s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
|
||||
static f = N["s"];
|
||||
>f : Symbol(C0.f, Decl(uniqueSymbolsDeclarations.ts, 154, 19))
|
||||
>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31))
|
||||
>"s" : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
|
||||
readonly a = s;
|
||||
>a : Symbol(C0.a, Decl(uniqueSymbolsDeclarations.ts, 155, 22))
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13))
|
||||
|
||||
readonly b = N.s;
|
||||
>b : Symbol(C0.b, Decl(uniqueSymbolsDeclarations.ts, 157, 19))
|
||||
>N.s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31))
|
||||
>s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
|
||||
readonly c = N["s"];
|
||||
>c : Symbol(C0.c, Decl(uniqueSymbolsDeclarations.ts, 158, 21))
|
||||
>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31))
|
||||
>"s" : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
|
||||
d = s;
|
||||
>d : Symbol(C0.d, Decl(uniqueSymbolsDeclarations.ts, 159, 24))
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13))
|
||||
|
||||
e = N.s;
|
||||
>e : Symbol(C0.e, Decl(uniqueSymbolsDeclarations.ts, 161, 10))
|
||||
>N.s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31))
|
||||
>s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
|
||||
f = N["s"];
|
||||
>f : Symbol(C0.f, Decl(uniqueSymbolsDeclarations.ts, 162, 12))
|
||||
>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31))
|
||||
>"s" : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
|
||||
method1() { return s; }
|
||||
>method1 : Symbol(C0.method1, Decl(uniqueSymbolsDeclarations.ts, 163, 15))
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13))
|
||||
|
||||
async method2() { return s; }
|
||||
>method2 : Symbol(C0.method2, Decl(uniqueSymbolsDeclarations.ts, 165, 27))
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13))
|
||||
|
||||
async * method3() { yield s; }
|
||||
>method3 : Symbol(C0.method3, Decl(uniqueSymbolsDeclarations.ts, 166, 33))
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13))
|
||||
|
||||
* method4() { yield s; }
|
||||
>method4 : Symbol(C0.method4, Decl(uniqueSymbolsDeclarations.ts, 167, 34))
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13))
|
||||
|
||||
method5(p = s) { return p; }
|
||||
>method5 : Symbol(C0.method5, Decl(uniqueSymbolsDeclarations.ts, 168, 28))
|
||||
>p : Symbol(p, Decl(uniqueSymbolsDeclarations.ts, 169, 12))
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13))
|
||||
>p : Symbol(p, Decl(uniqueSymbolsDeclarations.ts, 169, 12))
|
||||
}
|
||||
|
||||
// non-widening positions
|
||||
|
||||
// element access
|
||||
o[s];
|
||||
>o : Symbol(o, Decl(uniqueSymbolsDeclarations.ts, 117, 13))
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13))
|
||||
|
||||
o[N.s];
|
||||
>o : Symbol(o, Decl(uniqueSymbolsDeclarations.ts, 117, 13))
|
||||
>N.s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31))
|
||||
>s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
|
||||
o[N["s"]];
|
||||
>o : Symbol(o, Decl(uniqueSymbolsDeclarations.ts, 117, 13))
|
||||
>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31))
|
||||
>"s" : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
|
||||
// arguments (no-inference)
|
||||
f<typeof s>(s);
|
||||
>f : Symbol(f, Decl(uniqueSymbolsDeclarations.ts, 117, 42))
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13))
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13))
|
||||
|
||||
f<typeof N.s>(N.s);
|
||||
>f : Symbol(f, Decl(uniqueSymbolsDeclarations.ts, 117, 42))
|
||||
>N.s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31))
|
||||
>s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
>N.s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31))
|
||||
>s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
|
||||
f<typeof N.s>(N["s"]);
|
||||
>f : Symbol(f, Decl(uniqueSymbolsDeclarations.ts, 117, 42))
|
||||
>N.s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31))
|
||||
>s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31))
|
||||
>"s" : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
|
||||
g(s);
|
||||
>g : Symbol(g, Decl(uniqueSymbolsDeclarations.ts, 118, 31), Decl(uniqueSymbolsDeclarations.ts, 119, 38))
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13))
|
||||
|
||||
g(N.s);
|
||||
>g : Symbol(g, Decl(uniqueSymbolsDeclarations.ts, 118, 31), Decl(uniqueSymbolsDeclarations.ts, 119, 38))
|
||||
>N.s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31))
|
||||
>s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
|
||||
g(N["s"]);
|
||||
>g : Symbol(g, Decl(uniqueSymbolsDeclarations.ts, 118, 31), Decl(uniqueSymbolsDeclarations.ts, 119, 38))
|
||||
>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31))
|
||||
>"s" : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
|
||||
// falsy expressions
|
||||
s || "";
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13))
|
||||
|
||||
N.s || "";
|
||||
>N.s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31))
|
||||
>s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
|
||||
N["s"] || "";
|
||||
>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31))
|
||||
>"s" : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
|
||||
// conditionals
|
||||
Math.random() * 2 ? s : "a";
|
||||
>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --))
|
||||
>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
|
||||
>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --))
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13))
|
||||
|
||||
Math.random() * 2 ? N.s : "a";
|
||||
>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --))
|
||||
>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
|
||||
>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --))
|
||||
>N.s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31))
|
||||
>s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
|
||||
Math.random() * 2 ? N["s"] : "a";
|
||||
>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --))
|
||||
>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --))
|
||||
>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --))
|
||||
>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31))
|
||||
>"s" : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
|
||||
// computed property names
|
||||
({
|
||||
[s]: "a",
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13))
|
||||
|
||||
[N.s]: "b",
|
||||
>N.s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31))
|
||||
>s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
|
||||
});
|
||||
|
||||
class C1 {
|
||||
>C1 : Symbol(C1, Decl(uniqueSymbolsDeclarations.ts, 201, 3))
|
||||
|
||||
static [s]: "a";
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13))
|
||||
|
||||
static [N.s]: "b";
|
||||
>N.s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31))
|
||||
>s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
|
||||
[s]: "a";
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13))
|
||||
|
||||
[N.s]: "b";
|
||||
>N.s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
>N : Symbol(N, Decl(uniqueSymbolsDeclarations.ts, 115, 31))
|
||||
>s : Symbol(N.s, Decl(uniqueSymbolsDeclarations.ts, 116, 27))
|
||||
}
|
||||
|
||||
// contextual types
|
||||
|
||||
interface Context {
|
||||
>Context : Symbol(Context, Decl(uniqueSymbolsDeclarations.ts, 209, 1))
|
||||
|
||||
method1(): typeof s;
|
||||
>method1 : Symbol(Context.method1, Decl(uniqueSymbolsDeclarations.ts, 213, 19))
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13))
|
||||
|
||||
method2(): Promise<typeof s>;
|
||||
>method2 : Symbol(Context.method2, Decl(uniqueSymbolsDeclarations.ts, 214, 24))
|
||||
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13))
|
||||
|
||||
method3(): AsyncIterableIterator<typeof s>;
|
||||
>method3 : Symbol(Context.method3, Decl(uniqueSymbolsDeclarations.ts, 215, 33))
|
||||
>AsyncIterableIterator : Symbol(AsyncIterableIterator, Decl(lib.esnext.asynciterable.d.ts, --, --))
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13))
|
||||
|
||||
method4(): IterableIterator<typeof s>;
|
||||
>method4 : Symbol(Context.method4, Decl(uniqueSymbolsDeclarations.ts, 216, 47))
|
||||
>IterableIterator : Symbol(IterableIterator, Decl(lib.es2015.iterable.d.ts, --, --))
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13))
|
||||
|
||||
method5(p?: typeof s): typeof s;
|
||||
>method5 : Symbol(Context.method5, Decl(uniqueSymbolsDeclarations.ts, 217, 42))
|
||||
>p : Symbol(p, Decl(uniqueSymbolsDeclarations.ts, 218, 12))
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13))
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13))
|
||||
}
|
||||
|
||||
const o4: Context = {
|
||||
>o4 : Symbol(o4, Decl(uniqueSymbolsDeclarations.ts, 221, 5))
|
||||
>Context : Symbol(Context, Decl(uniqueSymbolsDeclarations.ts, 209, 1))
|
||||
|
||||
method1() {
|
||||
>method1 : Symbol(method1, Decl(uniqueSymbolsDeclarations.ts, 221, 21))
|
||||
|
||||
return s; // return type should not widen due to contextual type
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13))
|
||||
|
||||
},
|
||||
async method2() {
|
||||
>method2 : Symbol(method2, Decl(uniqueSymbolsDeclarations.ts, 224, 6))
|
||||
|
||||
return s; // return type should not widen due to contextual type
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13))
|
||||
|
||||
},
|
||||
async * method3() {
|
||||
>method3 : Symbol(method3, Decl(uniqueSymbolsDeclarations.ts, 227, 6))
|
||||
|
||||
yield s; // yield type should not widen due to contextual type
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13))
|
||||
|
||||
},
|
||||
* method4() {
|
||||
>method4 : Symbol(method4, Decl(uniqueSymbolsDeclarations.ts, 230, 6))
|
||||
|
||||
yield s; // yield type should not widen due to contextual type
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13))
|
||||
|
||||
},
|
||||
method5(p = s) { // parameter should not widen due to contextual type
|
||||
>method5 : Symbol(method5, Decl(uniqueSymbolsDeclarations.ts, 233, 6))
|
||||
>p : Symbol(p, Decl(uniqueSymbolsDeclarations.ts, 234, 12))
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarations.ts, 115, 13))
|
||||
|
||||
return p;
|
||||
>p : Symbol(p, Decl(uniqueSymbolsDeclarations.ts, 234, 12))
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,867 @@
|
||||
=== tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarations.ts ===
|
||||
// declarations with call initializer
|
||||
const constCall = Symbol();
|
||||
>constCall : unique symbol
|
||||
>Symbol() : unique symbol
|
||||
>Symbol : SymbolConstructor
|
||||
|
||||
let letCall = Symbol();
|
||||
>letCall : symbol
|
||||
>Symbol() : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
|
||||
var varCall = Symbol();
|
||||
>varCall : symbol
|
||||
>Symbol() : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
|
||||
// ambient declaration with type
|
||||
declare const constType: unique symbol;
|
||||
>constType : unique symbol
|
||||
|
||||
// declaration with type and call initializer
|
||||
const constTypeAndCall: unique symbol = Symbol();
|
||||
>constTypeAndCall : unique symbol
|
||||
>Symbol() : unique symbol
|
||||
>Symbol : SymbolConstructor
|
||||
|
||||
// declaration from initializer
|
||||
const constInitToConstCall = constCall;
|
||||
>constInitToConstCall : symbol
|
||||
>constCall : unique symbol
|
||||
|
||||
const constInitToLetCall = letCall;
|
||||
>constInitToLetCall : symbol
|
||||
>letCall : symbol
|
||||
|
||||
const constInitToVarCall = varCall;
|
||||
>constInitToVarCall : symbol
|
||||
>varCall : symbol
|
||||
|
||||
const constInitToConstDeclAmbient = constType;
|
||||
>constInitToConstDeclAmbient : symbol
|
||||
>constType : unique symbol
|
||||
|
||||
let letInitToConstCall = constCall;
|
||||
>letInitToConstCall : symbol
|
||||
>constCall : unique symbol
|
||||
|
||||
let letInitToLetCall = letCall;
|
||||
>letInitToLetCall : symbol
|
||||
>letCall : symbol
|
||||
|
||||
let letInitToVarCall = varCall;
|
||||
>letInitToVarCall : symbol
|
||||
>varCall : symbol
|
||||
|
||||
let letInitToConstDeclAmbient = constType;
|
||||
>letInitToConstDeclAmbient : symbol
|
||||
>constType : unique symbol
|
||||
|
||||
var varInitToConstCall = constCall;
|
||||
>varInitToConstCall : symbol
|
||||
>constCall : unique symbol
|
||||
|
||||
var varInitToLetCall = letCall;
|
||||
>varInitToLetCall : symbol
|
||||
>letCall : symbol
|
||||
|
||||
var varInitToVarCall = varCall;
|
||||
>varInitToVarCall : symbol
|
||||
>varCall : symbol
|
||||
|
||||
var varInitToConstDeclAmbient = constType;
|
||||
>varInitToConstDeclAmbient : symbol
|
||||
>constType : unique symbol
|
||||
|
||||
// declaration from initializer with type query
|
||||
const constInitToConstCallWithTypeQuery: typeof constCall = constCall;
|
||||
>constInitToConstCallWithTypeQuery : unique symbol
|
||||
>constCall : unique symbol
|
||||
>constCall : unique symbol
|
||||
|
||||
const constInitToConstDeclAmbientWithTypeQuery: typeof constType = constType;
|
||||
>constInitToConstDeclAmbientWithTypeQuery : unique symbol
|
||||
>constType : unique symbol
|
||||
>constType : unique symbol
|
||||
|
||||
// function return inference
|
||||
function funcReturnConstCall() { return constCall; }
|
||||
>funcReturnConstCall : () => symbol
|
||||
>constCall : unique symbol
|
||||
|
||||
function funcReturnLetCall() { return letCall; }
|
||||
>funcReturnLetCall : () => symbol
|
||||
>letCall : symbol
|
||||
|
||||
function funcReturnVarCall() { return varCall; }
|
||||
>funcReturnVarCall : () => symbol
|
||||
>varCall : symbol
|
||||
|
||||
// function return value with type query
|
||||
function funcReturnConstCallWithTypeQuery(): typeof constCall { return constCall; }
|
||||
>funcReturnConstCallWithTypeQuery : () => unique symbol
|
||||
>constCall : unique symbol
|
||||
>constCall : unique symbol
|
||||
|
||||
// generator function yield inference
|
||||
function* genFuncYieldConstCall() { yield constCall; }
|
||||
>genFuncYieldConstCall : () => IterableIterator<symbol>
|
||||
>yield constCall : any
|
||||
>constCall : unique symbol
|
||||
|
||||
function* genFuncYieldLetCall() { yield letCall; }
|
||||
>genFuncYieldLetCall : () => IterableIterator<symbol>
|
||||
>yield letCall : any
|
||||
>letCall : symbol
|
||||
|
||||
function* genFuncYieldVarCall() { yield varCall; }
|
||||
>genFuncYieldVarCall : () => IterableIterator<symbol>
|
||||
>yield varCall : any
|
||||
>varCall : symbol
|
||||
|
||||
// generator function yield with return type query
|
||||
function* genFuncYieldConstCallWithTypeQuery(): IterableIterator<typeof constCall> { yield constCall; }
|
||||
>genFuncYieldConstCallWithTypeQuery : () => IterableIterator<unique symbol>
|
||||
>IterableIterator : IterableIterator<T>
|
||||
>constCall : unique symbol
|
||||
>yield constCall : any
|
||||
>constCall : unique symbol
|
||||
|
||||
// async function return inference
|
||||
async function asyncFuncReturnConstCall() { return constCall; }
|
||||
>asyncFuncReturnConstCall : () => Promise<symbol>
|
||||
>constCall : unique symbol
|
||||
|
||||
async function asyncFuncReturnLetCall() { return letCall; }
|
||||
>asyncFuncReturnLetCall : () => Promise<symbol>
|
||||
>letCall : symbol
|
||||
|
||||
async function asyncFuncReturnVarCall() { return varCall; }
|
||||
>asyncFuncReturnVarCall : () => Promise<symbol>
|
||||
>varCall : symbol
|
||||
|
||||
// async generator function yield inference
|
||||
async function* asyncGenFuncYieldConstCall() { yield constCall; }
|
||||
>asyncGenFuncYieldConstCall : () => AsyncIterableIterator<symbol>
|
||||
>yield constCall : any
|
||||
>constCall : unique symbol
|
||||
|
||||
async function* asyncGenFuncYieldLetCall() { yield letCall; }
|
||||
>asyncGenFuncYieldLetCall : () => AsyncIterableIterator<symbol>
|
||||
>yield letCall : any
|
||||
>letCall : symbol
|
||||
|
||||
async function* asyncGenFuncYieldVarCall() { yield varCall; }
|
||||
>asyncGenFuncYieldVarCall : () => AsyncIterableIterator<symbol>
|
||||
>yield varCall : any
|
||||
>varCall : symbol
|
||||
|
||||
// classes
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
static readonly readonlyStaticCall = Symbol();
|
||||
>readonlyStaticCall : unique symbol
|
||||
>Symbol() : unique symbol
|
||||
>Symbol : SymbolConstructor
|
||||
|
||||
static readonly readonlyStaticType: unique symbol;
|
||||
>readonlyStaticType : unique symbol
|
||||
|
||||
static readonly readonlyStaticTypeAndCall: unique symbol = Symbol();
|
||||
>readonlyStaticTypeAndCall : unique symbol
|
||||
>Symbol() : unique symbol
|
||||
>Symbol : SymbolConstructor
|
||||
|
||||
static readwriteStaticCall = Symbol();
|
||||
>readwriteStaticCall : symbol
|
||||
>Symbol() : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
|
||||
readonly readonlyCall = Symbol();
|
||||
>readonlyCall : symbol
|
||||
>Symbol() : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
|
||||
readwriteCall = Symbol();
|
||||
>readwriteCall : symbol
|
||||
>Symbol() : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
}
|
||||
declare const c: C;
|
||||
>c : C
|
||||
>C : C
|
||||
|
||||
const constInitToCReadonlyStaticCall = C.readonlyStaticCall;
|
||||
>constInitToCReadonlyStaticCall : symbol
|
||||
>C.readonlyStaticCall : unique symbol
|
||||
>C : typeof C
|
||||
>readonlyStaticCall : unique symbol
|
||||
|
||||
const constInitToCReadonlyStaticType = C.readonlyStaticType;
|
||||
>constInitToCReadonlyStaticType : symbol
|
||||
>C.readonlyStaticType : unique symbol
|
||||
>C : typeof C
|
||||
>readonlyStaticType : unique symbol
|
||||
|
||||
const constInitToCReadonlyStaticTypeAndCall = C.readonlyStaticTypeAndCall;
|
||||
>constInitToCReadonlyStaticTypeAndCall : symbol
|
||||
>C.readonlyStaticTypeAndCall : unique symbol
|
||||
>C : typeof C
|
||||
>readonlyStaticTypeAndCall : unique symbol
|
||||
|
||||
const constInitToCReadwriteStaticCall = C.readwriteStaticCall;
|
||||
>constInitToCReadwriteStaticCall : symbol
|
||||
>C.readwriteStaticCall : symbol
|
||||
>C : typeof C
|
||||
>readwriteStaticCall : symbol
|
||||
|
||||
const constInitToCReadonlyStaticCallWithTypeQuery: typeof C.readonlyStaticCall = C.readonlyStaticCall;
|
||||
>constInitToCReadonlyStaticCallWithTypeQuery : unique symbol
|
||||
>C.readonlyStaticCall : unique symbol
|
||||
>C : typeof C
|
||||
>readonlyStaticCall : unique symbol
|
||||
>C.readonlyStaticCall : unique symbol
|
||||
>C : typeof C
|
||||
>readonlyStaticCall : unique symbol
|
||||
|
||||
const constInitToCReadonlyStaticTypeWithTypeQuery: typeof C.readonlyStaticType = C.readonlyStaticType;
|
||||
>constInitToCReadonlyStaticTypeWithTypeQuery : unique symbol
|
||||
>C.readonlyStaticType : unique symbol
|
||||
>C : typeof C
|
||||
>readonlyStaticType : unique symbol
|
||||
>C.readonlyStaticType : unique symbol
|
||||
>C : typeof C
|
||||
>readonlyStaticType : unique symbol
|
||||
|
||||
const constInitToCReadonlyStaticTypeAndCallWithTypeQuery: typeof C.readonlyStaticTypeAndCall = C.readonlyStaticTypeAndCall;
|
||||
>constInitToCReadonlyStaticTypeAndCallWithTypeQuery : unique symbol
|
||||
>C.readonlyStaticTypeAndCall : unique symbol
|
||||
>C : typeof C
|
||||
>readonlyStaticTypeAndCall : unique symbol
|
||||
>C.readonlyStaticTypeAndCall : unique symbol
|
||||
>C : typeof C
|
||||
>readonlyStaticTypeAndCall : unique symbol
|
||||
|
||||
const constInitToCReadwriteStaticCallWithTypeQuery: typeof C.readwriteStaticCall = C.readwriteStaticCall;
|
||||
>constInitToCReadwriteStaticCallWithTypeQuery : symbol
|
||||
>C.readwriteStaticCall : symbol
|
||||
>C : typeof C
|
||||
>readwriteStaticCall : symbol
|
||||
>C.readwriteStaticCall : symbol
|
||||
>C : typeof C
|
||||
>readwriteStaticCall : symbol
|
||||
|
||||
const constInitToCReadonlyCall = c.readonlyCall;
|
||||
>constInitToCReadonlyCall : symbol
|
||||
>c.readonlyCall : symbol
|
||||
>c : C
|
||||
>readonlyCall : symbol
|
||||
|
||||
const constInitToCReadwriteCall = c.readwriteCall;
|
||||
>constInitToCReadwriteCall : symbol
|
||||
>c.readwriteCall : symbol
|
||||
>c : C
|
||||
>readwriteCall : symbol
|
||||
|
||||
const constInitToCReadonlyCallWithTypeQuery: typeof c.readonlyCall = c.readonlyCall;
|
||||
>constInitToCReadonlyCallWithTypeQuery : symbol
|
||||
>c.readonlyCall : symbol
|
||||
>c : C
|
||||
>readonlyCall : symbol
|
||||
>c.readonlyCall : symbol
|
||||
>c : C
|
||||
>readonlyCall : symbol
|
||||
|
||||
const constInitToCReadwriteCallWithTypeQuery: typeof c.readwriteCall = c.readwriteCall;
|
||||
>constInitToCReadwriteCallWithTypeQuery : symbol
|
||||
>c.readwriteCall : symbol
|
||||
>c : C
|
||||
>readwriteCall : symbol
|
||||
>c.readwriteCall : symbol
|
||||
>c : C
|
||||
>readwriteCall : symbol
|
||||
|
||||
const constInitToCReadonlyCallWithIndexedAccess: C["readonlyCall"] = c.readonlyCall;
|
||||
>constInitToCReadonlyCallWithIndexedAccess : symbol
|
||||
>C : C
|
||||
>c.readonlyCall : symbol
|
||||
>c : C
|
||||
>readonlyCall : symbol
|
||||
|
||||
const constInitToCReadwriteCallWithIndexedAccess: C["readwriteCall"] = c.readwriteCall;
|
||||
>constInitToCReadwriteCallWithIndexedAccess : symbol
|
||||
>C : C
|
||||
>c.readwriteCall : symbol
|
||||
>c : C
|
||||
>readwriteCall : symbol
|
||||
|
||||
// interfaces
|
||||
interface I {
|
||||
>I : I
|
||||
|
||||
readonly readonlyType: unique symbol;
|
||||
>readonlyType : unique symbol
|
||||
}
|
||||
declare const i: I;
|
||||
>i : I
|
||||
>I : I
|
||||
|
||||
const constInitToIReadonlyType = i.readonlyType;
|
||||
>constInitToIReadonlyType : symbol
|
||||
>i.readonlyType : unique symbol
|
||||
>i : I
|
||||
>readonlyType : unique symbol
|
||||
|
||||
const constInitToIReadonlyTypeWithTypeQuery: typeof i.readonlyType = i.readonlyType;
|
||||
>constInitToIReadonlyTypeWithTypeQuery : unique symbol
|
||||
>i.readonlyType : unique symbol
|
||||
>i : I
|
||||
>readonlyType : unique symbol
|
||||
>i.readonlyType : unique symbol
|
||||
>i : I
|
||||
>readonlyType : unique symbol
|
||||
|
||||
const constInitToIReadonlyTypeWithIndexedAccess: I["readonlyType"] = i.readonlyType;
|
||||
>constInitToIReadonlyTypeWithIndexedAccess : unique symbol
|
||||
>I : I
|
||||
>i.readonlyType : unique symbol
|
||||
>i : I
|
||||
>readonlyType : unique symbol
|
||||
|
||||
// type literals
|
||||
type L = {
|
||||
>L : L
|
||||
|
||||
readonly readonlyType: unique symbol;
|
||||
>readonlyType : unique symbol
|
||||
|
||||
nested: {
|
||||
>nested : { readonly readonlyNestedType: unique symbol; }
|
||||
|
||||
readonly readonlyNestedType: unique symbol;
|
||||
>readonlyNestedType : unique symbol
|
||||
}
|
||||
};
|
||||
declare const l: L;
|
||||
>l : L
|
||||
>L : L
|
||||
|
||||
const constInitToLReadonlyType = l.readonlyType;
|
||||
>constInitToLReadonlyType : symbol
|
||||
>l.readonlyType : unique symbol
|
||||
>l : L
|
||||
>readonlyType : unique symbol
|
||||
|
||||
const constInitToLReadonlyNestedType = l.nested.readonlyNestedType;
|
||||
>constInitToLReadonlyNestedType : symbol
|
||||
>l.nested.readonlyNestedType : unique symbol
|
||||
>l.nested : { readonly readonlyNestedType: unique symbol; }
|
||||
>l : L
|
||||
>nested : { readonly readonlyNestedType: unique symbol; }
|
||||
>readonlyNestedType : unique symbol
|
||||
|
||||
const constInitToLReadonlyTypeWithTypeQuery: typeof l.readonlyType = l.readonlyType;
|
||||
>constInitToLReadonlyTypeWithTypeQuery : unique symbol
|
||||
>l.readonlyType : unique symbol
|
||||
>l : L
|
||||
>readonlyType : unique symbol
|
||||
>l.readonlyType : unique symbol
|
||||
>l : L
|
||||
>readonlyType : unique symbol
|
||||
|
||||
const constInitToLReadonlyNestedTypeWithTypeQuery: typeof l.nested.readonlyNestedType = l.nested.readonlyNestedType;
|
||||
>constInitToLReadonlyNestedTypeWithTypeQuery : unique symbol
|
||||
>l.nested.readonlyNestedType : unique symbol
|
||||
>l.nested : { readonly readonlyNestedType: unique symbol; }
|
||||
>l : L
|
||||
>nested : { readonly readonlyNestedType: unique symbol; }
|
||||
>readonlyNestedType : unique symbol
|
||||
>l.nested.readonlyNestedType : unique symbol
|
||||
>l.nested : { readonly readonlyNestedType: unique symbol; }
|
||||
>l : L
|
||||
>nested : { readonly readonlyNestedType: unique symbol; }
|
||||
>readonlyNestedType : unique symbol
|
||||
|
||||
const constInitToLReadonlyTypeWithIndexedAccess: L["readonlyType"] = l.readonlyType;
|
||||
>constInitToLReadonlyTypeWithIndexedAccess : unique symbol
|
||||
>L : L
|
||||
>l.readonlyType : unique symbol
|
||||
>l : L
|
||||
>readonlyType : unique symbol
|
||||
|
||||
const constInitToLReadonlyNestedTypeWithIndexedAccess: L["nested"]["readonlyNestedType"] = l.nested.readonlyNestedType;
|
||||
>constInitToLReadonlyNestedTypeWithIndexedAccess : unique symbol
|
||||
>L : L
|
||||
>l.nested.readonlyNestedType : unique symbol
|
||||
>l.nested : { readonly readonlyNestedType: unique symbol; }
|
||||
>l : L
|
||||
>nested : { readonly readonlyNestedType: unique symbol; }
|
||||
>readonlyNestedType : unique symbol
|
||||
|
||||
// type argument inference
|
||||
const promiseForConstCall = Promise.resolve(constCall);
|
||||
>promiseForConstCall : Promise<symbol>
|
||||
>Promise.resolve(constCall) : Promise<symbol>
|
||||
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
|
||||
>Promise : PromiseConstructor
|
||||
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
|
||||
>constCall : unique symbol
|
||||
|
||||
const arrayOfConstCall = [constCall];
|
||||
>arrayOfConstCall : symbol[]
|
||||
>[constCall] : symbol[]
|
||||
>constCall : unique symbol
|
||||
|
||||
// unique symbol widening in expressions
|
||||
declare const s: unique symbol;
|
||||
>s : unique symbol
|
||||
|
||||
declare namespace N { const s: unique symbol; }
|
||||
>N : typeof N
|
||||
>s : unique symbol
|
||||
|
||||
declare const o: { [s]: "a", [N.s]: "b" };
|
||||
>o : { [s]: "a"; [N.s]: "b"; }
|
||||
>s : unique symbol
|
||||
>N.s : unique symbol
|
||||
>N : typeof N
|
||||
>s : unique symbol
|
||||
|
||||
declare function f<T>(x: T): T;
|
||||
>f : <T>(x: T) => T
|
||||
>T : T
|
||||
>x : T
|
||||
>T : T
|
||||
>T : T
|
||||
|
||||
declare function g(x: typeof s): void;
|
||||
>g : { (x: unique symbol): void; (x: unique symbol): void; }
|
||||
>x : unique symbol
|
||||
>s : unique symbol
|
||||
|
||||
declare function g(x: typeof N.s): void;
|
||||
>g : { (x: unique symbol): void; (x: unique symbol): void; }
|
||||
>x : unique symbol
|
||||
>N.s : unique symbol
|
||||
>N : typeof N
|
||||
>s : unique symbol
|
||||
|
||||
// widening positions
|
||||
|
||||
// argument inference
|
||||
f(s);
|
||||
>f(s) : symbol
|
||||
>f : <T>(x: T) => T
|
||||
>s : unique symbol
|
||||
|
||||
f(N.s);
|
||||
>f(N.s) : symbol
|
||||
>f : <T>(x: T) => T
|
||||
>N.s : unique symbol
|
||||
>N : typeof N
|
||||
>s : unique symbol
|
||||
|
||||
f(N["s"]);
|
||||
>f(N["s"]) : symbol
|
||||
>f : <T>(x: T) => T
|
||||
>N["s"] : unique symbol
|
||||
>N : typeof N
|
||||
>"s" : "s"
|
||||
|
||||
// array literal elements
|
||||
[s];
|
||||
>[s] : symbol[]
|
||||
>s : unique symbol
|
||||
|
||||
[N.s];
|
||||
>[N.s] : symbol[]
|
||||
>N.s : unique symbol
|
||||
>N : typeof N
|
||||
>s : unique symbol
|
||||
|
||||
[N["s"]];
|
||||
>[N["s"]] : symbol[]
|
||||
>N["s"] : unique symbol
|
||||
>N : typeof N
|
||||
>"s" : "s"
|
||||
|
||||
// property assignments/methods
|
||||
const o2 = {
|
||||
>o2 : { a: symbol; b: symbol; c: symbol; method1(): symbol; method2(): Promise<symbol>; method3(): AsyncIterableIterator<symbol>; method4(): IterableIterator<symbol>; method5(p?: symbol): symbol; }
|
||||
>{ a: s, b: N.s, c: N["s"], method1() { return s; }, async method2() { return s; }, async * method3() { yield s; }, * method4() { yield s; }, method5(p = s) { return p; }} : { a: symbol; b: symbol; c: symbol; method1(): symbol; method2(): Promise<symbol>; method3(): AsyncIterableIterator<symbol>; method4(): IterableIterator<symbol>; method5(p?: symbol): symbol; }
|
||||
|
||||
a: s,
|
||||
>a : symbol
|
||||
>s : unique symbol
|
||||
|
||||
b: N.s,
|
||||
>b : symbol
|
||||
>N.s : unique symbol
|
||||
>N : typeof N
|
||||
>s : unique symbol
|
||||
|
||||
c: N["s"],
|
||||
>c : symbol
|
||||
>N["s"] : unique symbol
|
||||
>N : typeof N
|
||||
>"s" : "s"
|
||||
|
||||
method1() { return s; },
|
||||
>method1 : () => symbol
|
||||
>s : unique symbol
|
||||
|
||||
async method2() { return s; },
|
||||
>method2 : () => Promise<symbol>
|
||||
>s : unique symbol
|
||||
|
||||
async * method3() { yield s; },
|
||||
>method3 : () => AsyncIterableIterator<symbol>
|
||||
>yield s : any
|
||||
>s : unique symbol
|
||||
|
||||
* method4() { yield s; },
|
||||
>method4 : () => IterableIterator<symbol>
|
||||
>yield s : any
|
||||
>s : unique symbol
|
||||
|
||||
method5(p = s) { return p; }
|
||||
>method5 : (p?: symbol) => symbol
|
||||
>p : symbol
|
||||
>s : unique symbol
|
||||
>p : symbol
|
||||
|
||||
};
|
||||
|
||||
// property initializers
|
||||
class C0 {
|
||||
>C0 : C0
|
||||
|
||||
static readonly a = s;
|
||||
>a : symbol
|
||||
>s : unique symbol
|
||||
|
||||
static readonly b = N.s;
|
||||
>b : symbol
|
||||
>N.s : unique symbol
|
||||
>N : typeof N
|
||||
>s : unique symbol
|
||||
|
||||
static readonly c = N["s"];
|
||||
>c : symbol
|
||||
>N["s"] : unique symbol
|
||||
>N : typeof N
|
||||
>"s" : "s"
|
||||
|
||||
static d = s;
|
||||
>d : symbol
|
||||
>s : unique symbol
|
||||
|
||||
static e = N.s;
|
||||
>e : symbol
|
||||
>N.s : unique symbol
|
||||
>N : typeof N
|
||||
>s : unique symbol
|
||||
|
||||
static f = N["s"];
|
||||
>f : symbol
|
||||
>N["s"] : unique symbol
|
||||
>N : typeof N
|
||||
>"s" : "s"
|
||||
|
||||
readonly a = s;
|
||||
>a : symbol
|
||||
>s : unique symbol
|
||||
|
||||
readonly b = N.s;
|
||||
>b : symbol
|
||||
>N.s : unique symbol
|
||||
>N : typeof N
|
||||
>s : unique symbol
|
||||
|
||||
readonly c = N["s"];
|
||||
>c : symbol
|
||||
>N["s"] : unique symbol
|
||||
>N : typeof N
|
||||
>"s" : "s"
|
||||
|
||||
d = s;
|
||||
>d : symbol
|
||||
>s : unique symbol
|
||||
|
||||
e = N.s;
|
||||
>e : symbol
|
||||
>N.s : unique symbol
|
||||
>N : typeof N
|
||||
>s : unique symbol
|
||||
|
||||
f = N["s"];
|
||||
>f : symbol
|
||||
>N["s"] : unique symbol
|
||||
>N : typeof N
|
||||
>"s" : "s"
|
||||
|
||||
method1() { return s; }
|
||||
>method1 : () => symbol
|
||||
>s : unique symbol
|
||||
|
||||
async method2() { return s; }
|
||||
>method2 : () => Promise<symbol>
|
||||
>s : unique symbol
|
||||
|
||||
async * method3() { yield s; }
|
||||
>method3 : () => AsyncIterableIterator<symbol>
|
||||
>yield s : any
|
||||
>s : unique symbol
|
||||
|
||||
* method4() { yield s; }
|
||||
>method4 : () => IterableIterator<symbol>
|
||||
>yield s : any
|
||||
>s : unique symbol
|
||||
|
||||
method5(p = s) { return p; }
|
||||
>method5 : (p?: symbol) => symbol
|
||||
>p : symbol
|
||||
>s : unique symbol
|
||||
>p : symbol
|
||||
}
|
||||
|
||||
// non-widening positions
|
||||
|
||||
// element access
|
||||
o[s];
|
||||
>o[s] : "a"
|
||||
>o : { [s]: "a"; [N.s]: "b"; }
|
||||
>s : unique symbol
|
||||
|
||||
o[N.s];
|
||||
>o[N.s] : "b"
|
||||
>o : { [s]: "a"; [N.s]: "b"; }
|
||||
>N.s : unique symbol
|
||||
>N : typeof N
|
||||
>s : unique symbol
|
||||
|
||||
o[N["s"]];
|
||||
>o[N["s"]] : "b"
|
||||
>o : { [s]: "a"; [N.s]: "b"; }
|
||||
>N["s"] : unique symbol
|
||||
>N : typeof N
|
||||
>"s" : "s"
|
||||
|
||||
// arguments (no-inference)
|
||||
f<typeof s>(s);
|
||||
>f<typeof s>(s) : unique symbol
|
||||
>f : <T>(x: T) => T
|
||||
>s : unique symbol
|
||||
>s : unique symbol
|
||||
|
||||
f<typeof N.s>(N.s);
|
||||
>f<typeof N.s>(N.s) : unique symbol
|
||||
>f : <T>(x: T) => T
|
||||
>N.s : unique symbol
|
||||
>N : typeof N
|
||||
>s : unique symbol
|
||||
>N.s : unique symbol
|
||||
>N : typeof N
|
||||
>s : unique symbol
|
||||
|
||||
f<typeof N.s>(N["s"]);
|
||||
>f<typeof N.s>(N["s"]) : unique symbol
|
||||
>f : <T>(x: T) => T
|
||||
>N.s : unique symbol
|
||||
>N : typeof N
|
||||
>s : unique symbol
|
||||
>N["s"] : unique symbol
|
||||
>N : typeof N
|
||||
>"s" : "s"
|
||||
|
||||
g(s);
|
||||
>g(s) : void
|
||||
>g : { (x: unique symbol): void; (x: unique symbol): void; }
|
||||
>s : unique symbol
|
||||
|
||||
g(N.s);
|
||||
>g(N.s) : void
|
||||
>g : { (x: unique symbol): void; (x: unique symbol): void; }
|
||||
>N.s : unique symbol
|
||||
>N : typeof N
|
||||
>s : unique symbol
|
||||
|
||||
g(N["s"]);
|
||||
>g(N["s"]) : void
|
||||
>g : { (x: unique symbol): void; (x: unique symbol): void; }
|
||||
>N["s"] : unique symbol
|
||||
>N : typeof N
|
||||
>"s" : "s"
|
||||
|
||||
// falsy expressions
|
||||
s || "";
|
||||
>s || "" : unique symbol | ""
|
||||
>s : unique symbol
|
||||
>"" : ""
|
||||
|
||||
N.s || "";
|
||||
>N.s || "" : unique symbol | ""
|
||||
>N.s : unique symbol
|
||||
>N : typeof N
|
||||
>s : unique symbol
|
||||
>"" : ""
|
||||
|
||||
N["s"] || "";
|
||||
>N["s"] || "" : unique symbol | ""
|
||||
>N["s"] : unique symbol
|
||||
>N : typeof N
|
||||
>"s" : "s"
|
||||
>"" : ""
|
||||
|
||||
// conditionals
|
||||
Math.random() * 2 ? s : "a";
|
||||
>Math.random() * 2 ? s : "a" : unique symbol | "a"
|
||||
>Math.random() * 2 : number
|
||||
>Math.random() : number
|
||||
>Math.random : () => number
|
||||
>Math : Math
|
||||
>random : () => number
|
||||
>2 : 2
|
||||
>s : unique symbol
|
||||
>"a" : "a"
|
||||
|
||||
Math.random() * 2 ? N.s : "a";
|
||||
>Math.random() * 2 ? N.s : "a" : unique symbol | "a"
|
||||
>Math.random() * 2 : number
|
||||
>Math.random() : number
|
||||
>Math.random : () => number
|
||||
>Math : Math
|
||||
>random : () => number
|
||||
>2 : 2
|
||||
>N.s : unique symbol
|
||||
>N : typeof N
|
||||
>s : unique symbol
|
||||
>"a" : "a"
|
||||
|
||||
Math.random() * 2 ? N["s"] : "a";
|
||||
>Math.random() * 2 ? N["s"] : "a" : unique symbol | "a"
|
||||
>Math.random() * 2 : number
|
||||
>Math.random() : number
|
||||
>Math.random : () => number
|
||||
>Math : Math
|
||||
>random : () => number
|
||||
>2 : 2
|
||||
>N["s"] : unique symbol
|
||||
>N : typeof N
|
||||
>"s" : "s"
|
||||
>"a" : "a"
|
||||
|
||||
// computed property names
|
||||
({
|
||||
>({ [s]: "a", [N.s]: "b",}) : { [s]: string; [N.s]: string; }
|
||||
>{ [s]: "a", [N.s]: "b",} : { [s]: string; [N.s]: string; }
|
||||
|
||||
[s]: "a",
|
||||
>s : unique symbol
|
||||
>"a" : "a"
|
||||
|
||||
[N.s]: "b",
|
||||
>N.s : unique symbol
|
||||
>N : typeof N
|
||||
>s : unique symbol
|
||||
>"b" : "b"
|
||||
|
||||
});
|
||||
|
||||
class C1 {
|
||||
>C1 : C1
|
||||
|
||||
static [s]: "a";
|
||||
>s : unique symbol
|
||||
|
||||
static [N.s]: "b";
|
||||
>N.s : unique symbol
|
||||
>N : typeof N
|
||||
>s : unique symbol
|
||||
|
||||
[s]: "a";
|
||||
>s : unique symbol
|
||||
|
||||
[N.s]: "b";
|
||||
>N.s : unique symbol
|
||||
>N : typeof N
|
||||
>s : unique symbol
|
||||
}
|
||||
|
||||
// contextual types
|
||||
|
||||
interface Context {
|
||||
>Context : Context
|
||||
|
||||
method1(): typeof s;
|
||||
>method1 : () => unique symbol
|
||||
>s : unique symbol
|
||||
|
||||
method2(): Promise<typeof s>;
|
||||
>method2 : () => Promise<unique symbol>
|
||||
>Promise : Promise<T>
|
||||
>s : unique symbol
|
||||
|
||||
method3(): AsyncIterableIterator<typeof s>;
|
||||
>method3 : () => AsyncIterableIterator<unique symbol>
|
||||
>AsyncIterableIterator : AsyncIterableIterator<T>
|
||||
>s : unique symbol
|
||||
|
||||
method4(): IterableIterator<typeof s>;
|
||||
>method4 : () => IterableIterator<unique symbol>
|
||||
>IterableIterator : IterableIterator<T>
|
||||
>s : unique symbol
|
||||
|
||||
method5(p?: typeof s): typeof s;
|
||||
>method5 : (p?: unique symbol) => unique symbol
|
||||
>p : unique symbol
|
||||
>s : unique symbol
|
||||
>s : unique symbol
|
||||
}
|
||||
|
||||
const o4: Context = {
|
||||
>o4 : Context
|
||||
>Context : Context
|
||||
>{ method1() { return s; // return type should not widen due to contextual type }, async method2() { return s; // return type should not widen due to contextual type }, async * method3() { yield s; // yield type should not widen due to contextual type }, * method4() { yield s; // yield type should not widen due to contextual type }, method5(p = s) { // parameter should not widen due to contextual type return p; }} : { method1(): unique symbol; method2(): Promise<unique symbol>; method3(): AsyncIterableIterator<unique symbol>; method4(): IterableIterator<unique symbol>; method5(p?: unique symbol): unique symbol; }
|
||||
|
||||
method1() {
|
||||
>method1 : () => unique symbol
|
||||
|
||||
return s; // return type should not widen due to contextual type
|
||||
>s : unique symbol
|
||||
|
||||
},
|
||||
async method2() {
|
||||
>method2 : () => Promise<unique symbol>
|
||||
|
||||
return s; // return type should not widen due to contextual type
|
||||
>s : unique symbol
|
||||
|
||||
},
|
||||
async * method3() {
|
||||
>method3 : () => AsyncIterableIterator<unique symbol>
|
||||
|
||||
yield s; // yield type should not widen due to contextual type
|
||||
>yield s : any
|
||||
>s : unique symbol
|
||||
|
||||
},
|
||||
* method4() {
|
||||
>method4 : () => IterableIterator<unique symbol>
|
||||
|
||||
yield s; // yield type should not widen due to contextual type
|
||||
>yield s : any
|
||||
>s : unique symbol
|
||||
|
||||
},
|
||||
method5(p = s) { // parameter should not widen due to contextual type
|
||||
>method5 : (p?: unique symbol) => unique symbol
|
||||
>p : unique symbol
|
||||
>s : unique symbol
|
||||
|
||||
return p;
|
||||
>p : unique symbol
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,110 @@
|
||||
tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsErrors.ts(6,14): error TS2527: The inferred type of 'obj' references an inaccessible 'unique symbol' type. A type annotation is necessary.
|
||||
tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsErrors.ts(15,14): error TS2527: The inferred type of 'classExpression' references an inaccessible 'unique symbol' type. A type annotation is necessary.
|
||||
tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsErrors.ts(24,17): error TS2527: The inferred type of 'funcInferredReturnType' references an inaccessible 'unique symbol' type. A type annotation is necessary.
|
||||
tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsErrors.ts(24,64): error TS4078: Parameter 'obj' of exported function has or is using private name 's'.
|
||||
tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsErrors.ts(29,6): error TS4033: Property '[s]' of exported interface has or is using private name 's'.
|
||||
tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsErrors.ts(33,6): error TS4102: Method '[s]' of exported interface has or is using private name 's'.
|
||||
tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsErrors.ts(37,6): error TS4033: Property '[s]' of exported interface has or is using private name 's'.
|
||||
tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsErrors.ts(41,6): error TS4102: Method '[s]' of exported interface has or is using private name 's'.
|
||||
tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsErrors.ts(45,6): error TS4031: Public property '[s]' of exported class has or is using private name 's'.
|
||||
tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsErrors.ts(46,13): error TS4028: Public static property '[s]' of exported class has or is using private name 's'.
|
||||
tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsErrors.ts(50,6): error TS4100: Public method '[s]' of exported class has or is using private name 's'.
|
||||
tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsErrors.ts(51,13): error TS4097: Public static method '[s]' of exported class has or is using private name 's'.
|
||||
tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsErrors.ts(55,10): error TS4031: Public property '[s]' of exported class has or is using private name 's'.
|
||||
tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsErrors.ts(56,10): error TS4031: Public property '[s]' of exported class has or is using private name 's'.
|
||||
tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsErrors.ts(57,17): error TS4028: Public static property '[s]' of exported class has or is using private name 's'.
|
||||
tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsErrors.ts(58,17): error TS4028: Public static property '[s]' of exported class has or is using private name 's'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsErrors.ts (16 errors) ====
|
||||
declare const s: unique symbol;
|
||||
interface I { readonly readonlyType: unique symbol; }
|
||||
|
||||
// not allowed when emitting declarations
|
||||
|
||||
export const obj = {
|
||||
~~~
|
||||
!!! error TS2527: The inferred type of 'obj' references an inaccessible 'unique symbol' type. A type annotation is necessary.
|
||||
method1(p: typeof s): typeof s {
|
||||
return p;
|
||||
},
|
||||
method2(p: I["readonlyType"]): I["readonlyType"] {
|
||||
return p;
|
||||
}
|
||||
};
|
||||
|
||||
export const classExpression = class {
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2527: The inferred type of 'classExpression' references an inaccessible 'unique symbol' type. A type annotation is necessary.
|
||||
method1(p: typeof s): typeof s {
|
||||
return p;
|
||||
}
|
||||
method2(p: I["readonlyType"]): I["readonlyType"] {
|
||||
return p;
|
||||
}
|
||||
};
|
||||
|
||||
export function funcInferredReturnType(obj: { method(p: typeof s): void }) {
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2527: The inferred type of 'funcInferredReturnType' references an inaccessible 'unique symbol' type. A type annotation is necessary.
|
||||
~
|
||||
!!! error TS4078: Parameter 'obj' of exported function has or is using private name 's'.
|
||||
return obj;
|
||||
}
|
||||
|
||||
export interface InterfaceWithPrivateNamedProperties {
|
||||
[s]: any;
|
||||
~
|
||||
!!! error TS4033: Property '[s]' of exported interface has or is using private name 's'.
|
||||
}
|
||||
|
||||
export interface InterfaceWithPrivateNamedMethods {
|
||||
[s](): any;
|
||||
~
|
||||
!!! error TS4102: Method '[s]' of exported interface has or is using private name 's'.
|
||||
}
|
||||
|
||||
export type TypeLiteralWithPrivateNamedProperties = {
|
||||
[s]: any;
|
||||
~
|
||||
!!! error TS4033: Property '[s]' of exported interface has or is using private name 's'.
|
||||
}
|
||||
|
||||
export type TypeLiteralWithPrivateNamedMethods = {
|
||||
[s](): any;
|
||||
~
|
||||
!!! error TS4102: Method '[s]' of exported interface has or is using private name 's'.
|
||||
}
|
||||
|
||||
export class ClassWithPrivateNamedProperties {
|
||||
[s]: any;
|
||||
~
|
||||
!!! error TS4031: Public property '[s]' of exported class has or is using private name 's'.
|
||||
static [s]: any;
|
||||
~
|
||||
!!! error TS4028: Public static property '[s]' of exported class has or is using private name 's'.
|
||||
}
|
||||
|
||||
export class ClassWithPrivateNamedMethods {
|
||||
[s]() {}
|
||||
~
|
||||
!!! error TS4100: Public method '[s]' of exported class has or is using private name 's'.
|
||||
static [s]() {}
|
||||
~
|
||||
!!! error TS4097: Public static method '[s]' of exported class has or is using private name 's'.
|
||||
}
|
||||
|
||||
export class ClassWithPrivateNamedAccessors {
|
||||
get [s](): any { return undefined; }
|
||||
~
|
||||
!!! error TS4031: Public property '[s]' of exported class has or is using private name 's'.
|
||||
set [s](v: any) { }
|
||||
~
|
||||
!!! error TS4031: Public property '[s]' of exported class has or is using private name 's'.
|
||||
static get [s](): any { return undefined; }
|
||||
~
|
||||
!!! error TS4028: Public static property '[s]' of exported class has or is using private name 's'.
|
||||
static set [s](v: any) { }
|
||||
~
|
||||
!!! error TS4028: Public static property '[s]' of exported class has or is using private name 's'.
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
//// [uniqueSymbolsDeclarationsErrors.ts]
|
||||
declare const s: unique symbol;
|
||||
interface I { readonly readonlyType: unique symbol; }
|
||||
|
||||
// not allowed when emitting declarations
|
||||
|
||||
export const obj = {
|
||||
method1(p: typeof s): typeof s {
|
||||
return p;
|
||||
},
|
||||
method2(p: I["readonlyType"]): I["readonlyType"] {
|
||||
return p;
|
||||
}
|
||||
};
|
||||
|
||||
export const classExpression = class {
|
||||
method1(p: typeof s): typeof s {
|
||||
return p;
|
||||
}
|
||||
method2(p: I["readonlyType"]): I["readonlyType"] {
|
||||
return p;
|
||||
}
|
||||
};
|
||||
|
||||
export function funcInferredReturnType(obj: { method(p: typeof s): void }) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
export interface InterfaceWithPrivateNamedProperties {
|
||||
[s]: any;
|
||||
}
|
||||
|
||||
export interface InterfaceWithPrivateNamedMethods {
|
||||
[s](): any;
|
||||
}
|
||||
|
||||
export type TypeLiteralWithPrivateNamedProperties = {
|
||||
[s]: any;
|
||||
}
|
||||
|
||||
export type TypeLiteralWithPrivateNamedMethods = {
|
||||
[s](): any;
|
||||
}
|
||||
|
||||
export class ClassWithPrivateNamedProperties {
|
||||
[s]: any;
|
||||
static [s]: any;
|
||||
}
|
||||
|
||||
export class ClassWithPrivateNamedMethods {
|
||||
[s]() {}
|
||||
static [s]() {}
|
||||
}
|
||||
|
||||
export class ClassWithPrivateNamedAccessors {
|
||||
get [s](): any { return undefined; }
|
||||
set [s](v: any) { }
|
||||
static get [s](): any { return undefined; }
|
||||
static set [s](v: any) { }
|
||||
}
|
||||
|
||||
//// [uniqueSymbolsDeclarationsErrors.js]
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
// not allowed when emitting declarations
|
||||
exports.obj = {
|
||||
method1(p) {
|
||||
return p;
|
||||
},
|
||||
method2(p) {
|
||||
return p;
|
||||
}
|
||||
};
|
||||
exports.classExpression = class {
|
||||
method1(p) {
|
||||
return p;
|
||||
}
|
||||
method2(p) {
|
||||
return p;
|
||||
}
|
||||
};
|
||||
function funcInferredReturnType(obj) {
|
||||
return obj;
|
||||
}
|
||||
exports.funcInferredReturnType = funcInferredReturnType;
|
||||
class ClassWithPrivateNamedProperties {
|
||||
}
|
||||
exports.ClassWithPrivateNamedProperties = ClassWithPrivateNamedProperties;
|
||||
class ClassWithPrivateNamedMethods {
|
||||
[s]() { }
|
||||
static [s]() { }
|
||||
}
|
||||
exports.ClassWithPrivateNamedMethods = ClassWithPrivateNamedMethods;
|
||||
class ClassWithPrivateNamedAccessors {
|
||||
get [s]() { return undefined; }
|
||||
set [s](v) { }
|
||||
static get [s]() { return undefined; }
|
||||
static set [s](v) { }
|
||||
}
|
||||
exports.ClassWithPrivateNamedAccessors = ClassWithPrivateNamedAccessors;
|
||||
@@ -0,0 +1,135 @@
|
||||
=== tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsErrors.ts ===
|
||||
declare const s: unique symbol;
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarationsErrors.ts, 0, 13))
|
||||
|
||||
interface I { readonly readonlyType: unique symbol; }
|
||||
>I : Symbol(I, Decl(uniqueSymbolsDeclarationsErrors.ts, 0, 31))
|
||||
>readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbolsDeclarationsErrors.ts, 1, 13))
|
||||
|
||||
// not allowed when emitting declarations
|
||||
|
||||
export const obj = {
|
||||
>obj : Symbol(obj, Decl(uniqueSymbolsDeclarationsErrors.ts, 5, 12))
|
||||
|
||||
method1(p: typeof s): typeof s {
|
||||
>method1 : Symbol(method1, Decl(uniqueSymbolsDeclarationsErrors.ts, 5, 20))
|
||||
>p : Symbol(p, Decl(uniqueSymbolsDeclarationsErrors.ts, 6, 12))
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarationsErrors.ts, 0, 13))
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarationsErrors.ts, 0, 13))
|
||||
|
||||
return p;
|
||||
>p : Symbol(p, Decl(uniqueSymbolsDeclarationsErrors.ts, 6, 12))
|
||||
|
||||
},
|
||||
method2(p: I["readonlyType"]): I["readonlyType"] {
|
||||
>method2 : Symbol(method2, Decl(uniqueSymbolsDeclarationsErrors.ts, 8, 6))
|
||||
>p : Symbol(p, Decl(uniqueSymbolsDeclarationsErrors.ts, 9, 12))
|
||||
>I : Symbol(I, Decl(uniqueSymbolsDeclarationsErrors.ts, 0, 31))
|
||||
>I : Symbol(I, Decl(uniqueSymbolsDeclarationsErrors.ts, 0, 31))
|
||||
|
||||
return p;
|
||||
>p : Symbol(p, Decl(uniqueSymbolsDeclarationsErrors.ts, 9, 12))
|
||||
}
|
||||
};
|
||||
|
||||
export const classExpression = class {
|
||||
>classExpression : Symbol(classExpression, Decl(uniqueSymbolsDeclarationsErrors.ts, 14, 12))
|
||||
|
||||
method1(p: typeof s): typeof s {
|
||||
>method1 : Symbol(classExpression.method1, Decl(uniqueSymbolsDeclarationsErrors.ts, 14, 38))
|
||||
>p : Symbol(p, Decl(uniqueSymbolsDeclarationsErrors.ts, 15, 12))
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarationsErrors.ts, 0, 13))
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarationsErrors.ts, 0, 13))
|
||||
|
||||
return p;
|
||||
>p : Symbol(p, Decl(uniqueSymbolsDeclarationsErrors.ts, 15, 12))
|
||||
}
|
||||
method2(p: I["readonlyType"]): I["readonlyType"] {
|
||||
>method2 : Symbol(classExpression.method2, Decl(uniqueSymbolsDeclarationsErrors.ts, 17, 5))
|
||||
>p : Symbol(p, Decl(uniqueSymbolsDeclarationsErrors.ts, 18, 12))
|
||||
>I : Symbol(I, Decl(uniqueSymbolsDeclarationsErrors.ts, 0, 31))
|
||||
>I : Symbol(I, Decl(uniqueSymbolsDeclarationsErrors.ts, 0, 31))
|
||||
|
||||
return p;
|
||||
>p : Symbol(p, Decl(uniqueSymbolsDeclarationsErrors.ts, 18, 12))
|
||||
}
|
||||
};
|
||||
|
||||
export function funcInferredReturnType(obj: { method(p: typeof s): void }) {
|
||||
>funcInferredReturnType : Symbol(funcInferredReturnType, Decl(uniqueSymbolsDeclarationsErrors.ts, 21, 2))
|
||||
>obj : Symbol(obj, Decl(uniqueSymbolsDeclarationsErrors.ts, 23, 39))
|
||||
>method : Symbol(method, Decl(uniqueSymbolsDeclarationsErrors.ts, 23, 45))
|
||||
>p : Symbol(p, Decl(uniqueSymbolsDeclarationsErrors.ts, 23, 53))
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarationsErrors.ts, 0, 13))
|
||||
|
||||
return obj;
|
||||
>obj : Symbol(obj, Decl(uniqueSymbolsDeclarationsErrors.ts, 23, 39))
|
||||
}
|
||||
|
||||
export interface InterfaceWithPrivateNamedProperties {
|
||||
>InterfaceWithPrivateNamedProperties : Symbol(InterfaceWithPrivateNamedProperties, Decl(uniqueSymbolsDeclarationsErrors.ts, 25, 1))
|
||||
|
||||
[s]: any;
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarationsErrors.ts, 0, 13))
|
||||
}
|
||||
|
||||
export interface InterfaceWithPrivateNamedMethods {
|
||||
>InterfaceWithPrivateNamedMethods : Symbol(InterfaceWithPrivateNamedMethods, Decl(uniqueSymbolsDeclarationsErrors.ts, 29, 1))
|
||||
|
||||
[s](): any;
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarationsErrors.ts, 0, 13))
|
||||
}
|
||||
|
||||
export type TypeLiteralWithPrivateNamedProperties = {
|
||||
>TypeLiteralWithPrivateNamedProperties : Symbol(TypeLiteralWithPrivateNamedProperties, Decl(uniqueSymbolsDeclarationsErrors.ts, 33, 1))
|
||||
|
||||
[s]: any;
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarationsErrors.ts, 0, 13))
|
||||
}
|
||||
|
||||
export type TypeLiteralWithPrivateNamedMethods = {
|
||||
>TypeLiteralWithPrivateNamedMethods : Symbol(TypeLiteralWithPrivateNamedMethods, Decl(uniqueSymbolsDeclarationsErrors.ts, 37, 1))
|
||||
|
||||
[s](): any;
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarationsErrors.ts, 0, 13))
|
||||
}
|
||||
|
||||
export class ClassWithPrivateNamedProperties {
|
||||
>ClassWithPrivateNamedProperties : Symbol(ClassWithPrivateNamedProperties, Decl(uniqueSymbolsDeclarationsErrors.ts, 41, 1))
|
||||
|
||||
[s]: any;
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarationsErrors.ts, 0, 13))
|
||||
|
||||
static [s]: any;
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarationsErrors.ts, 0, 13))
|
||||
}
|
||||
|
||||
export class ClassWithPrivateNamedMethods {
|
||||
>ClassWithPrivateNamedMethods : Symbol(ClassWithPrivateNamedMethods, Decl(uniqueSymbolsDeclarationsErrors.ts, 46, 1))
|
||||
|
||||
[s]() {}
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarationsErrors.ts, 0, 13))
|
||||
|
||||
static [s]() {}
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarationsErrors.ts, 0, 13))
|
||||
}
|
||||
|
||||
export class ClassWithPrivateNamedAccessors {
|
||||
>ClassWithPrivateNamedAccessors : Symbol(ClassWithPrivateNamedAccessors, Decl(uniqueSymbolsDeclarationsErrors.ts, 51, 1))
|
||||
|
||||
get [s](): any { return undefined; }
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarationsErrors.ts, 0, 13))
|
||||
>undefined : Symbol(undefined)
|
||||
|
||||
set [s](v: any) { }
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarationsErrors.ts, 0, 13))
|
||||
>v : Symbol(v, Decl(uniqueSymbolsDeclarationsErrors.ts, 55, 12))
|
||||
|
||||
static get [s](): any { return undefined; }
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarationsErrors.ts, 0, 13))
|
||||
>undefined : Symbol(undefined)
|
||||
|
||||
static set [s](v: any) { }
|
||||
>s : Symbol(s, Decl(uniqueSymbolsDeclarationsErrors.ts, 0, 13))
|
||||
>v : Symbol(v, Decl(uniqueSymbolsDeclarationsErrors.ts, 57, 19))
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
=== tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsErrors.ts ===
|
||||
declare const s: unique symbol;
|
||||
>s : unique symbol
|
||||
|
||||
interface I { readonly readonlyType: unique symbol; }
|
||||
>I : I
|
||||
>readonlyType : unique symbol
|
||||
|
||||
// not allowed when emitting declarations
|
||||
|
||||
export const obj = {
|
||||
>obj : { method1(p: unique symbol): unique symbol; method2(p: unique symbol): unique symbol; }
|
||||
>{ method1(p: typeof s): typeof s { return p; }, method2(p: I["readonlyType"]): I["readonlyType"] { return p; }} : { method1(p: unique symbol): unique symbol; method2(p: unique symbol): unique symbol; }
|
||||
|
||||
method1(p: typeof s): typeof s {
|
||||
>method1 : (p: unique symbol) => unique symbol
|
||||
>p : unique symbol
|
||||
>s : unique symbol
|
||||
>s : unique symbol
|
||||
|
||||
return p;
|
||||
>p : unique symbol
|
||||
|
||||
},
|
||||
method2(p: I["readonlyType"]): I["readonlyType"] {
|
||||
>method2 : (p: unique symbol) => unique symbol
|
||||
>p : unique symbol
|
||||
>I : I
|
||||
>I : I
|
||||
|
||||
return p;
|
||||
>p : unique symbol
|
||||
}
|
||||
};
|
||||
|
||||
export const classExpression = class {
|
||||
>classExpression : typeof classExpression
|
||||
>class { method1(p: typeof s): typeof s { return p; } method2(p: I["readonlyType"]): I["readonlyType"] { return p; }} : typeof classExpression
|
||||
|
||||
method1(p: typeof s): typeof s {
|
||||
>method1 : (p: unique symbol) => unique symbol
|
||||
>p : unique symbol
|
||||
>s : unique symbol
|
||||
>s : unique symbol
|
||||
|
||||
return p;
|
||||
>p : unique symbol
|
||||
}
|
||||
method2(p: I["readonlyType"]): I["readonlyType"] {
|
||||
>method2 : (p: unique symbol) => unique symbol
|
||||
>p : unique symbol
|
||||
>I : I
|
||||
>I : I
|
||||
|
||||
return p;
|
||||
>p : unique symbol
|
||||
}
|
||||
};
|
||||
|
||||
export function funcInferredReturnType(obj: { method(p: typeof s): void }) {
|
||||
>funcInferredReturnType : (obj: { method(p: unique symbol): void; }) => { method(p: unique symbol): void; }
|
||||
>obj : { method(p: unique symbol): void; }
|
||||
>method : (p: unique symbol) => void
|
||||
>p : unique symbol
|
||||
>s : unique symbol
|
||||
|
||||
return obj;
|
||||
>obj : { method(p: unique symbol): void; }
|
||||
}
|
||||
|
||||
export interface InterfaceWithPrivateNamedProperties {
|
||||
>InterfaceWithPrivateNamedProperties : InterfaceWithPrivateNamedProperties
|
||||
|
||||
[s]: any;
|
||||
>s : unique symbol
|
||||
}
|
||||
|
||||
export interface InterfaceWithPrivateNamedMethods {
|
||||
>InterfaceWithPrivateNamedMethods : InterfaceWithPrivateNamedMethods
|
||||
|
||||
[s](): any;
|
||||
>s : unique symbol
|
||||
}
|
||||
|
||||
export type TypeLiteralWithPrivateNamedProperties = {
|
||||
>TypeLiteralWithPrivateNamedProperties : TypeLiteralWithPrivateNamedProperties
|
||||
|
||||
[s]: any;
|
||||
>s : unique symbol
|
||||
}
|
||||
|
||||
export type TypeLiteralWithPrivateNamedMethods = {
|
||||
>TypeLiteralWithPrivateNamedMethods : TypeLiteralWithPrivateNamedMethods
|
||||
|
||||
[s](): any;
|
||||
>s : unique symbol
|
||||
}
|
||||
|
||||
export class ClassWithPrivateNamedProperties {
|
||||
>ClassWithPrivateNamedProperties : ClassWithPrivateNamedProperties
|
||||
|
||||
[s]: any;
|
||||
>s : unique symbol
|
||||
|
||||
static [s]: any;
|
||||
>s : unique symbol
|
||||
}
|
||||
|
||||
export class ClassWithPrivateNamedMethods {
|
||||
>ClassWithPrivateNamedMethods : ClassWithPrivateNamedMethods
|
||||
|
||||
[s]() {}
|
||||
>s : unique symbol
|
||||
|
||||
static [s]() {}
|
||||
>s : unique symbol
|
||||
}
|
||||
|
||||
export class ClassWithPrivateNamedAccessors {
|
||||
>ClassWithPrivateNamedAccessors : ClassWithPrivateNamedAccessors
|
||||
|
||||
get [s](): any { return undefined; }
|
||||
>s : unique symbol
|
||||
>undefined : undefined
|
||||
|
||||
set [s](v: any) { }
|
||||
>s : unique symbol
|
||||
>v : any
|
||||
|
||||
static get [s](): any { return undefined; }
|
||||
>s : unique symbol
|
||||
>undefined : undefined
|
||||
|
||||
static set [s](v: any) { }
|
||||
>s : unique symbol
|
||||
>v : any
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
// @target: esnext
|
||||
// @lib: esnext
|
||||
// @declaration: true
|
||||
// @declaration: false
|
||||
|
||||
// declarations with call initializer
|
||||
const constCall = Symbol();
|
||||
@@ -125,6 +125,7 @@ declare function g(x: typeof s): void;
|
||||
declare function g(x: typeof N.s): void;
|
||||
|
||||
// widening positions
|
||||
|
||||
// argument inference
|
||||
f(s);
|
||||
f(N.s);
|
||||
@@ -135,11 +136,17 @@ f(N["s"]);
|
||||
[N.s];
|
||||
[N["s"]];
|
||||
|
||||
// property assignments
|
||||
// property assignments/methods
|
||||
const o2 = {
|
||||
a: s,
|
||||
b: N.s,
|
||||
c: N["s"]
|
||||
c: N["s"],
|
||||
|
||||
method1() { return s; },
|
||||
async method2() { return s; },
|
||||
async * method3() { yield s; },
|
||||
* method4() { yield s; },
|
||||
method5(p = s) { return p; },
|
||||
};
|
||||
|
||||
// property initializers
|
||||
@@ -159,6 +166,12 @@ class C0 {
|
||||
d = s;
|
||||
e = N.s;
|
||||
f = N["s"];
|
||||
|
||||
method1() { return s; }
|
||||
async method2() { return s; }
|
||||
async * method3() { yield s; }
|
||||
* method4() { yield s; }
|
||||
method5(p = s) { return p; }
|
||||
}
|
||||
|
||||
// non-widening positions
|
||||
@@ -198,4 +211,56 @@ class C1 {
|
||||
|
||||
[s]: "a";
|
||||
[N.s]: "b";
|
||||
}
|
||||
}
|
||||
|
||||
// contextual types
|
||||
|
||||
interface Context {
|
||||
method1(): typeof s;
|
||||
method2(): Promise<typeof s>;
|
||||
method3(): AsyncIterableIterator<typeof s>;
|
||||
method4(): IterableIterator<typeof s>;
|
||||
method5(p?: typeof s): typeof s;
|
||||
}
|
||||
|
||||
const o3: Context = {
|
||||
method1() {
|
||||
return s; // return type should not widen due to contextual type
|
||||
},
|
||||
async method2() {
|
||||
return s; // return type should not widen due to contextual type
|
||||
},
|
||||
async * method3() {
|
||||
yield s; // yield type should not widen due to contextual type
|
||||
},
|
||||
* method4() {
|
||||
yield s; // yield type should not widen due to contextual type
|
||||
},
|
||||
method5(p = s) { // parameter should not widen due to contextual type
|
||||
return p;
|
||||
},
|
||||
};
|
||||
|
||||
// allowed when not emitting declarations
|
||||
|
||||
const o4 = {
|
||||
method1(p: typeof s): typeof s {
|
||||
return p;
|
||||
},
|
||||
method2(p: I["readonlyType"]): I["readonlyType"] {
|
||||
return p;
|
||||
}
|
||||
};
|
||||
|
||||
const ce0 = class {
|
||||
method1(p: typeof s): typeof s {
|
||||
return p;
|
||||
}
|
||||
method2(p: I["readonlyType"]): I["readonlyType"] {
|
||||
return p;
|
||||
}
|
||||
};
|
||||
|
||||
function funcInferredReturnType(obj: { method(p: typeof s): void }) {
|
||||
return obj;
|
||||
}
|
||||
@@ -0,0 +1,242 @@
|
||||
// @target: esnext
|
||||
// @lib: esnext
|
||||
// @declaration: true
|
||||
|
||||
// declarations with call initializer
|
||||
const constCall = Symbol();
|
||||
let letCall = Symbol();
|
||||
var varCall = Symbol();
|
||||
|
||||
// ambient declaration with type
|
||||
declare const constType: unique symbol;
|
||||
|
||||
// declaration with type and call initializer
|
||||
const constTypeAndCall: unique symbol = Symbol();
|
||||
|
||||
// declaration from initializer
|
||||
const constInitToConstCall = constCall;
|
||||
const constInitToLetCall = letCall;
|
||||
const constInitToVarCall = varCall;
|
||||
const constInitToConstDeclAmbient = constType;
|
||||
let letInitToConstCall = constCall;
|
||||
let letInitToLetCall = letCall;
|
||||
let letInitToVarCall = varCall;
|
||||
let letInitToConstDeclAmbient = constType;
|
||||
var varInitToConstCall = constCall;
|
||||
var varInitToLetCall = letCall;
|
||||
var varInitToVarCall = varCall;
|
||||
var varInitToConstDeclAmbient = constType;
|
||||
|
||||
// declaration from initializer with type query
|
||||
const constInitToConstCallWithTypeQuery: typeof constCall = constCall;
|
||||
const constInitToConstDeclAmbientWithTypeQuery: typeof constType = constType;
|
||||
|
||||
// function return inference
|
||||
function funcReturnConstCall() { return constCall; }
|
||||
function funcReturnLetCall() { return letCall; }
|
||||
function funcReturnVarCall() { return varCall; }
|
||||
|
||||
// function return value with type query
|
||||
function funcReturnConstCallWithTypeQuery(): typeof constCall { return constCall; }
|
||||
|
||||
// generator function yield inference
|
||||
function* genFuncYieldConstCall() { yield constCall; }
|
||||
function* genFuncYieldLetCall() { yield letCall; }
|
||||
function* genFuncYieldVarCall() { yield varCall; }
|
||||
|
||||
// generator function yield with return type query
|
||||
function* genFuncYieldConstCallWithTypeQuery(): IterableIterator<typeof constCall> { yield constCall; }
|
||||
|
||||
// async function return inference
|
||||
async function asyncFuncReturnConstCall() { return constCall; }
|
||||
async function asyncFuncReturnLetCall() { return letCall; }
|
||||
async function asyncFuncReturnVarCall() { return varCall; }
|
||||
|
||||
// async generator function yield inference
|
||||
async function* asyncGenFuncYieldConstCall() { yield constCall; }
|
||||
async function* asyncGenFuncYieldLetCall() { yield letCall; }
|
||||
async function* asyncGenFuncYieldVarCall() { yield varCall; }
|
||||
|
||||
// classes
|
||||
class C {
|
||||
static readonly readonlyStaticCall = Symbol();
|
||||
static readonly readonlyStaticType: unique symbol;
|
||||
static readonly readonlyStaticTypeAndCall: unique symbol = Symbol();
|
||||
static readwriteStaticCall = Symbol();
|
||||
|
||||
readonly readonlyCall = Symbol();
|
||||
readwriteCall = Symbol();
|
||||
}
|
||||
declare const c: C;
|
||||
|
||||
const constInitToCReadonlyStaticCall = C.readonlyStaticCall;
|
||||
const constInitToCReadonlyStaticType = C.readonlyStaticType;
|
||||
const constInitToCReadonlyStaticTypeAndCall = C.readonlyStaticTypeAndCall;
|
||||
const constInitToCReadwriteStaticCall = C.readwriteStaticCall;
|
||||
|
||||
const constInitToCReadonlyStaticCallWithTypeQuery: typeof C.readonlyStaticCall = C.readonlyStaticCall;
|
||||
const constInitToCReadonlyStaticTypeWithTypeQuery: typeof C.readonlyStaticType = C.readonlyStaticType;
|
||||
const constInitToCReadonlyStaticTypeAndCallWithTypeQuery: typeof C.readonlyStaticTypeAndCall = C.readonlyStaticTypeAndCall;
|
||||
const constInitToCReadwriteStaticCallWithTypeQuery: typeof C.readwriteStaticCall = C.readwriteStaticCall;
|
||||
|
||||
const constInitToCReadonlyCall = c.readonlyCall;
|
||||
const constInitToCReadwriteCall = c.readwriteCall;
|
||||
const constInitToCReadonlyCallWithTypeQuery: typeof c.readonlyCall = c.readonlyCall;
|
||||
const constInitToCReadwriteCallWithTypeQuery: typeof c.readwriteCall = c.readwriteCall;
|
||||
const constInitToCReadonlyCallWithIndexedAccess: C["readonlyCall"] = c.readonlyCall;
|
||||
const constInitToCReadwriteCallWithIndexedAccess: C["readwriteCall"] = c.readwriteCall;
|
||||
|
||||
// interfaces
|
||||
interface I {
|
||||
readonly readonlyType: unique symbol;
|
||||
}
|
||||
declare const i: I;
|
||||
|
||||
const constInitToIReadonlyType = i.readonlyType;
|
||||
const constInitToIReadonlyTypeWithTypeQuery: typeof i.readonlyType = i.readonlyType;
|
||||
const constInitToIReadonlyTypeWithIndexedAccess: I["readonlyType"] = i.readonlyType;
|
||||
|
||||
// type literals
|
||||
type L = {
|
||||
readonly readonlyType: unique symbol;
|
||||
nested: {
|
||||
readonly readonlyNestedType: unique symbol;
|
||||
}
|
||||
};
|
||||
declare const l: L;
|
||||
|
||||
const constInitToLReadonlyType = l.readonlyType;
|
||||
const constInitToLReadonlyNestedType = l.nested.readonlyNestedType;
|
||||
const constInitToLReadonlyTypeWithTypeQuery: typeof l.readonlyType = l.readonlyType;
|
||||
const constInitToLReadonlyNestedTypeWithTypeQuery: typeof l.nested.readonlyNestedType = l.nested.readonlyNestedType;
|
||||
const constInitToLReadonlyTypeWithIndexedAccess: L["readonlyType"] = l.readonlyType;
|
||||
const constInitToLReadonlyNestedTypeWithIndexedAccess: L["nested"]["readonlyNestedType"] = l.nested.readonlyNestedType;
|
||||
|
||||
// type argument inference
|
||||
const promiseForConstCall = Promise.resolve(constCall);
|
||||
const arrayOfConstCall = [constCall];
|
||||
|
||||
// unique symbol widening in expressions
|
||||
declare const s: unique symbol;
|
||||
declare namespace N { const s: unique symbol; }
|
||||
declare const o: { [s]: "a", [N.s]: "b" };
|
||||
declare function f<T>(x: T): T;
|
||||
declare function g(x: typeof s): void;
|
||||
declare function g(x: typeof N.s): void;
|
||||
|
||||
// widening positions
|
||||
|
||||
// argument inference
|
||||
f(s);
|
||||
f(N.s);
|
||||
f(N["s"]);
|
||||
|
||||
// array literal elements
|
||||
[s];
|
||||
[N.s];
|
||||
[N["s"]];
|
||||
|
||||
// property assignments/methods
|
||||
const o2 = {
|
||||
a: s,
|
||||
b: N.s,
|
||||
c: N["s"],
|
||||
|
||||
method1() { return s; },
|
||||
async method2() { return s; },
|
||||
async * method3() { yield s; },
|
||||
* method4() { yield s; },
|
||||
method5(p = s) { return p; }
|
||||
};
|
||||
|
||||
// property initializers
|
||||
class C0 {
|
||||
static readonly a = s;
|
||||
static readonly b = N.s;
|
||||
static readonly c = N["s"];
|
||||
|
||||
static d = s;
|
||||
static e = N.s;
|
||||
static f = N["s"];
|
||||
|
||||
readonly a = s;
|
||||
readonly b = N.s;
|
||||
readonly c = N["s"];
|
||||
|
||||
d = s;
|
||||
e = N.s;
|
||||
f = N["s"];
|
||||
|
||||
method1() { return s; }
|
||||
async method2() { return s; }
|
||||
async * method3() { yield s; }
|
||||
* method4() { yield s; }
|
||||
method5(p = s) { return p; }
|
||||
}
|
||||
|
||||
// non-widening positions
|
||||
|
||||
// element access
|
||||
o[s];
|
||||
o[N.s];
|
||||
o[N["s"]];
|
||||
|
||||
// arguments (no-inference)
|
||||
f<typeof s>(s);
|
||||
f<typeof N.s>(N.s);
|
||||
f<typeof N.s>(N["s"]);
|
||||
g(s);
|
||||
g(N.s);
|
||||
g(N["s"]);
|
||||
|
||||
// falsy expressions
|
||||
s || "";
|
||||
N.s || "";
|
||||
N["s"] || "";
|
||||
|
||||
// conditionals
|
||||
Math.random() * 2 ? s : "a";
|
||||
Math.random() * 2 ? N.s : "a";
|
||||
Math.random() * 2 ? N["s"] : "a";
|
||||
|
||||
// computed property names
|
||||
({
|
||||
[s]: "a",
|
||||
[N.s]: "b",
|
||||
});
|
||||
|
||||
class C1 {
|
||||
static [s]: "a";
|
||||
static [N.s]: "b";
|
||||
|
||||
[s]: "a";
|
||||
[N.s]: "b";
|
||||
}
|
||||
|
||||
// contextual types
|
||||
|
||||
interface Context {
|
||||
method1(): typeof s;
|
||||
method2(): Promise<typeof s>;
|
||||
method3(): AsyncIterableIterator<typeof s>;
|
||||
method4(): IterableIterator<typeof s>;
|
||||
method5(p?: typeof s): typeof s;
|
||||
}
|
||||
|
||||
const o4: Context = {
|
||||
method1() {
|
||||
return s; // return type should not widen due to contextual type
|
||||
},
|
||||
async method2() {
|
||||
return s; // return type should not widen due to contextual type
|
||||
},
|
||||
async * method3() {
|
||||
yield s; // yield type should not widen due to contextual type
|
||||
},
|
||||
* method4() {
|
||||
yield s; // yield type should not widen due to contextual type
|
||||
},
|
||||
method5(p = s) { // parameter should not widen due to contextual type
|
||||
return p;
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,64 @@
|
||||
// @target: esnext
|
||||
// @lib: esnext
|
||||
// @module: commonjs
|
||||
// @declaration: true
|
||||
|
||||
declare const s: unique symbol;
|
||||
interface I { readonly readonlyType: unique symbol; }
|
||||
|
||||
// not allowed when emitting declarations
|
||||
|
||||
export const obj = {
|
||||
method1(p: typeof s): typeof s {
|
||||
return p;
|
||||
},
|
||||
method2(p: I["readonlyType"]): I["readonlyType"] {
|
||||
return p;
|
||||
}
|
||||
};
|
||||
|
||||
export const classExpression = class {
|
||||
method1(p: typeof s): typeof s {
|
||||
return p;
|
||||
}
|
||||
method2(p: I["readonlyType"]): I["readonlyType"] {
|
||||
return p;
|
||||
}
|
||||
};
|
||||
|
||||
export function funcInferredReturnType(obj: { method(p: typeof s): void }) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
export interface InterfaceWithPrivateNamedProperties {
|
||||
[s]: any;
|
||||
}
|
||||
|
||||
export interface InterfaceWithPrivateNamedMethods {
|
||||
[s](): any;
|
||||
}
|
||||
|
||||
export type TypeLiteralWithPrivateNamedProperties = {
|
||||
[s]: any;
|
||||
}
|
||||
|
||||
export type TypeLiteralWithPrivateNamedMethods = {
|
||||
[s](): any;
|
||||
}
|
||||
|
||||
export class ClassWithPrivateNamedProperties {
|
||||
[s]: any;
|
||||
static [s]: any;
|
||||
}
|
||||
|
||||
export class ClassWithPrivateNamedMethods {
|
||||
[s]() {}
|
||||
static [s]() {}
|
||||
}
|
||||
|
||||
export class ClassWithPrivateNamedAccessors {
|
||||
get [s](): any { return undefined; }
|
||||
set [s](v: any) { }
|
||||
static get [s](): any { return undefined; }
|
||||
static set [s](v: any) { }
|
||||
}
|
||||
Reference in new issue
Block a user