diff --git a/.gitmodules b/.gitmodules index f83d0f77c9e58..e5cf4c016e931 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,15 +1,25 @@ [submodule "tests/cases/user/TypeScript-React-Starter/TypeScript-React-Starter"] path = tests/cases/user/TypeScript-React-Starter/TypeScript-React-Starter url = https://github.com/Microsoft/TypeScript-React-Starter + ignore = all + shallow = true [submodule "tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter"] path = tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter url = https://github.com/Microsoft/TypeScript-Node-Starter.git + ignore = all + shallow = true [submodule "tests/cases/user/TypeScript-React-Native-Starter/TypeScript-React-Native-Starter"] path = tests/cases/user/TypeScript-React-Native-Starter/TypeScript-React-Native-Starter url = https://github.com/Microsoft/TypeScript-React-Native-Starter.git + ignore = all + shallow = true [submodule "tests/cases/user/TypeScript-Vue-Starter/TypeScript-Vue-Starter"] path = tests/cases/user/TypeScript-Vue-Starter/TypeScript-Vue-Starter url = https://github.com/Microsoft/TypeScript-Vue-Starter.git + ignore = all + shallow = true [submodule "tests/cases/user/TypeScript-WeChat-Starter/TypeScript-WeChat-Starter"] path = tests/cases/user/TypeScript-WeChat-Starter/TypeScript-WeChat-Starter url = https://github.com/Microsoft/TypeScript-WeChat-Starter.git + ignore = all + shallow = true diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index a0146740678df..8b3dd995caf5c 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -1680,7 +1680,7 @@ namespace ts { function bindAnonymousDeclaration(node: Declaration, symbolFlags: SymbolFlags, name: __String) { const symbol = createSymbol(symbolFlags, name); - if (symbolFlags & SymbolFlags.EnumMember) { + if (symbolFlags & (SymbolFlags.EnumMember | SymbolFlags.ClassMember)) { symbol.parent = container.symbol; } addDeclarationToSymbol(symbol, node, symbolFlags); @@ -1835,7 +1835,7 @@ namespace ts { } function checkStrictModeNumericLiteral(node: NumericLiteral) { - if (inStrictMode && node.numericLiteralFlags & NumericLiteralFlags.Octal) { + if (inStrictMode && node.numericLiteralFlags & TokenFlags.Octal) { file.bindDiagnostics.push(createDiagnosticForNode(node, Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); } } @@ -3319,7 +3319,7 @@ namespace ts { break; case SyntaxKind.NumericLiteral: - if ((node).numericLiteralFlags & NumericLiteralFlags.BinaryOrOctalSpecifier) { + if ((node).numericLiteralFlags & TokenFlags.BinaryOrOctalSpecifier) { transformFlags |= TransformFlags.AssertES2015; } break; diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 0a3dfd9cb743f..cb8cd5251cc94 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -527,6 +527,18 @@ namespace ts { Optional = 1 << 1, } + const enum ExpandingFlags { + None = 0, + Source = 1, + Target = 1 << 1, + Both = Source | Target, + } + + const enum MembersOrExportsResolutionKind { + resolvedExports = "resolvedExports", + resolvedMembers = "resolvedMembers" + } + const builtinGlobals = createSymbolTable(); builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol); @@ -566,10 +578,10 @@ namespace ts { diagnostics.add(diagnostic); } - function createSymbol(flags: SymbolFlags, name: __String) { + function createSymbol(flags: SymbolFlags, name: __String, checkFlags?: CheckFlags) { symbolCount++; const symbol = (new Symbol(flags | SymbolFlags.Transient, name)); - symbol.checkFlags = 0; + symbol.checkFlags = checkFlags || 0; return symbol; } @@ -657,6 +669,15 @@ namespace ts { } } + function combineSymbolTables(first: SymbolTable | undefined, second: SymbolTable | undefined): SymbolTable | undefined { + if (!first || first.size === 0) return second; + if (!second || second.size === 0) return first; + const combined = createSymbolTable(); + mergeSymbolTable(combined, first); + mergeSymbolTable(combined, second); + return combined; + } + function mergeSymbolTable(target: SymbolTable, source: SymbolTable) { source.forEach((sourceSymbol, id) => { let targetSymbol = target.get(id); @@ -774,7 +795,7 @@ namespace ts { const classDeclaration = parameter.parent.parent; const parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, SymbolFlags.Value); - const propertySymbol = getSymbol(classDeclaration.symbol.members, parameterName, SymbolFlags.Value); + const propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, SymbolFlags.Value); if (parameterSymbol && propertySymbol) { return [parameterSymbol, propertySymbol]; @@ -1039,7 +1060,7 @@ namespace ts { case SyntaxKind.ClassDeclaration: case SyntaxKind.ClassExpression: case SyntaxKind.InterfaceDeclaration: - if (result = lookup(getSymbolOfNode(location).members, name, meaning & SymbolFlags.Type)) { + if (result = lookup(getMembersOfSymbol(getSymbolOfNode(location)), name, meaning & SymbolFlags.Type)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { // ignore type parameters not declared in this container result = undefined; @@ -1882,7 +1903,9 @@ namespace ts { } function getExportsOfSymbol(symbol: Symbol): SymbolTable { - return symbol.flags & SymbolFlags.Module ? getExportsOfModule(symbol) : symbol.exports || emptySymbols; + return symbol.flags & SymbolFlags.Class ? getResolvedMembersOrExportsOfSymbol(symbol, MembersOrExportsResolutionKind.resolvedExports) : + symbol.flags & SymbolFlags.Module ? getExportsOfModule(symbol) : + symbol.exports || emptySymbols; } function getExportsOfModule(moduleSymbol: Symbol): SymbolTable { @@ -1983,11 +2006,11 @@ namespace ts { } function getSymbolOfNode(node: Node): Symbol { - return getMergedSymbol(node.symbol); + return getMergedSymbol(node.symbol && getLateBoundSymbol(node.symbol)); } function getParentOfSymbol(symbol: Symbol): Symbol { - return getMergedSymbol(symbol.parent); + return getMergedSymbol(symbol.parent && getLateBoundSymbol(symbol.parent)); } function getExportSymbolOfValueSymbolIfExported(symbol: Symbol): Symbol { @@ -2344,7 +2367,9 @@ namespace ts { function isEntityNameVisible(entityName: EntityNameOrEntityNameExpression, enclosingDeclaration: Node): SymbolVisibilityResult { // get symbol of the first identifier of the entityName let meaning: SymbolFlags; - if (entityName.parent.kind === SyntaxKind.TypeQuery || isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { + if (entityName.parent.kind === SyntaxKind.TypeQuery || + isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) || + entityName.parent.kind === SyntaxKind.ComputedPropertyName) { // Typeof value meaning = SymbolFlags.Value | SymbolFlags.ExportValue; } @@ -2509,6 +2534,9 @@ namespace ts { if (type.flags & TypeFlags.BooleanLiteral) { return (type).intrinsicName === "true" ? createTrue() : createFalse(); } + if (type.flags & TypeFlags.UniqueESSymbol) { + return createTypeOperatorNode(SyntaxKind.UniqueKeyword, createKeywordTypeNode(SyntaxKind.SymbolKeyword)); + } if (type.flags & TypeFlags.Void) { return createKeywordTypeNode(SyntaxKind.VoidKeyword); } @@ -2921,32 +2949,24 @@ namespace ts { function symbolToParameterDeclaration(parameterSymbol: Symbol, context: NodeBuilderContext): ParameterDeclaration { const parameterDeclaration = getDeclarationOfKind(parameterSymbol, SyntaxKind.Parameter); - if (isTransientSymbol(parameterSymbol) && parameterSymbol.isRestParameter) { - // special-case synthetic rest parameters in JS files - return createParameter( - /*decorators*/ undefined, - /*modifiers*/ undefined, - parameterSymbol.isRestParameter ? createToken(SyntaxKind.DotDotDotToken) : undefined, - "args", - /*questionToken*/ undefined, - typeToTypeNodeHelper(anyArrayType, context), - /*initializer*/ undefined); - } - const modifiers = parameterDeclaration.modifiers && parameterDeclaration.modifiers.map(getSynthesizedClone); - const dotDotDotToken = isRestParameter(parameterDeclaration) ? createToken(SyntaxKind.DotDotDotToken) : undefined; - const name = parameterDeclaration.name ? - parameterDeclaration.name.kind === SyntaxKind.Identifier ? - setEmitFlags(getSynthesizedClone(parameterDeclaration.name), EmitFlags.NoAsciiEscaping) : - cloneBindingName(parameterDeclaration.name) : - symbolName(parameterSymbol); - const questionToken = isOptionalParameter(parameterDeclaration) ? createToken(SyntaxKind.QuestionToken) : undefined; + Debug.assert(!!parameterDeclaration || isTransientSymbol(parameterSymbol) && !!parameterSymbol.isRestParameter); let parameterType = getTypeOfSymbol(parameterSymbol); - if (isRequiredInitializedParameter(parameterDeclaration)) { - parameterType = getNullableType(parameterType, TypeFlags.Undefined); + if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { + parameterType = getOptionalType(parameterType); } const parameterTypeNode = typeToTypeNodeHelper(parameterType, context); + const modifiers = parameterDeclaration && parameterDeclaration.modifiers && parameterDeclaration.modifiers.map(getSynthesizedClone); + const dotDotDotToken = !parameterDeclaration || isRestParameter(parameterDeclaration) ? createToken(SyntaxKind.DotDotDotToken) : undefined; + const name = parameterDeclaration + ? parameterDeclaration.name ? + parameterDeclaration.name.kind === SyntaxKind.Identifier ? + setEmitFlags(getSynthesizedClone(parameterDeclaration.name), EmitFlags.NoAsciiEscaping) : + cloneBindingName(parameterDeclaration.name) : + symbolName(parameterSymbol) + : symbolName(parameterSymbol); + const questionToken = parameterDeclaration && isOptionalParameter(parameterDeclaration) ? createToken(SyntaxKind.QuestionToken) : undefined; const parameterNode = createParameter( /*decorators*/ undefined, modifiers, @@ -3182,14 +3202,18 @@ namespace ts { const needsElementAccess = !isIdentifierStart(firstChar, languageVersion); if (needsElementAccess) { - writePunctuation(writer, SyntaxKind.OpenBracketToken); + if (firstChar !== CharacterCodes.openBracket) { + writePunctuation(writer, SyntaxKind.OpenBracketToken); + } if (isSingleOrDoubleQuote(firstChar)) { writer.writeStringLiteral(symbolName); } else { writer.writeSymbol(symbolName, symbol); } - writePunctuation(writer, SyntaxKind.CloseBracketToken); + if (firstChar !== CharacterCodes.openBracket) { + writePunctuation(writer, SyntaxKind.CloseBracketToken); + } } else { writePunctuation(writer, SyntaxKind.DotToken); @@ -3323,6 +3347,16 @@ namespace ts { else if (getObjectFlags(type) & (ObjectFlags.Anonymous | ObjectFlags.Mapped)) { writeAnonymousType(type, nextFlags); } + else if (type.flags & TypeFlags.UniqueESSymbol) { + if (flags & TypeFormatFlags.AllowUniqueESSymbolType) { + writeKeyword(writer, SyntaxKind.UniqueKeyword); + writeSpace(writer); + } + else { + writer.reportInaccessibleUniqueSymbolError(); + } + writeKeyword(writer, SyntaxKind.SymbolKeyword); + } else if (type.flags & TypeFlags.StringOrNumberLiteral) { writer.writeStringLiteral(literalTypeToString(type)); } @@ -3455,10 +3489,10 @@ namespace ts { !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === SyntaxKind.ClassExpression && flags & TypeFormatFlags.WriteClassExpressionAsTypeLiteral) || symbol.flags & (SymbolFlags.Enum | SymbolFlags.ValueModule)) { - writeTypeOfSymbol(type, flags); + writeTypeOfSymbol(type.symbol, flags); } else if (shouldWriteTypeOfFunctionSymbol()) { - writeTypeOfSymbol(type, flags); + writeTypeOfSymbol(type.symbol, flags); } else if (contains(symbolStack, symbol)) { // If type is an anonymous type literal in a type alias declaration, use type alias name @@ -3512,13 +3546,13 @@ namespace ts { } } - function writeTypeOfSymbol(type: ObjectType, typeFormatFlags?: TypeFormatFlags) { + function writeTypeOfSymbol(symbol: Symbol, typeFormatFlags?: TypeFormatFlags) { if (typeFormatFlags & TypeFormatFlags.InArrayType) { writePunctuation(writer, SyntaxKind.OpenParenToken); } writeKeyword(writer, SyntaxKind.TypeOfKeyword); writeSpace(writer); - buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, SymbolFlags.Value, SymbolFormatFlags.None, typeFormatFlags); + buildSymbolDisplay(symbol, writer, enclosingDeclaration, SymbolFlags.Value, SymbolFormatFlags.None, typeFormatFlags); if (typeFormatFlags & TypeFormatFlags.InArrayType) { writePunctuation(writer, SyntaxKind.CloseParenToken); } @@ -3529,6 +3563,13 @@ namespace ts { writeKeyword(writer, SyntaxKind.ReadonlyKeyword); writeSpace(writer); } + if (getCheckFlags(prop) & CheckFlags.Late) { + const decl = firstOrUndefined(prop.declarations); + const name = hasLateBindableName(decl) && resolveEntityName(decl.name.expression, SymbolFlags.Value); + if (name) { + writer.trackSymbol(name, enclosingDeclaration, SymbolFlags.Value); + } + } buildSymbolDisplay(prop, writer); if (prop.flags & SymbolFlags.Optional) { writePunctuation(writer, SyntaxKind.QuestionToken); @@ -3714,7 +3755,7 @@ namespace ts { let type = getTypeOfSymbol(p); if (parameterNode && isRequiredInitializedParameter(parameterNode)) { - type = getNullableType(type, TypeFlags.Undefined); + type = getOptionalType(type); } buildTypeDisplay(type, writer, enclosingDeclaration, flags, symbolStack); } @@ -4285,8 +4326,8 @@ namespace ts { return expr.kind === SyntaxKind.ArrayLiteralExpression && (expr).elements.length === 0; } - function addOptionality(type: Type, optional: boolean): Type { - return strictNullChecks && optional ? getNullableType(type, TypeFlags.Undefined) : type; + function addOptionality(type: Type, optional = true): Type { + return strictNullChecks && optional ? getOptionalType(type) : type; } // Return the inferred type for a variable, parameter, or property declaration @@ -4315,7 +4356,7 @@ namespace ts { const typeNode = getEffectiveTypeAnnotationNode(declaration); if (typeNode) { const declaredType = getTypeFromTypeNode(typeNode); - return addOptionality(declaredType, /*optional*/ declaration.questionToken && includeOptionality); + return addOptionality(declaredType, /*optional*/ !!declaration.questionToken && includeOptionality); } if ((noImplicitAny || isInJavaScriptFile(declaration)) && @@ -4337,8 +4378,8 @@ namespace ts { if (declaration.kind === SyntaxKind.Parameter) { const func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === SyntaxKind.SetAccessor && !hasDynamicName(func)) { - const getter = getDeclarationOfKind(declaration.parent.symbol, SyntaxKind.GetAccessor); + if (func.kind === SyntaxKind.SetAccessor && !hasNonBindableDynamicName(func)) { + const getter = getDeclarationOfKind(getSymbolOfNode(declaration.parent), SyntaxKind.GetAccessor); if (getter) { const getterSignature = getSignatureFromDeclaration(getter); const thisParameter = getAccessorThisParameter(func as AccessorDeclaration); @@ -4359,14 +4400,14 @@ namespace ts { type = getContextuallyTypedParameterType(declaration); } if (type) { - return addOptionality(type, /*optional*/ declaration.questionToken && includeOptionality); + return addOptionality(type, /*optional*/ !!declaration.questionToken && includeOptionality); } } // Use the type of the initializer expression if one is present if (declaration.initializer) { const type = checkDeclarationInitializer(declaration); - return addOptionality(type, /*optional*/ declaration.questionToken && includeOptionality); + return addOptionality(type, /*optional*/ !!declaration.questionToken && includeOptionality); } if (isJsxAttribute(declaration)) { @@ -4420,7 +4461,7 @@ namespace ts { jsDocType = declarationType; } else if (jsDocType !== unknownType && declarationType !== unknownType && !isTypeIdenticalTo(jsDocType, declarationType)) { - errorNextVariableDeclarationMustHaveSameType(symbol.valueDeclaration, jsDocType, declaration, declarationType); + errorNextVariableOrPropertyDeclarationMustHaveSameType(symbol.valueDeclaration, jsDocType, declaration, declarationType); } } else if (!jsDocType) { @@ -4528,6 +4569,12 @@ namespace ts { if (reportErrors) { reportErrorsFromWidening(declaration, type); } + + // always widen a 'unique symbol' type if the type was created for a different declaration. + if (type.flags & TypeFlags.UniqueESSymbol && !declaration.type && type.symbol !== getSymbolOfNode(declaration)) { + type = esSymbolType; + } + // During a normal type check we'll never get to here with a property assignment (the check of the containing // object literal uses a different path). We exclude widening only so that language services and type verification // tools see the actual type. @@ -4704,7 +4751,7 @@ namespace ts { links.type = baseTypeVariable ? getIntersectionType([type, baseTypeVariable]) : type; } else { - links.type = strictNullChecks && symbol.flags & SymbolFlags.Optional ? getNullableType(type, TypeFlags.Undefined) : type; + links.type = strictNullChecks && symbol.flags & SymbolFlags.Optional ? getOptionalType(type) : type; } } } @@ -5101,10 +5148,14 @@ namespace ts { } } - // Returns true if the interface given by the symbol is free of "this" references. Specifically, the result is - // true if the interface itself contains no references to "this" in its body, if all base types are interfaces, - // and if none of the base interfaces have a "this" type. - function isIndependentInterface(symbol: Symbol): boolean { + /** + * Returns true if the interface given by the symbol is free of "this" references. + * + * Specifically, the result is true if the interface itself contains no references + * to "this" in its body, if all base types are interfaces, + * and if none of the base interfaces have a "this" type. + */ + function isThislessInterface(symbol: Symbol): boolean { for (const declaration of symbol.declarations) { if (declaration.kind === SyntaxKind.InterfaceDeclaration) { if (declaration.flags & NodeFlags.ContainsThis) { @@ -5138,7 +5189,7 @@ namespace ts { // property types inferred from initializers and method return types inferred from return statements are very hard // to exhaustively analyze). We give interfaces a "this" type if we can't definitely determine that they are free of // "this" references. - if (outerTypeParameters || localTypeParameters || kind === ObjectFlags.Class || !isIndependentInterface(symbol)) { + if (outerTypeParameters || localTypeParameters || kind === ObjectFlags.Class || !isThislessInterface(symbol)) { type.objectFlags |= ObjectFlags.Reference; type.typeParameters = concatenate(outerTypeParameters, localTypeParameters); type.outerTypeParameters = outerTypeParameters; @@ -5320,22 +5371,12 @@ namespace ts { return undefined; } - // A type reference is considered independent if each type argument is considered independent. - function isIndependentTypeReference(node: TypeReferenceNode): boolean { - if (node.typeArguments) { - for (const typeNode of node.typeArguments) { - if (!isIndependentType(typeNode)) { - return false; - } - } - } - return true; - } - - // A type is considered independent if it the any, string, number, boolean, symbol, or void keyword, a string - // literal type, an array with an element type that is considered independent, or a type reference that is - // considered independent. - function isIndependentType(node: TypeNode): boolean { + /** + * A type is free of this references if it's the any, string, number, boolean, symbol, or void keyword, a string + * literal type, an array with an element type that is free of this references, or a type reference that is + * free of this references. + */ + function isThislessType(node: TypeNode): boolean { switch (node.kind) { case SyntaxKind.AnyKeyword: case SyntaxKind.StringKeyword: @@ -5350,54 +5391,58 @@ namespace ts { case SyntaxKind.LiteralType: return true; case SyntaxKind.ArrayType: - return isIndependentType((node).elementType); + return isThislessType((node).elementType); case SyntaxKind.TypeReference: - return isIndependentTypeReference(node); + return !(node as TypeReferenceNode).typeArguments || (node as TypeReferenceNode).typeArguments.every(isThislessType); } return false; } - // A variable-like declaration is considered independent (free of this references) if it has a type annotation - // that specifies an independent type, or if it has no type annotation and no initializer (and thus of type any). - function isIndependentVariableLikeDeclaration(node: VariableLikeDeclaration): boolean { + /** A type parameter is thisless if its contraint is thisless, or if it has no constraint. */ + function isThislessTypeParameter(node: TypeParameterDeclaration) { + return !node.constraint || isThislessType(node.constraint); + } + + /** + * A variable-like declaration is free of this references if it has a type annotation + * that is thisless, or if it has no type annotation and no initializer (and is thus of type any). + */ + function isThislessVariableLikeDeclaration(node: VariableLikeDeclaration): boolean { const typeNode = getEffectiveTypeAnnotationNode(node); - return typeNode ? isIndependentType(typeNode) : !node.initializer; + return typeNode ? isThislessType(typeNode) : !node.initializer; } - // A function-like declaration is considered independent (free of this references) if it has a return type - // annotation that is considered independent and if each parameter is considered independent. - function isIndependentFunctionLikeDeclaration(node: FunctionLikeDeclaration): boolean { - if (node.kind !== SyntaxKind.Constructor) { - const typeNode = getEffectiveReturnTypeNode(node); - if (!typeNode || !isIndependentType(typeNode)) { - return false; - } - } - for (const parameter of node.parameters) { - if (!isIndependentVariableLikeDeclaration(parameter)) { - return false; - } - } - return true; + /** + * A function-like declaration is considered free of `this` references if it has a return type + * annotation that is free of this references and if each parameter is thisless and if + * each type parameter (if present) is thisless. + */ + function isThislessFunctionLikeDeclaration(node: FunctionLikeDeclaration): boolean { + const returnType = getEffectiveReturnTypeNode(node); + return (node.kind === SyntaxKind.Constructor || (returnType && isThislessType(returnType))) && + node.parameters.every(isThislessVariableLikeDeclaration) && + (!node.typeParameters || node.typeParameters.every(isThislessTypeParameter)); } - // Returns true if the class or interface member given by the symbol is free of "this" references. The - // function may return false for symbols that are actually free of "this" references because it is not - // feasible to perform a complete analysis in all cases. In particular, property members with types - // inferred from their initializers and function members with inferred return types are conservatively - // assumed not to be free of "this" references. - function isIndependentMember(symbol: Symbol): boolean { + /** + * Returns true if the class or interface member given by the symbol is free of "this" references. The + * function may return false for symbols that are actually free of "this" references because it is not + * feasible to perform a complete analysis in all cases. In particular, property members with types + * inferred from their initializers and function members with inferred return types are conservatively + * assumed not to be free of "this" references. + */ + function isThisless(symbol: Symbol): boolean { if (symbol.declarations && symbol.declarations.length === 1) { const declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { case SyntaxKind.PropertyDeclaration: case SyntaxKind.PropertySignature: - return isIndependentVariableLikeDeclaration(declaration); + return isThislessVariableLikeDeclaration(declaration); case SyntaxKind.MethodDeclaration: case SyntaxKind.MethodSignature: case SyntaxKind.Constructor: - return isIndependentFunctionLikeDeclaration(declaration); + return isThislessFunctionLikeDeclaration(declaration); } } } @@ -5409,7 +5454,7 @@ namespace ts { function createInstantiatedSymbolTable(symbols: Symbol[], mapper: TypeMapper, mappingThisOnly: boolean): SymbolTable { const result = createSymbolTable(); for (const symbol of symbols) { - result.set(symbol.escapedName, mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper)); + result.set(symbol.escapedName, mappingThisOnly && isThisless(symbol) ? symbol : instantiateSymbol(symbol, mapper)); } return result; } @@ -5425,15 +5470,226 @@ namespace ts { function resolveDeclaredMembers(type: InterfaceType): InterfaceTypeWithDeclaredMembers { if (!(type).declaredProperties) { const symbol = type.symbol; - (type).declaredProperties = getNamedMembers(symbol.members); - (type).declaredCallSignatures = getSignaturesOfSymbol(symbol.members.get(InternalSymbolName.Call)); - (type).declaredConstructSignatures = getSignaturesOfSymbol(symbol.members.get(InternalSymbolName.New)); + const members = getMembersOfSymbol(symbol); + (type).declaredProperties = getNamedMembers(members); + (type).declaredCallSignatures = getSignaturesOfSymbol(members.get(InternalSymbolName.Call)); + (type).declaredConstructSignatures = getSignaturesOfSymbol(members.get(InternalSymbolName.New)); (type).declaredStringIndexInfo = getIndexInfoOfSymbol(symbol, IndexKind.String); (type).declaredNumberIndexInfo = getIndexInfoOfSymbol(symbol, IndexKind.Number); } return type; } + /** + * Indicates whether a type can be used as a late-bound name. + */ + function isTypeUsableAsLateBoundName(type: Type): type is LiteralType | UniqueESSymbolType { + return !!(type.flags & TypeFlags.StringOrNumberLiteralOrUnique); + } + + /** + * Indicates whether a declaration name is definitely late-bindable. + * A declaration name is only late-bindable if: + * - It is a `ComputedPropertyName`. + * - Its expression is an `Identifier` or either a `PropertyAccessExpression` an + * `ElementAccessExpression` consisting only of these same three types of nodes. + * - The type of its expression is a string or numeric literal type, or is a `unique symbol` type. + */ + function isLateBindableName(node: DeclarationName): node is LateBoundName { + return isComputedPropertyName(node) + && isEntityNameExpression(node.expression) + && isTypeUsableAsLateBoundName(checkComputedPropertyName(node)); + } + + /** + * Indicates whether a declaration has a late-bindable dynamic name. + */ + function hasLateBindableName(node: Declaration): node is LateBoundDeclaration { + const name = getNameOfDeclaration(node); + return name && isLateBindableName(name); + } + + /** + * Indicates whether a declaration has a dynamic name that cannot be late-bound. + */ + function hasNonBindableDynamicName(node: Declaration) { + return hasDynamicName(node) && !hasLateBindableName(node); + } + + /** + * Indicates whether a declaration name is a dynamic name that cannot be late-bound. + */ + function isNonBindableDynamicName(node: DeclarationName) { + return isDynamicName(node) && !isLateBindableName(node); + } + + /** + * Gets the symbolic name for a late-bound member from its type. + */ + function getLateBoundNameFromType(type: LiteralType | UniqueESSymbolType) { + if (type.flags & TypeFlags.UniqueESSymbol) { + return `__@${type.symbol.escapedName}@${getSymbolId(type.symbol)}` as __String; + } + if (type.flags & TypeFlags.StringOrNumberLiteral) { + return escapeLeadingUnderscores("" + (type).value); + } + } + + /** + * Adds a declaration to a late-bound dynamic member. This performs the same function for + * late-bound members that `addDeclarationToSymbol` in binder.ts performs for early-bound + * members. + */ + function addDeclarationToLateBoundSymbol(symbol: Symbol, member: LateBoundDeclaration, symbolFlags: SymbolFlags) { + Debug.assert(!!(getCheckFlags(symbol) & CheckFlags.Late), "Expected a late-bound symbol."); + symbol.flags |= symbolFlags; + getSymbolLinks(member.symbol).lateSymbol = symbol; + if (!symbol.declarations) { + symbol.declarations = [member]; + } + else { + symbol.declarations.push(member); + } + if (symbolFlags & SymbolFlags.Value) { + const valueDeclaration = symbol.valueDeclaration; + if (!valueDeclaration || valueDeclaration.kind !== member.kind) { + symbol.valueDeclaration = member; + } + } + } + + /** + * Performs late-binding of a dynamic member. This performs the same function for + * late-bound members that `declareSymbol` in binder.ts performs for early-bound + * members. + * + * If a symbol is a dynamic name from a computed property, we perform an additional "late" + * binding phase to attempt to resolve the name for the symbol from the type of the computed + * property's expression. If the type of the expression is a string-literal, numeric-literal, + * or unique symbol type, we can use that type as the name of the symbol. + * + * For example, given: + * + * const x = Symbol(); + * + * interface I { + * [x]: number; + * } + * + * The binder gives the property `[x]: number` a special symbol with the name "__computed". + * In the late-binding phase we can type-check the expression `x` and see that it has a + * unique symbol type which we can then use as the name of the member. This allows users + * to define custom symbols that can be used in the members of an object type. + * + * @param parent The containing symbol for the member. + * @param earlySymbols The early-bound symbols of the parent. + * @param lateSymbols The late-bound symbols of the parent. + * @param decl The member to bind. + */ + function lateBindMember(parent: Symbol, earlySymbols: SymbolTable | undefined, lateSymbols: SymbolTable, decl: LateBoundDeclaration) { + Debug.assert(!!decl.symbol, "The member is expected to have a symbol."); + const links = getNodeLinks(decl); + if (!links.resolvedSymbol) { + // In the event we attempt to resolve the late-bound name of this member recursively, + // fall back to the early-bound name of this member. + links.resolvedSymbol = decl.symbol; + const type = checkComputedPropertyName(decl.name); + if (isTypeUsableAsLateBoundName(type)) { + const memberName = getLateBoundNameFromType(type); + const symbolFlags = decl.symbol.flags; + + // Get or add a late-bound symbol for the member. This allows us to merge late-bound accessor declarations. + let lateSymbol = lateSymbols.get(memberName); + if (!lateSymbol) lateSymbols.set(memberName, lateSymbol = createSymbol(SymbolFlags.None, memberName, CheckFlags.Late)); + + // Report an error if a late-bound member has the same name as an early-bound member, + // or if we have another early-bound symbol declaration with the same name and + // conflicting flags. + const earlySymbol = earlySymbols && earlySymbols.get(memberName); + if (lateSymbol.flags & getExcludedSymbolFlags(symbolFlags) || earlySymbol) { + // If we have an existing early-bound member, combine its declarations so that we can + // report an error at each declaration. + const declarations = earlySymbol ? concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations; + const name = declarationNameToString(decl.name); + forEach(declarations, declaration => error(getNameOfDeclaration(declaration) || declaration, Diagnostics.Duplicate_declaration_0, name)); + error(decl.name || decl, Diagnostics.Duplicate_declaration_0, name); + lateSymbol = createSymbol(SymbolFlags.None, memberName, CheckFlags.Late); + } + + addDeclarationToLateBoundSymbol(lateSymbol, decl, symbolFlags); + lateSymbol.parent = parent; + return links.resolvedSymbol = lateSymbol; + } + } + return links.resolvedSymbol; + } + + function getResolvedMembersOrExportsOfSymbol(symbol: Symbol, resolutionKind: MembersOrExportsResolutionKind) { + const links = getSymbolLinks(symbol); + if (!links[resolutionKind]) { + const isStatic = resolutionKind === MembersOrExportsResolutionKind.resolvedExports; + const earlySymbols = !isStatic ? symbol.members : + symbol.flags & SymbolFlags.Module ? getExportsOfModuleWorker(symbol) : + symbol.exports; + + // In the event we recursively resolve the members/exports of the symbol, we + // set the initial value of resolvedMembers/resolvedExports to the early-bound + // members/exports of the symbol. + links[resolutionKind] = earlySymbols || emptySymbols; + + // fill in any as-yet-unresolved late-bound members. + const lateSymbols = createSymbolTable(); + for (const decl of symbol.declarations) { + const members = getMembersOfDeclaration(decl); + if (members) { + for (const member of members) { + if (isStatic === hasStaticModifier(member) && hasLateBindableName(member)) { + lateBindMember(symbol, earlySymbols, lateSymbols, member); + } + } + } + } + + links[resolutionKind] = combineSymbolTables(earlySymbols, lateSymbols) || emptySymbols; + } + + return links[resolutionKind]; + } + + /** + * Gets a SymbolTable containing both the early- and late-bound members of a symbol. + * + * For a description of late-binding, see `lateBindMember`. + */ + function getMembersOfSymbol(symbol: Symbol) { + return symbol.flags & SymbolFlags.LateBindingContainer + ? getResolvedMembersOrExportsOfSymbol(symbol, MembersOrExportsResolutionKind.resolvedMembers) + : symbol.members || emptySymbols; + } + + /** + * If a symbol is the dynamic name of the member of an object type, get the late-bound + * symbol of the member. + * + * For a description of late-binding, see `lateBindMember`. + */ + function getLateBoundSymbol(symbol: Symbol): Symbol { + if (symbol.flags & SymbolFlags.ClassMember && symbol.escapedName === InternalSymbolName.Computed) { + const links = getSymbolLinks(symbol); + if (!links.lateSymbol && some(symbol.declarations, hasLateBindableName)) { + // force late binding of members/exports. This will set the late-bound symbol + if (some(symbol.declarations, hasStaticModifier)) { + getExportsOfSymbol(symbol.parent); + } + else { + getMembersOfSymbol(symbol.parent); + } + } + return links.lateSymbol || (links.lateSymbol = symbol); + } + return symbol; + } + function getTypeWithThisArgument(type: Type, thisArgument?: Type): Type { if (getObjectFlags(type) & ObjectFlags.Reference) { const target = (type).target; @@ -5457,7 +5713,7 @@ namespace ts { let numberIndexInfo: IndexInfo; if (rangeEquals(typeParameters, typeArguments, 0, typeParameters.length)) { mapper = identityMapper; - members = source.symbol ? source.symbol.members : createSymbolTable(source.declaredProperties); + members = source.symbol ? getMembersOfSymbol(source.symbol) : createSymbolTable(source.declaredProperties); callSignatures = source.declaredCallSignatures; constructSignatures = source.declaredConstructSignatures; stringIndexInfo = source.declaredStringIndexInfo; @@ -5473,7 +5729,7 @@ namespace ts { } const baseTypes = getBaseTypes(source); if (baseTypes.length) { - if (source.symbol && members === source.symbol.members) { + if (source.symbol && members === getMembersOfSymbol(source.symbol)) { members = createSymbolTable(source.declaredProperties); } const thisArgument = lastOrUndefined(typeArguments); @@ -5715,7 +5971,7 @@ namespace ts { setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); } else if (symbol.flags & SymbolFlags.TypeLiteral) { - const members = symbol.members; + const members = getMembersOfSymbol(symbol); const callSignatures = getSignaturesOfSymbol(members.get(InternalSymbolName.Call)); const constructSignatures = getSignaturesOfSymbol(members.get(InternalSymbolName.New)); const stringIndexInfo = getIndexInfoOfSymbol(symbol, IndexKind.String); @@ -5775,7 +6031,9 @@ namespace ts { const modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); // The 'T' in 'keyof T' const templateReadonly = !!type.declaration.readonlyToken; const templateOptional = !!type.declaration.questionToken; - if (type.declaration.typeParameter.constraint.kind === SyntaxKind.TypeOperator) { + const constraintDeclaration = type.declaration.typeParameter.constraint; + if (constraintDeclaration.kind === SyntaxKind.TypeOperator && + (constraintDeclaration).operator === SyntaxKind.KeyOfKeyword) { // We have a { [P in keyof T]: X } for (const propertySymbol of getPropertiesOfType(modifiersType)) { addMemberForKeyType(getLiteralTypeFromPropertyName(propertySymbol), propertySymbol); @@ -5814,8 +6072,8 @@ namespace ts { const propName = escapeLeadingUnderscores((t).value); const modifiersProp = getPropertyOfType(modifiersType, propName); const isOptional = templateOptional || !!(modifiersProp && modifiersProp.flags & SymbolFlags.Optional); - const prop = createSymbol(SymbolFlags.Property | (isOptional ? SymbolFlags.Optional : 0), propName); - prop.checkFlags = templateReadonly || modifiersProp && isReadonlySymbol(modifiersProp) ? CheckFlags.Readonly : 0; + const checkFlags = templateReadonly || modifiersProp && isReadonlySymbol(modifiersProp) ? CheckFlags.Readonly : 0; + const prop = createSymbol(SymbolFlags.Property | (isOptional ? SymbolFlags.Optional : 0), propName, checkFlags); prop.type = propType; if (propertySymbol) { prop.syntheticOrigin = propertySymbol; @@ -5850,7 +6108,8 @@ namespace ts { function getModifiersTypeFromMappedType(type: MappedType) { if (!type.modifiersType) { const constraintDeclaration = type.declaration.typeParameter.constraint; - if (constraintDeclaration.kind === SyntaxKind.TypeOperator) { + if (constraintDeclaration.kind === SyntaxKind.TypeOperator && + (constraintDeclaration).operator === SyntaxKind.KeyOfKeyword) { // If the constraint declaration is a 'keyof T' node, the modifiers type is T. We check // AST nodes here because, when T is a non-generic type, the logic below eagerly resolves // 'keyof T' to a literal union type and we can't recover T from that type. @@ -6146,7 +6405,7 @@ namespace ts { t.flags & TypeFlags.StringLike ? globalStringType : t.flags & TypeFlags.NumberLike ? globalNumberType : t.flags & TypeFlags.BooleanLike ? globalBooleanType : - t.flags & TypeFlags.ESSymbol ? getGlobalESSymbolType(/*reportErrors*/ languageVersion >= ScriptTarget.ES2015) : + t.flags & TypeFlags.ESSymbolLike ? getGlobalESSymbolType(/*reportErrors*/ languageVersion >= ScriptTarget.ES2015) : t.flags & TypeFlags.NonPrimitive ? emptyObjectType : t; } @@ -6204,8 +6463,7 @@ namespace ts { } propTypes.push(type); } - const result = createSymbol(SymbolFlags.Property | commonFlags, name); - result.checkFlags = syntheticFlag | checkFlags; + const result = createSymbol(SymbolFlags.Property | commonFlags, name, syntheticFlag | checkFlags); result.containingType = containingType; result.declarations = declarations; result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes); @@ -6510,10 +6768,10 @@ namespace ts { // If only one accessor includes a this-type annotation, the other behaves as if it had the same type annotation if ((declaration.kind === SyntaxKind.GetAccessor || declaration.kind === SyntaxKind.SetAccessor) && - !hasDynamicName(declaration) && + !hasNonBindableDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { const otherKind = declaration.kind === SyntaxKind.GetAccessor ? SyntaxKind.SetAccessor : SyntaxKind.GetAccessor; - const other = getDeclarationOfKind(declaration.symbol, otherKind); + const other = getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } @@ -6527,21 +6785,35 @@ namespace ts { const typePredicate = declaration.type && declaration.type.kind === SyntaxKind.TypePredicate ? createTypePredicateFromTypePredicateNode(declaration.type as TypePredicateNode) : undefined; - // JS functions get a free rest parameter if they reference `arguments` - let hasRestLikeParameter = hasRestParameter(declaration); - if (!hasRestLikeParameter && isInJavaScriptFile(declaration) && containsArgumentsReference(declaration)) { - hasRestLikeParameter = true; - const syntheticArgsSymbol = createSymbol(SymbolFlags.Variable, "args" as __String); - syntheticArgsSymbol.type = anyArrayType; - syntheticArgsSymbol.isRestParameter = true; - parameters.push(syntheticArgsSymbol); - } - + const hasRestLikeParameter = hasRestParameter(declaration) || isInJavaScriptFile(declaration) && maybeAddJsSyntheticRestParameter(declaration, parameters); links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, returnType, typePredicate, minArgumentCount, hasRestLikeParameter, hasLiteralTypes); } return links.resolvedSignature; } + function maybeAddJsSyntheticRestParameter(declaration: SignatureDeclaration, parameters: Symbol[]): boolean { + // JS functions get a free rest parameter if: + // a) The last parameter has `...` preceding its type + // b) It references `arguments` somewhere + const lastParam = lastOrUndefined(declaration.parameters); + const lastParamTags = lastParam && getJSDocParameterTags(lastParam); + const lastParamVariadicType = lastParamTags && firstDefined(lastParamTags, p => + p.typeExpression && isJSDocVariadicType(p.typeExpression.type) ? p.typeExpression.type : undefined); + if (!lastParamVariadicType && !containsArgumentsReference(declaration)) { + return false; + } + + const syntheticArgsSymbol = createSymbol(SymbolFlags.Variable, "args" as __String); + syntheticArgsSymbol.type = lastParamVariadicType ? createArrayType(getTypeFromTypeNode(lastParamVariadicType.type)) : anyArrayType; + syntheticArgsSymbol.isRestParameter = true; + if (lastParamVariadicType) { + // Replace the last parameter with a rest parameter. + parameters.pop(); + } + parameters.push(syntheticArgsSymbol); + return true; + } + function getSignatureReturnTypeFromDeclaration(declaration: SignatureDeclaration, isJSConstructSignature: boolean, classType: Type) { if (isJSConstructSignature) { return getTypeFromTypeNode(declaration.parameters[0].type); @@ -6557,8 +6829,8 @@ namespace ts { // TypeScript 1.0 spec (April 2014): // If only one accessor includes a type annotation, the other behaves as if it had the same type annotation. - if (declaration.kind === SyntaxKind.GetAccessor && !hasDynamicName(declaration)) { - const setter = getDeclarationOfKind(declaration.symbol, SyntaxKind.SetAccessor); + if (declaration.kind === SyntaxKind.GetAccessor && !hasNonBindableDynamicName(declaration)) { + const setter = getDeclarationOfKind(getSymbolOfNode(declaration), SyntaxKind.SetAccessor); return getAnnotatedAccessorType(setter); } @@ -7096,7 +7368,7 @@ namespace ts { function getTypeFromJSDocNullableTypeNode(node: JSDocNullableType) { const type = getTypeFromTypeNode(node.type); - return strictNullChecks ? getUnionType([type, nullType]) : type; + return strictNullChecks ? getNullableType(type, TypeFlags.Null) : type; } function getTypeFromTypeReference(node: TypeReferenceType): Type { @@ -7355,7 +7627,8 @@ namespace ts { containsNonWideningType?: boolean; containsString?: boolean; containsNumber?: boolean; - containsStringOrNumberLiteral?: boolean; + containsESSymbol?: boolean; + containsLiteralOrUniqueESSymbol?: boolean; containsObjectType?: boolean; containsEmptyObject?: boolean; unionIndex?: number; @@ -7405,7 +7678,8 @@ namespace ts { // easier to reason about their origin. if (flags & TypeFlags.String) typeSet.containsString = true; if (flags & TypeFlags.Number) typeSet.containsNumber = true; - if (flags & TypeFlags.StringOrNumberLiteral) typeSet.containsStringOrNumberLiteral = true; + if (flags & TypeFlags.ESSymbol) typeSet.containsESSymbol = true; + if (flags & TypeFlags.StringOrNumberLiteralOrUnique) typeSet.containsLiteralOrUniqueESSymbol = true; const len = typeSet.length; const index = len && type.id > typeSet[len - 1].id ? ~len : binarySearch(typeSet, type, getTypeId, compareValues); if (index < 0) { @@ -7483,6 +7757,7 @@ namespace ts { const remove = t.flags & TypeFlags.StringLiteral && types.containsString || t.flags & TypeFlags.NumberLiteral && types.containsNumber || + t.flags & TypeFlags.UniqueESSymbol && types.containsESSymbol || t.flags & TypeFlags.StringOrNumberLiteral && t.flags & TypeFlags.FreshLiteral && containsType(types, (t).regularType); if (remove) { orderedRemoveItemAt(types, i); @@ -7512,7 +7787,7 @@ namespace ts { if (subtypeReduction) { removeSubtypes(typeSet); } - else if (typeSet.containsStringOrNumberLiteral) { + else if (typeSet.containsLiteralOrUniqueESSymbol) { removeRedundantLiteralTypes(typeSet); } if (typeSet.length === 0) { @@ -7685,7 +7960,16 @@ namespace ts { function getTypeFromTypeOperatorNode(node: TypeOperatorNode) { const links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = getIndexType(getTypeFromTypeNode(node.type)); + switch (node.operator) { + case SyntaxKind.KeyOfKeyword: + links.resolvedType = getIndexType(getTypeFromTypeNode(node.type)); + break; + case SyntaxKind.UniqueKeyword: + links.resolvedType = node.type.kind === SyntaxKind.SymbolKeyword + ? getESSymbolLikeTypeForNode(walkUpParenthesizedTypes(node.parent)) + : unknownType; + break; + } } return links.resolvedType; } @@ -7699,8 +7983,7 @@ namespace ts { function getPropertyTypeForIndexType(objectType: Type, indexType: Type, accessNode: ElementAccessExpression | IndexedAccessTypeNode, cacheSymbol: boolean) { const accessExpression = accessNode && accessNode.kind === SyntaxKind.ElementAccessExpression ? accessNode : undefined; - const propName = indexType.flags & TypeFlags.StringOrNumberLiteral ? - escapeLeadingUnderscores("" + (indexType).value) : + const propName = isTypeUsableAsLateBoundName(indexType) ? getLateBoundNameFromType(indexType) : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? getPropertyNameForKnownSymbolName(idText(((accessExpression.argumentExpression).name))) : undefined; @@ -7719,7 +8002,7 @@ namespace ts { return getTypeOfSymbol(prop); } } - if (!(indexType.flags & TypeFlags.Nullable) && isTypeAssignableToKind(indexType, TypeFlags.StringLike | TypeFlags.NumberLike | TypeFlags.ESSymbol)) { + if (!(indexType.flags & TypeFlags.Nullable) && isTypeAssignableToKind(indexType, TypeFlags.StringLike | TypeFlags.NumberLike | TypeFlags.ESSymbolLike)) { if (isTypeAny(objectType)) { return anyType; } @@ -7885,7 +8168,7 @@ namespace ts { if (!links.resolvedType) { // Deferred resolution of members is handled by resolveObjectTypeMembers const aliasSymbol = getAliasSymbolForTypeNode(node); - if (node.symbol.members.size === 0 && !aliasSymbol) { + if (getMembersOfSymbol(node.symbol).size === 0 && !aliasSymbol) { links.resolvedType = emptyTypeLiteralType; } else { @@ -8034,7 +8317,7 @@ namespace ts { function getFreshTypeOfLiteralType(type: Type) { if (type.flags & TypeFlags.StringOrNumberLiteral && !(type.flags & TypeFlags.FreshLiteral)) { if (!(type).freshType) { - const freshType = createLiteralType(type.flags | TypeFlags.FreshLiteral, (type).value, (type).symbol); + const freshType = createLiteralType(type.flags | TypeFlags.FreshLiteral, (type).value, (type).symbol); freshType.regularType = type; (type).freshType = freshType; } @@ -8070,13 +8353,19 @@ namespace ts { return links.resolvedType; } - function getTypeFromJSDocVariadicType(node: JSDocVariadicType): Type { - const links = getNodeLinks(node); - if (!links.resolvedType) { - const type = getTypeFromTypeNode(node.type); - links.resolvedType = type ? createArrayType(type) : unknownType; + function createUniqueESSymbolType(symbol: Symbol) { + const type = createType(TypeFlags.UniqueESSymbol); + type.symbol = symbol; + return type; + } + + function getESSymbolLikeTypeForNode(node: Node) { + if (isValidESSymbolDeclaration(node)) { + const symbol = getSymbolOfNode(node); + const links = getSymbolLinks(symbol); + return links.type || (links.type = createUniqueESSymbolType(symbol)); } - return links.resolvedType; + return esSymbolType; } function getThisType(node: Node): Type { @@ -8152,6 +8441,8 @@ namespace ts { case SyntaxKind.JSDocOptionalType: case SyntaxKind.JSDocTypeExpression: return getTypeFromTypeNode((node).type); + case SyntaxKind.JSDocVariadicType: + return getTypeFromJSDocVariadicType(node as JSDocVariadicType); case SyntaxKind.FunctionType: case SyntaxKind.ConstructorType: case SyntaxKind.TypeLiteral: @@ -8170,8 +8461,6 @@ namespace ts { case SyntaxKind.QualifiedName: const symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); - case SyntaxKind.JSDocVariadicType: - return getTypeFromJSDocVariadicType(node); default: return unknownType; } @@ -8314,8 +8603,7 @@ namespace ts { } // Keep the flags from the symbol we're instantiating. Mark that is instantiated, and // also transient so that we can just store data on it directly. - const result = createSymbol(symbol.flags, symbol.escapedName); - result.checkFlags = CheckFlags.Instantiated; + const result = createSymbol(symbol.flags, symbol.escapedName, CheckFlags.Instantiated); result.declarations = symbol.declarations; result.parent = symbol.parent; result.target = symbol; @@ -8879,6 +9167,7 @@ namespace ts { t & TypeFlags.NumberLiteral && !(t & TypeFlags.EnumLiteral) && (source).value === (target).value) return true; if (s & TypeFlags.BooleanLike && t & TypeFlags.Boolean) return true; + if (s & TypeFlags.ESSymbolLike && t & TypeFlags.ESSymbol) return true; if (s & TypeFlags.Enum && t & TypeFlags.Enum && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true; if (s & TypeFlags.EnumLiteral && t & TypeFlags.EnumLiteral) { if (s & TypeFlags.Union && t & TypeFlags.Union && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true; @@ -8889,6 +9178,7 @@ namespace ts { if (s & TypeFlags.Undefined && (!strictNullChecks || t & (TypeFlags.Undefined | TypeFlags.Void))) return true; if (s & TypeFlags.Null && (!strictNullChecks || t & TypeFlags.Null)) return true; if (s & TypeFlags.Object && t & TypeFlags.NonPrimitive) return true; + if (s & TypeFlags.UniqueESSymbol || t & TypeFlags.UniqueESSymbol) return false; if (relation === assignableRelation || relation === comparableRelation) { if (s & TypeFlags.Any) return true; // Type number or any numeric literal type is assignable to any numeric enum type or any @@ -8948,12 +9238,6 @@ namespace ts { let targetStack: Type[]; let maybeCount = 0; let depth = 0; - const enum ExpandingFlags { - None = 0, - Source = 1, - Target = 1 << 1, - Both = Source | Target, - } let expandingFlags = ExpandingFlags.None; let overflow = false; let isIntersectionConstituent = false; @@ -10364,6 +10648,19 @@ namespace ts { type; } + function getWidenedUniqueESSymbolType(type: Type): Type { + return type.flags & TypeFlags.UniqueESSymbol ? esSymbolType : + type.flags & TypeFlags.Union ? getUnionType(sameMap((type).types, getWidenedUniqueESSymbolType)) : + type; + } + + function getWidenedLiteralLikeTypeForContextualType(type: Type, contextualType: Type) { + if (!isLiteralLikeContextualType(contextualType)) { + type = getWidenedUniqueESSymbolType(getWidenedLiteralType(type)); + } + return type; + } + /** * Check if a Type was written as a tuple type literal. * Prefer using isTupleLikeType() unless the use of `elementTypes` is required. @@ -10424,6 +10721,11 @@ namespace ts { getUnionType([type, undefinedType, nullType]); } + function getOptionalType(type: Type): Type { + Debug.assert(strictNullChecks); + return type.flags & TypeFlags.Undefined ? type : getUnionType([type, undefinedType]); + } + function getNonNullableType(type: Type): Type { return strictNullChecks ? getTypeWithFacts(type, TypeFacts.NEUndefinedOrNull) : type; } @@ -10769,10 +11071,32 @@ namespace ts { return type === typeParameter || type.flags & TypeFlags.UnionOrIntersection && forEach((type).types, t => isTypeParameterAtTopLevel(t, typeParameter)); } - // Infer a suitable input type for a homomorphic mapped type { [P in keyof T]: X }. We construct - // an object type with the same set of properties as the source type, where the type of each - // property is computed by inferring from the source property type to X for the type - // variable T[P] (i.e. we treat the type T[P] as the type variable we're inferring for). + /** Create an object with properties named in the string literal type. Every property has type `{}` */ + function createEmptyObjectTypeFromStringLiteral(type: Type) { + const members = createSymbolTable(); + forEachType(type, t => { + if (!(t.flags & TypeFlags.StringLiteral)) { + return; + } + const name = escapeLeadingUnderscores((t as StringLiteralType).value); + const literalProp = createSymbol(SymbolFlags.Property, name); + literalProp.type = emptyObjectType; + if (t.symbol) { + literalProp.declarations = t.symbol.declarations; + literalProp.valueDeclaration = t.symbol.valueDeclaration; + } + members.set(name, literalProp); + }); + const indexInfo = type.flags & TypeFlags.String ? createIndexInfo(emptyObjectType, /*isReadonly*/ false) : undefined; + return createAnonymousType(undefined, members, emptyArray, emptyArray, indexInfo, undefined); + } + + /** + * Infer a suitable input type for a homomorphic mapped type { [P in keyof T]: X }. We construct + * an object type with the same set of properties as the source type, where the type of each + * property is computed by inferring from the source property type to X for the type + * variable T[P] (i.e. we treat the type T[P] as the type variable we're inferring for). + */ function inferTypeForHomomorphicMappedType(source: Type, target: MappedType): Type { const properties = getPropertiesOfType(source); let indexInfo = getIndexInfoOfType(source, IndexKind.String); @@ -10793,8 +11117,8 @@ namespace ts { if (propType.flags & TypeFlags.ContainsAnyFunctionType) { return undefined; } - const inferredProp = createSymbol(SymbolFlags.Property | prop.flags & optionalMask, prop.escapedName); - inferredProp.checkFlags = readonlyMask && isReadonlySymbol(prop) ? CheckFlags.Readonly : 0; + const checkFlags = readonlyMask && isReadonlySymbol(prop) ? CheckFlags.Readonly : 0; + const inferredProp = createSymbol(SymbolFlags.Property | prop.flags & optionalMask, prop.escapedName, checkFlags); inferredProp.declarations = prop.declarations; inferredProp.type = inferTargetType(propType); members.set(prop.escapedName, inferredProp); @@ -10928,7 +11252,15 @@ namespace ts { } } else if (source.flags & TypeFlags.Index && target.flags & TypeFlags.Index) { + priority ^= InferencePriority.Contravariant; inferFromTypes((source).type, (target).type); + priority ^= InferencePriority.Contravariant; + } + else if ((isLiteralType(source) || source.flags & TypeFlags.String) && target.flags & TypeFlags.Index) { + const empty = createEmptyObjectTypeFromStringLiteral(source); + priority ^= InferencePriority.Contravariant; + inferFromTypes(empty, (target as IndexType).type); + priority ^= InferencePriority.Contravariant; } else if (source.flags & TypeFlags.IndexedAccess && target.flags & TypeFlags.IndexedAccess) { inferFromTypes((source).objectType, (target).objectType); @@ -11204,16 +11536,19 @@ namespace ts { inferredType = getDefaultTypeArgumentType(!!(context.flags & InferenceFlags.AnyDefault)); } } + + inferredType = getWidenedUniqueESSymbolType(inferredType); inference.inferredType = inferredType; const constraint = getConstraintOfTypeParameter(context.signature.typeParameters[index]); if (constraint) { const instantiatedConstraint = instantiateType(constraint, context); if (!context.compareTypes(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) { - inference.inferredType = inferredType = instantiatedConstraint; + inference.inferredType = inferredType = getWidenedUniqueESSymbolType(instantiatedConstraint); } } } + return inferredType; } @@ -11502,7 +11837,7 @@ namespace ts { if (flags & TypeFlags.Null) { return TypeFacts.NullFacts; } - if (flags & TypeFlags.ESSymbol) { + if (flags & TypeFlags.ESSymbolLike) { return strictNullChecks ? TypeFacts.SymbolStrictFacts : TypeFacts.SymbolFacts; } if (flags & TypeFlags.NonPrimitive) { @@ -12773,7 +13108,7 @@ namespace ts { declaration.flags & NodeFlags.Ambient; const initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, getRootDeclaration(declaration) as VariableLikeDeclaration) : type) : type === autoType || type === autoArrayType ? undefinedType : - getNullableType(type, TypeFlags.Undefined); + getOptionalType(type); const flowType = getFlowTypeOfReference(node, type, initialType, flowContainer, !assumeInitialized); // A variable is considered uninitialized when it is possible to analyze the entire control flow graph // from declaration to use, and when the variable's declared type doesn't include undefined but the @@ -13604,7 +13939,7 @@ namespace ts { const objectLiteral = element.parent; const type = getApparentTypeOfContextualType(objectLiteral); if (type) { - if (!hasDynamicName(element)) { + if (!hasNonBindableDynamicName(element)) { // For a (non-symbol) computed property, there is no reason to look up the name // in the type. It will just be "__computed", which does not appear in any // SymbolTable. @@ -14048,7 +14383,7 @@ namespace ts { // This will allow types number, string, symbol or any. It will also allow enums, the unknown // type, and any union of these types (like string | number). if (links.resolvedType.flags & TypeFlags.Nullable || - !isTypeAssignableToKind(links.resolvedType, TypeFlags.StringLike | TypeFlags.NumberLike | TypeFlags.ESSymbol) && + !isTypeAssignableToKind(links.resolvedType, TypeFlags.StringLike | TypeFlags.NumberLike | TypeFlags.ESSymbolLike) && !isTypeAssignableTo(links.resolvedType, getUnionType([stringType, numberType, esSymbolType]))) { error(node, Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } @@ -14094,7 +14429,7 @@ namespace ts { let offset = 0; for (let i = 0; i < node.properties.length; i++) { const memberDecl = node.properties[i]; - let member = memberDecl.symbol; + let member = getSymbolOfNode(memberDecl); let literalName: __String | undefined; if (memberDecl.kind === SyntaxKind.PropertyAssignment || memberDecl.kind === SyntaxKind.ShorthandPropertyAssignment || @@ -14128,7 +14463,12 @@ namespace ts { } typeFlags |= type.flags; - const prop = createSymbol(SymbolFlags.Property | member.flags, literalName || member.escapedName); + + const nameType = hasLateBindableName(memberDecl) ? checkComputedPropertyName(memberDecl.name) : undefined; + const prop = nameType && isTypeUsableAsLateBoundName(nameType) + ? createSymbol(SymbolFlags.Property | member.flags, getLateBoundNameFromType(nameType), CheckFlags.Late) + : createSymbol(SymbolFlags.Property | member.flags, literalName || member.escapedName); + if (inDestructuringPattern) { // If object literal is an assignment pattern and if the assignment pattern specifies a default value // for the property, make the property optional. @@ -14196,7 +14536,7 @@ namespace ts { checkNodeDeferred(memberDecl); } - if (!literalName && hasDynamicName(memberDecl)) { + if (!literalName && hasNonBindableDynamicName(memberDecl)) { if (isNumericName(memberDecl.name)) { hasComputedNumberProperty = true; } @@ -15611,7 +15951,7 @@ namespace ts { } // Make sure the property type is the primitive symbol type - if ((expressionType.flags & TypeFlags.ESSymbol) === 0) { + if ((expressionType.flags & TypeFlags.ESSymbolLike) === 0) { if (reportError) { error(expression, Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, getTextOfNode(expression)); } @@ -15802,10 +16142,10 @@ namespace ts { return false; } - // If spread arguments are present, check that they correspond to a rest parameter. If so, no - // further checking is necessary. + // If a spread argument is present, check that it corresponds to a rest parameter or at least that it's in the valid range. if (spreadArgIndex >= 0) { - return isRestParameterIndex(signature, spreadArgIndex) || spreadArgIndex >= signature.minArgumentCount; + return isRestParameterIndex(signature, spreadArgIndex) || + signature.minArgumentCount <= spreadArgIndex && spreadArgIndex < signature.parameters.length; } // Too many arguments implies incorrect arity. @@ -16243,7 +16583,7 @@ namespace ts { case SyntaxKind.ComputedPropertyName: const nameType = checkComputedPropertyName(element.name); - if (isTypeAssignableToKind(nameType, TypeFlags.ESSymbol)) { + if (isTypeAssignableToKind(nameType, TypeFlags.ESSymbolLike)) { return nameType; } else { @@ -16513,10 +16853,13 @@ namespace ts { const paramCount = hasRestParameter ? min : min < max ? min + "-" + max : min; - const argCount = args.length - (hasSpreadArgument ? 1 : 0); - const error = hasRestParameter && hasSpreadArgument ? Diagnostics.Expected_at_least_0_arguments_but_got_a_minimum_of_1 : + let argCount = args.length; + if (argCount <= max && hasSpreadArgument) { + argCount--; + } + const error = hasRestParameter && hasSpreadArgument ? Diagnostics.Expected_at_least_0_arguments_but_got_1_or_more : hasRestParameter ? Diagnostics.Expected_at_least_0_arguments_but_got_1 : - hasSpreadArgument ? Diagnostics.Expected_0_arguments_but_got_a_minimum_of_1 : + hasSpreadArgument ? Diagnostics.Expected_0_arguments_but_got_1_or_more : Diagnostics.Expected_0_arguments_but_got_1; diagnostics.add(createDiagnosticForNode(node, error, paramCount, argCount)); } @@ -17051,7 +17394,7 @@ namespace ts { function getInferredClassType(symbol: Symbol) { const links = getSymbolLinks(symbol); if (!links.inferredClassType) { - links.inferredClassType = createAnonymousType(symbol, symbol.members || emptySymbols, emptyArray, emptyArray, /*stringIndexType*/ undefined, /*numberIndexType*/ undefined); + links.inferredClassType = createAnonymousType(symbol, getMembersOfSymbol(symbol) || emptySymbols, emptyArray, emptyArray, /*stringIndexType*/ undefined, /*numberIndexType*/ undefined); } return links.inferredClassType; } @@ -17110,7 +17453,32 @@ namespace ts { return resolveExternalModuleTypeByLiteral(node.arguments[0]); } - return getReturnTypeOfSignature(signature); + const returnType = getReturnTypeOfSignature(signature); + // Treat any call to the global 'Symbol' function that is part of a const variable or readonly property + // as a fresh unique symbol literal type. + if (returnType.flags & TypeFlags.ESSymbolLike && isSymbolOrSymbolForCall(node)) { + return getESSymbolLikeTypeForNode(walkUpParenthesizedExpressions(node.parent)); + } + return returnType; + } + + function isSymbolOrSymbolForCall(node: Node) { + if (!isCallExpression(node)) return false; + let left = node.expression; + if (isPropertyAccessExpression(left) && left.name.escapedText === "for") { + left = left.expression; + } + if (!isIdentifier(left) || left.escapedText !== "Symbol") { + return false; + } + + // make sure `Symbol` is the global symbol + const globalESSymbol = getGlobalESSymbolConstructorSymbol(/*reportErrors*/ false); + if (!globalESSymbol) { + return false; + } + + return globalESSymbol === resolveName(left, "Symbol" as __String, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); } function checkImportCallExpression(node: ImportCall): Type { @@ -17169,6 +17537,7 @@ namespace ts { if (!isRequireCall(node, /*checkArgumentIsStringLiteral*/ true)) { return false; } + // Make sure require is not a local function if (!isIdentifier(node.expression)) throw Debug.fail(); const resolvedRequire = resolveName(node.expression, node.expression.escapedText, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); @@ -17246,7 +17615,7 @@ namespace ts { if (strictNullChecks) { const declaration = symbol.valueDeclaration; if (declaration && (declaration).initializer) { - return getNullableType(type, TypeFlags.Undefined); + return getOptionalType(type); } } return type; @@ -17411,34 +17780,49 @@ namespace ts { : voidType; // Normal function } } + // Return a union of the return expression types. type = getUnionType(types, /*subtypeReduction*/ true); - - 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 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 type. + return createPromiseType(widenedType); + default: + return widenedType; + } } function checkAndAggregateYieldOperandTypes(func: FunctionLikeDeclaration, checkMode: CheckMode): Type[] { @@ -17483,8 +17867,8 @@ namespace ts { if (!(func.flags & NodeFlags.HasImplicitReturn)) { return false; } - const lastStatement = lastOrUndefined((func.body).statements); - if (lastStatement && lastStatement.kind === SyntaxKind.SwitchStatement && isExhaustiveSwitchStatement(lastStatement)) { + + if (some((func.body).statements, statement => statement.kind === SyntaxKind.SwitchStatement && isExhaustiveSwitchStatement(statement))) { return false; } return true; @@ -17814,7 +18198,7 @@ namespace ts { case SyntaxKind.MinusToken: case SyntaxKind.TildeToken: checkNonNullType(operandType, node.operand); - if (maybeTypeOfKind(operandType, TypeFlags.ESSymbol)) { + if (maybeTypeOfKind(operandType, TypeFlags.ESSymbolLike)) { error(node.operand, Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, tokenToString(node.operator)); } return numberType; @@ -17927,7 +18311,7 @@ namespace ts { // The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type, // and the right operand to be of type Any, an object type, or a type parameter type. // The result is always of the Boolean primitive type. - if (!(isTypeComparableTo(leftType, stringType) || isTypeAssignableToKind(leftType, TypeFlags.NumberLike | TypeFlags.ESSymbol))) { + if (!(isTypeComparableTo(leftType, stringType) || isTypeAssignableToKind(leftType, TypeFlags.NumberLike | TypeFlags.ESSymbolLike))) { error(left, Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } if (!isTypeAssignableToKind(rightType, TypeFlags.NonPrimitive | TypeFlags.TypeVariable)) { @@ -18321,8 +18705,8 @@ namespace ts { // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator: SyntaxKind): boolean { const offendingSymbolOperand = - maybeTypeOfKind(leftType, TypeFlags.ESSymbol) ? left : - maybeTypeOfKind(rightType, TypeFlags.ESSymbol) ? right : + maybeTypeOfKind(leftType, TypeFlags.ESSymbolLike) ? left : + maybeTypeOfKind(rightType, TypeFlags.ESSymbolLike) ? right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, tokenToString(operator)); @@ -18513,23 +18897,23 @@ namespace ts { function checkDeclarationInitializer(declaration: VariableLikeDeclaration) { const type = getTypeOfExpression(declaration.initializer, /*cache*/ true); return getCombinedNodeFlags(declaration) & NodeFlags.Const || - getCombinedModifierFlags(declaration) & ModifierFlags.Readonly && !isParameterPropertyDeclaration(declaration) || + (getCombinedModifierFlags(declaration) & ModifierFlags.Readonly && !isParameterPropertyDeclaration(declaration)) || isTypeAssertion(declaration.initializer) ? type : getWidenedLiteralType(type); } - function isLiteralContextualType(contextualType: Type) { + function isLiteralLikeContextualType(contextualType: Type) { if (contextualType) { if (contextualType.flags & TypeFlags.TypeVariable) { const constraint = getBaseConstraintOfType(contextualType) || emptyObjectType; // If the type parameter is constrained to the base primitive type we're checking for, // consider this a literal context. For example, given a type parameter 'T extends string', // this causes us to infer string literal types for T. - if (constraint.flags & (TypeFlags.String | TypeFlags.Number | TypeFlags.Boolean | TypeFlags.Enum)) { + if (constraint.flags & (TypeFlags.String | TypeFlags.Number | TypeFlags.Boolean | TypeFlags.Enum | TypeFlags.ESSymbol)) { return true; } contextualType = constraint; } - return maybeTypeOfKind(contextualType, (TypeFlags.Literal | TypeFlags.Index)); + return maybeTypeOfKind(contextualType, (TypeFlags.Literal | TypeFlags.Index | TypeFlags.UniqueESSymbol)); } return false; } @@ -18539,8 +18923,8 @@ namespace ts { contextualType = getContextualType(node); } const type = checkExpression(node, checkMode); - const shouldWiden = isTypeAssertion(node) || isLiteralContextualType(contextualType); - return shouldWiden ? type : getWidenedLiteralType(type); + return isTypeAssertion(node) ? type : + getWidenedLiteralLikeTypeForContextualType(type, contextualType); } function checkPropertyAssignment(node: PropertyAssignment, checkMode?: CheckMode): Type { @@ -18595,7 +18979,7 @@ namespace ts { function getTypeOfExpression(node: Expression, cache?: boolean) { // Optimize for the common case of a call to a function with a single non-generic call // signature where we can just fetch the return type without checking the arguments. - if (node.kind === SyntaxKind.CallExpression && (node).expression.kind !== SyntaxKind.SuperKeyword && !isRequireCall(node, /*checkArgumentIsStringLiteral*/ true)) { + if (node.kind === SyntaxKind.CallExpression && (node).expression.kind !== SyntaxKind.SuperKeyword && !isRequireCall(node, /*checkArgumentIsStringLiteral*/ true) && !isSymbolOrSymbolForCall(node)) { const funcType = checkNonNullExpression((node).expression); const signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { @@ -19316,11 +19700,11 @@ namespace ts { if (node.name.kind === SyntaxKind.ComputedPropertyName) { checkComputedPropertyName(node.name); } - if (!hasDynamicName(node)) { + if (!hasNonBindableDynamicName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. const otherKind = node.kind === SyntaxKind.GetAccessor ? SyntaxKind.SetAccessor : SyntaxKind.GetAccessor; - const otherAccessor = getDeclarationOfKind(node.symbol, otherKind); + const otherAccessor = getDeclarationOfKind(getSymbolOfNode(node), otherKind); if (otherAccessor) { const nodeFlags = getModifierFlags(node); const otherFlags = getModifierFlags(otherAccessor); @@ -19486,6 +19870,11 @@ namespace ts { checkTypeAssignableTo(constraintType, stringType, node.typeParameter.constraint); } + function checkTypeOperator(node: TypeOperatorNode) { + checkGrammarTypeOperatorNode(node); + checkSourceElement(node.type); + } + function isPrivateWithinAmbient(node: Node): boolean { return hasModifier(node, ModifierFlags.Private) && !!(node.flags & NodeFlags.Ambient); } @@ -20391,7 +20780,7 @@ namespace ts { checkComputedPropertyName(node.name); } - if (!hasDynamicName(node)) { + if (!hasNonBindableDynamicName(node)) { // first we want to check the local symbol that contain this declaration // - if node.localSymbol !== undefined - this is current declaration is exported and localSymbol points to the local symbol // - if node.localSymbol === undefined - this node is non-exported so we can just pick the result of getSymbolOfNode @@ -21002,7 +21391,7 @@ namespace ts { // initializer is consistent with type associated with the node const declarationType = convertAutoToAny(getWidenedTypeForVariableLikeDeclaration(node)); if (type !== unknownType && declarationType !== unknownType && !isTypeIdenticalTo(type, declarationType)) { - errorNextVariableDeclarationMustHaveSameType(symbol.valueDeclaration, type, node, declarationType); + errorNextVariableOrPropertyDeclarationMustHaveSameType(symbol.valueDeclaration, type, node, declarationType); } if (node.initializer) { checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, /*headMessage*/ undefined); @@ -21026,15 +21415,18 @@ namespace ts { } } - function errorNextVariableDeclarationMustHaveSameType(firstDeclaration: Declaration, firstType: Type, nextDeclaration: Declaration, nextType: Type): void { + function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration: Declaration, firstType: Type, nextDeclaration: Declaration, nextType: Type): void { const firstSourceFile = getSourceFileOfNode(firstDeclaration); const firstSpan = getErrorSpanForNode(firstSourceFile, getNameOfDeclaration(firstDeclaration) || firstDeclaration); const firstLocation = getLineAndCharacterOfPosition(firstSourceFile, firstSpan.start); const firstLocationDescription = firstSourceFile.fileName + " " + firstLocation.line + ":" + firstLocation.character; const nextDeclarationName = getNameOfDeclaration(nextDeclaration); + const message = nextDeclaration.kind === SyntaxKind.PropertyDeclaration || nextDeclaration.kind === SyntaxKind.PropertySignature + ? Diagnostics.Subsequent_property_declarations_must_have_the_same_type_Property_0_has_type_1_at_2_but_here_has_type_3 + : Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_has_type_1_at_2_but_here_has_type_3; error( nextDeclarationName, - Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_has_type_1_at_2_but_here_has_type_3, + message, declarationNameToString(nextDeclarationName), typeToString(firstType), firstLocationDescription, @@ -21811,10 +22203,11 @@ namespace ts { // Only process instance properties with computed names here. // Static properties cannot be in conflict with indexers, // and properties with literal names were already checked. - if (!hasModifier(member, ModifierFlags.Static) && hasDynamicName(member)) { - const propType = getTypeOfSymbol(member.symbol); - checkIndexConstraintForProperty(member.symbol, propType, type, declaredStringIndexer, stringIndexType, IndexKind.String); - checkIndexConstraintForProperty(member.symbol, propType, type, declaredNumberIndexer, numberIndexType, IndexKind.Number); + if (!hasModifier(member, ModifierFlags.Static) && hasNonBindableDynamicName(member)) { + const symbol = getSymbolOfNode(member); + const propType = getTypeOfSymbol(symbol); + checkIndexConstraintForProperty(symbol, propType, type, declaredStringIndexer, stringIndexType, IndexKind.String); + checkIndexConstraintForProperty(symbol, propType, type, declaredNumberIndexer, numberIndexType, IndexKind.Number); } } } @@ -23080,8 +23473,9 @@ namespace ts { case SyntaxKind.IntersectionType: return checkUnionOrIntersectionType(node); case SyntaxKind.ParenthesizedType: - case SyntaxKind.TypeOperator: return checkSourceElement((node).type); + case SyntaxKind.TypeOperator: + return checkTypeOperator(node); case SyntaxKind.JSDocAugmentsTag: return checkJSDocAugmentsTag(node as JSDocAugmentsTag); case SyntaxKind.JSDocTypedefTag: @@ -23091,14 +23485,15 @@ namespace ts { case SyntaxKind.JSDocFunctionType: checkSignatureDeclaration(node as JSDocFunctionType); // falls through - case SyntaxKind.JSDocVariadicType: case SyntaxKind.JSDocNonNullableType: case SyntaxKind.JSDocNullableType: case SyntaxKind.JSDocAllType: case SyntaxKind.JSDocUnknownType: - if (!isInJavaScriptFile(node) && !isInJSDoc(node)) { - grammarErrorOnNode(node, Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments); - } + checkJSDocTypeIsInJsFile(node); + forEachChild(node, checkSourceElement); + return; + case SyntaxKind.JSDocVariadicType: + checkJSDocVariadicType(node as JSDocVariadicType); return; case SyntaxKind.JSDocTypeExpression: return checkSourceElement((node as JSDocTypeExpression).type); @@ -23175,6 +23570,65 @@ namespace ts { } } + function checkJSDocTypeIsInJsFile(node: Node): void { + if (!isInJavaScriptFile(node)) { + grammarErrorOnNode(node, Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments); + } + } + + function checkJSDocVariadicType(node: JSDocVariadicType): void { + checkJSDocTypeIsInJsFile(node); + checkSourceElement(node.type); + + // Only legal location is in the *last* parameter tag. + const { parent } = node; + if (!isJSDocTypeExpression(parent)) { + error(node, Diagnostics.JSDoc_may_only_appear_in_the_last_parameter_of_a_signature); + } + + const paramTag = parent.parent; + if (!isJSDocParameterTag(paramTag)) { + error(node, Diagnostics.JSDoc_may_only_appear_in_the_last_parameter_of_a_signature); + return; + } + + const param = getParameterSymbolFromJSDoc(paramTag); + if (!param) { + // We will error in `checkJSDocParameterTag`. + return; + } + + const host = getHostSignatureFromJSDoc(paramTag); + if (!host || last(host.parameters).symbol !== param) { + error(node, Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list); + } + } + + function getTypeFromJSDocVariadicType(node: JSDocVariadicType): Type { + const type = getTypeFromTypeNode(node.type); + const { parent } = node; + const paramTag = parent.parent; + if (isJSDocTypeExpression(parent) && isJSDocParameterTag(paramTag)) { + // Else we will add a diagnostic, see `checkJSDocVariadicType`. + const param = getParameterSymbolFromJSDoc(paramTag); + if (param) { + const host = getHostSignatureFromJSDoc(paramTag); + /* + Only return an array type if the corresponding parameter is marked as a rest parameter. + So in the following situation we will not create an array type: + /** @param {...number} a * / + function f(a) {} + Because `a` will just be of type `number | undefined`. A synthetic `...args` will also be added, which *will* get an array type. + */ + const lastParamDeclaration = host && last(host.parameters); + if (lastParamDeclaration.symbol === param && isRestParameter(lastParamDeclaration)) { + return createArrayType(type); + } + } + } + return addOptionality(type); + } + // Function and class expression bodies are checked after all statements in the enclosing body. This is // to ensure constructs like the following are permitted: // const foo = function () { @@ -23372,7 +23826,7 @@ namespace ts { // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. // Note: that the memberFlags come from previous iteration. if (!isStatic) { - copySymbols(getSymbolOfNode(location).members, meaning & SymbolFlags.Type); + copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & SymbolFlags.Type); } break; case SyntaxKind.FunctionExpression: @@ -24282,7 +24736,7 @@ namespace ts { else if (isTupleType(type)) { return TypeReferenceSerializationKind.ArrayLikeType; } - else if (isTypeAssignableToKind(type, TypeFlags.ESSymbol)) { + else if (isTypeAssignableToKind(type, TypeFlags.ESSymbolLike)) { return TypeReferenceSerializationKind.ESSymbolType; } else if (isFunctionType(type)) { @@ -24302,9 +24756,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); + type = getOptionalType(type); } + getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); } @@ -24428,6 +24887,11 @@ namespace ts { getTypeReferenceDirectivesForEntityName, getTypeReferenceDirectivesForSymbol, isLiteralConstDeclaration, + isLateBound: (node: Declaration): node is LateBoundDeclaration => { + node = getParseTreeNode(node, isDeclaration); + const symbol = node && getSymbolOfNode(node); + return !!(symbol && getCheckFlags(symbol) & CheckFlags.Late); + }, writeLiteralConstValue, getJsxFactoryEntity: () => _jsxFactoryEntity }; @@ -25416,8 +25880,48 @@ namespace ts { } } - function checkGrammarForNonSymbolComputedProperty(node: DeclarationName, message: DiagnosticMessage) { - if (isDynamicName(node)) { + function checkGrammarTypeOperatorNode(node: TypeOperatorNode) { + if (node.operator === SyntaxKind.UniqueKeyword) { + if (node.type.kind !== SyntaxKind.SymbolKeyword) { + return grammarErrorOnNode(node.type, Diagnostics._0_expected, tokenToString(SyntaxKind.SymbolKeyword)); + } + + const parent = walkUpParenthesizedTypes(node.parent); + switch (parent.kind) { + case SyntaxKind.VariableDeclaration: + const decl = parent as VariableDeclaration; + if (decl.name.kind !== SyntaxKind.Identifier) { + return grammarErrorOnNode(node, Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name); + } + if (!isVariableDeclarationInVariableStatement(decl)) { + return grammarErrorOnNode(node, Diagnostics.unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement); + } + if (!(decl.parent.flags & NodeFlags.Const)) { + return grammarErrorOnNode((parent).name, Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); + } + break; + + case SyntaxKind.PropertyDeclaration: + if (!hasModifier(parent, ModifierFlags.Static) || + !hasModifier(parent, ModifierFlags.Readonly)) { + return grammarErrorOnNode((parent).name, Diagnostics.A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly); + } + break; + + case SyntaxKind.PropertySignature: + if (!hasModifier(parent, ModifierFlags.Readonly)) { + return grammarErrorOnNode((parent).name, Diagnostics.A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly); + } + break; + + default: + return grammarErrorOnNode(node, Diagnostics.unique_symbol_types_are_not_allowed_here); + } + } + } + + function checkGrammarForInvalidDynamicName(node: DeclarationName, message: DiagnosticMessage) { + if (isNonBindableDynamicName(node)) { return grammarErrorOnNode(node, message); } } @@ -25445,17 +25949,17 @@ namespace ts { // and accessors are not allowed in ambient contexts in general, // so this error only really matters for methods. if (node.flags & NodeFlags.Ambient) { - return checkGrammarForNonSymbolComputedProperty(node.name, Diagnostics.A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol); + return checkGrammarForInvalidDynamicName(node.name, Diagnostics.A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } else if (!node.body) { - return checkGrammarForNonSymbolComputedProperty(node.name, Diagnostics.A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol); + return checkGrammarForInvalidDynamicName(node.name, Diagnostics.A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } } else if (node.parent.kind === SyntaxKind.InterfaceDeclaration) { - return checkGrammarForNonSymbolComputedProperty(node.name, Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol); + return checkGrammarForInvalidDynamicName(node.name, Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } else if (node.parent.kind === SyntaxKind.TypeLiteral) { - return checkGrammarForNonSymbolComputedProperty(node.name, Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); + return checkGrammarForInvalidDynamicName(node.name, Diagnostics.A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } } @@ -25707,12 +26211,12 @@ namespace ts { function checkGrammarProperty(node: PropertyDeclaration) { if (isClassLike(node.parent)) { - if (checkGrammarForNonSymbolComputedProperty(node.name, Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol)) { + if (checkGrammarForInvalidDynamicName(node.name, Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } } else if (node.parent.kind === SyntaxKind.InterfaceDeclaration) { - if (checkGrammarForNonSymbolComputedProperty(node.name, Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { + if (checkGrammarForInvalidDynamicName(node.name, Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } if (node.initializer) { @@ -25720,7 +26224,7 @@ namespace ts { } } else if (node.parent.kind === SyntaxKind.TypeLiteral) { - if (checkGrammarForNonSymbolComputedProperty(node.name, Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { + if (checkGrammarForInvalidDynamicName(node.name, Diagnostics.A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } if (node.initializer) { @@ -25809,7 +26313,7 @@ namespace ts { function checkGrammarNumericLiteral(node: NumericLiteral): boolean { // Grammar checking - if (node.numericLiteralFlags & NumericLiteralFlags.Octal) { + if (node.numericLiteralFlags & TokenFlags.Octal) { let diagnosticMessage: DiagnosticMessage | undefined; if (languageVersion >= ScriptTarget.ES5) { diagnosticMessage = Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 9f839923e7d1c..caf6f553baf07 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -2169,6 +2169,10 @@ namespace ts { return expectedPos >= 0 && str.indexOf(suffix, expectedPos) === expectedPos; } + export function removeSuffix(str: string, suffix: string): string { + return endsWith(str, suffix) ? str.slice(0, str.length - suffix.length) : str; + } + export function stringContains(str: string, substring: string): boolean { return str.indexOf(substring) !== -1; } diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index 3276e68b2ac59..ebd2985dd45c2 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -190,6 +190,7 @@ namespace ts { const writer = 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")); } } @@ -1227,7 +1238,7 @@ namespace ts { } function emitPropertyDeclaration(node: Declaration) { - if (hasDynamicName(node)) { + if (hasDynamicName(node) && !resolver.isLateBound(node)) { return; } @@ -1246,10 +1257,8 @@ namespace ts { emitBindingPattern(node.name); } else { - // If this node is a computed name, it can only be a symbol, because we've already skipped - // it if it's not a well known symbol. In that case, the text of the name will be exactly - // what we want, namely the name expression enclosed in brackets. - writeTextOfNode(currentText, node.name); + writeNameOfDeclaration(node, getVariableDeclarationTypeVisibilityError); + // If optional property emit ? but in the case of parameterProperty declaration with "?" indicating optional parameter for the constructor // we don't want to emit property declaration with "?" if ((node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature || @@ -1387,7 +1396,7 @@ namespace ts { } function emitAccessorDeclaration(node: AccessorDeclaration) { - if (hasDynamicName(node)) { + if (hasDynamicName(node) && !resolver.isLateBound(node)) { return; } @@ -1398,7 +1407,7 @@ namespace ts { emitJsDocComments(accessors.getAccessor); emitJsDocComments(accessors.setAccessor); emitClassMemberDeclarationFlags(getModifierFlags(node) | (accessors.setAccessor ? 0 : ModifierFlags.Readonly)); - writeTextOfNode(currentText, node.name); + writeNameOfDeclaration(node, getAccessorNameVisibilityError); if (!hasModifier(node, ModifierFlags.Private)) { accessorWithTypeAnnotation = node; let type = getTypeAnnotationFromAccessor(node); @@ -1426,6 +1435,37 @@ namespace ts { } } + function getAccessorNameVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult) { + const diagnosticMessage = getAccessorNameVisibilityDiagnosticMessage(symbolAccessibilityResult); + return diagnosticMessage !== undefined ? { + diagnosticMessage, + errorNode: node, + typeName: node.name + } : undefined; + } + + function getAccessorNameVisibilityDiagnosticMessage(symbolAccessibilityResult: SymbolAccessibilityResult) { + if (hasModifier(node, ModifierFlags.Static)) { + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : + Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; + } + else if (node.parent.kind === SyntaxKind.ClassDeclaration) { + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : + Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; + } + else { + return symbolAccessibilityResult.errorModuleName ? + Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 : + Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1; + } + } + function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic { let diagnosticMessage: DiagnosticMessage; if (accessorWithTypeAnnotation.kind === SyntaxKind.SetAccessor) { @@ -1467,7 +1507,7 @@ namespace ts { } function writeFunctionDeclaration(node: FunctionLikeDeclaration) { - if (hasDynamicName(node)) { + if (hasDynamicName(node) && !resolver.isLateBound(node)) { return; } @@ -1489,13 +1529,69 @@ namespace ts { write("constructor"); } else { - writeTextOfNode(currentText, node.name); + writeNameOfDeclaration(node, getMethodNameVisibilityError); if (hasQuestionToken(node)) { write("?"); } } emitSignatureDeclaration(node); } + + function getMethodNameVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic { + const diagnosticMessage = getMethodNameVisibilityDiagnosticMessage(symbolAccessibilityResult); + return diagnosticMessage !== undefined ? { + diagnosticMessage, + errorNode: node, + typeName: node.name + } : undefined; + } + + function getMethodNameVisibilityDiagnosticMessage(symbolAccessibilityResult: SymbolAccessibilityResult) { + if (hasModifier(node, ModifierFlags.Static)) { + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : + Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_private_name_1; + } + else if (node.parent.kind === SyntaxKind.ClassDeclaration) { + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : + Diagnostics.Public_method_0_of_exported_class_has_or_is_using_private_name_1; + } + else { + return symbolAccessibilityResult.errorModuleName ? + Diagnostics.Method_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 : + Diagnostics.Method_0_of_exported_interface_has_or_is_using_private_name_1; + } + } + } + + function writeNameOfDeclaration(node: NamedDeclaration, getSymbolAccessibilityDiagnostic: GetSymbolAccessibilityDiagnostic) { + if (hasDynamicName(node)) { + // If this node has a dynamic name, it can only be an identifier or property access because + // we've already skipped it otherwise. + Debug.assert(resolver.isLateBound(node)); + + writeLateBoundNameOfDeclaration(node as LateBoundDeclaration, getSymbolAccessibilityDiagnostic); + } + else { + // If this node is a computed name, it can only be a symbol, because we've already skipped + // it if it's not a well known symbol. In that case, the text of the name will be exactly + // what we want, namely the name expression enclosed in brackets. + writeTextOfNode(currentText, node.name); + } + } + + function writeLateBoundNameOfDeclaration(node: LateBoundDeclaration, getSymbolAccessibilityDiagnostic: GetSymbolAccessibilityDiagnostic) { + writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; + const entityName = node.name.expression; + const visibilityResult = resolver.isEntityNameVisible(entityName, enclosingDeclaration); + handleSymbolAccessibilityError(visibilityResult); + recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); + writeTextOfNode(currentText, node.name); } function emitSignatureDeclarationWithJsDocComments(node: SignatureDeclaration) { diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 964264ff6e8e4..95929632ef0a0 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -491,23 +491,23 @@ "category": "Error", "code": 1164 }, - "A computed property name in an ambient context must directly refer to a built-in symbol.": { + "A computed property name in an ambient context must refer to an expression whose type is a literal type or a 'unique symbol' type.": { "category": "Error", "code": 1165 }, - "A computed property name in a class property declaration must directly refer to a built-in symbol.": { + "A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type.": { "category": "Error", "code": 1166 }, - "A computed property name in a method overload must directly refer to a built-in symbol.": { + "A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type.": { "category": "Error", "code": 1168 }, - "A computed property name in an interface must directly refer to a built-in symbol.": { + "A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type.": { "category": "Error", "code": 1169 }, - "A computed property name in a type literal must directly refer to a built-in symbol.": { + "A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type.": { "category": "Error", "code": 1170 }, @@ -911,6 +911,30 @@ "category": "Error", "code": 1329 }, + "A property of an interface or type literal whose type is a 'unique symbol' type must be 'readonly'.": { + "category": "Error", + "code": 1330 + }, + "A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'.": { + "category": "Error", + "code": 1331 + }, + "A variable whose type is a 'unique symbol' type must be 'const'.": { + "category": "Error", + "code": 1332 + }, + "'unique symbol' types may not be used on a variable declaration with a binding name.": { + "category": "Error", + "code": 1333 + }, + "'unique symbol' types are only allowed on variables in a variable statement.": { + "category": "Error", + "code": 1334 + }, + "'unique symbol' types are not allowed here.": { + "category": "Error", + "code": 1335 + }, "Duplicate identifier '{0}'.": { "category": "Error", @@ -1780,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 }, @@ -1896,11 +1920,11 @@ "category": "Error", "code": 2555 }, - "Expected {0} arguments, but got a minimum of {1}.": { + "Expected {0} arguments, but got {1} or more.": { "category": "Error", "code": 2556 }, - "Expected at least {0} arguments, but got a minimum of {1}.": { + "Expected at least {0} arguments, but got {1} or more.": { "category": "Error", "code": 2557 }, @@ -2228,6 +2252,14 @@ "category": "Error", "code": 2716 }, + "Subsequent property declarations must have the same type. Property '{0}' has type '{1}' at {2}, but here has type '{3}'.": { + "category": "Error", + "code": 2717 + }, + "Duplicate declaration '{0}'.": { + "category": "Error", + "code": 2718 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", @@ -2530,6 +2562,39 @@ "code": 4094 }, + "Public static method '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named.": { + "category": "Error", + "code": 4095 + }, + "Public static method '{0}' of exported class has or is using name '{1}' from private module '{2}'.": { + "category": "Error", + "code": 4096 + }, + "Public static method '{0}' of exported class has or is using private name '{1}'.": { + "category": "Error", + "code": 4097 + }, + "Public method '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named.": { + "category": "Error", + "code": 4098 + }, + "Public method '{0}' of exported class has or is using name '{1}' from private module '{2}'.": { + "category": "Error", + "code": 4099 + }, + "Public method '{0}' of exported class has or is using private name '{1}'.": { + "category": "Error", + "code": 4100 + }, + "Method '{0}' of exported interface has or is using name '{1}' from private module '{2}'.": { + "category": "Error", + "code": 4101 + }, + "Method '{0}' of exported interface has or is using private name '{1}'.": { + "category": "Error", + "code": 4102 + }, + "The current host does not support the '{0}' option.": { "category": "Error", "code": 5001 @@ -3547,6 +3612,10 @@ "category": "Error", "code": 8027 }, + "JSDoc '...' may only appear in the last parameter of a signature.": { + "category": "Error", + "code": 8028 + }, "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clause.": { "category": "Error", "code": 9002 diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 35d35b4082608..dfc22e3183374 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -736,15 +736,17 @@ namespace ts { return createSynthesizedNode(SyntaxKind.ThisType); } - export function createTypeOperatorNode(type: TypeNode) { + export function createTypeOperatorNode(type: TypeNode): TypeOperatorNode; + export function createTypeOperatorNode(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword, type: TypeNode): TypeOperatorNode; + export function createTypeOperatorNode(operatorOrType: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | TypeNode, type?: TypeNode) { const node = createSynthesizedNode(SyntaxKind.TypeOperator) as TypeOperatorNode; - node.operator = SyntaxKind.KeyOfKeyword; - node.type = parenthesizeElementTypeMember(type); + node.operator = typeof operatorOrType === "number" ? operatorOrType : SyntaxKind.KeyOfKeyword; + node.type = parenthesizeElementTypeMember(typeof operatorOrType === "number" ? type : operatorOrType); return node; } export function updateTypeOperatorNode(node: TypeOperatorNode, type: TypeNode) { - return node.type !== type ? updateNode(createTypeOperatorNode(type), node) : node; + return node.type !== type ? updateNode(createTypeOperatorNode(node.operator, type), node) : node; } export function createIndexedAccessTypeNode(objectType: TypeNode, indexType: TypeNode) { diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 5456e889353aa..db2c09e34b899 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -753,20 +753,19 @@ namespace ts { return sourceFile; } - function addJSDocComment(node: T): T { const comments = getJSDocCommentRanges(node, sourceFile.text); if (comments) { for (const comment of comments) { const jsDoc = JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); - if (!jsDoc) { - continue; - } - - if (!node.jsDoc) { - node.jsDoc = []; + if (jsDoc) { + if (!node.jsDoc) { + node.jsDoc = [jsDoc]; + } + else { + node.jsDoc.push(jsDoc); + } } - node.jsDoc.push(jsDoc); } } @@ -1144,16 +1143,20 @@ namespace ts { } } - // note: this function creates only node - function createNode(kind: TKind, pos?: number): Node | Token | Identifier { + function createNode(kind: SyntaxKind, pos?: number): Node { nodeCount++; - if (!(pos >= 0)) { - pos = scanner.getStartPos(); - } + const p = pos >= 0 ? pos : scanner.getStartPos(); + return isNodeKind(kind) || kind === SyntaxKind.Unknown ? new NodeConstructor(kind, p, p) : + kind === SyntaxKind.Identifier ? new IdentifierConstructor(kind, p, p) : + new TokenConstructor(kind, p, p); + } - return isNodeKind(kind) ? new NodeConstructor(kind, pos, pos) : - kind === SyntaxKind.Identifier ? new IdentifierConstructor(kind, pos, pos) : - new TokenConstructor(kind, pos, pos); + function createNodeWithJSDoc(kind: SyntaxKind): Node { + const node = createNode(kind); + if (scanner.getTokenFlags() & TokenFlags.PrecedingJSDocComment) { + addJSDocComment(node); + } + return node; } function createNodeArray(elements: T[], pos: number, end?: number): NodeArray { @@ -1193,7 +1196,7 @@ namespace ts { parseErrorAtCurrentToken(diagnosticMessage, arg0); } - const result = createNode(kind, scanner.getStartPos()); + const result = createNode(kind); if (kind === SyntaxKind.Identifier) { (result as Identifier).escapedText = "" as __String; @@ -2111,7 +2114,7 @@ namespace ts { // We also do not need to check for negatives because any prefix operator would be part of a // parent unary expression. if (node.kind === SyntaxKind.NumericLiteral) { - (node).numericLiteralFlags = scanner.getNumericLiteralFlags(); + (node).numericLiteralFlags = scanner.getTokenFlags() & TokenFlags.NumericLiteralFlags; } nextToken(); @@ -2185,10 +2188,10 @@ namespace ts { function parseJSDocFunctionType(): JSDocFunctionType | TypeReferenceNode { if (lookAhead(nextTokenIsOpenParen)) { - const result = createNode(SyntaxKind.JSDocFunctionType); + const result = createNodeWithJSDoc(SyntaxKind.JSDocFunctionType); nextToken(); fillSignature(SyntaxKind.ColonToken, SignatureFlags.Type | SignatureFlags.JSDoc, result); - return addJSDocComment(finishNode(result)); + return finishNode(result); } const node = createNode(SyntaxKind.TypeReference); node.typeName = parseIdentifierName(); @@ -2272,7 +2275,7 @@ namespace ts { } function parseParameter(): ParameterDeclaration { - const node = createNode(SyntaxKind.Parameter); + const node = createNodeWithJSDoc(SyntaxKind.Parameter); if (token() === SyntaxKind.ThisKeyword) { node.name = createIdentifier(/*isIdentifier*/ true); node.type = parseParameterType(); @@ -2302,7 +2305,7 @@ namespace ts { node.type = parseParameterType(); node.initializer = parseInitializer(); - return addJSDocComment(finishNode(node)); + return finishNode(node); } function fillSignature( @@ -2389,21 +2392,17 @@ namespace ts { } function parseSignatureMember(kind: SyntaxKind.CallSignature | SyntaxKind.ConstructSignature): CallSignatureDeclaration | ConstructSignatureDeclaration { - const node = createNode(kind); + const node = createNodeWithJSDoc(kind); if (kind === SyntaxKind.ConstructSignature) { parseExpected(SyntaxKind.NewKeyword); } fillSignature(SyntaxKind.ColonToken, SignatureFlags.Type, node); parseTypeMemberSemicolon(); - return addJSDocComment(finishNode(node)); + return finishNode(node); } function isIndexSignature(): boolean { - if (token() !== SyntaxKind.OpenBracketToken) { - return false; - } - - return lookAhead(isUnambiguouslyIndexSignature); + return token() === SyntaxKind.OpenBracketToken && lookAhead(isUnambiguouslyIndexSignature); } function isUnambiguouslyIndexSignature() { @@ -2461,49 +2460,35 @@ namespace ts { return token() === SyntaxKind.ColonToken || token() === SyntaxKind.CommaToken || token() === SyntaxKind.CloseBracketToken; } - function parseIndexSignatureDeclaration(fullStart: number, decorators: NodeArray, modifiers: NodeArray): IndexSignatureDeclaration { - const node = createNode(SyntaxKind.IndexSignature, fullStart); - node.decorators = decorators; - node.modifiers = modifiers; + function parseIndexSignatureDeclaration(node: IndexSignatureDeclaration): IndexSignatureDeclaration { + node.kind = SyntaxKind.IndexSignature; node.parameters = parseBracketedList(ParsingContext.Parameters, parseParameter, SyntaxKind.OpenBracketToken, SyntaxKind.CloseBracketToken); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); - return addJSDocComment(finishNode(node)); + return finishNode(node); } - function parsePropertyOrMethodSignature(fullStart: number, modifiers: NodeArray): PropertySignature | MethodSignature { - const name = parsePropertyName(); - const questionToken = parseOptionalToken(SyntaxKind.QuestionToken); - + function parsePropertyOrMethodSignature(node: PropertySignature | MethodSignature): PropertySignature | MethodSignature { + node.name = parsePropertyName(); + node.questionToken = parseOptionalToken(SyntaxKind.QuestionToken); if (token() === SyntaxKind.OpenParenToken || token() === SyntaxKind.LessThanToken) { - const method = createNode(SyntaxKind.MethodSignature, fullStart); - method.modifiers = modifiers; - method.name = name; - method.questionToken = questionToken; - + node.kind = SyntaxKind.MethodSignature; // Method signatures don't exist in expression contexts. So they have neither // [Yield] nor [Await] - fillSignature(SyntaxKind.ColonToken, SignatureFlags.Type, method); - parseTypeMemberSemicolon(); - return addJSDocComment(finishNode(method)); + fillSignature(SyntaxKind.ColonToken, SignatureFlags.Type, node); } else { - const property = createNode(SyntaxKind.PropertySignature, fullStart); - property.modifiers = modifiers; - property.name = name; - property.questionToken = questionToken; - property.type = parseTypeAnnotation(); - + node.kind = SyntaxKind.PropertySignature; + node.type = parseTypeAnnotation(); if (token() === SyntaxKind.EqualsToken) { // Although type literal properties cannot not have initializers, we attempt // to parse an initializer so we can report in the checker that an interface // property or type literal property cannot have an initializer. - property.initializer = parseInitializer(); + (node).initializer = parseInitializer(); } - - parseTypeMemberSemicolon(); - return addJSDocComment(finishNode(property)); } + parseTypeMemberSemicolon(); + return finishNode(node); } function isTypeMemberStart(): boolean { @@ -2546,12 +2531,12 @@ namespace ts { if (token() === SyntaxKind.NewKeyword && lookAhead(nextTokenIsOpenParenOrLessThan)) { return parseSignatureMember(SyntaxKind.ConstructSignature); } - const fullStart = getNodePos(); - const modifiers = parseModifiers(); + const node = createNodeWithJSDoc(SyntaxKind.Unknown); + node.modifiers = parseModifiers(); if (isIndexSignature()) { - return parseIndexSignatureDeclaration(fullStart, /*decorators*/ undefined, modifiers); + return parseIndexSignatureDeclaration(node); } - return parsePropertyOrMethodSignature(fullStart, modifiers); + return parsePropertyOrMethodSignature(node); } function nextTokenIsOpenParenOrLessThan() { @@ -2623,12 +2608,12 @@ namespace ts { } function parseFunctionOrConstructorType(kind: SyntaxKind): FunctionOrConstructorTypeNode { - const node = createNode(kind); + const node = createNodeWithJSDoc(kind); if (kind === SyntaxKind.ConstructorType) { parseExpected(SyntaxKind.NewKeyword); } fillSignature(SyntaxKind.EqualsGreaterThanToken, SignatureFlags.Type, node); - return addJSDocComment(finishNode(node)); + return finishNode(node); } function parseKeywordAndNoDot(): TypeNode | undefined { @@ -2665,8 +2650,8 @@ namespace ts { case SyntaxKind.AnyKeyword: case SyntaxKind.StringKeyword: case SyntaxKind.NumberKeyword: - case SyntaxKind.BooleanKeyword: case SyntaxKind.SymbolKeyword: + case SyntaxKind.BooleanKeyword: case SyntaxKind.UndefinedKeyword: case SyntaxKind.NeverKeyword: case SyntaxKind.ObjectKeyword: @@ -2678,8 +2663,6 @@ namespace ts { return parseJSDocUnknownOrNullableType(); case SyntaxKind.FunctionKeyword: return parseJSDocFunctionType(); - case SyntaxKind.DotDotDotToken: - return parseJSDocNodeWithType(SyntaxKind.JSDocVariadicType); case SyntaxKind.ExclamationToken: return parseJSDocNodeWithType(SyntaxKind.JSDocNonNullableType); case SyntaxKind.NoSubstitutionTemplateLiteral: @@ -2722,6 +2705,7 @@ namespace ts { case SyntaxKind.NumberKeyword: case SyntaxKind.BooleanKeyword: case SyntaxKind.SymbolKeyword: + case SyntaxKind.UniqueKeyword: case SyntaxKind.VoidKeyword: case SyntaxKind.UndefinedKeyword: case SyntaxKind.NullKeyword: @@ -2807,7 +2791,7 @@ namespace ts { return finishNode(postfix); } - function parseTypeOperator(operator: SyntaxKind.KeyOfKeyword) { + function parseTypeOperator(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword) { const node = createNode(SyntaxKind.TypeOperator); parseExpected(operator); node.operator = operator; @@ -2816,9 +2800,17 @@ namespace ts { } function parseTypeOperatorOrHigher(): TypeNode { - switch (token()) { + const operator = token(); + switch (operator) { case SyntaxKind.KeyOfKeyword: - return parseTypeOperator(SyntaxKind.KeyOfKeyword); + case SyntaxKind.UniqueKeyword: + return parseTypeOperator(operator); + case SyntaxKind.DotDotDotToken: { + const result = createNode(SyntaxKind.JSDocVariadicType) as JSDocVariadicType; + nextToken(); + result.type = parsePostfixTypeOrHigher(); + return finishNode(result); + } } return parsePostfixTypeOrHigher(); } @@ -3216,7 +3208,7 @@ namespace ts { ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); - return addJSDocComment(finishNode(arrowFunction)); + return finishNode(arrowFunction); } // True -> We definitely expect a parenthesized arrow function here. @@ -3285,24 +3277,40 @@ namespace ts { return Tristate.True; } + // Check for "(xxx yyy", where xxx is a modifier and yyy is an identifier. This + // isn't actually allowed, but we want to treat it as a lambda so we can provide + // a good error message. + if (isModifierKind(second) && lookAhead(nextTokenIsIdentifier)) { + return Tristate.True; + } + // If we had "(" followed by something that's not an identifier, // then this definitely doesn't look like a lambda. - // Note: we could be a little more lenient and allow - // "(public" or "(private". These would not ever actually be allowed, - // but we could provide a good error message instead of bailing out. if (!isIdentifier()) { return Tristate.False; } - // If we have something like "(a:", then we must have a - // type-annotated parameter in an arrow function expression. - if (nextToken() === SyntaxKind.ColonToken) { - return Tristate.True; + switch (nextToken()) { + case SyntaxKind.ColonToken: + // If we have something like "(a:", then we must have a + // type-annotated parameter in an arrow function expression. + return Tristate.True; + case SyntaxKind.QuestionToken: + nextToken(); + // If we have "(a?:" or "(a?," or "(a?=" or "(a?)" then it is definitely a lamnda. + if (token() === SyntaxKind.ColonToken || token() === SyntaxKind.CommaToken || token() === SyntaxKind.EqualsToken || token() === SyntaxKind.CloseParenToken) { + return Tristate.True; + } + // Otherwise it is definitely not a lambda. + return Tristate.False; + case SyntaxKind.CommaToken: + case SyntaxKind.EqualsToken: + case SyntaxKind.CloseParenToken: + // If we have "(a," or "(a=" or "(a)" this *could* be an arrow function + return Tristate.Unknown; } - - // This *could* be a parenthesized arrow function. - // Return Unknown to let the caller know. - return Tristate.Unknown; + // It is definitely not an arrow function + return Tristate.False; } else { Debug.assert(first === SyntaxKind.LessThanToken); @@ -3383,7 +3391,7 @@ namespace ts { } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity: boolean): ArrowFunction { - const node = createNode(SyntaxKind.ArrowFunction); + const node = createNodeWithJSDoc(SyntaxKind.ArrowFunction); node.modifiers = parseModifiersForArrowFunction(); const isAsync = hasModifier(node, ModifierFlags.Async) ? SignatureFlags.Await : SignatureFlags.None; // Arrow functions are never generators. @@ -3408,8 +3416,7 @@ namespace ts { // - "a ? (b): c" will have "(b):" parsed as a signature with a return type annotation. // // So we need just a bit of lookahead to ensure that it can only be a signature. - if (!allowAmbiguity && ((token() !== SyntaxKind.EqualsGreaterThanToken && token() !== SyntaxKind.OpenBraceToken) || - find(node.parameters, p => p.initializer && ts.isIdentifier(p.initializer) && p.initializer.escapedText === "= not found"))) { + if (!allowAmbiguity && token() !== SyntaxKind.EqualsGreaterThanToken && token() !== SyntaxKind.OpenBraceToken) { // Returning undefined here will cause our caller to rewind to where we started from. return undefined; } @@ -4015,7 +4022,7 @@ namespace ts { } function parseJsxText(): JsxText { - const node = createNode(SyntaxKind.JsxText, scanner.getStartPos()); + const node = createNode(SyntaxKind.JsxText); node.containsOnlyWhiteSpaces = currentToken === SyntaxKind.JsxTextAllWhiteSpaces; currentToken = scanner.scanJsxToken(); return finishNode(node); @@ -4423,11 +4430,11 @@ namespace ts { } function parseParenthesizedExpression(): ParenthesizedExpression { - const node = createNode(SyntaxKind.ParenthesizedExpression); + const node = createNodeWithJSDoc(SyntaxKind.ParenthesizedExpression); parseExpected(SyntaxKind.OpenParenToken); node.expression = allowInAnd(parseExpression); parseExpected(SyntaxKind.CloseParenToken); - return addJSDocComment(finishNode(node)); + return finishNode(node); } function parseSpreadElement(): Expression { @@ -4458,41 +4465,32 @@ namespace ts { return finishNode(node); } - function tryParseAccessorDeclaration(fullStart: number, decorators: NodeArray, modifiers: NodeArray): AccessorDeclaration | undefined { - if (parseContextualModifier(SyntaxKind.GetKeyword)) { - return parseAccessorDeclaration(SyntaxKind.GetAccessor, fullStart, decorators, modifiers); - } - else if (parseContextualModifier(SyntaxKind.SetKeyword)) { - return parseAccessorDeclaration(SyntaxKind.SetAccessor, fullStart, decorators, modifiers); + function parseObjectLiteralElement(): ObjectLiteralElementLike { + const node = createNodeWithJSDoc(SyntaxKind.Unknown); + + if (parseOptionalToken(SyntaxKind.DotDotDotToken)) { + node.kind = SyntaxKind.SpreadAssignment; + (node).expression = parseAssignmentExpressionOrHigher(); + return finishNode(node); } - return undefined; - } + node.decorators = parseDecorators(); + node.modifiers = parseModifiers(); - function parseObjectLiteralElement(): ObjectLiteralElementLike { - const fullStart = scanner.getStartPos(); - const dotDotDotToken = parseOptionalToken(SyntaxKind.DotDotDotToken); - if (dotDotDotToken) { - const spreadElement = createNode(SyntaxKind.SpreadAssignment, fullStart); - spreadElement.expression = parseAssignmentExpressionOrHigher(); - return addJSDocComment(finishNode(spreadElement)); + if (parseContextualModifier(SyntaxKind.GetKeyword)) { + return parseAccessorDeclaration(node, SyntaxKind.GetAccessor); } - const decorators = parseDecorators(); - const modifiers = parseModifiers(); - - const accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers); - if (accessor) { - return accessor; + if (parseContextualModifier(SyntaxKind.SetKeyword)) { + return parseAccessorDeclaration(node, SyntaxKind.SetAccessor); } const asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken); const tokenIsIdentifier = isIdentifier(); - const propertyName = parsePropertyName(); - + node.name = parsePropertyName(); // Disallowing of optional property assignments happens in the grammar checker. - const questionToken = parseOptionalToken(SyntaxKind.QuestionToken); + (node).questionToken = parseOptionalToken(SyntaxKind.QuestionToken); if (asteriskToken || token() === SyntaxKind.OpenParenToken || token() === SyntaxKind.LessThanToken) { - return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); + return parseMethodDeclaration(node, asteriskToken); } // check if it is short-hand property assignment or normal property assignment @@ -4502,27 +4500,20 @@ namespace ts { // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern const isShorthandPropertyAssignment = tokenIsIdentifier && (token() === SyntaxKind.CommaToken || token() === SyntaxKind.CloseBraceToken || token() === SyntaxKind.EqualsToken); - if (isShorthandPropertyAssignment) { - const shorthandDeclaration = createNode(SyntaxKind.ShorthandPropertyAssignment, fullStart); - shorthandDeclaration.name = propertyName; - shorthandDeclaration.questionToken = questionToken; + node.kind = SyntaxKind.ShorthandPropertyAssignment; const equalsToken = parseOptionalToken(SyntaxKind.EqualsToken); if (equalsToken) { - shorthandDeclaration.equalsToken = equalsToken; - shorthandDeclaration.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); + (node).equalsToken = equalsToken; + (node).objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); } - return addJSDocComment(finishNode(shorthandDeclaration)); } else { - const propertyAssignment = createNode(SyntaxKind.PropertyAssignment, fullStart); - propertyAssignment.modifiers = modifiers; - propertyAssignment.name = propertyName; - propertyAssignment.questionToken = questionToken; + node.kind = SyntaxKind.PropertyAssignment; parseExpected(SyntaxKind.ColonToken); - propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); - return addJSDocComment(finishNode(propertyAssignment)); + (node).initializer = allowInAnd(parseAssignmentExpressionOrHigher); } + return finishNode(node); } function parseObjectLiteralExpression(): ObjectLiteralExpression { @@ -4548,7 +4539,7 @@ namespace ts { setDecoratorContext(/*val*/ false); } - const node = createNode(SyntaxKind.FunctionExpression); + const node = createNodeWithJSDoc(SyntaxKind.FunctionExpression); node.modifiers = parseModifiers(); parseExpected(SyntaxKind.FunctionKeyword); node.asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken); @@ -4568,7 +4559,7 @@ namespace ts { setDecoratorContext(/*val*/ true); } - return addJSDocComment(finishNode(node)); + return finishNode(node); } function parseOptionalIdentifier(): Identifier | undefined { @@ -4793,7 +4784,7 @@ namespace ts { parseExpected(SyntaxKind.OpenParenToken); node.expression = allowInAnd(parseExpression); parseExpected(SyntaxKind.CloseParenToken); - const caseBlock = createNode(SyntaxKind.CaseBlock, scanner.getStartPos()); + const caseBlock = createNode(SyntaxKind.CaseBlock); parseExpected(SyntaxKind.OpenBraceToken); caseBlock.clauses = parseList(ParsingContext.SwitchClauses, parseCaseOrDefaultClause); parseExpected(SyntaxKind.CloseBraceToken); @@ -4863,21 +4854,19 @@ namespace ts { // Avoiding having to do the lookahead for a labeled statement by just trying to parse // out an expression, seeing if it is identifier and then seeing if it is followed by // a colon. - const fullStart = scanner.getStartPos(); + const node = createNodeWithJSDoc(SyntaxKind.Unknown); const expression = allowInAnd(parseExpression); - if (expression.kind === SyntaxKind.Identifier && parseOptional(SyntaxKind.ColonToken)) { - const labeledStatement = createNode(SyntaxKind.LabeledStatement, fullStart); - labeledStatement.label = expression; - labeledStatement.statement = parseStatement(); - return addJSDocComment(finishNode(labeledStatement)); + node.kind = SyntaxKind.LabeledStatement; + (node).label = expression; + (node).statement = parseStatement(); } else { - const expressionStatement = createNode(SyntaxKind.ExpressionStatement, fullStart); - expressionStatement.expression = expression; + node.kind = SyntaxKind.ExpressionStatement; + (node).expression = expression; parseSemicolon(); - return addJSDocComment(finishNode(expressionStatement)); } + return finishNode(node); } function nextTokenIsIdentifierOrKeywordOnSameLine() { @@ -5059,16 +5048,16 @@ namespace ts { case SyntaxKind.OpenBraceToken: return parseBlock(/*ignoreMissingOpenBrace*/ false); case SyntaxKind.VarKeyword: - return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); + return parseVariableStatement(createNodeWithJSDoc(SyntaxKind.VariableDeclaration)); case SyntaxKind.LetKeyword: if (isLetDeclaration()) { - return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); + return parseVariableStatement(createNodeWithJSDoc(SyntaxKind.VariableDeclaration)); } break; case SyntaxKind.FunctionKeyword: - return parseFunctionDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); + return parseFunctionDeclaration(createNodeWithJSDoc(SyntaxKind.FunctionDeclaration)); case SyntaxKind.ClassKeyword: - return parseClassDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); + return parseClassDeclaration(createNodeWithJSDoc(SyntaxKind.ClassDeclaration)); case SyntaxKind.IfKeyword: return parseIfStatement(); case SyntaxKind.DoKeyword: @@ -5123,63 +5112,67 @@ namespace ts { return parseExpressionOrLabeledStatement(); } + function isDeclareModifier(modifier: Modifier) { + return modifier.kind === SyntaxKind.DeclareKeyword; + } + function parseDeclaration(): Statement { - const fullStart = getNodePos(); - const decorators = parseDecorators(); - const modifiers = parseModifiers(); - if (some(modifiers, m => m.kind === SyntaxKind.DeclareKeyword)) { - for (const m of modifiers) { + const node = createNodeWithJSDoc(SyntaxKind.Unknown); + node.decorators = parseDecorators(); + node.modifiers = parseModifiers(); + if (some(node.modifiers, isDeclareModifier)) { + for (const m of node.modifiers) { m.flags |= NodeFlags.Ambient; } - return doInsideOfContext(NodeFlags.Ambient, () => parseDeclarationWorker(fullStart, decorators, modifiers)); + return doInsideOfContext(NodeFlags.Ambient, () => parseDeclarationWorker(node)); } else { - return parseDeclarationWorker(fullStart, decorators, modifiers); + return parseDeclarationWorker(node); } } - function parseDeclarationWorker(fullStart: number, decorators: NodeArray | undefined, modifiers: NodeArray | undefined): Statement { + function parseDeclarationWorker(node: Statement): Statement { switch (token()) { case SyntaxKind.VarKeyword: case SyntaxKind.LetKeyword: case SyntaxKind.ConstKeyword: - return parseVariableStatement(fullStart, decorators, modifiers); + return parseVariableStatement(node); case SyntaxKind.FunctionKeyword: - return parseFunctionDeclaration(fullStart, decorators, modifiers); + return parseFunctionDeclaration(node); case SyntaxKind.ClassKeyword: - return parseClassDeclaration(fullStart, decorators, modifiers); + return parseClassDeclaration(node); case SyntaxKind.InterfaceKeyword: - return parseInterfaceDeclaration(fullStart, decorators, modifiers); + return parseInterfaceDeclaration(node); case SyntaxKind.TypeKeyword: - return parseTypeAliasDeclaration(fullStart, decorators, modifiers); + return parseTypeAliasDeclaration(node); case SyntaxKind.EnumKeyword: - return parseEnumDeclaration(fullStart, decorators, modifiers); + return parseEnumDeclaration(node); case SyntaxKind.GlobalKeyword: case SyntaxKind.ModuleKeyword: case SyntaxKind.NamespaceKeyword: - return parseModuleDeclaration(fullStart, decorators, modifiers); + return parseModuleDeclaration(node); case SyntaxKind.ImportKeyword: - return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); + return parseImportDeclarationOrImportEqualsDeclaration(node); case SyntaxKind.ExportKeyword: nextToken(); switch (token()) { case SyntaxKind.DefaultKeyword: case SyntaxKind.EqualsToken: - return parseExportAssignment(fullStart, decorators, modifiers); + return parseExportAssignment(node); case SyntaxKind.AsKeyword: - return parseNamespaceExportDeclaration(fullStart, decorators, modifiers); + return parseNamespaceExportDeclaration(node); default: - return parseExportDeclaration(fullStart, decorators, modifiers); + return parseExportDeclaration(node); } default: - if (decorators || modifiers) { + if (node.decorators || node.modifiers) { // We reached this point because we encountered decorators and/or modifiers and assumed a declaration // would follow. For recovery and error reporting purposes, return an incomplete declaration. - const node = createMissingNode(SyntaxKind.MissingDeclaration, /*reportAtCurrentPosition*/ true, Diagnostics.Declaration_expected); - node.pos = fullStart; - node.decorators = decorators; - node.modifiers = modifiers; - return finishNode(node); + const missing = createMissingNode(SyntaxKind.MissingDeclaration, /*reportAtCurrentPosition*/ true, Diagnostics.Declaration_expected); + missing.pos = node.pos; + missing.decorators = node.decorators; + missing.modifiers = node.modifiers; + return finishNode(missing); } } } @@ -5314,19 +5307,15 @@ namespace ts { return nextTokenIsIdentifier() && nextToken() === SyntaxKind.CloseParenToken; } - function parseVariableStatement(fullStart: number, decorators: NodeArray, modifiers: NodeArray): VariableStatement { - const node = createNode(SyntaxKind.VariableStatement, fullStart); - node.decorators = decorators; - node.modifiers = modifiers; + function parseVariableStatement(node: VariableStatement): VariableStatement { + node.kind = SyntaxKind.VariableStatement; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); parseSemicolon(); - return addJSDocComment(finishNode(node)); + return finishNode(node); } - function parseFunctionDeclaration(fullStart: number, decorators: NodeArray, modifiers: NodeArray): FunctionDeclaration { - const node = createNode(SyntaxKind.FunctionDeclaration, fullStart); - node.decorators = decorators; - node.modifiers = modifiers; + function parseFunctionDeclaration(node: FunctionDeclaration): FunctionDeclaration { + node.kind = SyntaxKind.FunctionDeclaration; parseExpected(SyntaxKind.FunctionKeyword); node.asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken); node.name = hasModifier(node, ModifierFlags.Default) ? parseOptionalIdentifier() : parseIdentifier(); @@ -5334,40 +5323,30 @@ namespace ts { const isAsync = hasModifier(node, ModifierFlags.Async) ? SignatureFlags.Await : SignatureFlags.None; fillSignature(SyntaxKind.ColonToken, isGenerator | isAsync, node); node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, Diagnostics.or_expected); - return addJSDocComment(finishNode(node)); + return finishNode(node); } - function parseConstructorDeclaration(pos: number, decorators: NodeArray, modifiers: NodeArray): ConstructorDeclaration { - const node = createNode(SyntaxKind.Constructor, pos); - node.decorators = decorators; - node.modifiers = modifiers; + function parseConstructorDeclaration(node: ConstructorDeclaration): ConstructorDeclaration { + node.kind = SyntaxKind.Constructor; parseExpected(SyntaxKind.ConstructorKeyword); fillSignature(SyntaxKind.ColonToken, SignatureFlags.None, node); node.body = parseFunctionBlockOrSemicolon(SignatureFlags.None, Diagnostics.or_expected); - return addJSDocComment(finishNode(node)); + return finishNode(node); } - function parseMethodDeclaration(fullStart: number, decorators: NodeArray, modifiers: NodeArray, asteriskToken: AsteriskToken, name: PropertyName, questionToken: QuestionToken, diagnosticMessage?: DiagnosticMessage): MethodDeclaration { - const method = createNode(SyntaxKind.MethodDeclaration, fullStart); - method.decorators = decorators; - method.modifiers = modifiers; - method.asteriskToken = asteriskToken; - method.name = name; - method.questionToken = questionToken; + function parseMethodDeclaration(node: MethodDeclaration, asteriskToken: AsteriskToken, diagnosticMessage?: DiagnosticMessage): MethodDeclaration { + node.kind = SyntaxKind.MethodDeclaration; + node.asteriskToken = asteriskToken; const isGenerator = asteriskToken ? SignatureFlags.Yield : SignatureFlags.None; - const isAsync = hasModifier(method, ModifierFlags.Async) ? SignatureFlags.Await : SignatureFlags.None; - fillSignature(SyntaxKind.ColonToken, isGenerator | isAsync, method); - method.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, diagnosticMessage); - return addJSDocComment(finishNode(method)); + const isAsync = hasModifier(node, ModifierFlags.Async) ? SignatureFlags.Await : SignatureFlags.None; + fillSignature(SyntaxKind.ColonToken, isGenerator | isAsync, node); + node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, diagnosticMessage); + return finishNode(node); } - function parsePropertyDeclaration(fullStart: number, decorators: NodeArray, modifiers: NodeArray, name: PropertyName, questionToken: QuestionToken): ClassElement { - const property = createNode(SyntaxKind.PropertyDeclaration, fullStart); - property.decorators = decorators; - property.modifiers = modifiers; - property.name = name; - property.questionToken = questionToken; - property.type = parseTypeAnnotation(); + function parsePropertyDeclaration(node: PropertyDeclaration): PropertyDeclaration { + node.kind = SyntaxKind.PropertyDeclaration; + node.type = parseTypeAnnotation(); // For instance properties specifically, since they are evaluated inside the constructor, // we do *not * want to parse yield expressions, so we specifically turn the yield context @@ -5378,37 +5357,32 @@ namespace ts { // AccessibilityModifier_opt static_opt PropertyName TypeAnnotation_opt Initializer_opt[In, ?Yield]; // // The checker may still error in the static case to explicitly disallow the yield expression. - property.initializer = hasModifier(property, ModifierFlags.Static) + node.initializer = hasModifier(node, ModifierFlags.Static) ? allowInAnd(parseInitializer) : doOutsideOfContext(NodeFlags.YieldContext | NodeFlags.DisallowInContext, parseInitializer); parseSemicolon(); - return addJSDocComment(finishNode(property)); + return finishNode(node); } - function parsePropertyOrMethodDeclaration(fullStart: number, decorators: NodeArray, modifiers: NodeArray): ClassElement { + function parsePropertyOrMethodDeclaration(node: PropertyDeclaration | MethodDeclaration): PropertyDeclaration | MethodDeclaration { const asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken); - const name = parsePropertyName(); - + node.name = parsePropertyName(); // Note: this is not legal as per the grammar. But we allow it in the parser and // report an error in the grammar checker. - const questionToken = parseOptionalToken(SyntaxKind.QuestionToken); + node.questionToken = parseOptionalToken(SyntaxKind.QuestionToken); if (asteriskToken || token() === SyntaxKind.OpenParenToken || token() === SyntaxKind.LessThanToken) { - return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, Diagnostics.or_expected); - } - else { - return parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken); + return parseMethodDeclaration(node, asteriskToken, Diagnostics.or_expected); } + return parsePropertyDeclaration(node); } - function parseAccessorDeclaration(kind: SyntaxKind, fullStart: number, decorators: NodeArray, modifiers: NodeArray): AccessorDeclaration { - const node = createNode(kind, fullStart); - node.decorators = decorators; - node.modifiers = modifiers; + function parseAccessorDeclaration(node: AccessorDeclaration, kind: AccessorDeclaration["kind"]): AccessorDeclaration { + node.kind = kind; node.name = parsePropertyName(); fillSignature(SyntaxKind.ColonToken, SignatureFlags.None, node); node.body = parseFunctionBlockOrSemicolon(SignatureFlags.None); - return addJSDocComment(finishNode(node)); + return finishNode(node); } function isClassMemberModifier(idToken: SyntaxKind) { @@ -5560,21 +5534,24 @@ namespace ts { return finishNode(result); } - const fullStart = getNodePos(); - const decorators = parseDecorators(); - const modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true); + const node = createNodeWithJSDoc(SyntaxKind.Unknown); + node.decorators = parseDecorators(); + node.modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true); + + if (parseContextualModifier(SyntaxKind.GetKeyword)) { + return parseAccessorDeclaration(node, SyntaxKind.GetAccessor); + } - const accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers); - if (accessor) { - return accessor; + if (parseContextualModifier(SyntaxKind.SetKeyword)) { + return parseAccessorDeclaration(node, SyntaxKind.SetAccessor); } if (token() === SyntaxKind.ConstructorKeyword) { - return parseConstructorDeclaration(fullStart, decorators, modifiers); + return parseConstructorDeclaration(node); } if (isIndexSignature()) { - return parseIndexSignatureDeclaration(fullStart, decorators, modifiers); + return parseIndexSignatureDeclaration(node); } // It is very important that we check this *after* checking indexers because @@ -5585,13 +5562,13 @@ namespace ts { token() === SyntaxKind.AsteriskToken || token() === SyntaxKind.OpenBracketToken) { - return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); + return parsePropertyOrMethodDeclaration(node); } - if (decorators || modifiers) { + if (node.decorators || node.modifiers) { // treat this as a property declaration with a missing name. - const name = createMissingNode(SyntaxKind.Identifier, /*reportAtCurrentPosition*/ true, Diagnostics.Declaration_expected); - return parsePropertyDeclaration(fullStart, decorators, modifiers, name, /*questionToken*/ undefined); + node.name = createMissingNode(SyntaxKind.Identifier, /*reportAtCurrentPosition*/ true, Diagnostics.Declaration_expected); + return parsePropertyDeclaration(node); } // 'isClassMemberStart' should have hinted not to attempt parsing. @@ -5599,21 +5576,15 @@ namespace ts { } function parseClassExpression(): ClassExpression { - return parseClassDeclarationOrExpression( - /*fullStart*/ scanner.getStartPos(), - /*decorators*/ undefined, - /*modifiers*/ undefined, - SyntaxKind.ClassExpression); + return parseClassDeclarationOrExpression(createNodeWithJSDoc(SyntaxKind.Unknown), SyntaxKind.ClassExpression); } - function parseClassDeclaration(fullStart: number, decorators: NodeArray, modifiers: NodeArray): ClassDeclaration { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, SyntaxKind.ClassDeclaration); + function parseClassDeclaration(node: ClassLikeDeclaration): ClassDeclaration { + return parseClassDeclarationOrExpression(node, SyntaxKind.ClassDeclaration); } - function parseClassDeclarationOrExpression(fullStart: number, decorators: NodeArray, modifiers: NodeArray, kind: SyntaxKind): ClassLikeDeclaration { - const node = createNode(kind, fullStart); - node.decorators = decorators; - node.modifiers = modifiers; + function parseClassDeclarationOrExpression(node: ClassLikeDeclaration, kind: ClassLikeDeclaration["kind"]): ClassLikeDeclaration { + node.kind = kind; parseExpected(SyntaxKind.ClassKeyword); node.name = parseNameOfClassDeclarationOrExpression(); node.typeParameters = parseTypeParameters(); @@ -5629,7 +5600,7 @@ namespace ts { node.members = createMissingList(); } - return addJSDocComment(finishNode(node)); + return finishNode(node); } function parseNameOfClassDeclarationOrExpression(): Identifier | undefined { @@ -5692,29 +5663,25 @@ namespace ts { return parseList(ParsingContext.ClassMembers, parseClassElement); } - function parseInterfaceDeclaration(fullStart: number, decorators: NodeArray, modifiers: NodeArray): InterfaceDeclaration { - const node = createNode(SyntaxKind.InterfaceDeclaration, fullStart); - node.decorators = decorators; - node.modifiers = modifiers; + function parseInterfaceDeclaration(node: InterfaceDeclaration): InterfaceDeclaration { + node.kind = SyntaxKind.InterfaceDeclaration; parseExpected(SyntaxKind.InterfaceKeyword); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(); node.members = parseObjectTypeMembers(); - return addJSDocComment(finishNode(node)); + return finishNode(node); } - function parseTypeAliasDeclaration(fullStart: number, decorators: NodeArray, modifiers: NodeArray): TypeAliasDeclaration { - const node = createNode(SyntaxKind.TypeAliasDeclaration, fullStart); - node.decorators = decorators; - node.modifiers = modifiers; + function parseTypeAliasDeclaration(node: TypeAliasDeclaration): TypeAliasDeclaration { + node.kind = SyntaxKind.TypeAliasDeclaration; parseExpected(SyntaxKind.TypeKeyword); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); parseExpected(SyntaxKind.EqualsToken); node.type = parseType(); parseSemicolon(); - return addJSDocComment(finishNode(node)); + return finishNode(node); } // In an ambient declaration, the grammar only allows integer literals as initializers. @@ -5722,16 +5689,14 @@ namespace ts { // ConstantEnumMemberSection, which starts at the beginning of an enum declaration // or any time an integer literal initializer is encountered. function parseEnumMember(): EnumMember { - const node = createNode(SyntaxKind.EnumMember, scanner.getStartPos()); + const node = createNodeWithJSDoc(SyntaxKind.EnumMember); node.name = parsePropertyName(); node.initializer = allowInAnd(parseInitializer); - return addJSDocComment(finishNode(node)); + return finishNode(node); } - function parseEnumDeclaration(fullStart: number, decorators: NodeArray, modifiers: NodeArray): EnumDeclaration { - const node = createNode(SyntaxKind.EnumDeclaration, fullStart); - node.decorators = decorators; - node.modifiers = modifiers; + function parseEnumDeclaration(node: EnumDeclaration): EnumDeclaration { + node.kind = SyntaxKind.EnumDeclaration; parseExpected(SyntaxKind.EnumKeyword); node.name = parseIdentifier(); if (parseExpected(SyntaxKind.OpenBraceToken)) { @@ -5741,11 +5706,11 @@ namespace ts { else { node.members = createMissingList(); } - return addJSDocComment(finishNode(node)); + return finishNode(node); } function parseModuleBlock(): ModuleBlock { - const node = createNode(SyntaxKind.ModuleBlock, scanner.getStartPos()); + const node = createNode(SyntaxKind.ModuleBlock); if (parseExpected(SyntaxKind.OpenBraceToken)) { node.statements = parseList(ParsingContext.BlockStatements, parseStatement); parseExpected(SyntaxKind.CloseBraceToken); @@ -5756,25 +5721,21 @@ namespace ts { return finishNode(node); } - function parseModuleOrNamespaceDeclaration(fullStart: number, decorators: NodeArray, modifiers: NodeArray, flags: NodeFlags): ModuleDeclaration { - const node = createNode(SyntaxKind.ModuleDeclaration, fullStart); + function parseModuleOrNamespaceDeclaration(node: ModuleDeclaration, flags: NodeFlags): ModuleDeclaration { + node.kind = SyntaxKind.ModuleDeclaration; // If we are parsing a dotted namespace name, we want to // propagate the 'Namespace' flag across the names if set. const namespaceFlag = flags & NodeFlags.Namespace; - node.decorators = decorators; - node.modifiers = modifiers; node.flags |= flags; node.name = parseIdentifier(); node.body = parseOptional(SyntaxKind.DotToken) - ? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, NodeFlags.NestedNamespace | namespaceFlag) + ? parseModuleOrNamespaceDeclaration(createNode(SyntaxKind.Unknown), NodeFlags.NestedNamespace | namespaceFlag) : parseModuleBlock(); - return addJSDocComment(finishNode(node)); + return finishNode(node); } - function parseAmbientExternalModuleDeclaration(fullStart: number, decorators: NodeArray, modifiers: NodeArray): ModuleDeclaration { - const node = createNode(SyntaxKind.ModuleDeclaration, fullStart); - node.decorators = decorators; - node.modifiers = modifiers; + function parseAmbientExternalModuleDeclaration(node: ModuleDeclaration): ModuleDeclaration { + node.kind = SyntaxKind.ModuleDeclaration; if (token() === SyntaxKind.GlobalKeyword) { // parse 'global' as name of global scope augmentation node.name = parseIdentifier(); @@ -5784,22 +5745,20 @@ namespace ts { node.name = parseLiteralNode(); node.name.text = internIdentifier(node.name.text); } - if (token() === SyntaxKind.OpenBraceToken) { node.body = parseModuleBlock(); } else { parseSemicolon(); } - return finishNode(node); } - function parseModuleDeclaration(fullStart: number, decorators: NodeArray, modifiers: NodeArray): ModuleDeclaration { + function parseModuleDeclaration(node: ModuleDeclaration): ModuleDeclaration { let flags: NodeFlags = 0; if (token() === SyntaxKind.GlobalKeyword) { // global augmentation - return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); + return parseAmbientExternalModuleDeclaration(node); } else if (parseOptional(SyntaxKind.NamespaceKeyword)) { flags |= NodeFlags.Namespace; @@ -5807,10 +5766,10 @@ namespace ts { else { parseExpected(SyntaxKind.ModuleKeyword); if (token() === SyntaxKind.StringLiteral) { - return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); + return parseAmbientExternalModuleDeclaration(node); } } - return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); + return parseModuleOrNamespaceDeclaration(node, flags); } function isExternalModuleReference() { @@ -5826,21 +5785,16 @@ namespace ts { return nextToken() === SyntaxKind.SlashToken; } - function parseNamespaceExportDeclaration(fullStart: number, decorators: NodeArray, modifiers: NodeArray): NamespaceExportDeclaration { - const exportDeclaration = createNode(SyntaxKind.NamespaceExportDeclaration, fullStart); - exportDeclaration.decorators = decorators; - exportDeclaration.modifiers = modifiers; + function parseNamespaceExportDeclaration(node: NamespaceExportDeclaration): NamespaceExportDeclaration { + node.kind = SyntaxKind.NamespaceExportDeclaration; parseExpected(SyntaxKind.AsKeyword); parseExpected(SyntaxKind.NamespaceKeyword); - - exportDeclaration.name = parseIdentifier(); - + node.name = parseIdentifier(); parseSemicolon(); - - return finishNode(exportDeclaration); + return finishNode(node); } - function parseImportDeclarationOrImportEqualsDeclaration(fullStart: number, decorators: NodeArray, modifiers: NodeArray): ImportEqualsDeclaration | ImportDeclaration { + function parseImportDeclarationOrImportEqualsDeclaration(node: ImportEqualsDeclaration | ImportDeclaration): ImportEqualsDeclaration | ImportDeclaration { parseExpected(SyntaxKind.ImportKeyword); const afterImportPos = scanner.getStartPos(); @@ -5848,39 +5802,34 @@ namespace ts { if (isIdentifier()) { identifier = parseIdentifier(); if (token() !== SyntaxKind.CommaToken && token() !== SyntaxKind.FromKeyword) { - return parseImportEqualsDeclaration(fullStart, decorators, modifiers, identifier); + return parseImportEqualsDeclaration(node, identifier); } } // Import statement - const importDeclaration = createNode(SyntaxKind.ImportDeclaration, fullStart); - importDeclaration.decorators = decorators; - importDeclaration.modifiers = modifiers; - + node.kind = SyntaxKind.ImportDeclaration; // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; if (identifier || // import id token() === SyntaxKind.AsteriskToken || // import * token() === SyntaxKind.OpenBraceToken) { // import { - importDeclaration.importClause = parseImportClause(identifier, afterImportPos); + (node).importClause = parseImportClause(identifier, afterImportPos); parseExpected(SyntaxKind.FromKeyword); } - importDeclaration.moduleSpecifier = parseModuleSpecifier(); + (node).moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); - return finishNode(importDeclaration); + return finishNode(node); } - function parseImportEqualsDeclaration(fullStart: number, decorators: NodeArray, modifiers: NodeArray, identifier: ts.Identifier): ImportEqualsDeclaration { - const importEqualsDeclaration = createNode(SyntaxKind.ImportEqualsDeclaration, fullStart); - importEqualsDeclaration.decorators = decorators; - importEqualsDeclaration.modifiers = modifiers; - importEqualsDeclaration.name = identifier; + function parseImportEqualsDeclaration(node: ImportEqualsDeclaration, identifier: ts.Identifier): ImportEqualsDeclaration { + node.kind = SyntaxKind.ImportEqualsDeclaration; + node.name = identifier; parseExpected(SyntaxKind.EqualsToken); - importEqualsDeclaration.moduleReference = parseModuleReference(); + node.moduleReference = parseModuleReference(); parseSemicolon(); - return addJSDocComment(finishNode(importEqualsDeclaration)); + return finishNode(node); } function parseImportClause(identifier: Identifier, fullStart: number) { @@ -6004,17 +5953,14 @@ namespace ts { return finishNode(node); } - function parseExportDeclaration(fullStart: number, decorators: NodeArray, modifiers: NodeArray): ExportDeclaration { - const node = createNode(SyntaxKind.ExportDeclaration, fullStart); - node.decorators = decorators; - node.modifiers = modifiers; + function parseExportDeclaration(node: ExportDeclaration): ExportDeclaration { + node.kind = SyntaxKind.ExportDeclaration; if (parseOptional(SyntaxKind.AsteriskToken)) { parseExpected(SyntaxKind.FromKeyword); node.moduleSpecifier = parseModuleSpecifier(); } else { node.exportClause = parseNamedImportsOrExports(SyntaxKind.NamedExports); - // It is not uncommon to accidentally omit the 'from' keyword. Additionally, in editing scenarios, // the 'from' keyword can be parsed as a named export when the export clause is unterminated (i.e. `export { from "moduleName";`) // If we don't have a 'from' keyword, see if we have a string literal such that ASI won't take effect. @@ -6027,10 +5973,8 @@ namespace ts { return finishNode(node); } - function parseExportAssignment(fullStart: number, decorators: NodeArray, modifiers: NodeArray): ExportAssignment { - const node = createNode(SyntaxKind.ExportAssignment, fullStart); - node.decorators = decorators; - node.modifiers = modifiers; + function parseExportAssignment(node: ExportAssignment): ExportAssignment { + node.kind = SyntaxKind.ExportAssignment; if (parseOptional(SyntaxKind.EqualsToken)) { node.isExportEquals = true; } @@ -6223,7 +6167,7 @@ namespace ts { comment.parent = parent; } - if (isInJavaScriptFile(parent)) { + if (contextFlags & NodeFlags.JavaScriptFile) { if (!sourceFile.jsDocDiagnostics) { sourceFile.jsDocDiagnostics = []; } @@ -6826,7 +6770,7 @@ namespace ts { function tryParseChildTag(target: PropertyLikeParse): JSDocTypeTag | JSDocPropertyTag | JSDocParameterTag | false { Debug.assert(token() === SyntaxKind.AtToken); - const atToken = createNode(SyntaxKind.AtToken, scanner.getStartPos()); + const atToken = createNode(SyntaxKind.AtToken); atToken.end = scanner.getTextPos(); nextJSDocToken(); diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 9fddece11d01a..8dc5a10c626f9 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -27,7 +27,7 @@ namespace ts { isReservedWord(): boolean; isUnterminated(): boolean; /* @internal */ - getNumericLiteralFlags(): NumericLiteralFlags; + getTokenFlags(): TokenFlags; reScanGreaterToken(): SyntaxKind; reScanSlashToken(): SyntaxKind; reScanTemplateToken(): SyntaxKind; @@ -125,6 +125,7 @@ namespace ts { "type": SyntaxKind.TypeKeyword, "typeof": SyntaxKind.TypeOfKeyword, "undefined": SyntaxKind.UndefinedKeyword, + "unique": SyntaxKind.UniqueKeyword, "var": SyntaxKind.VarKeyword, "void": SyntaxKind.VoidKeyword, "while": SyntaxKind.WhileKeyword, @@ -814,10 +815,7 @@ namespace ts { let token: SyntaxKind; let tokenValue: string; - let precedingLineBreak: boolean; - let hasExtendedUnicodeEscape: boolean; - let tokenIsUnterminated: boolean; - let numericLiteralFlags: NumericLiteralFlags; + let tokenFlags: TokenFlags; setText(text, start, length); @@ -828,12 +826,12 @@ namespace ts { getTokenPos: () => tokenPos, getTokenText: () => text.substring(tokenPos, pos), getTokenValue: () => tokenValue, - hasExtendedUnicodeEscape: () => hasExtendedUnicodeEscape, - hasPrecedingLineBreak: () => precedingLineBreak, + hasExtendedUnicodeEscape: () => (tokenFlags & TokenFlags.ExtendedUnicodeEscape) !== 0, + hasPrecedingLineBreak: () => (tokenFlags & TokenFlags.PrecedingLineBreak) !== 0, isIdentifier: () => token === SyntaxKind.Identifier || token > SyntaxKind.LastReservedWord, isReservedWord: () => token >= SyntaxKind.FirstReservedWord && token <= SyntaxKind.LastReservedWord, - isUnterminated: () => tokenIsUnterminated, - getNumericLiteralFlags: () => numericLiteralFlags, + isUnterminated: () => (tokenFlags & TokenFlags.Unterminated) !== 0, + getTokenFlags: () => tokenFlags, reScanGreaterToken, reScanSlashToken, reScanTemplateToken, @@ -870,7 +868,7 @@ namespace ts { let end = pos; if (text.charCodeAt(pos) === CharacterCodes.E || text.charCodeAt(pos) === CharacterCodes.e) { pos++; - numericLiteralFlags = NumericLiteralFlags.Scientific; + tokenFlags |= TokenFlags.Scientific; if (text.charCodeAt(pos) === CharacterCodes.plus || text.charCodeAt(pos) === CharacterCodes.minus) pos++; if (isDigit(text.charCodeAt(pos))) { pos++; @@ -942,7 +940,7 @@ namespace ts { while (true) { if (pos >= end) { result += text.substring(start, pos); - tokenIsUnterminated = true; + tokenFlags |= TokenFlags.Unterminated; error(Diagnostics.Unterminated_string_literal); break; } @@ -960,7 +958,7 @@ namespace ts { } if (isLineBreak(ch)) { result += text.substring(start, pos); - tokenIsUnterminated = true; + tokenFlags |= TokenFlags.Unterminated; error(Diagnostics.Unterminated_string_literal); break; } @@ -984,7 +982,7 @@ namespace ts { while (true) { if (pos >= end) { contents += text.substring(start, pos); - tokenIsUnterminated = true; + tokenFlags |= TokenFlags.Unterminated; error(Diagnostics.Unterminated_template_literal); resultingToken = startedWithBacktick ? SyntaxKind.NoSubstitutionTemplateLiteral : SyntaxKind.TemplateTail; break; @@ -1070,7 +1068,7 @@ namespace ts { case CharacterCodes.u: // '\u{DDDDDDDD}' if (pos < end && text.charCodeAt(pos) === CharacterCodes.openBrace) { - hasExtendedUnicodeEscape = true; + tokenFlags |= TokenFlags.ExtendedUnicodeEscape; pos++; return scanExtendedUnicodeEscape(); } @@ -1239,10 +1237,7 @@ namespace ts { function scan(): SyntaxKind { startPos = pos; - hasExtendedUnicodeEscape = false; - precedingLineBreak = false; - tokenIsUnterminated = false; - numericLiteralFlags = 0; + tokenFlags = 0; while (true) { tokenPos = pos; if (pos >= end) { @@ -1264,7 +1259,7 @@ namespace ts { switch (ch) { case CharacterCodes.lineFeed: case CharacterCodes.carriageReturn: - precedingLineBreak = true; + tokenFlags |= TokenFlags.PrecedingLineBreak; if (skipTrivia) { pos++; continue; @@ -1395,6 +1390,9 @@ namespace ts { // Multi-line comment if (text.charCodeAt(pos + 1) === CharacterCodes.asterisk) { pos += 2; + if (text.charCodeAt(pos) === CharacterCodes.asterisk && text.charCodeAt(pos + 1) !== CharacterCodes.slash) { + tokenFlags |= TokenFlags.PrecedingJSDocComment; + } let commentClosed = false; while (pos < end) { @@ -1407,7 +1405,7 @@ namespace ts { } if (isLineBreak(ch)) { - precedingLineBreak = true; + tokenFlags |= TokenFlags.PrecedingLineBreak; } pos++; } @@ -1420,7 +1418,9 @@ namespace ts { continue; } else { - tokenIsUnterminated = !commentClosed; + if (!commentClosed) { + tokenFlags |= TokenFlags.Unterminated; + } return token = SyntaxKind.MultiLineCommentTrivia; } } @@ -1441,7 +1441,7 @@ namespace ts { value = 0; } tokenValue = "" + value; - numericLiteralFlags = NumericLiteralFlags.HexSpecifier; + tokenFlags |= TokenFlags.HexSpecifier; return token = SyntaxKind.NumericLiteral; } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === CharacterCodes.B || text.charCodeAt(pos + 1) === CharacterCodes.b)) { @@ -1452,7 +1452,7 @@ namespace ts { value = 0; } tokenValue = "" + value; - numericLiteralFlags = NumericLiteralFlags.BinarySpecifier; + tokenFlags |= TokenFlags.BinarySpecifier; return token = SyntaxKind.NumericLiteral; } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === CharacterCodes.O || text.charCodeAt(pos + 1) === CharacterCodes.o)) { @@ -1463,13 +1463,13 @@ namespace ts { value = 0; } tokenValue = "" + value; - numericLiteralFlags = NumericLiteralFlags.OctalSpecifier; + tokenFlags |= TokenFlags.OctalSpecifier; return token = SyntaxKind.NumericLiteral; } // Try to parse as an octal if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanOctalDigits(); - numericLiteralFlags = NumericLiteralFlags.Octal; + tokenFlags |= TokenFlags.Octal; return token = SyntaxKind.NumericLiteral; } // This fall-through is a deviation from the EcmaScript grammar. The grammar says that a leading zero @@ -1626,7 +1626,7 @@ namespace ts { continue; } else if (isLineBreak(ch)) { - precedingLineBreak = true; + tokenFlags |= TokenFlags.PrecedingLineBreak; pos++; continue; } @@ -1669,14 +1669,14 @@ namespace ts { // If we reach the end of a file, or hit a newline, then this is an unterminated // regex. Report error and return what we have so far. if (p >= end) { - tokenIsUnterminated = true; + tokenFlags |= TokenFlags.Unterminated; error(Diagnostics.Unterminated_regular_expression_literal); break; } const ch = text.charCodeAt(p); if (isLineBreak(ch)) { - tokenIsUnterminated = true; + tokenFlags |= TokenFlags.Unterminated; error(Diagnostics.Unterminated_regular_expression_literal); break; } @@ -1894,7 +1894,7 @@ namespace ts { const saveTokenPos = tokenPos; const saveToken = token; const saveTokenValue = tokenValue; - const savePrecedingLineBreak = precedingLineBreak; + const saveTokenFlags = tokenFlags; const result = callback(); // If our callback returned something 'falsy' or we're just looking ahead, @@ -1905,7 +1905,7 @@ namespace ts { tokenPos = saveTokenPos; token = saveToken; tokenValue = saveTokenValue; - precedingLineBreak = savePrecedingLineBreak; + tokenFlags = saveTokenFlags; } return result; } @@ -1916,10 +1916,8 @@ namespace ts { const saveStartPos = startPos; const saveTokenPos = tokenPos; const saveToken = token; - const savePrecedingLineBreak = precedingLineBreak; const saveTokenValue = tokenValue; - const saveHasExtendedUnicodeEscape = hasExtendedUnicodeEscape; - const saveTokenIsUnterminated = tokenIsUnterminated; + const saveTokenFlags = tokenFlags; setText(text, start, length); const result = callback(); @@ -1929,10 +1927,8 @@ namespace ts { startPos = saveStartPos; tokenPos = saveTokenPos; token = saveToken; - precedingLineBreak = savePrecedingLineBreak; tokenValue = saveTokenValue; - hasExtendedUnicodeEscape = saveHasExtendedUnicodeEscape; - tokenIsUnterminated = saveTokenIsUnterminated; + tokenFlags = saveTokenFlags; return result; } @@ -1973,11 +1969,8 @@ namespace ts { startPos = textPos; tokenPos = textPos; token = SyntaxKind.Unknown; - precedingLineBreak = false; - tokenValue = undefined; - hasExtendedUnicodeEscape = false; - tokenIsUnterminated = false; + tokenFlags = 0; } } } diff --git a/src/compiler/transformers/es2015.ts b/src/compiler/transformers/es2015.ts index 989b082757050..0c5c3cfbd3ab2 100644 --- a/src/compiler/transformers/es2015.ts +++ b/src/compiler/transformers/es2015.ts @@ -3633,7 +3633,7 @@ namespace ts { * @param node A string literal. */ function visitNumericLiteral(node: NumericLiteral) { - if (node.numericLiteralFlags & NumericLiteralFlags.BinaryOrOctalSpecifier) { + if (node.numericLiteralFlags & TokenFlags.BinaryOrOctalSpecifier) { return setTextRange(createNumericLiteral(node.text), node); } return node; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 0cd9e5db0a2e5..a833a8aca2bae 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -212,6 +212,7 @@ namespace ts { SymbolKeyword, TypeKeyword, UndefinedKeyword, + UniqueKeyword, FromKeyword, GlobalKeyword, OfKeyword, // LastKeyword and LastToken and LastContextualKeyword @@ -681,6 +682,17 @@ namespace ts { name?: DeclarationName; } + /* @internal */ + export interface DynamicNamedDeclaration extends NamedDeclaration { + name: ComputedPropertyName; + } + + /* @internal */ + // A declaration that supports late-binding (used in checker) + export interface LateBoundDeclaration extends DynamicNamedDeclaration { + name: LateBoundName; + } + export interface DeclarationStatement extends NamedDeclaration, Statement { name?: Identifier | StringLiteral | NumericLiteral; } @@ -690,6 +702,12 @@ namespace ts { expression: Expression; } + /* @internal */ + // A name that supports late-binding (used in checker) + export interface LateBoundName extends ComputedPropertyName { + expression: EntityNameExpression; + } + export interface Decorator extends Node { kind: SyntaxKind.Decorator; parent?: NamedDeclaration; @@ -1049,10 +1067,15 @@ namespace ts { export interface TypeOperatorNode extends TypeNode { kind: SyntaxKind.TypeOperator; - operator: SyntaxKind.KeyOfKeyword; + operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword; type: TypeNode; } + /* @internal */ + export interface UniqueTypeOperatorNode extends TypeOperatorNode { + operator: SyntaxKind.UniqueKeyword; + } + export interface IndexedAccessTypeNode extends TypeNode { kind: SyntaxKind.IndexedAccessType; objectType: TypeNode; @@ -1451,20 +1474,25 @@ namespace ts { } /* @internal */ - export const enum NumericLiteralFlags { + export const enum TokenFlags { None = 0, - Scientific = 1 << 1, // e.g. `10e2` - Octal = 1 << 2, // e.g. `0777` - HexSpecifier = 1 << 3, // e.g. `0x00000000` - BinarySpecifier = 1 << 4, // e.g. `0b0110010000000000` - OctalSpecifier = 1 << 5, // e.g. `0o777` + PrecedingLineBreak = 1 << 0, + PrecedingJSDocComment = 1 << 1, + Unterminated = 1 << 2, + ExtendedUnicodeEscape = 1 << 3, + Scientific = 1 << 4, // e.g. `10e2` + Octal = 1 << 5, // e.g. `0777` + HexSpecifier = 1 << 6, // e.g. `0x00000000` + BinarySpecifier = 1 << 7, // e.g. `0b0110010000000000` + OctalSpecifier = 1 << 8, // e.g. `0o777` BinaryOrOctalSpecifier = BinarySpecifier | OctalSpecifier, + NumericLiteralFlags = Scientific | Octal | HexSpecifier | BinarySpecifier | OctalSpecifier } export interface NumericLiteral extends LiteralExpression { kind: SyntaxKind.NumericLiteral; /* @internal */ - numericLiteralFlags?: NumericLiteralFlags; + numericLiteralFlags?: TokenFlags; } export interface TemplateHead extends LiteralLikeNode { @@ -2860,6 +2888,7 @@ namespace ts { trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void; reportInaccessibleThisError(): void; reportPrivateInBaseOfClassExpression(propertyName: string): void; + reportInaccessibleUniqueSymbolError(): void; } export const enum TypeFormatFlags { @@ -2880,6 +2909,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 { @@ -2981,6 +3011,7 @@ namespace ts { isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean; getNodeCheckFlags(node: Node): NodeCheckFlags; isDeclarationVisible(node: Declaration): boolean; + isLateBound(node: Declaration): node is LateBoundDeclaration; collectLinkedAliases(node: Identifier): Node[]; isImplementationOfOverload(node: FunctionLikeDeclaration): boolean | undefined; isRequiredInitializedParameter(node: ParameterDeclaration): boolean; @@ -3088,6 +3119,9 @@ namespace ts { // The set of things we consider semantically classifiable. Used to speed up the LS during // classification. Classifiable = Class | Enum | TypeAlias | Interface | TypeParameter | Module, + + /* @internal */ + LateBindingContainer = Class | Interface | TypeLiteral | ObjectLiteral, } export interface Symbol { @@ -3119,19 +3153,21 @@ namespace ts { instantiations?: Map; // Instantiations of generic type alias (undefined if non-generic) mapper?: TypeMapper; // Type mapper for instantiation alias referenced?: boolean; // True if alias symbol has been referenced as a value - containingType?: UnionOrIntersectionType; // Containing union or intersection type for synthetic property + containingType?: UnionOrIntersectionType; // Containing union or intersection type for synthetic property leftSpread?: Symbol; // Left source for synthetic spread property rightSpread?: Symbol; // Right source for synthetic spread property syntheticOrigin?: Symbol; // For a property on a mapped or spread type, points back to the original property syntheticLiteralTypeOrigin?: StringLiteralType; // For a property on a mapped type, indicates the type whose text to use as the declaration name, instead of the symbol name isDiscriminantProperty?: boolean; // True if discriminant synthetic property - resolvedExports?: SymbolTable; // Resolved exports of module + resolvedExports?: SymbolTable; // Resolved exports of module or combined early- and late-bound static members of a class. + resolvedMembers?: SymbolTable; // Combined early- and late-bound members of a symbol exportsChecked?: boolean; // True if exports of external module have been checked typeParametersChecked?: boolean; // True if type parameters of merged class and interface declarations have been checked. - isDeclarationWithCollidingName?: boolean; // True if symbol is block scoped redeclaration + isDeclarationWithCollidingName?: boolean; // True if symbol is block scoped redeclaration bindingElement?: BindingElement; // Binding element associated with property symbol exportsSomeValue?: boolean; // True if module exports some value (not just types) enumKind?: EnumKind; // Enum declaration classification + lateSymbol?: Symbol; // Late-bound symbol for a computed property } /* @internal */ @@ -3152,6 +3188,7 @@ namespace ts { ContainsProtected = 1 << 7, // Synthetic property with protected constituent(s) ContainsPrivate = 1 << 8, // Synthetic property with private constituent(s) ContainsStatic = 1 << 9, // Synthetic property with static constituent(s) + Late = 1 << 10, // Late-bound symbol for a computed property with a dynamic name Synthetic = SyntheticProperty | SyntheticMethod } @@ -3281,45 +3318,49 @@ namespace ts { BooleanLiteral = 1 << 7, EnumLiteral = 1 << 8, // Always combined with StringLiteral, NumberLiteral, or Union ESSymbol = 1 << 9, // Type of symbol primitive introduced in ES6 - Void = 1 << 10, - Undefined = 1 << 11, - Null = 1 << 12, - Never = 1 << 13, // Never type - TypeParameter = 1 << 14, // Type parameter - Object = 1 << 15, // Object type - Union = 1 << 16, // Union (T | U) - Intersection = 1 << 17, // Intersection (T & U) - Index = 1 << 18, // keyof T - IndexedAccess = 1 << 19, // T[K] + UniqueESSymbol = 1 << 10, // unique symbol + Void = 1 << 11, + Undefined = 1 << 12, + Null = 1 << 13, + Never = 1 << 14, // Never type + TypeParameter = 1 << 15, // Type parameter + Object = 1 << 16, // Object type + Union = 1 << 17, // Union (T | U) + Intersection = 1 << 18, // Intersection (T & U) + Index = 1 << 19, // keyof T + IndexedAccess = 1 << 20, // T[K] /* @internal */ - FreshLiteral = 1 << 20, // Fresh literal type + FreshLiteral = 1 << 21, // Fresh literal or unique type /* @internal */ - ContainsWideningType = 1 << 21, // Type is or contains undefined or null widening type + ContainsWideningType = 1 << 22, // Type is or contains undefined or null widening type /* @internal */ - ContainsObjectLiteral = 1 << 22, // Type is or contains object literal type + ContainsObjectLiteral = 1 << 23, // Type is or contains object literal type /* @internal */ - ContainsAnyFunctionType = 1 << 23, // Type is or contains the anyFunctionType - NonPrimitive = 1 << 24, // intrinsic object type + ContainsAnyFunctionType = 1 << 24, // Type is or contains the anyFunctionType + NonPrimitive = 1 << 25, // intrinsic object type /* @internal */ - JsxAttributes = 1 << 25, // Jsx attributes type - MarkerType = 1 << 26, // Marker type used for variance probing + JsxAttributes = 1 << 26, // Jsx attributes type + MarkerType = 1 << 27, // Marker type used for variance probing /* @internal */ Nullable = Undefined | Null, Literal = StringLiteral | NumberLiteral | BooleanLiteral, - Unit = Literal | Nullable, + Unit = Literal | UniqueESSymbol | Nullable, StringOrNumberLiteral = StringLiteral | NumberLiteral, /* @internal */ + StringOrNumberLiteralOrUnique = StringOrNumberLiteral | UniqueESSymbol, + /* @internal */ DefinitelyFalsy = StringLiteral | NumberLiteral | BooleanLiteral | Void | Undefined | Null, PossiblyFalsy = DefinitelyFalsy | String | Number | Boolean, /* @internal */ Intrinsic = Any | String | Number | Boolean | BooleanLiteral | ESSymbol | Void | Undefined | Null | Never | NonPrimitive, /* @internal */ - Primitive = String | Number | Boolean | Enum | EnumLiteral | ESSymbol | Void | Undefined | Null | Literal, + Primitive = String | Number | Boolean | Enum | EnumLiteral | ESSymbol | Void | Undefined | Null | Literal | UniqueESSymbol, StringLike = String | StringLiteral | Index, NumberLike = Number | NumberLiteral | Enum, BooleanLike = Boolean | BooleanLiteral, EnumLike = Enum | EnumLiteral, + ESSymbolLike = ESSymbol | UniqueESSymbol, UnionOrIntersection = Union | Intersection, StructuredType = Object | Union | Intersection, StructuredOrTypeVariable = StructuredType | TypeParameter | Index | IndexedAccess, @@ -3327,12 +3368,12 @@ namespace ts { // 'Narrowable' types are types where narrowing actually narrows. // This *should* be every type other than null, undefined, void, and never - Narrowable = Any | StructuredType | TypeParameter | Index | IndexedAccess | StringLike | NumberLike | BooleanLike | ESSymbol | NonPrimitive, + Narrowable = Any | StructuredType | TypeParameter | Index | IndexedAccess | StringLike | NumberLike | BooleanLike | ESSymbol | UniqueESSymbol | NonPrimitive, NotUnionOrUnit = Any | ESSymbol | Object | NonPrimitive, /* @internal */ RequiresWidening = ContainsWideningType | ContainsObjectLiteral, /* @internal */ - PropagatingFlags = ContainsWideningType | ContainsObjectLiteral | ContainsAnyFunctionType + PropagatingFlags = ContainsWideningType | ContainsObjectLiteral | ContainsAnyFunctionType, } export type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; @@ -3362,6 +3403,11 @@ namespace ts { regularType?: LiteralType; // Regular version of type } + // Unique symbol types (TypeFlags.UniqueESSymbol) + export interface UniqueESSymbolType extends Type { + symbol: Symbol; + } + export interface StringLiteralType extends LiteralType { value: string; } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index cee907e12e050..90e217abe4fc5 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -56,6 +56,7 @@ namespace ts { clear: () => str = "", trackSymbol: noop, reportInaccessibleThisError: noop, + reportInaccessibleUniqueSymbolError: noop, reportPrivateInBaseOfClassExpression: noop, }; } @@ -910,6 +911,18 @@ namespace ts { } } + export function getMembersOfDeclaration(node: Declaration): NodeArray | undefined { + switch (node.kind) { + case SyntaxKind.InterfaceDeclaration: + case SyntaxKind.ClassDeclaration: + case SyntaxKind.ClassExpression: + case SyntaxKind.TypeLiteral: + return (node).members; + case SyntaxKind.ObjectLiteralExpression: + return (node).properties; + } + } + export function isVariableLike(node: Node): node is VariableLikeDeclaration { if (node) { switch (node.kind) { @@ -927,6 +940,17 @@ namespace ts { return false; } + export function isVariableDeclarationInVariableStatement(node: VariableDeclaration) { + return node.parent.kind === SyntaxKind.VariableDeclarationList + && 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: @@ -1623,16 +1647,22 @@ namespace ts { return undefined; } const name = node.name.escapedText; + const decl = getHostSignatureFromJSDoc(node); + if (!decl) { + return undefined; + } + const parameter = find(decl.parameters, p => p.name.kind === SyntaxKind.Identifier && p.name.escapedText === name); + return parameter && parameter.symbol; + } + + export function getHostSignatureFromJSDoc(node: JSDocParameterTag): FunctionLike | undefined { const host = getJSDocHost(node); const decl = getSourceOfAssignment(host) || getSingleInitializerOfVariableStatement(host) || getSingleVariableOfVariableStatement(host) || getNestedModuleDeclaration(host) || host; - if (decl && isFunctionLike(decl)) { - const parameter = find(decl.parameters, p => p.name.kind === SyntaxKind.Identifier && p.name.escapedText === name); - return parameter && parameter.symbol; - } + return decl && isFunctionLike(decl) ? decl : undefined; } export function getJSDocHost(node: JSDocTag): HasJSDoc { @@ -1707,15 +1737,27 @@ namespace ts { return getAssignmentTargetKind(node) !== AssignmentKind.None; } + function walkUp(node: Node, kind: SyntaxKind) { + while (node && node.kind === kind) { + node = node.parent; + } + return node; + } + + export function walkUpParenthesizedTypes(node: Node) { + return walkUp(node, SyntaxKind.ParenthesizedType); + } + + export function walkUpParenthesizedExpressions(node: Node) { + return walkUp(node, SyntaxKind.ParenthesizedExpression); + } + // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped export function isDeleteTarget(node: Node): boolean { if (node.kind !== SyntaxKind.PropertyAccessExpression && node.kind !== SyntaxKind.ElementAccessExpression) { return false; } - node = node.parent; - while (node && node.kind === SyntaxKind.ParenthesizedExpression) { - node = node.parent; - } + node = walkUpParenthesizedExpressions(node.parent); return node && node.kind === SyntaxKind.DeleteExpression; } @@ -1975,7 +2017,7 @@ namespace ts { * is a property of the Symbol constructor that denotes a built in * Symbol. */ - export function hasDynamicName(declaration: Declaration): boolean { + export function hasDynamicName(declaration: Declaration): declaration is DynamicNamedDeclaration { const name = getNameOfDeclaration(declaration); return name && isDynamicName(name); } @@ -3021,6 +3063,14 @@ namespace ts { return !!getSelectedModifierFlags(node, flags); } + export function hasStaticModifier(node: Node): boolean { + return hasModifier(node, ModifierFlags.Static); + } + + export function hasReadonlyModifier(node: Node): boolean { + return hasModifier(node, ModifierFlags.Readonly); + } + export function getSelectedModifierFlags(node: Node, flags: ModifierFlags): ModifierFlags { return getModifierFlags(node) & flags; } diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index a49a0a805d96c..c185d99f8e970 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1703,8 +1703,8 @@ Actual: ${stringify(fullActual)}`); Harness.IO.log(stringify(sigHelp)); } - public printCompletionListMembers() { - const completions = this.getCompletionListAtCaret(); + public printCompletionListMembers(options: ts.GetCompletionsAtPositionOptions | undefined) { + const completions = this.getCompletionListAtCaret(options); this.printMembersOrCompletions(completions); } @@ -2549,6 +2549,9 @@ Actual: ${stringify(fullActual)}`); } const sortedExpectedArray = expectedTextArray.sort(); const sortedActualArray = actualTextArray.sort(); + if (sortedExpectedArray.length !== sortedActualArray.length) { + this.raiseError(`Expected ${sortedExpectedArray.length} import fixes, got ${sortedActualArray.length}`); + } ts.zipWith(sortedExpectedArray, sortedActualArray, (expected, actual, index) => { if (expected !== actual) { this.raiseError(`Import fix at index ${index} doesn't match.\n${showTextDiff(expected, actual)}`); @@ -2867,7 +2870,7 @@ Actual: ${stringify(fullActual)}`); if (negative) { if (codeFixes.length) { - this.raiseError(`verifyCodeFixAvailable failed - expected no fixes but found one.`); + this.raiseError(`verifyCodeFixAvailable failed - expected no fixes but found ${codeFixes.map(c => c.description)}.`); } return; } @@ -3073,45 +3076,45 @@ Actual: ${stringify(fullActual)}`); hasAction: boolean | undefined, options: FourSlashInterface.VerifyCompletionListContainsOptions | undefined, ) { - for (const item of items) { - if (item.name === entryId.name && item.source === entryId.source) { - if (documentation !== undefined || text !== undefined || entryId.source !== undefined) { - const details = this.getCompletionEntryDetails(item.name, item.source); - - if (documentation !== undefined) { - assert.equal(ts.displayPartsToString(details.documentation), documentation, this.assertionMessageAtLastKnownMarker("completion item documentation for " + entryId)); - } - if (text !== undefined) { - assert.equal(ts.displayPartsToString(details.displayParts), text, this.assertionMessageAtLastKnownMarker("completion item detail text for " + entryId)); - } - - if (entryId.source === undefined) { - assert.equal(options && options.sourceDisplay, undefined); - } - else { - assert.deepEqual(details.source, [ts.textPart(options!.sourceDisplay)]); - } - } - - if (kind !== undefined) { - assert.equal(item.kind, kind, this.assertionMessageAtLastKnownMarker("completion item kind for " + entryId)); - } + const matchingItems = items.filter(item => item.name === entryId.name && item.source === entryId.source); + if (matchingItems.length === 0) { + const itemsString = items.map(item => stringify({ name: item.name, source: item.source, kind: item.kind })).join(",\n"); + this.raiseError(`Expected "${stringify({ entryId, text, documentation, kind })}" to be in list [${itemsString}]`); + } + else if (matchingItems.length > 1 && !(options && options.allowDuplicate)) { + this.raiseError(`Found duplicate completion items for ${stringify(entryId)}`); + } + const item = matchingItems[0]; - if (spanIndex !== undefined) { - const span = this.getTextSpanForRangeAtIndex(spanIndex); - assert.isTrue(TestState.textSpansEqual(span, item.replacementSpan), this.assertionMessageAtLastKnownMarker(stringify(span) + " does not equal " + stringify(item.replacementSpan) + " replacement span for " + entryId)); - } + if (documentation !== undefined || text !== undefined || entryId.source !== undefined) { + const details = this.getCompletionEntryDetails(item.name, item.source); - assert.equal(item.hasAction, hasAction, "hasAction"); - assert.equal(item.isRecommended, options && options.isRecommended, "isRecommended"); + if (documentation !== undefined) { + assert.equal(ts.displayPartsToString(details.documentation), documentation, this.assertionMessageAtLastKnownMarker("completion item documentation for " + entryId)); + } + if (text !== undefined) { + assert.equal(ts.displayPartsToString(details.displayParts), text, this.assertionMessageAtLastKnownMarker("completion item detail text for " + entryId)); + } - return; + if (entryId.source === undefined) { + assert.equal(options && options.sourceDisplay, undefined); } + else { + assert.deepEqual(details.source, [ts.textPart(options!.sourceDisplay)]); + } + } + + if (kind !== undefined) { + assert.equal(item.kind, kind, this.assertionMessageAtLastKnownMarker("completion item kind for " + entryId)); } - const itemsString = items.map(item => stringify({ name: item.name, source: item.source, kind: item.kind })).join(",\n"); + if (spanIndex !== undefined) { + const span = this.getTextSpanForRangeAtIndex(spanIndex); + assert.isTrue(TestState.textSpansEqual(span, item.replacementSpan), this.assertionMessageAtLastKnownMarker(stringify(span) + " does not equal " + stringify(item.replacementSpan) + " replacement span for " + entryId)); + } - this.raiseError(`Expected "${stringify({ entryId, text, documentation, kind })}" to be in list [${itemsString}]`); + assert.equal(item.hasAction, hasAction); + assert.equal(item.isRecommended, options && options.isRecommended, "isRecommended"); } private findFile(indexOrName: string | number) { @@ -4356,8 +4359,8 @@ namespace FourSlashInterface { this.state.printCurrentSignatureHelp(); } - public printCompletionListMembers() { - this.state.printCompletionListMembers(); + public printCompletionListMembers(options: ts.GetCompletionsAtPositionOptions | undefined) { + this.state.printCompletionListMembers(options); } public printAvailableCodeFixes() { @@ -4557,6 +4560,7 @@ namespace FourSlashInterface { export interface VerifyCompletionListContainsOptions extends ts.GetCompletionsAtPositionOptions { sourceDisplay: string; isRecommended?: true; + allowDuplicate?: true; // TODO: GH#20042 } export interface NewContentOptions { diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index ea573726eb8c4..3525774b21cf9 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -1482,7 +1482,7 @@ namespace ts.projectSystem { it("ignores files excluded by a custom safe type list", () => { const file1 = { - path: "/a/b/f1.ts", + path: "/a/b/f1.js", content: "export let x = 5" }; const office = { @@ -1503,7 +1503,7 @@ namespace ts.projectSystem { it("ignores files excluded by the default type list", () => { const file1 = { - path: "/a/b/f1.ts", + path: "/a/b/f1.js", content: "export let x = 5" }; const minFile = { diff --git a/src/harness/unittests/typingsInstaller.ts b/src/harness/unittests/typingsInstaller.ts index e321fb1c99ddc..393d55a5ea438 100644 --- a/src/harness/unittests/typingsInstaller.ts +++ b/src/harness/unittests/typingsInstaller.ts @@ -304,35 +304,35 @@ namespace ts.projectSystem { // 1. react typings are installed for .jsx // 2. loose files names are matched against safe list for typings if // this is a JS project (only js, jsx, d.ts files are present) - const file1 = { + const lodashJs = { path: "/a/b/lodash.js", content: "" }; - const file2 = { + const file2Jsx = { path: "/a/b/file2.jsx", content: "" }; - const file3 = { + const file3dts = { path: "/a/b/file3.d.ts", content: "" }; - const react = { + const reactDts = { path: "/a/data/node_modules/@types/react/index.d.ts", content: "declare const react: { x: number }" }; - const lodash = { + const lodashDts = { path: "/a/data/node_modules/@types/lodash/index.d.ts", content: "declare const lodash: { x: number }" }; - const host = createServerHost([file1, file2, file3, customTypesMap]); + const host = createServerHost([lodashJs, file2Jsx, file3dts, customTypesMap]); const installer = new (class extends Installer { constructor() { super(host, { typesRegistry: createTypesRegistry("lodash", "react") }); } installWorker(_requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction): void { const installedTypings = ["@types/lodash", "@types/react"]; - const typingFiles = [lodash, react]; + const typingFiles = [lodashDts, reactDts]; executeCommand(this, host, installedTypings, typingFiles, cb); } })(); @@ -342,35 +342,74 @@ namespace ts.projectSystem { projectService.openExternalProject({ projectFileName, options: { allowJS: true, moduleResolution: ModuleResolutionKind.NodeJs }, - rootFiles: [toExternalFile(file1.path), toExternalFile(file2.path), toExternalFile(file3.path)], - typeAcquisition: {} + rootFiles: [toExternalFile(lodashJs.path), toExternalFile(file2Jsx.path), toExternalFile(file3dts.path)], + typeAcquisition: { } }); const p = projectService.externalProjects[0]; projectService.checkNumberOfProjects({ externalProjects: 1 }); - checkProjectActualFiles(p, [file1.path, file2.path, file3.path]); + checkProjectActualFiles(p, [file2Jsx.path, file3dts.path]); installer.installAll(/*expectedCount*/ 1); checkNumberOfProjects(projectService, { externalProjects: 1 }); host.checkTimeoutQueueLengthAndRun(2); checkNumberOfProjects(projectService, { externalProjects: 1 }); - checkProjectActualFiles(p, [file1.path, file2.path, file3.path, lodash.path, react.path]); + checkProjectActualFiles(p, [file2Jsx.path, file3dts.path, lodashDts.path, reactDts.path]); }); + it("external project - type acquisition with enable: false", () => { + // Tests: + // Exclude + const jqueryJs = { + path: "/a/b/jquery.js", + content: "" + }; + + const host = createServerHost([jqueryJs]); + const installer = new (class extends Installer { + constructor() { + super(host, { typesRegistry: createTypesRegistry("jquery") }); + } + enqueueInstallTypingsRequest(project: server.Project, typeAcquisition: TypeAcquisition, unresolvedImports: server.SortedReadonlyArray) { + super.enqueueInstallTypingsRequest(project, typeAcquisition, unresolvedImports); + } + installWorker(_requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction): void { + const installedTypings: string[] = []; + const typingFiles: FileOrFolder[] = []; + executeCommand(this, host, installedTypings, typingFiles, cb); + } + })(); + + const projectFileName = "/a/app/test.csproj"; + const projectService = createProjectService(host, { typingsInstaller: installer }); + projectService.openExternalProject({ + projectFileName, + options: { allowJS: true, moduleResolution: ModuleResolutionKind.NodeJs }, + rootFiles: [toExternalFile(jqueryJs.path)], + typeAcquisition: { enable: false } + }); + + const p = projectService.externalProjects[0]; + projectService.checkNumberOfProjects({ externalProjects: 1 }); + + checkProjectActualFiles(p, [jqueryJs.path]); + + installer.checkPendingCommands(/*expectedCount*/ 0); + }); it("external project - no type acquisition, with js & ts files", () => { // Tests: // 1. No typings are included for JS projects when the project contains ts files - const file1 = { + const jqueryJs = { path: "/a/b/jquery.js", content: "" }; - const file2 = { + const file2Ts = { path: "/a/b/file2.ts", content: "" }; - const host = createServerHost([file1, file2]); + const host = createServerHost([jqueryJs, file2Ts]); const installer = new (class extends Installer { constructor() { super(host, { typesRegistry: createTypesRegistry("jquery") }); @@ -390,18 +429,19 @@ namespace ts.projectSystem { projectService.openExternalProject({ projectFileName, options: { allowJS: true, moduleResolution: ModuleResolutionKind.NodeJs }, - rootFiles: [toExternalFile(file1.path), toExternalFile(file2.path)], + rootFiles: [toExternalFile(jqueryJs.path), toExternalFile(file2Ts.path)], typeAcquisition: {} }); const p = projectService.externalProjects[0]; projectService.checkNumberOfProjects({ externalProjects: 1 }); - checkProjectActualFiles(p, [file2.path]); + + checkProjectActualFiles(p, [jqueryJs.path, file2Ts.path]); installer.checkPendingCommands(/*expectedCount*/ 0); checkNumberOfProjects(projectService, { externalProjects: 1 }); - checkProjectActualFiles(p, [file2.path]); + checkProjectActualFiles(p, [jqueryJs.path, file2Ts.path]); }); it("external project - with type acquisition, with only js, d.ts files", () => { @@ -409,15 +449,15 @@ namespace ts.projectSystem { // 1. Safelist matching, type acquisition includes/excludes and package.json typings are all acquired // 2. Types for safelist matches are not included when they also appear in the type acquisition exclude list // 3. Multiple includes and excludes are respected in type acquisition - const file1 = { + const lodashJs = { path: "/a/b/lodash.js", content: "" }; - const file2 = { + const commanderJs = { path: "/a/b/commander.js", content: "" }; - const file3 = { + const file3dts = { path: "/a/b/file3.d.ts", content: "" }; @@ -448,7 +488,7 @@ namespace ts.projectSystem { content: "declare const moment: { x: number }" }; - const host = createServerHost([file1, file2, file3, packageJson, customTypesMap]); + const host = createServerHost([lodashJs, commanderJs, file3dts, packageJson, customTypesMap]); const installer = new (class extends Installer { constructor() { super(host, { typesRegistry: createTypesRegistry("jquery", "commander", "moment", "express") }); @@ -465,20 +505,25 @@ namespace ts.projectSystem { projectService.openExternalProject({ projectFileName, options: { allowJS: true, moduleResolution: ModuleResolutionKind.NodeJs }, - rootFiles: [toExternalFile(file1.path), toExternalFile(file2.path), toExternalFile(file3.path)], - typeAcquisition: { include: ["jquery", "moment"], exclude: ["lodash"] } + rootFiles: [toExternalFile(lodashJs.path), toExternalFile(commanderJs.path), toExternalFile(file3dts.path)], + typeAcquisition: { enable: true, include: ["jquery", "moment"], exclude: ["lodash"] } }); const p = projectService.externalProjects[0]; projectService.checkNumberOfProjects({ externalProjects: 1 }); - checkProjectActualFiles(p, [file1.path, file2.path, file3.path]); + checkProjectActualFiles(p, [file3dts.path]); installer.installAll(/*expectedCount*/ 1); checkNumberOfProjects(projectService, { externalProjects: 1 }); host.checkTimeoutQueueLengthAndRun(2); checkNumberOfProjects(projectService, { externalProjects: 1 }); - checkProjectActualFiles(p, [file1.path, file2.path, file3.path, commander.path, express.path, jquery.path, moment.path]); + // Commander: Existed as a JS file + // JQuery: Specified in 'include' + // Moment: Specified in 'include' + // Express: Specified in package.json + // lodash: Excluded (not present) + checkProjectActualFiles(p, [file3dts.path, commander.path, jquery.path, moment.path, express.path]); }); it("Throttle - delayed typings to install", () => { @@ -548,7 +593,7 @@ namespace ts.projectSystem { const p = projectService.externalProjects[0]; projectService.checkNumberOfProjects({ externalProjects: 1 }); - checkProjectActualFiles(p, [lodashJs.path, commanderJs.path, file3.path]); + checkProjectActualFiles(p, [file3.path]); installer.checkPendingCommands(/*expectedCount*/ 1); installer.executePendingCommands(); // expected all typings file to exist @@ -557,7 +602,7 @@ namespace ts.projectSystem { } host.checkTimeoutQueueLengthAndRun(2); checkNumberOfProjects(projectService, { externalProjects: 1 }); - checkProjectActualFiles(p, [lodashJs.path, commanderJs.path, file3.path, commander.path, express.path, jquery.path, moment.path, lodash.path]); + checkProjectActualFiles(p, [file3.path, commander.path, express.path, jquery.path, moment.path, lodash.path]); }); it("Throttle - delayed run install requests", () => { @@ -648,7 +693,7 @@ namespace ts.projectSystem { const p1 = projectService.externalProjects[0]; const p2 = projectService.externalProjects[1]; projectService.checkNumberOfProjects({ externalProjects: 2 }); - checkProjectActualFiles(p1, [lodashJs.path, commanderJs.path, file3.path]); + checkProjectActualFiles(p1, [file3.path]); checkProjectActualFiles(p2, [file3.path]); installer.executePendingCommands(); @@ -659,7 +704,7 @@ namespace ts.projectSystem { installer.executePendingCommands(); host.checkTimeoutQueueLengthAndRun(3); // for 2 projects and 1 refreshing inferred project - checkProjectActualFiles(p1, [lodashJs.path, commanderJs.path, file3.path, commander.path, jquery.path, lodash.path, cordova.path]); + checkProjectActualFiles(p1, [file3.path, commander.path, jquery.path, lodash.path, cordova.path]); checkProjectActualFiles(p2, [file3.path, grunt.path, gulp.path]); }); @@ -973,7 +1018,7 @@ namespace ts.projectSystem { } }; session.executeCommand(changeRequest); - host.checkTimeoutQueueLengthAndRun(2); // This enqueues the updategraph and refresh inferred projects + host.checkTimeoutQueueLengthAndRun(0); // This enqueues the updategraph and refresh inferred projects const version2 = proj.getCachedUnresolvedImportsPerFile_TestOnly().getVersion(); assert.equal(version1, version2, "set of unresolved imports should not change"); }); diff --git a/src/harness/virtualFileSystemWithWatch.ts b/src/harness/virtualFileSystemWithWatch.ts index 25581093f3dd6..d4d203cabbbe1 100644 --- a/src/harness/virtualFileSystemWithWatch.ts +++ b/src/harness/virtualFileSystemWithWatch.ts @@ -144,9 +144,9 @@ interface Array {}` } export function checkFileNames(caption: string, actualFileNames: ReadonlyArray, expectedFileNames: string[]) { - assert.equal(actualFileNames.length, expectedFileNames.length, `${caption}: incorrect actual number of files, expected ${expectedFileNames}, got ${actualFileNames}`); + assert.equal(actualFileNames.length, expectedFileNames.length, `${caption}: incorrect actual number of files, expected:\r\n${expectedFileNames.join("\r\n")}\r\ngot: ${actualFileNames.join("\r\n")}`); for (const f of expectedFileNames) { - assert.isTrue(contains(actualFileNames, f), `${caption}: expected to find ${f} in ${actualFileNames}`); + assert.equal(true, contains(actualFileNames, f), `${caption}: expected to find ${f} in ${actualFileNames}`); } } diff --git a/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl index a55da48f2c233..b840d498fc597 100644 --- a/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1614,6 +1614,9 @@ + + + @@ -5274,24 +5277,36 @@ + + + + + + + + + + + + @@ -6003,18 +6018,27 @@ + + + + + + + + + @@ -6048,18 +6072,27 @@ + + + + + + + + + diff --git a/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl index 3bb9642d207df..20ef6bead259b 100644 --- a/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1623,6 +1623,9 @@ + + + @@ -5283,24 +5286,36 @@ + + + + + + + + + + + + @@ -6012,18 +6027,27 @@ + + + + + + + + + @@ -6057,18 +6081,27 @@ + + + + + + + + + diff --git a/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl index d362101e51f8f..b44c64df54b8d 100644 --- a/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1608,6 +1608,9 @@ + + + @@ -5262,24 +5265,36 @@ + + + + + + + + + + + + @@ -5985,18 +6000,27 @@ + + + + + + + + + @@ -6030,18 +6054,27 @@ + + + + + + + + + diff --git a/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl index 58a00519e044a..d22a3ecd34cb9 100644 --- a/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1623,6 +1623,9 @@ + + + @@ -4128,6 +4131,15 @@ + + + + + + + + + @@ -5283,24 +5295,36 @@ + + + + + + + + + + + + @@ -6012,18 +6036,27 @@ + + + + + + + + + @@ -6057,18 +6090,27 @@ + + + + + + + + + diff --git a/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl index 803d5940ac256..8f93f56d3a5fb 100644 --- a/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1623,6 +1623,9 @@ + + + @@ -5283,24 +5286,36 @@ + + + + + + + + + + + + @@ -6012,18 +6027,27 @@ + + + + + + + + + @@ -6057,18 +6081,27 @@ + + + + + + + + + diff --git a/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl index 6ea7ba86fc76a..2de627949fb82 100644 --- a/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1614,6 +1614,9 @@ + + + @@ -5274,24 +5277,36 @@ + + + + + + + + + + + + @@ -6003,18 +6018,27 @@ + + + + + + + + + @@ -6048,18 +6072,27 @@ + + + + + + + + + diff --git a/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl index 80c5f4e15d2fb..77eb0455379b4 100644 --- a/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1614,6 +1614,9 @@ + + + @@ -5274,24 +5277,36 @@ + + + + + + + + + + + + @@ -5434,7 +5449,7 @@ - + @@ -6003,18 +6018,27 @@ + + + + + + + + + @@ -6048,18 +6072,27 @@ + + + + + + + + + @@ -7921,7 +7954,7 @@ - + diff --git a/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl index 0badf531a7552..1b11c502992b4 100644 --- a/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1601,6 +1601,9 @@ + + + @@ -5255,24 +5258,36 @@ + + + + + + + + + + + + @@ -5978,18 +5993,27 @@ + + + + + + + + + @@ -6023,18 +6047,27 @@ + + + + + + + + + diff --git a/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl index b71915fbd67be..6d200bf7e3b43 100644 --- a/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1613,6 +1613,9 @@ + + + @@ -5273,24 +5276,36 @@ + + + + + + + + + + + + @@ -6002,18 +6017,27 @@ + + + + + + + + + @@ -6047,18 +6071,27 @@ + + + + + + + + + diff --git a/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl index 6c92a1c0bd16f..5cba29af5e269 100644 --- a/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1607,6 +1607,9 @@ + + + @@ -5267,24 +5270,36 @@ + + + + + + + + + + + + @@ -5996,18 +6011,27 @@ + + + + + + + + + @@ -6041,18 +6065,27 @@ + + + + + + + + + diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 726621a540dc3..00fbdf528099d 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -2193,8 +2193,13 @@ namespace ts.server { applySafeList(proj: protocol.ExternalProject): NormalizedPath[] { const { rootFiles, typeAcquisition } = proj; - const types = (typeAcquisition && typeAcquisition.include) || []; + Debug.assert(!!typeAcquisition, "proj.typeAcquisition should be set by now"); + // If type acquisition has been explicitly disabled, do not exclude anything from the project + if (typeAcquisition.enable === false) { + return []; + } + const typeAcqInclude = typeAcquisition.include || (typeAcquisition.include = []); const excludeRules: string[] = []; const normalizedNames = rootFiles.map(f => normalizeSlashes(f.fileName)) as NormalizedPath[]; @@ -2209,8 +2214,10 @@ namespace ts.server { // If the file matches, collect its types packages and exclude rules if (rule.types) { for (const type of rule.types) { - if (types.indexOf(type) < 0) { - types.push(type); + // Best-effort de-duping here - doesn't need to be unduplicated but + // we don't want the list to become a 400-element array of just 'kendo' + if (typeAcqInclude.indexOf(type) < 0) { + typeAcqInclude.push(type); } } } @@ -2248,12 +2255,6 @@ namespace ts.server { } } } - - // Copy back this field into the project if needed - if (types.length > 0) { - proj.typeAcquisition = proj.typeAcquisition || {}; - proj.typeAcquisition.include = types; - } } const excludeRegexes = excludeRules.map(e => new RegExp(e, "i")); @@ -2264,7 +2265,7 @@ namespace ts.server { } else { let exclude = false; - if (typeAcquisition && (typeAcquisition.enable || typeAcquisition.enableAutoDiscovery)) { + if (typeAcquisition.enable || typeAcquisition.enableAutoDiscovery) { const baseName = getBaseFileName(normalizedNames[i].toLowerCase()); if (fileExtensionIs(baseName, "js")) { const inferredTypingName = removeFileExtension(baseName); @@ -2272,7 +2273,14 @@ namespace ts.server { if (this.legacySafelist[cleanedTypingName]) { this.logger.info(`Excluded '${normalizedNames[i]}' because it matched ${cleanedTypingName} from the legacy safelist`); excludedFiles.push(normalizedNames[i]); + // *exclude* it from the project... exclude = true; + // ... but *include* it in the list of types to acquire + const typeName = this.legacySafelist[cleanedTypingName]; + // Same best-effort dedupe as above + if (typeAcqInclude.indexOf(typeName) < 0) { + typeAcqInclude.push(typeName); + } } } } @@ -2292,6 +2300,12 @@ namespace ts.server { const typeAcquisition = convertEnableAutoDiscoveryToEnable(proj.typingOptions); proj.typeAcquisition = typeAcquisition; } + proj.typeAcquisition = proj.typeAcquisition || {}; + proj.typeAcquisition.include = proj.typeAcquisition.include || []; + proj.typeAcquisition.exclude = proj.typeAcquisition.exclude || []; + if (proj.typeAcquisition.enable === undefined) { + proj.typeAcquisition.enable = hasNoTypeScriptSource(proj.rootFiles.map(f => f.fileName)); + } const excludedFiles = this.applySafeList(proj); diff --git a/src/server/project.ts b/src/server/project.ts index d2526ab2abb8a..8988e8b1bec19 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -52,6 +52,11 @@ namespace ts.server { return counts.ts === 0 && counts.tsx === 0; } + /* @internal */ + export function hasNoTypeScriptSource(fileNames: string[]): boolean { + return !fileNames.some(fileName => (fileExtensionIs(fileName, Extension.Ts) && !fileExtensionIs(fileName, Extension.Dts)) || fileExtensionIs(fileName, Extension.Tsx)); + } + /* @internal */ export interface ProjectFilesWithTSDiagnostics extends protocol.ProjectFiles { projectErrors: ReadonlyArray; @@ -1436,26 +1441,10 @@ namespace ts.server { } setTypeAcquisition(newTypeAcquisition: TypeAcquisition): void { - if (!newTypeAcquisition) { - // set default typings options - newTypeAcquisition = { - enable: allRootFilesAreJsOrDts(this), - include: [], - exclude: [] - }; - } - else { - if (newTypeAcquisition.enable === undefined) { - // if autoDiscovery was not specified by the caller - set it based on the content of the project - newTypeAcquisition.enable = allRootFilesAreJsOrDts(this); - } - if (!newTypeAcquisition.include) { - newTypeAcquisition.include = []; - } - if (!newTypeAcquisition.exclude) { - newTypeAcquisition.exclude = []; - } - } + Debug.assert(!!newTypeAcquisition, "newTypeAcquisition may not be null/undefined"); + Debug.assert(!!newTypeAcquisition.include, "newTypeAcquisition.include may not be null/undefined"); + Debug.assert(!!newTypeAcquisition.exclude, "newTypeAcquisition.exclude may not be null/undefined"); + Debug.assert(typeof newTypeAcquisition.enable === "boolean", "newTypeAcquisition.enable may not be null/undefined"); this.typeAcquisition = newTypeAcquisition; } } diff --git a/src/server/typingsInstaller/typingsInstaller.ts b/src/server/typingsInstaller/typingsInstaller.ts index eacbebbf4abf2..63bbc2197891d 100644 --- a/src/server/typingsInstaller/typingsInstaller.ts +++ b/src/server/typingsInstaller/typingsInstaller.ts @@ -123,9 +123,6 @@ namespace ts.server.typingsInstaller { this.log.writeLine(`Finished typings discovery: ${JSON.stringify(discoverTypingsResult)}`); } - // respond with whatever cached typings we have now - this.sendResponse(this.createSetTypings(req, discoverTypingsResult.cachedTypingPaths)); - // start watching files this.watchFiles(req.projectName, discoverTypingsResult.filesToWatch); @@ -134,6 +131,7 @@ namespace ts.server.typingsInstaller { this.installTypings(req, req.cachePath || this.globalCachePath, discoverTypingsResult.cachedTypingPaths, discoverTypingsResult.newTypingNames); } else { + this.sendResponse(this.createSetTypings(req, discoverTypingsResult.cachedTypingPaths)); if (this.log.isEnabled()) { this.log.writeLine(`No new typings were requested as a result of typings discovery`); } diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index 8971d1aa75ecf..cd67d10330cc2 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -322,7 +322,7 @@ namespace ts.codefix { tryGetModuleNameAsNodeModule(options, moduleFileName, host, getCanonicalFileName, sourceDirectory) || tryGetModuleNameFromBaseUrl(options, moduleFileName, getCanonicalFileName) || options.rootDirs && tryGetModuleNameFromRootDirs(options.rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName) || - removeFileExtension(getRelativePath(moduleFileName, sourceDirectory, getCanonicalFileName)); + removeExtensionAndIndexPostFix(getRelativePath(moduleFileName, sourceDirectory, getCanonicalFileName), options); } function tryGetModuleNameFromAmbientModule(moduleSymbol: Symbol): string | undefined { @@ -343,7 +343,7 @@ namespace ts.codefix { } const relativeNameWithIndex = removeFileExtension(relativeName); - relativeName = removeExtensionAndIndexPostFix(relativeName); + relativeName = removeExtensionAndIndexPostFix(relativeName, options); if (options.paths) { for (const key in options.paths) { @@ -393,7 +393,7 @@ namespace ts.codefix { return roots && firstDefined(roots, unNormalizedTypeRoot => { const typeRoot = toPath(unNormalizedTypeRoot, /*basePath*/ undefined, getCanonicalFileName); if (startsWith(moduleFileName, typeRoot)) { - return removeExtensionAndIndexPostFix(moduleFileName.substring(typeRoot.length + 1)); + return removeExtensionAndIndexPostFix(moduleFileName.substring(typeRoot.length + 1), options); } }); } @@ -527,12 +527,9 @@ namespace ts.codefix { return firstDefined(rootDirs, rootDir => getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName)); } - function removeExtensionAndIndexPostFix(fileName: string) { - fileName = removeFileExtension(fileName); - if (endsWith(fileName, "/index")) { - fileName = fileName.substr(0, fileName.length - 6/* "/index".length */); - } - return fileName; + function removeExtensionAndIndexPostFix(fileName: string, options: CompilerOptions): string { + const noExtension = removeFileExtension(fileName); + return getEmitModuleResolutionKind(options) === ModuleResolutionKind.NodeJs ? removeSuffix(noExtension, "/index") : noExtension; } function getRelativePathIfInDirectory(path: string, directoryPath: string, getCanonicalFileName: GetCanonicalFileName): string | undefined { diff --git a/src/services/codefixes/inferFromUsage.ts b/src/services/codefixes/inferFromUsage.ts index 378c73f2f756e..3f03180360d2e 100644 --- a/src/services/codefixes/inferFromUsage.ts +++ b/src/services/codefixes/inferFromUsage.ts @@ -246,6 +246,7 @@ namespace ts.codefix { }, reportInaccessibleThisError: () => { typeIsAccessible = false; }, reportPrivateInBaseOfClassExpression: () => { typeIsAccessible = false; }, + reportInaccessibleUniqueSymbolError: () => { typeIsAccessible = false; } }; } writer.clear(); diff --git a/src/services/completions.ts b/src/services/completions.ts index 9c3edf834a469..ec6f1f2a5b461 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -1059,6 +1059,14 @@ namespace ts.Completions { for (let symbol of typeChecker.getExportsOfModule(moduleSymbol)) { let { name } = symbol; + + // Don't add a completion for a re-export, only for the original. + // If `symbol.parent !== moduleSymbol`, this comes from an `export * from "foo"` re-export. Those don't create new symbols. + // If `some(...)`, this comes from an `export { foo } from "foo"` re-export, which creates a new symbol (thus isn't caught by the first check). + if (symbol.parent !== moduleSymbol || some(symbol.declarations, d => isExportSpecifier(d) && !!d.parent.parent.moduleSpecifier)) { + continue; + } + const isDefaultExport = name === "default"; if (isDefaultExport) { const localSymbol = getLocalSymbolForExportDefault(symbol); @@ -1071,11 +1079,6 @@ namespace ts.Completions { } } - if (symbol.declarations && symbol.declarations.some(d => isExportSpecifier(d) && !!d.parent.parent.moduleSpecifier)) { - // Don't add a completion for a re-export, only for the original. - continue; - } - if (stringContainsCharactersInOrder(name.toLowerCase(), tokenTextLowerCase)) { symbols.push(symbol); symbolToOriginInfoMap[getSymbolId(symbol)] = { moduleSymbol, isDefaultExport }; diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index 5afe4cb1d3190..0a444a7280afd 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -36,24 +36,7 @@ namespace ts.formatting { const enclosingCommentRange = getRangeOfEnclosingComment(sourceFile, position, /*onlyMultiLine*/ true, precedingToken || null); // tslint:disable-line:no-null-keyword if (enclosingCommentRange) { - const previousLine = getLineAndCharacterOfPosition(sourceFile, position).line - 1; - const commentStartLine = getLineAndCharacterOfPosition(sourceFile, enclosingCommentRange.pos).line; - - Debug.assert(commentStartLine >= 0); - - if (previousLine <= commentStartLine) { - return findFirstNonWhitespaceColumn(getStartPositionOfLine(commentStartLine, sourceFile), position, sourceFile, options); - } - - const startPostionOfLine = getStartPositionOfLine(previousLine, sourceFile); - const { column, character } = findFirstNonWhitespaceCharacterAndColumn(startPostionOfLine, position, sourceFile, options); - - if (column === 0) { - return column; - } - - const firstNonWhitespaceCharacterCode = sourceFile.text.charCodeAt(startPostionOfLine + character); - return firstNonWhitespaceCharacterCode === CharacterCodes.asterisk ? column - 1 : column; + return getCommentIndent(sourceFile, position, options, enclosingCommentRange); } if (!precedingToken) { @@ -72,20 +55,7 @@ namespace ts.formatting { // for block indentation, we should look for a line which contains something that's not // whitespace. if (options.indentStyle === IndentStyle.Block) { - - // move backwards until we find a line with a non-whitespace character, - // then find the first non-whitespace character for that line. - let current = position; - while (current > 0) { - const char = sourceFile.text.charCodeAt(current); - if (!isWhiteSpaceLike(char)) { - break; - } - current--; - } - - const lineStart = ts.getLineStartPositionForPosition(current, sourceFile); - return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current, sourceFile, options); + return getBlockIndent(sourceFile, position, options); } if (precedingToken.kind === SyntaxKind.CommaToken && precedingToken.parent.kind !== SyntaxKind.BinaryExpression) { @@ -96,26 +66,60 @@ namespace ts.formatting { } } + return getSmartIndent(sourceFile, position, precedingToken, lineAtPosition, assumeNewLineBeforeCloseBrace, options); + } + + function getCommentIndent(sourceFile: SourceFile, position: number, options: EditorSettings, enclosingCommentRange: CommentRange): number { + const previousLine = getLineAndCharacterOfPosition(sourceFile, position).line - 1; + const commentStartLine = getLineAndCharacterOfPosition(sourceFile, enclosingCommentRange.pos).line; + + Debug.assert(commentStartLine >= 0); + + if (previousLine <= commentStartLine) { + return findFirstNonWhitespaceColumn(getStartPositionOfLine(commentStartLine, sourceFile), position, sourceFile, options); + } + + const startPostionOfLine = getStartPositionOfLine(previousLine, sourceFile); + const { column, character } = findFirstNonWhitespaceCharacterAndColumn(startPostionOfLine, position, sourceFile, options); + + if (column === 0) { + return column; + } + + const firstNonWhitespaceCharacterCode = sourceFile.text.charCodeAt(startPostionOfLine + character); + return firstNonWhitespaceCharacterCode === CharacterCodes.asterisk ? column - 1 : column; + } + + function getBlockIndent(sourceFile: SourceFile, position: number, options: EditorSettings): number { + // move backwards until we find a line with a non-whitespace character, + // then find the first non-whitespace character for that line. + let current = position; + while (current > 0) { + const char = sourceFile.text.charCodeAt(current); + if (!isWhiteSpaceLike(char)) { + break; + } + current--; + } + + const lineStart = ts.getLineStartPositionForPosition(current, sourceFile); + return findFirstNonWhitespaceColumn(lineStart, current, sourceFile, options); + } + + function getSmartIndent(sourceFile: SourceFile, position: number, precedingToken: Node, lineAtPosition: number, assumeNewLineBeforeCloseBrace: boolean, options: EditorSettings): number { // try to find node that can contribute to indentation and includes 'position' starting from 'precedingToken' // if such node is found - compute initial indentation for 'position' inside this node - let previous: Node; + let previous: Node | undefined; let current = precedingToken; - let currentStart: LineAndCharacter; - let indentationDelta: number; - while (current) { - if (positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(current, previous)) { - currentStart = getStartLineAndCharacterForNode(current, sourceFile); - + if (positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(current, previous, /*isNextChild*/ true)) { + const currentStart = getStartLineAndCharacterForNode(current, sourceFile); const nextTokenKind = nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile); - if (nextTokenKind !== NextTokenKind.Unknown) { + const indentationDelta = nextTokenKind !== NextTokenKind.Unknown // handle cases when codefix is about to be inserted before the close brace - indentationDelta = assumeNewLineBeforeCloseBrace && nextTokenKind === NextTokenKind.CloseBrace ? options.indentSize : 0; - } - else { - indentationDelta = lineAtPosition !== currentStart.line ? options.indentSize : 0; - } - break; + ? assumeNewLineBeforeCloseBrace && nextTokenKind === NextTokenKind.CloseBrace ? options.indentSize : 0 + : lineAtPosition !== currentStart.line ? options.indentSize : 0; + return getIndentationForNodeWorker(current, currentStart, /*ignoreActualIndentationRange*/ undefined, indentationDelta, sourceFile, /*isNextChild*/ true, options); } // check if current node is a list item - if yes, take indentation from it @@ -131,18 +135,13 @@ namespace ts.formatting { previous = current; current = current.parent; } - - if (!current) { - // no parent was found - return the base indentation of the SourceFile - return getBaseIndentation(options); - } - - return getIndentationForNodeWorker(current, currentStart, /*ignoreActualIndentationRange*/ undefined, indentationDelta, sourceFile, options); + // no parent was found - return the base indentation of the SourceFile + return getBaseIndentation(options); } export function getIndentationForNode(n: Node, ignoreActualIndentationRange: TextRange, sourceFile: SourceFile, options: EditorSettings): number { const start = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); - return getIndentationForNodeWorker(n, start, ignoreActualIndentationRange, /*indentationDelta*/ 0, sourceFile, options); + return getIndentationForNodeWorker(n, start, ignoreActualIndentationRange, /*indentationDelta*/ 0, sourceFile, /*isNextChild*/ false, options); } export function getBaseIndentation(options: EditorSettings) { @@ -155,11 +154,9 @@ namespace ts.formatting { ignoreActualIndentationRange: TextRange, indentationDelta: number, sourceFile: SourceFile, + isNextChild: boolean, options: EditorSettings): number { - - let parent: Node = current.parent; - let containingListOrParentStart: LineAndCharacter; - + let parent = current.parent!; // Walk up the tree and collect indentation for parent-child node pairs. Indentation is not added if // * parent and child nodes start on the same line, or // * parent is an IfStatement and child starts on the same line as an 'else clause'. @@ -178,7 +175,7 @@ namespace ts.formatting { } } - containingListOrParentStart = getContainingListOrParentStart(parent, current, sourceFile); + const containingListOrParentStart = getContainingListOrParentStart(parent, current, sourceFile); const parentAndChildShareLine = containingListOrParentStart.line === currentStart.line || childStartsOnTheSameLineWithElseInIfStatement(parent, current, currentStart.line, sourceFile); @@ -196,7 +193,7 @@ namespace ts.formatting { } // increase indentation if parent node wants its content to be indented and parent and child nodes don't start on the same line - if (shouldIndentChildNode(parent, current) && !parentAndChildShareLine) { + if (shouldIndentChildNode(parent, current, isNextChild) && !parentAndChildShareLine) { indentationDelta += options.indentSize; } @@ -214,7 +211,7 @@ namespace ts.formatting { current = parent; parent = current.parent; - currentStart = useTrueStart ? sourceFile.getLineAndCharacterOfPosition(current.getStart()) : containingListOrParentStart; + currentStart = useTrueStart ? sourceFile.getLineAndCharacterOfPosition(current.getStart(sourceFile)) : containingListOrParentStart; } return indentationDelta + getBaseIndentation(options); @@ -533,8 +530,7 @@ namespace ts.formatting { return false; } - /* @internal */ - export function nodeWillIndentChild(parent: TextRangeWithKind, child: TextRangeWithKind, indentByDefault: boolean) { + export function nodeWillIndentChild(parent: TextRangeWithKind, child: TextRangeWithKind | undefined, indentByDefault: boolean): boolean { const childKind = child ? child.kind : SyntaxKind.Unknown; switch (parent.kind) { case SyntaxKind.DoStatement: @@ -555,7 +551,7 @@ namespace ts.formatting { return childKind !== SyntaxKind.NamedExports; case SyntaxKind.ImportDeclaration: return childKind !== SyntaxKind.ImportClause || - ((child).namedBindings && (child).namedBindings.kind !== SyntaxKind.NamedImports); + (!!(child).namedBindings && (child).namedBindings.kind !== SyntaxKind.NamedImports); case SyntaxKind.JsxElement: return childKind !== SyntaxKind.JsxClosingElement; } @@ -563,11 +559,44 @@ namespace ts.formatting { return indentByDefault; } - /* - Function returns true when the parent node should indent the given child by an explicit rule - */ - export function shouldIndentChildNode(parent: TextRangeWithKind, child?: TextRangeWithKind): boolean { - return nodeContentIsAlwaysIndented(parent.kind) || nodeWillIndentChild(parent, child, /*indentByDefault*/ false); + function isControlFlowEndingStatement(kind: SyntaxKind, parent: TextRangeWithKind): boolean { + switch (kind) { + case SyntaxKind.ReturnStatement: + case SyntaxKind.ThrowStatement: + switch (parent.kind) { + case SyntaxKind.Block: + const grandParent = (parent as Node).parent; + switch (grandParent && grandParent.kind) { + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.FunctionExpression: + // We may want to write inner functions after this. + return false; + default: + return true; + } + case SyntaxKind.CaseClause: + case SyntaxKind.DefaultClause: + case SyntaxKind.SourceFile: + case SyntaxKind.ModuleBlock: + return true; + default: + throw Debug.fail(); + } + case SyntaxKind.ContinueStatement: + case SyntaxKind.BreakStatement: + return true; + default: + return false; + } + } + + /** + * True when the parent node should indent the given child by an explicit rule. + * @param isNextChild If true, we are judging indent of a hypothetical child *after* this one, not the current child. + */ + export function shouldIndentChildNode(parent: TextRangeWithKind, child?: TextRangeWithKind, isNextChild = false): boolean { + return (nodeContentIsAlwaysIndented(parent.kind) || nodeWillIndentChild(parent, child, /*indentByDefault*/ false)) + && !(isNextChild && child && isControlFlowEndingStatement(child.kind, parent)); } } } diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts index 7d3b8e1845a0a..06feabf439e7a 100644 --- a/src/services/navigationBar.ts +++ b/src/services/navigationBar.ts @@ -269,6 +269,24 @@ namespace ts.NavigationBar { addLeafNode(node); break; + case SyntaxKind.BinaryExpression: { + const special = getSpecialPropertyAssignmentKind(node as BinaryExpression); + switch (special) { + case SpecialPropertyAssignmentKind.ExportsProperty: + case SpecialPropertyAssignmentKind.ModuleExports: + case SpecialPropertyAssignmentKind.PrototypeProperty: + addNodeWithRecursiveChild(node, (node as BinaryExpression).right); + break; + case SpecialPropertyAssignmentKind.ThisProperty: + case SpecialPropertyAssignmentKind.Property: + case SpecialPropertyAssignmentKind.None: + break; + default: + Debug.assertNever(special); + } + } + // falls through + default: if (hasJSDocNodes(node)) { forEach(node.jsDoc, jsDoc => { diff --git a/src/services/utilities.ts b/src/services/utilities.ts index cf71118292a90..dfbaad0b05a39 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -364,7 +364,7 @@ namespace ts { const rightKind = getNodeKind(right); return rightKind === ScriptElementKind.unknown ? ScriptElementKind.constElement : rightKind; case SpecialPropertyAssignmentKind.PrototypeProperty: - return ScriptElementKind.memberFunctionElement; // instance method + return isFunctionExpression(right) ? ScriptElementKind.memberFunctionElement : ScriptElementKind.memberVariableElement; case SpecialPropertyAssignmentKind.ThisProperty: return ScriptElementKind.memberVariableElement; // property case SpecialPropertyAssignmentKind.Property: @@ -441,6 +441,7 @@ namespace ts { * Assumes `candidate.start <= position` holds. */ export function positionBelongsToNode(candidate: Node, position: number, sourceFile: SourceFile): boolean { + Debug.assert(candidate.pos <= position); return position < candidate.end || !isCompletedNode(candidate, sourceFile); } @@ -1130,6 +1131,7 @@ namespace ts { clear: resetWriter, trackSymbol: noop, reportInaccessibleThisError: noop, + reportInaccessibleUniqueSymbolError: noop, reportPrivateInBaseOfClassExpression: noop, }; diff --git a/tests/baselines/reference/YieldStarExpression4_es6.types b/tests/baselines/reference/YieldStarExpression4_es6.types index 1d72e6dc50651..86b727306d473 100644 --- a/tests/baselines/reference/YieldStarExpression4_es6.types +++ b/tests/baselines/reference/YieldStarExpression4_es6.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/YieldStarExpression4_es6.ts === function *g() { ->g : () => IterableIterator +>g : () => IterableIterator yield * []; >yield * [] : any diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index bed9969abaad5..dad035cddd24d 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -200,162 +200,163 @@ declare namespace ts { SymbolKeyword = 137, TypeKeyword = 138, UndefinedKeyword = 139, - FromKeyword = 140, - GlobalKeyword = 141, - OfKeyword = 142, - QualifiedName = 143, - ComputedPropertyName = 144, - TypeParameter = 145, - Parameter = 146, - Decorator = 147, - PropertySignature = 148, - PropertyDeclaration = 149, - MethodSignature = 150, - MethodDeclaration = 151, - Constructor = 152, - GetAccessor = 153, - SetAccessor = 154, - CallSignature = 155, - ConstructSignature = 156, - IndexSignature = 157, - TypePredicate = 158, - TypeReference = 159, - FunctionType = 160, - ConstructorType = 161, - TypeQuery = 162, - TypeLiteral = 163, - ArrayType = 164, - TupleType = 165, - UnionType = 166, - IntersectionType = 167, - ParenthesizedType = 168, - ThisType = 169, - TypeOperator = 170, - IndexedAccessType = 171, - MappedType = 172, - LiteralType = 173, - ObjectBindingPattern = 174, - ArrayBindingPattern = 175, - BindingElement = 176, - ArrayLiteralExpression = 177, - ObjectLiteralExpression = 178, - PropertyAccessExpression = 179, - ElementAccessExpression = 180, - CallExpression = 181, - NewExpression = 182, - TaggedTemplateExpression = 183, - TypeAssertionExpression = 184, - ParenthesizedExpression = 185, - FunctionExpression = 186, - ArrowFunction = 187, - DeleteExpression = 188, - TypeOfExpression = 189, - VoidExpression = 190, - AwaitExpression = 191, - PrefixUnaryExpression = 192, - PostfixUnaryExpression = 193, - BinaryExpression = 194, - ConditionalExpression = 195, - TemplateExpression = 196, - YieldExpression = 197, - SpreadElement = 198, - ClassExpression = 199, - OmittedExpression = 200, - ExpressionWithTypeArguments = 201, - AsExpression = 202, - NonNullExpression = 203, - MetaProperty = 204, - TemplateSpan = 205, - SemicolonClassElement = 206, - Block = 207, - VariableStatement = 208, - EmptyStatement = 209, - ExpressionStatement = 210, - IfStatement = 211, - DoStatement = 212, - WhileStatement = 213, - ForStatement = 214, - ForInStatement = 215, - ForOfStatement = 216, - ContinueStatement = 217, - BreakStatement = 218, - ReturnStatement = 219, - WithStatement = 220, - SwitchStatement = 221, - LabeledStatement = 222, - ThrowStatement = 223, - TryStatement = 224, - DebuggerStatement = 225, - VariableDeclaration = 226, - VariableDeclarationList = 227, - FunctionDeclaration = 228, - ClassDeclaration = 229, - InterfaceDeclaration = 230, - TypeAliasDeclaration = 231, - EnumDeclaration = 232, - ModuleDeclaration = 233, - ModuleBlock = 234, - CaseBlock = 235, - NamespaceExportDeclaration = 236, - ImportEqualsDeclaration = 237, - ImportDeclaration = 238, - ImportClause = 239, - NamespaceImport = 240, - NamedImports = 241, - ImportSpecifier = 242, - ExportAssignment = 243, - ExportDeclaration = 244, - NamedExports = 245, - ExportSpecifier = 246, - MissingDeclaration = 247, - ExternalModuleReference = 248, - JsxElement = 249, - JsxSelfClosingElement = 250, - JsxOpeningElement = 251, - JsxClosingElement = 252, - JsxFragment = 253, - JsxOpeningFragment = 254, - JsxClosingFragment = 255, - JsxAttribute = 256, - JsxAttributes = 257, - JsxSpreadAttribute = 258, - JsxExpression = 259, - CaseClause = 260, - DefaultClause = 261, - HeritageClause = 262, - CatchClause = 263, - PropertyAssignment = 264, - ShorthandPropertyAssignment = 265, - SpreadAssignment = 266, - EnumMember = 267, - SourceFile = 268, - Bundle = 269, - JSDocTypeExpression = 270, - JSDocAllType = 271, - JSDocUnknownType = 272, - JSDocNullableType = 273, - JSDocNonNullableType = 274, - JSDocOptionalType = 275, - JSDocFunctionType = 276, - JSDocVariadicType = 277, - JSDocComment = 278, - JSDocTypeLiteral = 279, - JSDocTag = 280, - JSDocAugmentsTag = 281, - JSDocClassTag = 282, - JSDocParameterTag = 283, - JSDocReturnTag = 284, - JSDocTypeTag = 285, - JSDocTemplateTag = 286, - JSDocTypedefTag = 287, - JSDocPropertyTag = 288, - SyntaxList = 289, - NotEmittedStatement = 290, - PartiallyEmittedExpression = 291, - CommaListExpression = 292, - MergeDeclarationMarker = 293, - EndOfDeclarationMarker = 294, - Count = 295, + UniqueKeyword = 140, + FromKeyword = 141, + GlobalKeyword = 142, + OfKeyword = 143, + QualifiedName = 144, + ComputedPropertyName = 145, + TypeParameter = 146, + Parameter = 147, + Decorator = 148, + PropertySignature = 149, + PropertyDeclaration = 150, + MethodSignature = 151, + MethodDeclaration = 152, + Constructor = 153, + GetAccessor = 154, + SetAccessor = 155, + CallSignature = 156, + ConstructSignature = 157, + IndexSignature = 158, + TypePredicate = 159, + TypeReference = 160, + FunctionType = 161, + ConstructorType = 162, + TypeQuery = 163, + TypeLiteral = 164, + ArrayType = 165, + TupleType = 166, + UnionType = 167, + IntersectionType = 168, + ParenthesizedType = 169, + ThisType = 170, + TypeOperator = 171, + IndexedAccessType = 172, + MappedType = 173, + LiteralType = 174, + ObjectBindingPattern = 175, + ArrayBindingPattern = 176, + BindingElement = 177, + ArrayLiteralExpression = 178, + ObjectLiteralExpression = 179, + PropertyAccessExpression = 180, + ElementAccessExpression = 181, + CallExpression = 182, + NewExpression = 183, + TaggedTemplateExpression = 184, + TypeAssertionExpression = 185, + ParenthesizedExpression = 186, + FunctionExpression = 187, + ArrowFunction = 188, + DeleteExpression = 189, + TypeOfExpression = 190, + VoidExpression = 191, + AwaitExpression = 192, + PrefixUnaryExpression = 193, + PostfixUnaryExpression = 194, + BinaryExpression = 195, + ConditionalExpression = 196, + TemplateExpression = 197, + YieldExpression = 198, + SpreadElement = 199, + ClassExpression = 200, + OmittedExpression = 201, + ExpressionWithTypeArguments = 202, + AsExpression = 203, + NonNullExpression = 204, + MetaProperty = 205, + TemplateSpan = 206, + SemicolonClassElement = 207, + Block = 208, + VariableStatement = 209, + EmptyStatement = 210, + ExpressionStatement = 211, + IfStatement = 212, + DoStatement = 213, + WhileStatement = 214, + ForStatement = 215, + ForInStatement = 216, + ForOfStatement = 217, + ContinueStatement = 218, + BreakStatement = 219, + ReturnStatement = 220, + WithStatement = 221, + SwitchStatement = 222, + LabeledStatement = 223, + ThrowStatement = 224, + TryStatement = 225, + DebuggerStatement = 226, + VariableDeclaration = 227, + VariableDeclarationList = 228, + FunctionDeclaration = 229, + ClassDeclaration = 230, + InterfaceDeclaration = 231, + TypeAliasDeclaration = 232, + EnumDeclaration = 233, + ModuleDeclaration = 234, + ModuleBlock = 235, + CaseBlock = 236, + NamespaceExportDeclaration = 237, + ImportEqualsDeclaration = 238, + ImportDeclaration = 239, + ImportClause = 240, + NamespaceImport = 241, + NamedImports = 242, + ImportSpecifier = 243, + ExportAssignment = 244, + ExportDeclaration = 245, + NamedExports = 246, + ExportSpecifier = 247, + MissingDeclaration = 248, + ExternalModuleReference = 249, + JsxElement = 250, + JsxSelfClosingElement = 251, + JsxOpeningElement = 252, + JsxClosingElement = 253, + JsxFragment = 254, + JsxOpeningFragment = 255, + JsxClosingFragment = 256, + JsxAttribute = 257, + JsxAttributes = 258, + JsxSpreadAttribute = 259, + JsxExpression = 260, + CaseClause = 261, + DefaultClause = 262, + HeritageClause = 263, + CatchClause = 264, + PropertyAssignment = 265, + ShorthandPropertyAssignment = 266, + SpreadAssignment = 267, + EnumMember = 268, + SourceFile = 269, + Bundle = 270, + JSDocTypeExpression = 271, + JSDocAllType = 272, + JSDocUnknownType = 273, + JSDocNullableType = 274, + JSDocNonNullableType = 275, + JSDocOptionalType = 276, + JSDocFunctionType = 277, + JSDocVariadicType = 278, + JSDocComment = 279, + JSDocTypeLiteral = 280, + JSDocTag = 281, + JSDocAugmentsTag = 282, + JSDocClassTag = 283, + JSDocParameterTag = 284, + JSDocReturnTag = 285, + JSDocTypeTag = 286, + JSDocTemplateTag = 287, + JSDocTypedefTag = 288, + JSDocPropertyTag = 289, + SyntaxList = 290, + NotEmittedStatement = 291, + PartiallyEmittedExpression = 292, + CommaListExpression = 293, + MergeDeclarationMarker = 294, + EndOfDeclarationMarker = 295, + Count = 296, FirstAssignment = 58, LastAssignment = 70, FirstCompoundAssignment = 59, @@ -363,15 +364,15 @@ declare namespace ts { FirstReservedWord = 72, LastReservedWord = 107, FirstKeyword = 72, - LastKeyword = 142, + LastKeyword = 143, FirstFutureReservedWord = 108, LastFutureReservedWord = 116, - FirstTypeNode = 158, - LastTypeNode = 173, + FirstTypeNode = 159, + LastTypeNode = 174, FirstPunctuation = 17, LastPunctuation = 70, FirstToken = 0, - LastToken = 142, + LastToken = 143, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -380,11 +381,11 @@ declare namespace ts { LastTemplateToken = 16, FirstBinaryOperator = 27, LastBinaryOperator = 70, - FirstNode = 143, - FirstJSDocNode = 270, - LastJSDocNode = 288, - FirstJSDocTagNode = 280, - LastJSDocTagNode = 288, + FirstNode = 144, + FirstJSDocNode = 271, + LastJSDocNode = 289, + FirstJSDocTagNode = 281, + LastJSDocTagNode = 289, } enum NodeFlags { None = 0, @@ -739,7 +740,7 @@ declare namespace ts { } interface TypeOperatorNode extends TypeNode { kind: SyntaxKind.TypeOperator; - operator: SyntaxKind.KeyOfKeyword; + operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword; type: TypeNode; } interface IndexedAccessTypeNode extends TypeNode { @@ -1825,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, @@ -1843,6 +1845,7 @@ declare namespace ts { WriteClassExpressionAsTypeLiteral = 16384, InArrayType = 32768, UseAliasDefinedOutsideCurrentScope = 65536, + AllowUniqueESSymbolType = 131072, } enum SymbolFormatFlags { None = 0, @@ -1996,32 +1999,34 @@ declare namespace ts { BooleanLiteral = 128, EnumLiteral = 256, ESSymbol = 512, - Void = 1024, - Undefined = 2048, - Null = 4096, - Never = 8192, - TypeParameter = 16384, - Object = 32768, - Union = 65536, - Intersection = 131072, - Index = 262144, - IndexedAccess = 524288, - NonPrimitive = 16777216, - MarkerType = 67108864, + UniqueESSymbol = 1024, + Void = 2048, + Undefined = 4096, + Null = 8192, + Never = 16384, + TypeParameter = 32768, + Object = 65536, + Union = 131072, + Intersection = 262144, + Index = 524288, + IndexedAccess = 1048576, + NonPrimitive = 33554432, + MarkerType = 134217728, Literal = 224, - Unit = 6368, + Unit = 13536, StringOrNumberLiteral = 96, - PossiblyFalsy = 7406, - StringLike = 262178, + PossiblyFalsy = 14574, + StringLike = 524322, NumberLike = 84, BooleanLike = 136, EnumLike = 272, - UnionOrIntersection = 196608, - StructuredType = 229376, - StructuredOrTypeVariable = 1032192, - TypeVariable = 540672, - Narrowable = 17810175, - NotUnionOrUnit = 16810497, + ESSymbolLike = 1536, + UnionOrIntersection = 393216, + StructuredType = 458752, + StructuredOrTypeVariable = 2064384, + TypeVariable = 1081344, + Narrowable = 35620607, + NotUnionOrUnit = 33620481, } type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; interface Type { @@ -2036,6 +2041,9 @@ declare namespace ts { freshType?: LiteralType; regularType?: LiteralType; } + interface UniqueESSymbolType extends Type { + symbol: Symbol; + } interface StringLiteralType extends LiteralType { value: string; } @@ -3350,6 +3358,7 @@ declare namespace ts { function updateParenthesizedType(node: ParenthesizedTypeNode, type: TypeNode): ParenthesizedTypeNode; function createThisTypeNode(): ThisTypeNode; function createTypeOperatorNode(type: TypeNode): TypeOperatorNode; + function createTypeOperatorNode(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword, type: TypeNode): TypeOperatorNode; function updateTypeOperatorNode(node: TypeOperatorNode, type: TypeNode): TypeOperatorNode; function createIndexedAccessTypeNode(objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode; function updateIndexedAccessTypeNode(node: IndexedAccessTypeNode, objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 00b22e56dc9fd..5f89d2e9b4489 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -200,162 +200,163 @@ declare namespace ts { SymbolKeyword = 137, TypeKeyword = 138, UndefinedKeyword = 139, - FromKeyword = 140, - GlobalKeyword = 141, - OfKeyword = 142, - QualifiedName = 143, - ComputedPropertyName = 144, - TypeParameter = 145, - Parameter = 146, - Decorator = 147, - PropertySignature = 148, - PropertyDeclaration = 149, - MethodSignature = 150, - MethodDeclaration = 151, - Constructor = 152, - GetAccessor = 153, - SetAccessor = 154, - CallSignature = 155, - ConstructSignature = 156, - IndexSignature = 157, - TypePredicate = 158, - TypeReference = 159, - FunctionType = 160, - ConstructorType = 161, - TypeQuery = 162, - TypeLiteral = 163, - ArrayType = 164, - TupleType = 165, - UnionType = 166, - IntersectionType = 167, - ParenthesizedType = 168, - ThisType = 169, - TypeOperator = 170, - IndexedAccessType = 171, - MappedType = 172, - LiteralType = 173, - ObjectBindingPattern = 174, - ArrayBindingPattern = 175, - BindingElement = 176, - ArrayLiteralExpression = 177, - ObjectLiteralExpression = 178, - PropertyAccessExpression = 179, - ElementAccessExpression = 180, - CallExpression = 181, - NewExpression = 182, - TaggedTemplateExpression = 183, - TypeAssertionExpression = 184, - ParenthesizedExpression = 185, - FunctionExpression = 186, - ArrowFunction = 187, - DeleteExpression = 188, - TypeOfExpression = 189, - VoidExpression = 190, - AwaitExpression = 191, - PrefixUnaryExpression = 192, - PostfixUnaryExpression = 193, - BinaryExpression = 194, - ConditionalExpression = 195, - TemplateExpression = 196, - YieldExpression = 197, - SpreadElement = 198, - ClassExpression = 199, - OmittedExpression = 200, - ExpressionWithTypeArguments = 201, - AsExpression = 202, - NonNullExpression = 203, - MetaProperty = 204, - TemplateSpan = 205, - SemicolonClassElement = 206, - Block = 207, - VariableStatement = 208, - EmptyStatement = 209, - ExpressionStatement = 210, - IfStatement = 211, - DoStatement = 212, - WhileStatement = 213, - ForStatement = 214, - ForInStatement = 215, - ForOfStatement = 216, - ContinueStatement = 217, - BreakStatement = 218, - ReturnStatement = 219, - WithStatement = 220, - SwitchStatement = 221, - LabeledStatement = 222, - ThrowStatement = 223, - TryStatement = 224, - DebuggerStatement = 225, - VariableDeclaration = 226, - VariableDeclarationList = 227, - FunctionDeclaration = 228, - ClassDeclaration = 229, - InterfaceDeclaration = 230, - TypeAliasDeclaration = 231, - EnumDeclaration = 232, - ModuleDeclaration = 233, - ModuleBlock = 234, - CaseBlock = 235, - NamespaceExportDeclaration = 236, - ImportEqualsDeclaration = 237, - ImportDeclaration = 238, - ImportClause = 239, - NamespaceImport = 240, - NamedImports = 241, - ImportSpecifier = 242, - ExportAssignment = 243, - ExportDeclaration = 244, - NamedExports = 245, - ExportSpecifier = 246, - MissingDeclaration = 247, - ExternalModuleReference = 248, - JsxElement = 249, - JsxSelfClosingElement = 250, - JsxOpeningElement = 251, - JsxClosingElement = 252, - JsxFragment = 253, - JsxOpeningFragment = 254, - JsxClosingFragment = 255, - JsxAttribute = 256, - JsxAttributes = 257, - JsxSpreadAttribute = 258, - JsxExpression = 259, - CaseClause = 260, - DefaultClause = 261, - HeritageClause = 262, - CatchClause = 263, - PropertyAssignment = 264, - ShorthandPropertyAssignment = 265, - SpreadAssignment = 266, - EnumMember = 267, - SourceFile = 268, - Bundle = 269, - JSDocTypeExpression = 270, - JSDocAllType = 271, - JSDocUnknownType = 272, - JSDocNullableType = 273, - JSDocNonNullableType = 274, - JSDocOptionalType = 275, - JSDocFunctionType = 276, - JSDocVariadicType = 277, - JSDocComment = 278, - JSDocTypeLiteral = 279, - JSDocTag = 280, - JSDocAugmentsTag = 281, - JSDocClassTag = 282, - JSDocParameterTag = 283, - JSDocReturnTag = 284, - JSDocTypeTag = 285, - JSDocTemplateTag = 286, - JSDocTypedefTag = 287, - JSDocPropertyTag = 288, - SyntaxList = 289, - NotEmittedStatement = 290, - PartiallyEmittedExpression = 291, - CommaListExpression = 292, - MergeDeclarationMarker = 293, - EndOfDeclarationMarker = 294, - Count = 295, + UniqueKeyword = 140, + FromKeyword = 141, + GlobalKeyword = 142, + OfKeyword = 143, + QualifiedName = 144, + ComputedPropertyName = 145, + TypeParameter = 146, + Parameter = 147, + Decorator = 148, + PropertySignature = 149, + PropertyDeclaration = 150, + MethodSignature = 151, + MethodDeclaration = 152, + Constructor = 153, + GetAccessor = 154, + SetAccessor = 155, + CallSignature = 156, + ConstructSignature = 157, + IndexSignature = 158, + TypePredicate = 159, + TypeReference = 160, + FunctionType = 161, + ConstructorType = 162, + TypeQuery = 163, + TypeLiteral = 164, + ArrayType = 165, + TupleType = 166, + UnionType = 167, + IntersectionType = 168, + ParenthesizedType = 169, + ThisType = 170, + TypeOperator = 171, + IndexedAccessType = 172, + MappedType = 173, + LiteralType = 174, + ObjectBindingPattern = 175, + ArrayBindingPattern = 176, + BindingElement = 177, + ArrayLiteralExpression = 178, + ObjectLiteralExpression = 179, + PropertyAccessExpression = 180, + ElementAccessExpression = 181, + CallExpression = 182, + NewExpression = 183, + TaggedTemplateExpression = 184, + TypeAssertionExpression = 185, + ParenthesizedExpression = 186, + FunctionExpression = 187, + ArrowFunction = 188, + DeleteExpression = 189, + TypeOfExpression = 190, + VoidExpression = 191, + AwaitExpression = 192, + PrefixUnaryExpression = 193, + PostfixUnaryExpression = 194, + BinaryExpression = 195, + ConditionalExpression = 196, + TemplateExpression = 197, + YieldExpression = 198, + SpreadElement = 199, + ClassExpression = 200, + OmittedExpression = 201, + ExpressionWithTypeArguments = 202, + AsExpression = 203, + NonNullExpression = 204, + MetaProperty = 205, + TemplateSpan = 206, + SemicolonClassElement = 207, + Block = 208, + VariableStatement = 209, + EmptyStatement = 210, + ExpressionStatement = 211, + IfStatement = 212, + DoStatement = 213, + WhileStatement = 214, + ForStatement = 215, + ForInStatement = 216, + ForOfStatement = 217, + ContinueStatement = 218, + BreakStatement = 219, + ReturnStatement = 220, + WithStatement = 221, + SwitchStatement = 222, + LabeledStatement = 223, + ThrowStatement = 224, + TryStatement = 225, + DebuggerStatement = 226, + VariableDeclaration = 227, + VariableDeclarationList = 228, + FunctionDeclaration = 229, + ClassDeclaration = 230, + InterfaceDeclaration = 231, + TypeAliasDeclaration = 232, + EnumDeclaration = 233, + ModuleDeclaration = 234, + ModuleBlock = 235, + CaseBlock = 236, + NamespaceExportDeclaration = 237, + ImportEqualsDeclaration = 238, + ImportDeclaration = 239, + ImportClause = 240, + NamespaceImport = 241, + NamedImports = 242, + ImportSpecifier = 243, + ExportAssignment = 244, + ExportDeclaration = 245, + NamedExports = 246, + ExportSpecifier = 247, + MissingDeclaration = 248, + ExternalModuleReference = 249, + JsxElement = 250, + JsxSelfClosingElement = 251, + JsxOpeningElement = 252, + JsxClosingElement = 253, + JsxFragment = 254, + JsxOpeningFragment = 255, + JsxClosingFragment = 256, + JsxAttribute = 257, + JsxAttributes = 258, + JsxSpreadAttribute = 259, + JsxExpression = 260, + CaseClause = 261, + DefaultClause = 262, + HeritageClause = 263, + CatchClause = 264, + PropertyAssignment = 265, + ShorthandPropertyAssignment = 266, + SpreadAssignment = 267, + EnumMember = 268, + SourceFile = 269, + Bundle = 270, + JSDocTypeExpression = 271, + JSDocAllType = 272, + JSDocUnknownType = 273, + JSDocNullableType = 274, + JSDocNonNullableType = 275, + JSDocOptionalType = 276, + JSDocFunctionType = 277, + JSDocVariadicType = 278, + JSDocComment = 279, + JSDocTypeLiteral = 280, + JSDocTag = 281, + JSDocAugmentsTag = 282, + JSDocClassTag = 283, + JSDocParameterTag = 284, + JSDocReturnTag = 285, + JSDocTypeTag = 286, + JSDocTemplateTag = 287, + JSDocTypedefTag = 288, + JSDocPropertyTag = 289, + SyntaxList = 290, + NotEmittedStatement = 291, + PartiallyEmittedExpression = 292, + CommaListExpression = 293, + MergeDeclarationMarker = 294, + EndOfDeclarationMarker = 295, + Count = 296, FirstAssignment = 58, LastAssignment = 70, FirstCompoundAssignment = 59, @@ -363,15 +364,15 @@ declare namespace ts { FirstReservedWord = 72, LastReservedWord = 107, FirstKeyword = 72, - LastKeyword = 142, + LastKeyword = 143, FirstFutureReservedWord = 108, LastFutureReservedWord = 116, - FirstTypeNode = 158, - LastTypeNode = 173, + FirstTypeNode = 159, + LastTypeNode = 174, FirstPunctuation = 17, LastPunctuation = 70, FirstToken = 0, - LastToken = 142, + LastToken = 143, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -380,11 +381,11 @@ declare namespace ts { LastTemplateToken = 16, FirstBinaryOperator = 27, LastBinaryOperator = 70, - FirstNode = 143, - FirstJSDocNode = 270, - LastJSDocNode = 288, - FirstJSDocTagNode = 280, - LastJSDocTagNode = 288, + FirstNode = 144, + FirstJSDocNode = 271, + LastJSDocNode = 289, + FirstJSDocTagNode = 281, + LastJSDocTagNode = 289, } enum NodeFlags { None = 0, @@ -739,7 +740,7 @@ declare namespace ts { } interface TypeOperatorNode extends TypeNode { kind: SyntaxKind.TypeOperator; - operator: SyntaxKind.KeyOfKeyword; + operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword; type: TypeNode; } interface IndexedAccessTypeNode extends TypeNode { @@ -1825,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, @@ -1843,6 +1845,7 @@ declare namespace ts { WriteClassExpressionAsTypeLiteral = 16384, InArrayType = 32768, UseAliasDefinedOutsideCurrentScope = 65536, + AllowUniqueESSymbolType = 131072, } enum SymbolFormatFlags { None = 0, @@ -1996,32 +1999,34 @@ declare namespace ts { BooleanLiteral = 128, EnumLiteral = 256, ESSymbol = 512, - Void = 1024, - Undefined = 2048, - Null = 4096, - Never = 8192, - TypeParameter = 16384, - Object = 32768, - Union = 65536, - Intersection = 131072, - Index = 262144, - IndexedAccess = 524288, - NonPrimitive = 16777216, - MarkerType = 67108864, + UniqueESSymbol = 1024, + Void = 2048, + Undefined = 4096, + Null = 8192, + Never = 16384, + TypeParameter = 32768, + Object = 65536, + Union = 131072, + Intersection = 262144, + Index = 524288, + IndexedAccess = 1048576, + NonPrimitive = 33554432, + MarkerType = 134217728, Literal = 224, - Unit = 6368, + Unit = 13536, StringOrNumberLiteral = 96, - PossiblyFalsy = 7406, - StringLike = 262178, + PossiblyFalsy = 14574, + StringLike = 524322, NumberLike = 84, BooleanLike = 136, EnumLike = 272, - UnionOrIntersection = 196608, - StructuredType = 229376, - StructuredOrTypeVariable = 1032192, - TypeVariable = 540672, - Narrowable = 17810175, - NotUnionOrUnit = 16810497, + ESSymbolLike = 1536, + UnionOrIntersection = 393216, + StructuredType = 458752, + StructuredOrTypeVariable = 2064384, + TypeVariable = 1081344, + Narrowable = 35620607, + NotUnionOrUnit = 33620481, } type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; interface Type { @@ -2036,6 +2041,9 @@ declare namespace ts { freshType?: LiteralType; regularType?: LiteralType; } + interface UniqueESSymbolType extends Type { + symbol: Symbol; + } interface StringLiteralType extends LiteralType { value: string; } @@ -3297,6 +3305,7 @@ declare namespace ts { function updateParenthesizedType(node: ParenthesizedTypeNode, type: TypeNode): ParenthesizedTypeNode; function createThisTypeNode(): ThisTypeNode; function createTypeOperatorNode(type: TypeNode): TypeOperatorNode; + function createTypeOperatorNode(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword, type: TypeNode): TypeOperatorNode; function updateTypeOperatorNode(node: TypeOperatorNode, type: TypeNode): TypeOperatorNode; function createIndexedAccessTypeNode(objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode; function updateIndexedAccessTypeNode(node: IndexedAccessTypeNode, objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode; diff --git a/tests/baselines/reference/asyncImportNestedYield.types b/tests/baselines/reference/asyncImportNestedYield.types index 872e314150030..f7fbfa8f96200 100644 --- a/tests/baselines/reference/asyncImportNestedYield.types +++ b/tests/baselines/reference/asyncImportNestedYield.types @@ -1,6 +1,6 @@ === tests/cases/compiler/asyncImportNestedYield.ts === async function* foo() { ->foo : () => AsyncIterableIterator<"foo"> +>foo : () => AsyncIterableIterator import((await import(yield "foo")).default); >import((await import(yield "foo")).default) : Promise diff --git a/tests/baselines/reference/callWithSpread2.errors.txt b/tests/baselines/reference/callWithSpread2.errors.txt index 89617ab6074c3..9028d37af0906 100644 --- a/tests/baselines/reference/callWithSpread2.errors.txt +++ b/tests/baselines/reference/callWithSpread2.errors.txt @@ -1,21 +1,23 @@ -tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(30,5): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'. +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(22,1): error TS2556: Expected 1 arguments, but got 2 or more. +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(23,1): error TS2556: Expected 0 arguments, but got 1 or more. +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(26,5): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'. Type 'string' is not assignable to type 'number'. -tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(31,5): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'. +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(27,5): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'. Type 'string' is not assignable to type 'number'. -tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(32,13): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'. +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(28,13): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'. Type 'string' is not assignable to type 'number'. -tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(33,13): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'. +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(29,13): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'. Type 'string' is not assignable to type 'number'. -tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(34,11): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'. +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(30,11): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'. Type 'string' is not assignable to type 'number'. -tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(35,11): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'. +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(31,11): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'. Type 'string' is not assignable to type 'number'. -tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(36,1): error TS2556: Expected 1-3 arguments, but got a minimum of 0. -tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(37,1): error TS2556: Expected 1-3 arguments, but got a minimum of 0. -tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(38,1): error TS2556: Expected 1-3 arguments, but got a minimum of 0. +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(32,1): error TS2556: Expected 1-3 arguments, but got 0 or more. +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(33,1): error TS2556: Expected 1-3 arguments, but got 0 or more. +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(34,1): error TS2556: Expected 1-3 arguments, but got 0 or more. -==== tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts (9 errors) ==== +==== tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts (11 errors) ==== declare function all(a?: number, b?: number): void; declare function weird(a?: number | string, b?: number | string): void; declare function prefix(s: string, a?: number, b?: number): void; @@ -36,13 +38,13 @@ tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(38,1): erro rest("d", ...ns) - // this covers the arguments case + // extra arguments normal("g", ...ns) - normal("h", ...mixed) - normal("i", ...tuple) + ~~~~~~~~~~~~~~~~~~ +!!! error TS2556: Expected 1 arguments, but got 2 or more. thunk(...ns) - thunk(...mixed) - thunk(...tuple) + ~~~~~~~~~~~~ +!!! error TS2556: Expected 0 arguments, but got 1 or more. // bad all(...mixed) @@ -71,11 +73,11 @@ tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(38,1): erro !!! error TS2345: Type 'string' is not assignable to type 'number'. prefix(...ns) // required parameters are required ~~~~~~~~~~~~~ -!!! error TS2556: Expected 1-3 arguments, but got a minimum of 0. +!!! error TS2556: Expected 1-3 arguments, but got 0 or more. prefix(...mixed) ~~~~~~~~~~~~~~~~ -!!! error TS2556: Expected 1-3 arguments, but got a minimum of 0. +!!! error TS2556: Expected 1-3 arguments, but got 0 or more. prefix(...tuple) ~~~~~~~~~~~~~~~~ -!!! error TS2556: Expected 1-3 arguments, but got a minimum of 0. +!!! error TS2556: Expected 1-3 arguments, but got 0 or more. \ No newline at end of file diff --git a/tests/baselines/reference/callWithSpread2.js b/tests/baselines/reference/callWithSpread2.js index 55296d924f774..27bcc893ca8c0 100644 --- a/tests/baselines/reference/callWithSpread2.js +++ b/tests/baselines/reference/callWithSpread2.js @@ -19,13 +19,9 @@ prefix("a", ...ns) rest("d", ...ns) -// this covers the arguments case +// extra arguments normal("g", ...ns) -normal("h", ...mixed) -normal("i", ...tuple) thunk(...ns) -thunk(...mixed) -thunk(...tuple) // bad all(...mixed) @@ -47,13 +43,9 @@ weird.apply(void 0, mixed); weird.apply(void 0, tuple); prefix.apply(void 0, ["a"].concat(ns)); rest.apply(void 0, ["d"].concat(ns)); -// this covers the arguments case +// extra arguments normal.apply(void 0, ["g"].concat(ns)); -normal.apply(void 0, ["h"].concat(mixed)); -normal.apply(void 0, ["i"].concat(tuple)); thunk.apply(void 0, ns); -thunk.apply(void 0, mixed); -thunk.apply(void 0, tuple); // bad all.apply(void 0, mixed); all.apply(void 0, tuple); diff --git a/tests/baselines/reference/callWithSpread2.symbols b/tests/baselines/reference/callWithSpread2.symbols index 169e8c8d47e73..8ce7fb6f903f7 100644 --- a/tests/baselines/reference/callWithSpread2.symbols +++ b/tests/baselines/reference/callWithSpread2.symbols @@ -64,31 +64,15 @@ rest("d", ...ns) >ns : Symbol(ns, Decl(callWithSpread2.ts, 7, 11)) -// this covers the arguments case +// extra arguments normal("g", ...ns) >normal : Symbol(normal, Decl(callWithSpread2.ts, 3, 83)) >ns : Symbol(ns, Decl(callWithSpread2.ts, 7, 11)) -normal("h", ...mixed) ->normal : Symbol(normal, Decl(callWithSpread2.ts, 3, 83)) ->mixed : Symbol(mixed, Decl(callWithSpread2.ts, 8, 11)) - -normal("i", ...tuple) ->normal : Symbol(normal, Decl(callWithSpread2.ts, 3, 83)) ->tuple : Symbol(tuple, Decl(callWithSpread2.ts, 9, 11)) - thunk(...ns) >thunk : Symbol(thunk, Decl(callWithSpread2.ts, 4, 41)) >ns : Symbol(ns, Decl(callWithSpread2.ts, 7, 11)) -thunk(...mixed) ->thunk : Symbol(thunk, Decl(callWithSpread2.ts, 4, 41)) ->mixed : Symbol(mixed, Decl(callWithSpread2.ts, 8, 11)) - -thunk(...tuple) ->thunk : Symbol(thunk, Decl(callWithSpread2.ts, 4, 41)) ->tuple : Symbol(tuple, Decl(callWithSpread2.ts, 9, 11)) - // bad all(...mixed) >all : Symbol(all, Decl(callWithSpread2.ts, 0, 0)) diff --git a/tests/baselines/reference/callWithSpread2.types b/tests/baselines/reference/callWithSpread2.types index 75f0f18d28782..4c87b9bd74d5b 100644 --- a/tests/baselines/reference/callWithSpread2.types +++ b/tests/baselines/reference/callWithSpread2.types @@ -78,7 +78,7 @@ rest("d", ...ns) >ns : number[] -// this covers the arguments case +// extra arguments normal("g", ...ns) >normal("g", ...ns) : void >normal : (s: string) => void @@ -86,38 +86,12 @@ normal("g", ...ns) >...ns : number >ns : number[] -normal("h", ...mixed) ->normal("h", ...mixed) : void ->normal : (s: string) => void ->"h" : "h" ->...mixed : string | number ->mixed : (string | number)[] - -normal("i", ...tuple) ->normal("i", ...tuple) : void ->normal : (s: string) => void ->"i" : "i" ->...tuple : string | number ->tuple : [number, string] - thunk(...ns) >thunk(...ns) : string >thunk : () => string >...ns : number >ns : number[] -thunk(...mixed) ->thunk(...mixed) : string ->thunk : () => string ->...mixed : string | number ->mixed : (string | number)[] - -thunk(...tuple) ->thunk(...tuple) : string ->thunk : () => string ->...tuple : string | number ->tuple : [number, string] - // bad all(...mixed) >all(...mixed) : void diff --git a/tests/baselines/reference/capturedParametersInInitializers2.errors.txt b/tests/baselines/reference/capturedParametersInInitializers2.errors.txt index 9e9f48e539086..70435b77cee84 100644 --- a/tests/baselines/reference/capturedParametersInInitializers2.errors.txt +++ b/tests/baselines/reference/capturedParametersInInitializers2.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/capturedParametersInInitializers2.ts(1,36): error TS2373: Initializer of parameter 'y' cannot reference identifier 'x' declared after it. -tests/cases/compiler/capturedParametersInInitializers2.ts(4,26): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/compiler/capturedParametersInInitializers2.ts(4,26): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ==== tests/cases/compiler/capturedParametersInInitializers2.ts (2 errors) ==== @@ -10,5 +10,5 @@ tests/cases/compiler/capturedParametersInInitializers2.ts(4,26): error TS1166: A } function foo2(y = class {[x] = x}, x = 1) { ~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. } \ No newline at end of file diff --git a/tests/baselines/reference/classWithDuplicateIdentifier.errors.txt b/tests/baselines/reference/classWithDuplicateIdentifier.errors.txt index 55e9714ee59b5..de862cf387fee 100644 --- a/tests/baselines/reference/classWithDuplicateIdentifier.errors.txt +++ b/tests/baselines/reference/classWithDuplicateIdentifier.errors.txt @@ -2,7 +2,7 @@ tests/cases/compiler/classWithDuplicateIdentifier.ts(3,5): error TS2300: Duplica tests/cases/compiler/classWithDuplicateIdentifier.ts(6,5): error TS2300: Duplicate identifier 'b'. tests/cases/compiler/classWithDuplicateIdentifier.ts(7,5): error TS2300: Duplicate identifier 'b'. tests/cases/compiler/classWithDuplicateIdentifier.ts(11,5): error TS2300: Duplicate identifier 'c'. -tests/cases/compiler/classWithDuplicateIdentifier.ts(11,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'c' has type 'number' at tests/cases/compiler/classWithDuplicateIdentifier.ts 9:4, but here has type 'string'. +tests/cases/compiler/classWithDuplicateIdentifier.ts(11,5): error TS2717: Subsequent property declarations must have the same type. Property 'c' has type 'number' at tests/cases/compiler/classWithDuplicateIdentifier.ts 9:4, but here has type 'string'. ==== tests/cases/compiler/classWithDuplicateIdentifier.ts (5 errors) ==== @@ -26,6 +26,6 @@ tests/cases/compiler/classWithDuplicateIdentifier.ts(11,5): error TS2403: Subseq ~ !!! error TS2300: Duplicate identifier 'c'. ~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'c' has type 'number' at tests/cases/compiler/classWithDuplicateIdentifier.ts 9:4, but here has type 'string'. +!!! error TS2717: Subsequent property declarations must have the same type. Property 'c' has type 'number' at tests/cases/compiler/classWithDuplicateIdentifier.ts 9:4, but here has type 'string'. } \ No newline at end of file diff --git a/tests/baselines/reference/complicatedPrivacy.errors.txt b/tests/baselines/reference/complicatedPrivacy.errors.txt index 661b0693807c4..750beb1994d3d 100644 --- a/tests/baselines/reference/complicatedPrivacy.errors.txt +++ b/tests/baselines/reference/complicatedPrivacy.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/complicatedPrivacy.ts(11,24): error TS1054: A 'get' accessor cannot have parameters. -tests/cases/compiler/complicatedPrivacy.ts(35,5): error TS1170: A computed property name in a type literal must directly refer to a built-in symbol. +tests/cases/compiler/complicatedPrivacy.ts(35,5): error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/complicatedPrivacy.ts(35,6): error TS2693: 'number' only refers to a type, but is being used as a value here. tests/cases/compiler/complicatedPrivacy.ts(73,55): error TS2694: Namespace 'mglo5' has no exported member 'i6'. @@ -43,7 +43,7 @@ tests/cases/compiler/complicatedPrivacy.ts(73,55): error TS2694: Namespace 'mglo { [number]: C1; // Used to be indexer, now it is a computed property ~~~~~~~~ -!!! error TS1170: A computed property name in a type literal must directly refer to a built-in symbol. +!!! error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type. ~~~~~~ !!! error TS2693: 'number' only refers to a type, but is being used as a value here. }) { diff --git a/tests/baselines/reference/computedPropertyNames12_ES5.errors.txt b/tests/baselines/reference/computedPropertyNames12_ES5.errors.txt index 71f81c27245f9..309b734dfeaf7 100644 --- a/tests/baselines/reference/computedPropertyNames12_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNames12_ES5.errors.txt @@ -1,12 +1,12 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(5,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(6,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(7,12): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(8,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(9,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(12,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(13,12): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(14,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(15,12): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(5,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(6,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(7,12): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(8,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(9,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(12,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(13,12): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(14,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(15,12): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts (9 errors) ==== @@ -16,31 +16,31 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(15 class C { [s]: number; ~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. [n] = n; ~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. static [s + s]: string; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. [s + n] = 2; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. [+s]: typeof s; ~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. static [""]: number; [0]: number; [a]: number; ~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. static [true]: number; ~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. [`hello bye`] = 0; ~~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. static [`hello ${a} bye`] = 0 ~~~~~~~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames12_ES5.symbols b/tests/baselines/reference/computedPropertyNames12_ES5.symbols index a6519a5dedf55..619a54c76c9ee 100644 --- a/tests/baselines/reference/computedPropertyNames12_ES5.symbols +++ b/tests/baselines/reference/computedPropertyNames12_ES5.symbols @@ -31,10 +31,10 @@ class C { >s : Symbol(s, Decl(computedPropertyNames12_ES5.ts, 0, 3)) static [""]: number; ->"" : Symbol(C[[""]], Decl(computedPropertyNames12_ES5.ts, 8, 19)) +>"" : Symbol(C[""], Decl(computedPropertyNames12_ES5.ts, 8, 19)) [0]: number; ->0 : Symbol(C[[0]], Decl(computedPropertyNames12_ES5.ts, 9, 24)) +>0 : Symbol(C[0], Decl(computedPropertyNames12_ES5.ts, 9, 24)) [a]: number; >a : Symbol(a, Decl(computedPropertyNames12_ES5.ts, 2, 3)) diff --git a/tests/baselines/reference/computedPropertyNames12_ES6.errors.txt b/tests/baselines/reference/computedPropertyNames12_ES6.errors.txt index 8d8cce7e1408d..13920995eaa9a 100644 --- a/tests/baselines/reference/computedPropertyNames12_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNames12_ES6.errors.txt @@ -1,12 +1,12 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(5,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(6,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(7,12): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(8,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(9,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(12,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(13,12): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(14,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(15,12): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(5,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(6,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(7,12): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(8,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(9,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(12,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(13,12): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(14,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(15,12): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts (9 errors) ==== @@ -16,31 +16,31 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(15 class C { [s]: number; ~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. [n] = n; ~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. static [s + s]: string; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. [s + n] = 2; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. [+s]: typeof s; ~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. static [""]: number; [0]: number; [a]: number; ~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. static [true]: number; ~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. [`hello bye`] = 0; ~~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. static [`hello ${a} bye`] = 0 ~~~~~~~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames12_ES6.symbols b/tests/baselines/reference/computedPropertyNames12_ES6.symbols index 3ba128eb1c26e..9cb6fb3fa4bf7 100644 --- a/tests/baselines/reference/computedPropertyNames12_ES6.symbols +++ b/tests/baselines/reference/computedPropertyNames12_ES6.symbols @@ -31,10 +31,10 @@ class C { >s : Symbol(s, Decl(computedPropertyNames12_ES6.ts, 0, 3)) static [""]: number; ->"" : Symbol(C[[""]], Decl(computedPropertyNames12_ES6.ts, 8, 19)) +>"" : Symbol(C[""], Decl(computedPropertyNames12_ES6.ts, 8, 19)) [0]: number; ->0 : Symbol(C[[0]], Decl(computedPropertyNames12_ES6.ts, 9, 24)) +>0 : Symbol(C[0], Decl(computedPropertyNames12_ES6.ts, 9, 24)) [a]: number; >a : Symbol(a, Decl(computedPropertyNames12_ES6.ts, 2, 3)) diff --git a/tests/baselines/reference/computedPropertyNames13_ES5.symbols b/tests/baselines/reference/computedPropertyNames13_ES5.symbols index 493ea44b3399d..4fae0886ca2ef 100644 --- a/tests/baselines/reference/computedPropertyNames13_ES5.symbols +++ b/tests/baselines/reference/computedPropertyNames13_ES5.symbols @@ -29,10 +29,10 @@ class C { >s : Symbol(s, Decl(computedPropertyNames13_ES5.ts, 0, 3)) static [""]() { } ->"" : Symbol(C[[""]], Decl(computedPropertyNames13_ES5.ts, 8, 14)) +>"" : Symbol(C[""], Decl(computedPropertyNames13_ES5.ts, 8, 14)) [0]() { } ->0 : Symbol(C[[0]], Decl(computedPropertyNames13_ES5.ts, 9, 21)) +>0 : Symbol(C[0], Decl(computedPropertyNames13_ES5.ts, 9, 21)) [a]() { } >a : Symbol(a, Decl(computedPropertyNames13_ES5.ts, 2, 3)) diff --git a/tests/baselines/reference/computedPropertyNames13_ES6.symbols b/tests/baselines/reference/computedPropertyNames13_ES6.symbols index 7c421d3f9f77c..1f3a1c1460c9a 100644 --- a/tests/baselines/reference/computedPropertyNames13_ES6.symbols +++ b/tests/baselines/reference/computedPropertyNames13_ES6.symbols @@ -29,10 +29,10 @@ class C { >s : Symbol(s, Decl(computedPropertyNames13_ES6.ts, 0, 3)) static [""]() { } ->"" : Symbol(C[[""]], Decl(computedPropertyNames13_ES6.ts, 8, 14)) +>"" : Symbol(C[""], Decl(computedPropertyNames13_ES6.ts, 8, 14)) [0]() { } ->0 : Symbol(C[[0]], Decl(computedPropertyNames13_ES6.ts, 9, 21)) +>0 : Symbol(C[0], Decl(computedPropertyNames13_ES6.ts, 9, 21)) [a]() { } >a : Symbol(a, Decl(computedPropertyNames13_ES6.ts, 2, 3)) diff --git a/tests/baselines/reference/computedPropertyNames16_ES5.symbols b/tests/baselines/reference/computedPropertyNames16_ES5.symbols index 43f6e208957f7..dff21e3cd97cc 100644 --- a/tests/baselines/reference/computedPropertyNames16_ES5.symbols +++ b/tests/baselines/reference/computedPropertyNames16_ES5.symbols @@ -31,11 +31,11 @@ class C { >s : Symbol(s, Decl(computedPropertyNames16_ES5.ts, 0, 3)) static set [""](v) { } ->"" : Symbol(C[[""]], Decl(computedPropertyNames16_ES5.ts, 8, 28)) +>"" : Symbol(C[""], Decl(computedPropertyNames16_ES5.ts, 8, 28)) >v : Symbol(v, Decl(computedPropertyNames16_ES5.ts, 9, 20)) get [0]() { return 0; } ->0 : Symbol(C[[0]], Decl(computedPropertyNames16_ES5.ts, 9, 26)) +>0 : Symbol(C[0], Decl(computedPropertyNames16_ES5.ts, 9, 26)) set [a](v) { } >a : Symbol(a, Decl(computedPropertyNames16_ES5.ts, 2, 3)) diff --git a/tests/baselines/reference/computedPropertyNames16_ES6.symbols b/tests/baselines/reference/computedPropertyNames16_ES6.symbols index 4febdc01b9b7f..3e1af442b2ddd 100644 --- a/tests/baselines/reference/computedPropertyNames16_ES6.symbols +++ b/tests/baselines/reference/computedPropertyNames16_ES6.symbols @@ -31,11 +31,11 @@ class C { >s : Symbol(s, Decl(computedPropertyNames16_ES6.ts, 0, 3)) static set [""](v) { } ->"" : Symbol(C[[""]], Decl(computedPropertyNames16_ES6.ts, 8, 28)) +>"" : Symbol(C[""], Decl(computedPropertyNames16_ES6.ts, 8, 28)) >v : Symbol(v, Decl(computedPropertyNames16_ES6.ts, 9, 20)) get [0]() { return 0; } ->0 : Symbol(C[[0]], Decl(computedPropertyNames16_ES6.ts, 9, 26)) +>0 : Symbol(C[0], Decl(computedPropertyNames16_ES6.ts, 9, 26)) set [a](v) { } >a : Symbol(a, Decl(computedPropertyNames16_ES6.ts, 2, 3)) diff --git a/tests/baselines/reference/computedPropertyNames35_ES5.errors.txt b/tests/baselines/reference/computedPropertyNames35_ES5.errors.txt index aaf5648702865..47ad09c51e3de 100644 --- a/tests/baselines/reference/computedPropertyNames35_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNames35_ES5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames35_ES5.ts(4,5): error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +tests/cases/conformance/es6/computedProperties/computedPropertyNames35_ES5.ts(4,5): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/es6/computedProperties/computedPropertyNames35_ES5.ts(4,10): error TS2467: A computed property name cannot reference a type parameter from its containing type. @@ -8,7 +8,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames35_ES5.ts(4, bar(): string; [foo()](): void; ~~~~~~~~~~ -!!! error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2467: A computed property name cannot reference a type parameter from its containing type. } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames35_ES6.errors.txt b/tests/baselines/reference/computedPropertyNames35_ES6.errors.txt index c8ef5efac31f5..8a0be33325c9c 100644 --- a/tests/baselines/reference/computedPropertyNames35_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNames35_ES6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames35_ES6.ts(4,5): error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +tests/cases/conformance/es6/computedProperties/computedPropertyNames35_ES6.ts(4,5): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/es6/computedProperties/computedPropertyNames35_ES6.ts(4,10): error TS2467: A computed property name cannot reference a type parameter from its containing type. @@ -8,7 +8,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames35_ES6.ts(4, bar(): string; [foo()](): void; ~~~~~~~~~~ -!!! error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2467: A computed property name cannot reference a type parameter from its containing type. } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNames36_ES5.symbols b/tests/baselines/reference/computedPropertyNames36_ES5.symbols index b0ee9a5a6c335..f0c9adbf22f1b 100644 --- a/tests/baselines/reference/computedPropertyNames36_ES5.symbols +++ b/tests/baselines/reference/computedPropertyNames36_ES5.symbols @@ -17,11 +17,11 @@ class C { // Computed properties get ["get1"]() { return new Foo } ->"get1" : Symbol(C[["get1"]], Decl(computedPropertyNames36_ES5.ts, 4, 22)) +>"get1" : Symbol(C["get1"], Decl(computedPropertyNames36_ES5.ts, 4, 22)) >Foo : Symbol(Foo, Decl(computedPropertyNames36_ES5.ts, 0, 0)) set ["set1"](p: Foo2) { } ->"set1" : Symbol(C[["set1"]], Decl(computedPropertyNames36_ES5.ts, 7, 37)) +>"set1" : Symbol(C["set1"], Decl(computedPropertyNames36_ES5.ts, 7, 37)) >p : Symbol(p, Decl(computedPropertyNames36_ES5.ts, 8, 17)) >Foo2 : Symbol(Foo2, Decl(computedPropertyNames36_ES5.ts, 0, 15)) } diff --git a/tests/baselines/reference/computedPropertyNames36_ES6.symbols b/tests/baselines/reference/computedPropertyNames36_ES6.symbols index 5a7fa1cdb8dc1..ad406fa526612 100644 --- a/tests/baselines/reference/computedPropertyNames36_ES6.symbols +++ b/tests/baselines/reference/computedPropertyNames36_ES6.symbols @@ -17,11 +17,11 @@ class C { // Computed properties get ["get1"]() { return new Foo } ->"get1" : Symbol(C[["get1"]], Decl(computedPropertyNames36_ES6.ts, 4, 22)) +>"get1" : Symbol(C["get1"], Decl(computedPropertyNames36_ES6.ts, 4, 22)) >Foo : Symbol(Foo, Decl(computedPropertyNames36_ES6.ts, 0, 0)) set ["set1"](p: Foo2) { } ->"set1" : Symbol(C[["set1"]], Decl(computedPropertyNames36_ES6.ts, 7, 37)) +>"set1" : Symbol(C["set1"], Decl(computedPropertyNames36_ES6.ts, 7, 37)) >p : Symbol(p, Decl(computedPropertyNames36_ES6.ts, 8, 17)) >Foo2 : Symbol(Foo2, Decl(computedPropertyNames36_ES6.ts, 0, 15)) } diff --git a/tests/baselines/reference/computedPropertyNames37_ES5.symbols b/tests/baselines/reference/computedPropertyNames37_ES5.symbols index 7763c5970a35f..5d9ea09078038 100644 --- a/tests/baselines/reference/computedPropertyNames37_ES5.symbols +++ b/tests/baselines/reference/computedPropertyNames37_ES5.symbols @@ -17,11 +17,11 @@ class C { // Computed properties get ["get1"]() { return new Foo } ->"get1" : Symbol(C[["get1"]], Decl(computedPropertyNames37_ES5.ts, 4, 22)) +>"get1" : Symbol(C["get1"], Decl(computedPropertyNames37_ES5.ts, 4, 22)) >Foo : Symbol(Foo, Decl(computedPropertyNames37_ES5.ts, 0, 0)) set ["set1"](p: Foo2) { } ->"set1" : Symbol(C[["set1"]], Decl(computedPropertyNames37_ES5.ts, 7, 37)) +>"set1" : Symbol(C["set1"], Decl(computedPropertyNames37_ES5.ts, 7, 37)) >p : Symbol(p, Decl(computedPropertyNames37_ES5.ts, 8, 17)) >Foo2 : Symbol(Foo2, Decl(computedPropertyNames37_ES5.ts, 0, 15)) } diff --git a/tests/baselines/reference/computedPropertyNames37_ES6.symbols b/tests/baselines/reference/computedPropertyNames37_ES6.symbols index d2e1e2fdc6e69..f30cd6cad377e 100644 --- a/tests/baselines/reference/computedPropertyNames37_ES6.symbols +++ b/tests/baselines/reference/computedPropertyNames37_ES6.symbols @@ -17,11 +17,11 @@ class C { // Computed properties get ["get1"]() { return new Foo } ->"get1" : Symbol(C[["get1"]], Decl(computedPropertyNames37_ES6.ts, 4, 22)) +>"get1" : Symbol(C["get1"], Decl(computedPropertyNames37_ES6.ts, 4, 22)) >Foo : Symbol(Foo, Decl(computedPropertyNames37_ES6.ts, 0, 0)) set ["set1"](p: Foo2) { } ->"set1" : Symbol(C[["set1"]], Decl(computedPropertyNames37_ES6.ts, 7, 37)) +>"set1" : Symbol(C["set1"], Decl(computedPropertyNames37_ES6.ts, 7, 37)) >p : Symbol(p, Decl(computedPropertyNames37_ES6.ts, 8, 17)) >Foo2 : Symbol(Foo2, Decl(computedPropertyNames37_ES6.ts, 0, 15)) } diff --git a/tests/baselines/reference/computedPropertyNames40_ES5.symbols b/tests/baselines/reference/computedPropertyNames40_ES5.symbols index 67535664576f1..d59a516b5e280 100644 --- a/tests/baselines/reference/computedPropertyNames40_ES5.symbols +++ b/tests/baselines/reference/computedPropertyNames40_ES5.symbols @@ -17,10 +17,10 @@ class C { // Computed properties [""]() { return new Foo } ->"" : Symbol(C[[""]], Decl(computedPropertyNames40_ES5.ts, 4, 28), Decl(computedPropertyNames40_ES5.ts, 7, 29)) +>"" : Symbol(C[""], Decl(computedPropertyNames40_ES5.ts, 4, 28), Decl(computedPropertyNames40_ES5.ts, 7, 29)) >Foo : Symbol(Foo, Decl(computedPropertyNames40_ES5.ts, 0, 0)) [""]() { return new Foo2 } ->"" : Symbol(C[[""]], Decl(computedPropertyNames40_ES5.ts, 4, 28), Decl(computedPropertyNames40_ES5.ts, 7, 29)) +>"" : Symbol(C[""], Decl(computedPropertyNames40_ES5.ts, 4, 28), Decl(computedPropertyNames40_ES5.ts, 7, 29)) >Foo2 : Symbol(Foo2, Decl(computedPropertyNames40_ES5.ts, 0, 15)) } diff --git a/tests/baselines/reference/computedPropertyNames40_ES6.symbols b/tests/baselines/reference/computedPropertyNames40_ES6.symbols index 71cb41642fc66..f5881fa6a6b59 100644 --- a/tests/baselines/reference/computedPropertyNames40_ES6.symbols +++ b/tests/baselines/reference/computedPropertyNames40_ES6.symbols @@ -17,10 +17,10 @@ class C { // Computed properties [""]() { return new Foo } ->"" : Symbol(C[[""]], Decl(computedPropertyNames40_ES6.ts, 4, 28), Decl(computedPropertyNames40_ES6.ts, 7, 29)) +>"" : Symbol(C[""], Decl(computedPropertyNames40_ES6.ts, 4, 28), Decl(computedPropertyNames40_ES6.ts, 7, 29)) >Foo : Symbol(Foo, Decl(computedPropertyNames40_ES6.ts, 0, 0)) [""]() { return new Foo2 } ->"" : Symbol(C[[""]], Decl(computedPropertyNames40_ES6.ts, 4, 28), Decl(computedPropertyNames40_ES6.ts, 7, 29)) +>"" : Symbol(C[""], Decl(computedPropertyNames40_ES6.ts, 4, 28), Decl(computedPropertyNames40_ES6.ts, 7, 29)) >Foo2 : Symbol(Foo2, Decl(computedPropertyNames40_ES6.ts, 0, 15)) } diff --git a/tests/baselines/reference/computedPropertyNames41_ES5.symbols b/tests/baselines/reference/computedPropertyNames41_ES5.symbols index 821a39c8d594f..c0642d6b0a6a7 100644 --- a/tests/baselines/reference/computedPropertyNames41_ES5.symbols +++ b/tests/baselines/reference/computedPropertyNames41_ES5.symbols @@ -17,6 +17,6 @@ class C { // Computed properties static [""]() { return new Foo } ->"" : Symbol(C[[""]], Decl(computedPropertyNames41_ES5.ts, 4, 28)) +>"" : Symbol(C[""], Decl(computedPropertyNames41_ES5.ts, 4, 28)) >Foo : Symbol(Foo, Decl(computedPropertyNames41_ES5.ts, 0, 0)) } diff --git a/tests/baselines/reference/computedPropertyNames41_ES6.symbols b/tests/baselines/reference/computedPropertyNames41_ES6.symbols index a075603e252c7..10ef48e4d16c9 100644 --- a/tests/baselines/reference/computedPropertyNames41_ES6.symbols +++ b/tests/baselines/reference/computedPropertyNames41_ES6.symbols @@ -17,6 +17,6 @@ class C { // Computed properties static [""]() { return new Foo } ->"" : Symbol(C[[""]], Decl(computedPropertyNames41_ES6.ts, 4, 28)) +>"" : Symbol(C[""], Decl(computedPropertyNames41_ES6.ts, 4, 28)) >Foo : Symbol(Foo, Decl(computedPropertyNames41_ES6.ts, 0, 0)) } diff --git a/tests/baselines/reference/computedPropertyNames42_ES5.symbols b/tests/baselines/reference/computedPropertyNames42_ES5.symbols index c4fc11571f0de..7c3fa50362a1a 100644 --- a/tests/baselines/reference/computedPropertyNames42_ES5.symbols +++ b/tests/baselines/reference/computedPropertyNames42_ES5.symbols @@ -17,6 +17,6 @@ class C { // Computed properties [""]: Foo; ->"" : Symbol(C[[""]], Decl(computedPropertyNames42_ES5.ts, 4, 22)) +>"" : Symbol(C[""], Decl(computedPropertyNames42_ES5.ts, 4, 22)) >Foo : Symbol(Foo, Decl(computedPropertyNames42_ES5.ts, 0, 0)) } diff --git a/tests/baselines/reference/computedPropertyNames42_ES6.symbols b/tests/baselines/reference/computedPropertyNames42_ES6.symbols index fef7d3c50089d..2055a90e07406 100644 --- a/tests/baselines/reference/computedPropertyNames42_ES6.symbols +++ b/tests/baselines/reference/computedPropertyNames42_ES6.symbols @@ -17,6 +17,6 @@ class C { // Computed properties [""]: Foo; ->"" : Symbol(C[[""]], Decl(computedPropertyNames42_ES6.ts, 4, 22)) +>"" : Symbol(C[""], Decl(computedPropertyNames42_ES6.ts, 4, 22)) >Foo : Symbol(Foo, Decl(computedPropertyNames42_ES6.ts, 0, 0)) } diff --git a/tests/baselines/reference/computedPropertyNames43_ES5.symbols b/tests/baselines/reference/computedPropertyNames43_ES5.symbols index 3765c9af51d63..3fe757202806d 100644 --- a/tests/baselines/reference/computedPropertyNames43_ES5.symbols +++ b/tests/baselines/reference/computedPropertyNames43_ES5.symbols @@ -22,11 +22,11 @@ class D extends C { // Computed properties get ["get1"]() { return new Foo } ->"get1" : Symbol(D[["get1"]], Decl(computedPropertyNames43_ES5.ts, 7, 19)) +>"get1" : Symbol(D["get1"], Decl(computedPropertyNames43_ES5.ts, 7, 19)) >Foo : Symbol(Foo, Decl(computedPropertyNames43_ES5.ts, 0, 0)) set ["set1"](p: Foo2) { } ->"set1" : Symbol(D[["set1"]], Decl(computedPropertyNames43_ES5.ts, 9, 37)) +>"set1" : Symbol(D["set1"], Decl(computedPropertyNames43_ES5.ts, 9, 37)) >p : Symbol(p, Decl(computedPropertyNames43_ES5.ts, 10, 17)) >Foo2 : Symbol(Foo2, Decl(computedPropertyNames43_ES5.ts, 0, 15)) } diff --git a/tests/baselines/reference/computedPropertyNames43_ES6.symbols b/tests/baselines/reference/computedPropertyNames43_ES6.symbols index f37c0943bfd6b..4c2c808277104 100644 --- a/tests/baselines/reference/computedPropertyNames43_ES6.symbols +++ b/tests/baselines/reference/computedPropertyNames43_ES6.symbols @@ -22,11 +22,11 @@ class D extends C { // Computed properties get ["get1"]() { return new Foo } ->"get1" : Symbol(D[["get1"]], Decl(computedPropertyNames43_ES6.ts, 7, 19)) +>"get1" : Symbol(D["get1"], Decl(computedPropertyNames43_ES6.ts, 7, 19)) >Foo : Symbol(Foo, Decl(computedPropertyNames43_ES6.ts, 0, 0)) set ["set1"](p: Foo2) { } ->"set1" : Symbol(D[["set1"]], Decl(computedPropertyNames43_ES6.ts, 9, 37)) +>"set1" : Symbol(D["set1"], Decl(computedPropertyNames43_ES6.ts, 9, 37)) >p : Symbol(p, Decl(computedPropertyNames43_ES6.ts, 10, 17)) >Foo2 : Symbol(Foo2, Decl(computedPropertyNames43_ES6.ts, 0, 15)) } diff --git a/tests/baselines/reference/computedPropertyNames44_ES5.symbols b/tests/baselines/reference/computedPropertyNames44_ES5.symbols index ed097da110a70..ca3841411a099 100644 --- a/tests/baselines/reference/computedPropertyNames44_ES5.symbols +++ b/tests/baselines/reference/computedPropertyNames44_ES5.symbols @@ -16,7 +16,7 @@ class C { >Foo2 : Symbol(Foo2, Decl(computedPropertyNames44_ES5.ts, 0, 15)) get ["get1"]() { return new Foo } ->"get1" : Symbol(C[["get1"]], Decl(computedPropertyNames44_ES5.ts, 4, 22)) +>"get1" : Symbol(C["get1"], Decl(computedPropertyNames44_ES5.ts, 4, 22)) >Foo : Symbol(Foo, Decl(computedPropertyNames44_ES5.ts, 0, 0)) } @@ -25,7 +25,7 @@ class D extends C { >C : Symbol(C, Decl(computedPropertyNames44_ES5.ts, 1, 19)) set ["set1"](p: Foo) { } ->"set1" : Symbol(D[["set1"]], Decl(computedPropertyNames44_ES5.ts, 8, 19)) +>"set1" : Symbol(D["set1"], Decl(computedPropertyNames44_ES5.ts, 8, 19)) >p : Symbol(p, Decl(computedPropertyNames44_ES5.ts, 9, 17)) >Foo : Symbol(Foo, Decl(computedPropertyNames44_ES5.ts, 0, 0)) } diff --git a/tests/baselines/reference/computedPropertyNames44_ES6.symbols b/tests/baselines/reference/computedPropertyNames44_ES6.symbols index 7ac6914fe5a6c..13abd6f8f24a9 100644 --- a/tests/baselines/reference/computedPropertyNames44_ES6.symbols +++ b/tests/baselines/reference/computedPropertyNames44_ES6.symbols @@ -16,7 +16,7 @@ class C { >Foo2 : Symbol(Foo2, Decl(computedPropertyNames44_ES6.ts, 0, 15)) get ["get1"]() { return new Foo } ->"get1" : Symbol(C[["get1"]], Decl(computedPropertyNames44_ES6.ts, 4, 22)) +>"get1" : Symbol(C["get1"], Decl(computedPropertyNames44_ES6.ts, 4, 22)) >Foo : Symbol(Foo, Decl(computedPropertyNames44_ES6.ts, 0, 0)) } @@ -25,7 +25,7 @@ class D extends C { >C : Symbol(C, Decl(computedPropertyNames44_ES6.ts, 1, 19)) set ["set1"](p: Foo) { } ->"set1" : Symbol(D[["set1"]], Decl(computedPropertyNames44_ES6.ts, 8, 19)) +>"set1" : Symbol(D["set1"], Decl(computedPropertyNames44_ES6.ts, 8, 19)) >p : Symbol(p, Decl(computedPropertyNames44_ES6.ts, 9, 17)) >Foo : Symbol(Foo, Decl(computedPropertyNames44_ES6.ts, 0, 0)) } diff --git a/tests/baselines/reference/computedPropertyNames45_ES5.symbols b/tests/baselines/reference/computedPropertyNames45_ES5.symbols index 3028174bb4f3e..04887f8e9ffec 100644 --- a/tests/baselines/reference/computedPropertyNames45_ES5.symbols +++ b/tests/baselines/reference/computedPropertyNames45_ES5.symbols @@ -12,7 +12,7 @@ class C { >C : Symbol(C, Decl(computedPropertyNames45_ES5.ts, 1, 19)) get ["get1"]() { return new Foo } ->"get1" : Symbol(C[["get1"]], Decl(computedPropertyNames45_ES5.ts, 3, 9)) +>"get1" : Symbol(C["get1"], Decl(computedPropertyNames45_ES5.ts, 3, 9)) >Foo : Symbol(Foo, Decl(computedPropertyNames45_ES5.ts, 0, 0)) } @@ -26,7 +26,7 @@ class D extends C { >Foo2 : Symbol(Foo2, Decl(computedPropertyNames45_ES5.ts, 0, 15)) set ["set1"](p: Foo) { } ->"set1" : Symbol(D[["set1"]], Decl(computedPropertyNames45_ES5.ts, 9, 22)) +>"set1" : Symbol(D["set1"], Decl(computedPropertyNames45_ES5.ts, 9, 22)) >p : Symbol(p, Decl(computedPropertyNames45_ES5.ts, 10, 17)) >Foo : Symbol(Foo, Decl(computedPropertyNames45_ES5.ts, 0, 0)) } diff --git a/tests/baselines/reference/computedPropertyNames45_ES6.symbols b/tests/baselines/reference/computedPropertyNames45_ES6.symbols index 110fe23aeef38..5e01cb0201e80 100644 --- a/tests/baselines/reference/computedPropertyNames45_ES6.symbols +++ b/tests/baselines/reference/computedPropertyNames45_ES6.symbols @@ -12,7 +12,7 @@ class C { >C : Symbol(C, Decl(computedPropertyNames45_ES6.ts, 1, 19)) get ["get1"]() { return new Foo } ->"get1" : Symbol(C[["get1"]], Decl(computedPropertyNames45_ES6.ts, 3, 9)) +>"get1" : Symbol(C["get1"], Decl(computedPropertyNames45_ES6.ts, 3, 9)) >Foo : Symbol(Foo, Decl(computedPropertyNames45_ES6.ts, 0, 0)) } @@ -26,7 +26,7 @@ class D extends C { >Foo2 : Symbol(Foo2, Decl(computedPropertyNames45_ES6.ts, 0, 15)) set ["set1"](p: Foo) { } ->"set1" : Symbol(D[["set1"]], Decl(computedPropertyNames45_ES6.ts, 9, 22)) +>"set1" : Symbol(D["set1"], Decl(computedPropertyNames45_ES6.ts, 9, 22)) >p : Symbol(p, Decl(computedPropertyNames45_ES6.ts, 10, 17)) >Foo : Symbol(Foo, Decl(computedPropertyNames45_ES6.ts, 0, 0)) } diff --git a/tests/baselines/reference/computedPropertyNamesDeclarationEmit3_ES5.errors.txt b/tests/baselines/reference/computedPropertyNamesDeclarationEmit3_ES5.errors.txt index b6effe98a91ec..8ac89ebdb1976 100644 --- a/tests/baselines/reference/computedPropertyNamesDeclarationEmit3_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNamesDeclarationEmit3_ES5.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNamesDeclarationEmit3_ES5.ts(2,5): error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +tests/cases/conformance/es6/computedProperties/computedPropertyNamesDeclarationEmit3_ES5.ts(2,5): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNamesDeclarationEmit3_ES5.ts (1 errors) ==== interface I { ["" + ""](): void; ~~~~~~~~~ -!!! error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNamesDeclarationEmit3_ES6.errors.txt b/tests/baselines/reference/computedPropertyNamesDeclarationEmit3_ES6.errors.txt index 99832a42e37ac..79b0971d0b7b4 100644 --- a/tests/baselines/reference/computedPropertyNamesDeclarationEmit3_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNamesDeclarationEmit3_ES6.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNamesDeclarationEmit3_ES6.ts(2,5): error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +tests/cases/conformance/es6/computedProperties/computedPropertyNamesDeclarationEmit3_ES6.ts(2,5): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNamesDeclarationEmit3_ES6.ts (1 errors) ==== interface I { ["" + ""](): void; ~~~~~~~~~ -!!! error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNamesDeclarationEmit4_ES5.errors.txt b/tests/baselines/reference/computedPropertyNamesDeclarationEmit4_ES5.errors.txt index fd84ac72270b9..be1543e81eb41 100644 --- a/tests/baselines/reference/computedPropertyNamesDeclarationEmit4_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNamesDeclarationEmit4_ES5.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNamesDeclarationEmit4_ES5.ts(2,5): error TS1170: A computed property name in a type literal must directly refer to a built-in symbol. +tests/cases/conformance/es6/computedProperties/computedPropertyNamesDeclarationEmit4_ES5.ts(2,5): error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNamesDeclarationEmit4_ES5.ts (1 errors) ==== var v: { ["" + ""](): void; ~~~~~~~~~ -!!! error TS1170: A computed property name in a type literal must directly refer to a built-in symbol. +!!! error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type. } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNamesDeclarationEmit4_ES6.errors.txt b/tests/baselines/reference/computedPropertyNamesDeclarationEmit4_ES6.errors.txt index 7cdd26576cb99..51daaef725f1b 100644 --- a/tests/baselines/reference/computedPropertyNamesDeclarationEmit4_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNamesDeclarationEmit4_ES6.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNamesDeclarationEmit4_ES6.ts(2,5): error TS1170: A computed property name in a type literal must directly refer to a built-in symbol. +tests/cases/conformance/es6/computedProperties/computedPropertyNamesDeclarationEmit4_ES6.ts(2,5): error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNamesDeclarationEmit4_ES6.ts (1 errors) ==== var v: { ["" + ""](): void; ~~~~~~~~~ -!!! error TS1170: A computed property name in a type literal must directly refer to a built-in symbol. +!!! error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type. } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNamesOnOverloads_ES5.errors.txt b/tests/baselines/reference/computedPropertyNamesOnOverloads_ES5.errors.txt index 2a17d7da81570..cdd5577f01100 100644 --- a/tests/baselines/reference/computedPropertyNamesOnOverloads_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNamesOnOverloads_ES5.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads_ES5.ts(4,5): error TS1168: A computed property name in a method overload must directly refer to a built-in symbol. -tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads_ES5.ts(5,5): error TS1168: A computed property name in a method overload must directly refer to a built-in symbol. +tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads_ES5.ts(4,5): error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads_ES5.ts(5,5): error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads_ES5.ts (2 errors) ==== @@ -8,9 +8,9 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads_ class C { [methodName](v: string); ~~~~~~~~~~~~ -!!! error TS1168: A computed property name in a method overload must directly refer to a built-in symbol. +!!! error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type. [methodName](); ~~~~~~~~~~~~ -!!! error TS1168: A computed property name in a method overload must directly refer to a built-in symbol. +!!! error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type. [methodName](v?: string) { } } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNamesOnOverloads_ES6.errors.txt b/tests/baselines/reference/computedPropertyNamesOnOverloads_ES6.errors.txt index 381ee7c17bac9..3f31d4088106c 100644 --- a/tests/baselines/reference/computedPropertyNamesOnOverloads_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNamesOnOverloads_ES6.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads_ES6.ts(4,5): error TS1168: A computed property name in a method overload must directly refer to a built-in symbol. -tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads_ES6.ts(5,5): error TS1168: A computed property name in a method overload must directly refer to a built-in symbol. +tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads_ES6.ts(4,5): error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads_ES6.ts(5,5): error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads_ES6.ts (2 errors) ==== @@ -8,9 +8,9 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNamesOnOverloads_ class C { [methodName](v: string); ~~~~~~~~~~~~ -!!! error TS1168: A computed property name in a method overload must directly refer to a built-in symbol. +!!! error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type. [methodName](); ~~~~~~~~~~~~ -!!! error TS1168: A computed property name in a method overload must directly refer to a built-in symbol. +!!! error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type. [methodName](v?: string) { } } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNamesSourceMap1_ES5.symbols b/tests/baselines/reference/computedPropertyNamesSourceMap1_ES5.symbols index 9f4f5110e8fcb..cdb193e3bd394 100644 --- a/tests/baselines/reference/computedPropertyNamesSourceMap1_ES5.symbols +++ b/tests/baselines/reference/computedPropertyNamesSourceMap1_ES5.symbols @@ -3,12 +3,12 @@ class C { >C : Symbol(C, Decl(computedPropertyNamesSourceMap1_ES5.ts, 0, 0)) ["hello"]() { ->"hello" : Symbol(C[["hello"]], Decl(computedPropertyNamesSourceMap1_ES5.ts, 0, 9)) +>"hello" : Symbol(C["hello"], Decl(computedPropertyNamesSourceMap1_ES5.ts, 0, 9)) debugger; } get ["goodbye"]() { ->"goodbye" : Symbol(C[["goodbye"]], Decl(computedPropertyNamesSourceMap1_ES5.ts, 3, 5)) +>"goodbye" : Symbol(C["goodbye"], Decl(computedPropertyNamesSourceMap1_ES5.ts, 3, 5)) return 0; } diff --git a/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.symbols b/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.symbols index 447bbaebb7cc8..e8ebdab2fd8b4 100644 --- a/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.symbols +++ b/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.symbols @@ -3,12 +3,12 @@ class C { >C : Symbol(C, Decl(computedPropertyNamesSourceMap1_ES6.ts, 0, 0)) ["hello"]() { ->"hello" : Symbol(C[["hello"]], Decl(computedPropertyNamesSourceMap1_ES6.ts, 0, 9)) +>"hello" : Symbol(C["hello"], Decl(computedPropertyNamesSourceMap1_ES6.ts, 0, 9)) debugger; } get ["goodbye"]() { ->"goodbye" : Symbol(C[["goodbye"]], Decl(computedPropertyNamesSourceMap1_ES6.ts, 3, 2)) +>"goodbye" : Symbol(C["goodbye"], Decl(computedPropertyNamesSourceMap1_ES6.ts, 3, 2)) return 0; } diff --git a/tests/baselines/reference/decoratorOnClassMethod13.symbols b/tests/baselines/reference/decoratorOnClassMethod13.symbols index 7cd369be14421..5700e6a3bf3a0 100644 --- a/tests/baselines/reference/decoratorOnClassMethod13.symbols +++ b/tests/baselines/reference/decoratorOnClassMethod13.symbols @@ -15,9 +15,9 @@ class C { @dec ["1"]() { } >dec : Symbol(dec, Decl(decoratorOnClassMethod13.ts, 0, 0)) ->"1" : Symbol(C[["1"]], Decl(decoratorOnClassMethod13.ts, 2, 9)) +>"1" : Symbol(C["1"], Decl(decoratorOnClassMethod13.ts, 2, 9)) @dec ["b"]() { } >dec : Symbol(dec, Decl(decoratorOnClassMethod13.ts, 0, 0)) ->"b" : Symbol(C[["b"]], Decl(decoratorOnClassMethod13.ts, 3, 20)) +>"b" : Symbol(C["b"], Decl(decoratorOnClassMethod13.ts, 3, 20)) } diff --git a/tests/baselines/reference/decoratorOnClassMethod4.symbols b/tests/baselines/reference/decoratorOnClassMethod4.symbols index da0e9eafca7f6..30d300a937a79 100644 --- a/tests/baselines/reference/decoratorOnClassMethod4.symbols +++ b/tests/baselines/reference/decoratorOnClassMethod4.symbols @@ -15,5 +15,5 @@ class C { @dec ["method"]() {} >dec : Symbol(dec, Decl(decoratorOnClassMethod4.ts, 0, 0)) ->"method" : Symbol(C[["method"]], Decl(decoratorOnClassMethod4.ts, 2, 9)) +>"method" : Symbol(C["method"], Decl(decoratorOnClassMethod4.ts, 2, 9)) } diff --git a/tests/baselines/reference/decoratorOnClassMethod5.symbols b/tests/baselines/reference/decoratorOnClassMethod5.symbols index bd895deeea808..004af8b9f8e8a 100644 --- a/tests/baselines/reference/decoratorOnClassMethod5.symbols +++ b/tests/baselines/reference/decoratorOnClassMethod5.symbols @@ -15,5 +15,5 @@ class C { @dec() ["method"]() {} >dec : Symbol(dec, Decl(decoratorOnClassMethod5.ts, 0, 0)) ->"method" : Symbol(C[["method"]], Decl(decoratorOnClassMethod5.ts, 2, 9)) +>"method" : Symbol(C["method"], Decl(decoratorOnClassMethod5.ts, 2, 9)) } diff --git a/tests/baselines/reference/decoratorOnClassMethod6.symbols b/tests/baselines/reference/decoratorOnClassMethod6.symbols index 6391192ece3de..bc9046aa666a6 100644 --- a/tests/baselines/reference/decoratorOnClassMethod6.symbols +++ b/tests/baselines/reference/decoratorOnClassMethod6.symbols @@ -15,5 +15,5 @@ class C { @dec ["method"]() {} >dec : Symbol(dec, Decl(decoratorOnClassMethod6.ts, 0, 0)) ->"method" : Symbol(C[["method"]], Decl(decoratorOnClassMethod6.ts, 2, 9)) +>"method" : Symbol(C["method"], Decl(decoratorOnClassMethod6.ts, 2, 9)) } diff --git a/tests/baselines/reference/decoratorOnClassMethod7.symbols b/tests/baselines/reference/decoratorOnClassMethod7.symbols index 9ec0de0c205f9..90e538ebfc4f7 100644 --- a/tests/baselines/reference/decoratorOnClassMethod7.symbols +++ b/tests/baselines/reference/decoratorOnClassMethod7.symbols @@ -15,5 +15,5 @@ class C { @dec public ["method"]() {} >dec : Symbol(dec, Decl(decoratorOnClassMethod7.ts, 0, 0)) ->"method" : Symbol(C[["method"]], Decl(decoratorOnClassMethod7.ts, 2, 9)) +>"method" : Symbol(C["method"], Decl(decoratorOnClassMethod7.ts, 2, 9)) } diff --git a/tests/baselines/reference/decoratorsOnComputedProperties.errors.txt b/tests/baselines/reference/decoratorsOnComputedProperties.errors.txt index 2aef827d4f514..42b678e088f7f 100644 --- a/tests/baselines/reference/decoratorsOnComputedProperties.errors.txt +++ b/tests/baselines/reference/decoratorsOnComputedProperties.errors.txt @@ -1,82 +1,82 @@ -tests/cases/compiler/decoratorsOnComputedProperties.ts(18,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(19,8): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(20,8): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(21,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(22,8): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(23,8): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/compiler/decoratorsOnComputedProperties.ts(18,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(19,8): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(20,8): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(21,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(22,8): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(23,8): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/decoratorsOnComputedProperties.ts(27,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(28,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(29,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(30,5): error TS1206: Decorators are not valid here. -tests/cases/compiler/decoratorsOnComputedProperties.ts(35,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/compiler/decoratorsOnComputedProperties.ts(35,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/decoratorsOnComputedProperties.ts(36,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(37,5): error TS1206: Decorators are not valid here. -tests/cases/compiler/decoratorsOnComputedProperties.ts(38,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/compiler/decoratorsOnComputedProperties.ts(38,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/decoratorsOnComputedProperties.ts(39,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(40,5): error TS1206: Decorators are not valid here. -tests/cases/compiler/decoratorsOnComputedProperties.ts(52,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(53,8): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(54,8): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(55,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(56,8): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(57,8): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/compiler/decoratorsOnComputedProperties.ts(52,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(53,8): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(54,8): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(55,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(56,8): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(57,8): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/decoratorsOnComputedProperties.ts(62,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(63,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(64,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(65,5): error TS1206: Decorators are not valid here. -tests/cases/compiler/decoratorsOnComputedProperties.ts(70,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/compiler/decoratorsOnComputedProperties.ts(70,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/decoratorsOnComputedProperties.ts(71,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(72,5): error TS1206: Decorators are not valid here. -tests/cases/compiler/decoratorsOnComputedProperties.ts(73,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/compiler/decoratorsOnComputedProperties.ts(73,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/decoratorsOnComputedProperties.ts(74,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(75,5): error TS1206: Decorators are not valid here. -tests/cases/compiler/decoratorsOnComputedProperties.ts(88,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(89,8): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(90,8): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(92,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(93,8): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(94,8): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/compiler/decoratorsOnComputedProperties.ts(88,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(89,8): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(90,8): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(92,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(93,8): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(94,8): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/decoratorsOnComputedProperties.ts(98,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(99,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(100,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(101,5): error TS1206: Decorators are not valid here. -tests/cases/compiler/decoratorsOnComputedProperties.ts(106,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/compiler/decoratorsOnComputedProperties.ts(106,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/decoratorsOnComputedProperties.ts(107,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(108,5): error TS1206: Decorators are not valid here. -tests/cases/compiler/decoratorsOnComputedProperties.ts(110,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/compiler/decoratorsOnComputedProperties.ts(110,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/decoratorsOnComputedProperties.ts(111,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(112,5): error TS1206: Decorators are not valid here. -tests/cases/compiler/decoratorsOnComputedProperties.ts(124,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(125,8): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(126,8): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(128,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(129,8): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(131,8): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/compiler/decoratorsOnComputedProperties.ts(124,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(125,8): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(126,8): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(128,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(129,8): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(131,8): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/decoratorsOnComputedProperties.ts(135,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(136,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(137,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(138,5): error TS1206: Decorators are not valid here. -tests/cases/compiler/decoratorsOnComputedProperties.ts(143,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/compiler/decoratorsOnComputedProperties.ts(143,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/decoratorsOnComputedProperties.ts(144,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(145,5): error TS1206: Decorators are not valid here. -tests/cases/compiler/decoratorsOnComputedProperties.ts(147,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/compiler/decoratorsOnComputedProperties.ts(147,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/decoratorsOnComputedProperties.ts(148,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(150,5): error TS1206: Decorators are not valid here. -tests/cases/compiler/decoratorsOnComputedProperties.ts(162,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(163,8): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(164,8): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(166,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(167,8): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/compiler/decoratorsOnComputedProperties.ts(169,8): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/compiler/decoratorsOnComputedProperties.ts(162,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(163,8): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(164,8): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(166,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(167,8): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/compiler/decoratorsOnComputedProperties.ts(169,8): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/decoratorsOnComputedProperties.ts(173,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(174,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(175,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(176,5): error TS1206: Decorators are not valid here. -tests/cases/compiler/decoratorsOnComputedProperties.ts(181,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/compiler/decoratorsOnComputedProperties.ts(181,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/decoratorsOnComputedProperties.ts(182,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(183,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(184,5): error TS1206: Decorators are not valid here. -tests/cases/compiler/decoratorsOnComputedProperties.ts(185,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/compiler/decoratorsOnComputedProperties.ts(185,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/decoratorsOnComputedProperties.ts(186,5): error TS1206: Decorators are not valid here. tests/cases/compiler/decoratorsOnComputedProperties.ts(188,5): error TS1206: Decorators are not valid here. @@ -101,22 +101,22 @@ tests/cases/compiler/decoratorsOnComputedProperties.ts(188,5): error TS1206: Dec [Symbol.match]: any = null; [foo()]: any; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [foo()]: any; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [foo()]: any = null; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. [fieldNameA]: any; ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [fieldNameB]: any; ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [fieldNameC]: any = null; ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. } void class B { @@ -138,7 +138,7 @@ tests/cases/compiler/decoratorsOnComputedProperties.ts(188,5): error TS1206: Dec [Symbol.match]: any = null; [foo()]: any; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [foo()]: any; ~ !!! error TS1206: Decorators are not valid here. @@ -147,7 +147,7 @@ tests/cases/compiler/decoratorsOnComputedProperties.ts(188,5): error TS1206: Dec !!! error TS1206: Decorators are not valid here. [fieldNameA]: any; ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [fieldNameB]: any; ~ !!! error TS1206: Decorators are not valid here. @@ -167,22 +167,22 @@ tests/cases/compiler/decoratorsOnComputedProperties.ts(188,5): error TS1206: Dec [Symbol.match]: any = null; [foo()]: any; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [foo()]: any; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [foo()]: any = null; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. [fieldNameA]: any; ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [fieldNameB]: any; ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [fieldNameC]: any = null; ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ["some" + "method"]() {} } @@ -205,7 +205,7 @@ tests/cases/compiler/decoratorsOnComputedProperties.ts(188,5): error TS1206: Dec [Symbol.match]: any = null; [foo()]: any; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [foo()]: any; ~ !!! error TS1206: Decorators are not valid here. @@ -214,7 +214,7 @@ tests/cases/compiler/decoratorsOnComputedProperties.ts(188,5): error TS1206: Dec !!! error TS1206: Decorators are not valid here. [fieldNameA]: any; ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [fieldNameB]: any; ~ !!! error TS1206: Decorators are not valid here. @@ -235,23 +235,23 @@ tests/cases/compiler/decoratorsOnComputedProperties.ts(188,5): error TS1206: Dec [Symbol.match]: any = null; [foo()]: any; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [foo()]: any; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [foo()]: any = null; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ["some" + "method"]() {} [fieldNameA]: any; ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [fieldNameB]: any; ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [fieldNameC]: any = null; ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. } void class F { @@ -273,7 +273,7 @@ tests/cases/compiler/decoratorsOnComputedProperties.ts(188,5): error TS1206: Dec [Symbol.match]: any = null; [foo()]: any; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [foo()]: any; ~ !!! error TS1206: Decorators are not valid here. @@ -283,7 +283,7 @@ tests/cases/compiler/decoratorsOnComputedProperties.ts(188,5): error TS1206: Dec ["some" + "method"]() {} [fieldNameA]: any; ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [fieldNameB]: any; ~ !!! error TS1206: Decorators are not valid here. @@ -303,24 +303,24 @@ tests/cases/compiler/decoratorsOnComputedProperties.ts(188,5): error TS1206: Dec [Symbol.match]: any = null; [foo()]: any; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [foo()]: any; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [foo()]: any = null; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ["some" + "method"]() {} [fieldNameA]: any; ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [fieldNameB]: any; ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ["some" + "method2"]() {} @x [fieldNameC]: any = null; ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. } void class H { @@ -342,7 +342,7 @@ tests/cases/compiler/decoratorsOnComputedProperties.ts(188,5): error TS1206: Dec [Symbol.match]: any = null; [foo()]: any; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [foo()]: any; ~ !!! error TS1206: Decorators are not valid here. @@ -352,7 +352,7 @@ tests/cases/compiler/decoratorsOnComputedProperties.ts(188,5): error TS1206: Dec ["some" + "method"]() {} [fieldNameA]: any; ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [fieldNameB]: any; ~ !!! error TS1206: Decorators are not valid here. @@ -373,24 +373,24 @@ tests/cases/compiler/decoratorsOnComputedProperties.ts(188,5): error TS1206: Dec [Symbol.match]: any = null; [foo()]: any; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [foo()]: any; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [foo()]: any = null; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x ["some" + "method"]() {} [fieldNameA]: any; ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [fieldNameB]: any; ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ["some" + "method2"]() {} @x [fieldNameC]: any = null; ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. } void class J { @@ -412,7 +412,7 @@ tests/cases/compiler/decoratorsOnComputedProperties.ts(188,5): error TS1206: Dec [Symbol.match]: any = null; [foo()]: any; ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [foo()]: any; ~ !!! error TS1206: Decorators are not valid here. @@ -424,7 +424,7 @@ tests/cases/compiler/decoratorsOnComputedProperties.ts(188,5): error TS1206: Dec !!! error TS1206: Decorators are not valid here. [fieldNameA]: any; ~~~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. @x [fieldNameB]: any; ~ !!! error TS1206: Decorators are not valid here. diff --git a/tests/baselines/reference/decoratorsOnComputedProperties.symbols b/tests/baselines/reference/decoratorsOnComputedProperties.symbols index a9fb280f96ed1..f55f60b3f4eb7 100644 --- a/tests/baselines/reference/decoratorsOnComputedProperties.symbols +++ b/tests/baselines/reference/decoratorsOnComputedProperties.symbols @@ -26,7 +26,7 @@ class A { @x ["property"]: any; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) ->"property" : Symbol(A[["property"]], Decl(decoratorsOnComputedProperties.ts, 8, 9)) +>"property" : Symbol(A["property"], Decl(decoratorsOnComputedProperties.ts, 8, 9)) @x [Symbol.toStringTag]: any; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) @@ -36,7 +36,7 @@ class A { @x ["property2"]: any = 2; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) ->"property2" : Symbol(A[["property2"]], Decl(decoratorsOnComputedProperties.ts, 10, 33)) +>"property2" : Symbol(A["property2"], Decl(decoratorsOnComputedProperties.ts, 10, 33)) @x [Symbol.iterator]: any = null; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) @@ -45,7 +45,7 @@ class A { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) ["property3"]: any; ->"property3" : Symbol(A[["property3"]], Decl(decoratorsOnComputedProperties.ts, 12, 37)) +>"property3" : Symbol(A["property3"], Decl(decoratorsOnComputedProperties.ts, 12, 37)) [Symbol.isConcatSpreadable]: any; >Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) @@ -53,7 +53,7 @@ class A { >isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ["property4"]: any = 2; ->"property4" : Symbol(A[["property4"]], Decl(decoratorsOnComputedProperties.ts, 14, 37)) +>"property4" : Symbol(A["property4"], Decl(decoratorsOnComputedProperties.ts, 14, 37)) [Symbol.match]: any = null; >Symbol.match : Symbol(SymbolConstructor.match, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) @@ -88,7 +88,7 @@ void class B { @x ["property"]: any; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) ->"property" : Symbol(B[["property"]], Decl(decoratorsOnComputedProperties.ts, 25, 14)) +>"property" : Symbol(B["property"], Decl(decoratorsOnComputedProperties.ts, 25, 14)) @x [Symbol.toStringTag]: any; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) @@ -98,7 +98,7 @@ void class B { @x ["property2"]: any = 2; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) ->"property2" : Symbol(B[["property2"]], Decl(decoratorsOnComputedProperties.ts, 27, 33)) +>"property2" : Symbol(B["property2"], Decl(decoratorsOnComputedProperties.ts, 27, 33)) @x [Symbol.iterator]: any = null; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) @@ -107,7 +107,7 @@ void class B { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) ["property3"]: any; ->"property3" : Symbol(B[["property3"]], Decl(decoratorsOnComputedProperties.ts, 29, 37)) +>"property3" : Symbol(B["property3"], Decl(decoratorsOnComputedProperties.ts, 29, 37)) [Symbol.isConcatSpreadable]: any; >Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) @@ -115,7 +115,7 @@ void class B { >isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ["property4"]: any = 2; ->"property4" : Symbol(B[["property4"]], Decl(decoratorsOnComputedProperties.ts, 31, 37)) +>"property4" : Symbol(B["property4"], Decl(decoratorsOnComputedProperties.ts, 31, 37)) [Symbol.match]: any = null; >Symbol.match : Symbol(SymbolConstructor.match, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) @@ -151,7 +151,7 @@ class C { @x ["property"]: any; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) ->"property" : Symbol(C[["property"]], Decl(decoratorsOnComputedProperties.ts, 42, 9)) +>"property" : Symbol(C["property"], Decl(decoratorsOnComputedProperties.ts, 42, 9)) @x [Symbol.toStringTag]: any; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) @@ -161,7 +161,7 @@ class C { @x ["property2"]: any = 2; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) ->"property2" : Symbol(C[["property2"]], Decl(decoratorsOnComputedProperties.ts, 44, 33)) +>"property2" : Symbol(C["property2"], Decl(decoratorsOnComputedProperties.ts, 44, 33)) @x [Symbol.iterator]: any = null; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) @@ -170,7 +170,7 @@ class C { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) ["property3"]: any; ->"property3" : Symbol(C[["property3"]], Decl(decoratorsOnComputedProperties.ts, 46, 37)) +>"property3" : Symbol(C["property3"], Decl(decoratorsOnComputedProperties.ts, 46, 37)) [Symbol.isConcatSpreadable]: any; >Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) @@ -178,7 +178,7 @@ class C { >isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ["property4"]: any = 2; ->"property4" : Symbol(C[["property4"]], Decl(decoratorsOnComputedProperties.ts, 48, 37)) +>"property4" : Symbol(C["property4"], Decl(decoratorsOnComputedProperties.ts, 48, 37)) [Symbol.match]: any = null; >Symbol.match : Symbol(SymbolConstructor.match, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) @@ -215,7 +215,7 @@ void class D { @x ["property"]: any; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) ->"property" : Symbol(D[["property"]], Decl(decoratorsOnComputedProperties.ts, 60, 14)) +>"property" : Symbol(D["property"], Decl(decoratorsOnComputedProperties.ts, 60, 14)) @x [Symbol.toStringTag]: any; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) @@ -225,7 +225,7 @@ void class D { @x ["property2"]: any = 2; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) ->"property2" : Symbol(D[["property2"]], Decl(decoratorsOnComputedProperties.ts, 62, 33)) +>"property2" : Symbol(D["property2"], Decl(decoratorsOnComputedProperties.ts, 62, 33)) @x [Symbol.iterator]: any = null; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) @@ -234,7 +234,7 @@ void class D { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) ["property3"]: any; ->"property3" : Symbol(D[["property3"]], Decl(decoratorsOnComputedProperties.ts, 64, 37)) +>"property3" : Symbol(D["property3"], Decl(decoratorsOnComputedProperties.ts, 64, 37)) [Symbol.isConcatSpreadable]: any; >Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) @@ -242,7 +242,7 @@ void class D { >isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ["property4"]: any = 2; ->"property4" : Symbol(D[["property4"]], Decl(decoratorsOnComputedProperties.ts, 66, 37)) +>"property4" : Symbol(D["property4"], Decl(decoratorsOnComputedProperties.ts, 66, 37)) [Symbol.match]: any = null; >Symbol.match : Symbol(SymbolConstructor.match, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) @@ -279,7 +279,7 @@ class E { @x ["property"]: any; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) ->"property" : Symbol(E[["property"]], Decl(decoratorsOnComputedProperties.ts, 78, 9)) +>"property" : Symbol(E["property"], Decl(decoratorsOnComputedProperties.ts, 78, 9)) @x [Symbol.toStringTag]: any; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) @@ -289,7 +289,7 @@ class E { @x ["property2"]: any = 2; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) ->"property2" : Symbol(E[["property2"]], Decl(decoratorsOnComputedProperties.ts, 80, 33)) +>"property2" : Symbol(E["property2"], Decl(decoratorsOnComputedProperties.ts, 80, 33)) @x [Symbol.iterator]: any = null; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) @@ -298,7 +298,7 @@ class E { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) ["property3"]: any; ->"property3" : Symbol(E[["property3"]], Decl(decoratorsOnComputedProperties.ts, 82, 37)) +>"property3" : Symbol(E["property3"], Decl(decoratorsOnComputedProperties.ts, 82, 37)) [Symbol.isConcatSpreadable]: any; >Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) @@ -306,7 +306,7 @@ class E { >isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ["property4"]: any = 2; ->"property4" : Symbol(E[["property4"]], Decl(decoratorsOnComputedProperties.ts, 84, 37)) +>"property4" : Symbol(E["property4"], Decl(decoratorsOnComputedProperties.ts, 84, 37)) [Symbol.match]: any = null; >Symbol.match : Symbol(SymbolConstructor.match, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) @@ -342,7 +342,7 @@ void class F { @x ["property"]: any; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) ->"property" : Symbol(F[["property"]], Decl(decoratorsOnComputedProperties.ts, 96, 14)) +>"property" : Symbol(F["property"], Decl(decoratorsOnComputedProperties.ts, 96, 14)) @x [Symbol.toStringTag]: any; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) @@ -352,7 +352,7 @@ void class F { @x ["property2"]: any = 2; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) ->"property2" : Symbol(F[["property2"]], Decl(decoratorsOnComputedProperties.ts, 98, 33)) +>"property2" : Symbol(F["property2"], Decl(decoratorsOnComputedProperties.ts, 98, 33)) @x [Symbol.iterator]: any = null; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) @@ -361,7 +361,7 @@ void class F { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) ["property3"]: any; ->"property3" : Symbol(F[["property3"]], Decl(decoratorsOnComputedProperties.ts, 100, 37)) +>"property3" : Symbol(F["property3"], Decl(decoratorsOnComputedProperties.ts, 100, 37)) [Symbol.isConcatSpreadable]: any; >Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) @@ -369,7 +369,7 @@ void class F { >isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ["property4"]: any = 2; ->"property4" : Symbol(F[["property4"]], Decl(decoratorsOnComputedProperties.ts, 102, 37)) +>"property4" : Symbol(F["property4"], Decl(decoratorsOnComputedProperties.ts, 102, 37)) [Symbol.match]: any = null; >Symbol.match : Symbol(SymbolConstructor.match, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) @@ -406,7 +406,7 @@ class G { @x ["property"]: any; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) ->"property" : Symbol(G[["property"]], Decl(decoratorsOnComputedProperties.ts, 114, 9)) +>"property" : Symbol(G["property"], Decl(decoratorsOnComputedProperties.ts, 114, 9)) @x [Symbol.toStringTag]: any; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) @@ -416,7 +416,7 @@ class G { @x ["property2"]: any = 2; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) ->"property2" : Symbol(G[["property2"]], Decl(decoratorsOnComputedProperties.ts, 116, 33)) +>"property2" : Symbol(G["property2"], Decl(decoratorsOnComputedProperties.ts, 116, 33)) @x [Symbol.iterator]: any = null; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) @@ -425,7 +425,7 @@ class G { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) ["property3"]: any; ->"property3" : Symbol(G[["property3"]], Decl(decoratorsOnComputedProperties.ts, 118, 37)) +>"property3" : Symbol(G["property3"], Decl(decoratorsOnComputedProperties.ts, 118, 37)) [Symbol.isConcatSpreadable]: any; >Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) @@ -433,7 +433,7 @@ class G { >isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ["property4"]: any = 2; ->"property4" : Symbol(G[["property4"]], Decl(decoratorsOnComputedProperties.ts, 120, 37)) +>"property4" : Symbol(G["property4"], Decl(decoratorsOnComputedProperties.ts, 120, 37)) [Symbol.match]: any = null; >Symbol.match : Symbol(SymbolConstructor.match, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) @@ -470,7 +470,7 @@ void class H { @x ["property"]: any; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) ->"property" : Symbol(H[["property"]], Decl(decoratorsOnComputedProperties.ts, 133, 14)) +>"property" : Symbol(H["property"], Decl(decoratorsOnComputedProperties.ts, 133, 14)) @x [Symbol.toStringTag]: any; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) @@ -480,7 +480,7 @@ void class H { @x ["property2"]: any = 2; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) ->"property2" : Symbol(H[["property2"]], Decl(decoratorsOnComputedProperties.ts, 135, 33)) +>"property2" : Symbol(H["property2"], Decl(decoratorsOnComputedProperties.ts, 135, 33)) @x [Symbol.iterator]: any = null; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) @@ -489,7 +489,7 @@ void class H { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) ["property3"]: any; ->"property3" : Symbol(H[["property3"]], Decl(decoratorsOnComputedProperties.ts, 137, 37)) +>"property3" : Symbol(H["property3"], Decl(decoratorsOnComputedProperties.ts, 137, 37)) [Symbol.isConcatSpreadable]: any; >Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) @@ -497,7 +497,7 @@ void class H { >isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ["property4"]: any = 2; ->"property4" : Symbol(H[["property4"]], Decl(decoratorsOnComputedProperties.ts, 139, 37)) +>"property4" : Symbol(H["property4"], Decl(decoratorsOnComputedProperties.ts, 139, 37)) [Symbol.match]: any = null; >Symbol.match : Symbol(SymbolConstructor.match, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) @@ -535,7 +535,7 @@ class I { @x ["property"]: any; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) ->"property" : Symbol(I[["property"]], Decl(decoratorsOnComputedProperties.ts, 152, 9)) +>"property" : Symbol(I["property"], Decl(decoratorsOnComputedProperties.ts, 152, 9)) @x [Symbol.toStringTag]: any; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) @@ -545,7 +545,7 @@ class I { @x ["property2"]: any = 2; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) ->"property2" : Symbol(I[["property2"]], Decl(decoratorsOnComputedProperties.ts, 154, 33)) +>"property2" : Symbol(I["property2"], Decl(decoratorsOnComputedProperties.ts, 154, 33)) @x [Symbol.iterator]: any = null; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) @@ -554,7 +554,7 @@ class I { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) ["property3"]: any; ->"property3" : Symbol(I[["property3"]], Decl(decoratorsOnComputedProperties.ts, 156, 37)) +>"property3" : Symbol(I["property3"], Decl(decoratorsOnComputedProperties.ts, 156, 37)) [Symbol.isConcatSpreadable]: any; >Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) @@ -562,7 +562,7 @@ class I { >isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ["property4"]: any = 2; ->"property4" : Symbol(I[["property4"]], Decl(decoratorsOnComputedProperties.ts, 158, 37)) +>"property4" : Symbol(I["property4"], Decl(decoratorsOnComputedProperties.ts, 158, 37)) [Symbol.match]: any = null; >Symbol.match : Symbol(SymbolConstructor.match, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) @@ -601,7 +601,7 @@ void class J { @x ["property"]: any; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) ->"property" : Symbol(J[["property"]], Decl(decoratorsOnComputedProperties.ts, 171, 14)) +>"property" : Symbol(J["property"], Decl(decoratorsOnComputedProperties.ts, 171, 14)) @x [Symbol.toStringTag]: any; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) @@ -611,7 +611,7 @@ void class J { @x ["property2"]: any = 2; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) ->"property2" : Symbol(J[["property2"]], Decl(decoratorsOnComputedProperties.ts, 173, 33)) +>"property2" : Symbol(J["property2"], Decl(decoratorsOnComputedProperties.ts, 173, 33)) @x [Symbol.iterator]: any = null; >x : Symbol(x, Decl(decoratorsOnComputedProperties.ts, 0, 0)) @@ -620,7 +620,7 @@ void class J { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) ["property3"]: any; ->"property3" : Symbol(J[["property3"]], Decl(decoratorsOnComputedProperties.ts, 175, 37)) +>"property3" : Symbol(J["property3"], Decl(decoratorsOnComputedProperties.ts, 175, 37)) [Symbol.isConcatSpreadable]: any; >Symbol.isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) @@ -628,7 +628,7 @@ void class J { >isConcatSpreadable : Symbol(SymbolConstructor.isConcatSpreadable, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) ["property4"]: any = 2; ->"property4" : Symbol(J[["property4"]], Decl(decoratorsOnComputedProperties.ts, 177, 37)) +>"property4" : Symbol(J["property4"], Decl(decoratorsOnComputedProperties.ts, 177, 37)) [Symbol.match]: any = null; >Symbol.match : Symbol(SymbolConstructor.match, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) diff --git a/tests/baselines/reference/duplicateClassElements.errors.txt b/tests/baselines/reference/duplicateClassElements.errors.txt index f30b4a193f131..be7e5a7770d64 100644 --- a/tests/baselines/reference/duplicateClassElements.errors.txt +++ b/tests/baselines/reference/duplicateClassElements.errors.txt @@ -16,7 +16,7 @@ tests/cases/compiler/duplicateClassElements.ts(26,9): error TS2300: Duplicate id tests/cases/compiler/duplicateClassElements.ts(29,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/duplicateClassElements.ts(32,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/duplicateClassElements.ts(34,12): error TS2300: Duplicate identifier 'x2'. -tests/cases/compiler/duplicateClassElements.ts(34,12): error TS2403: Subsequent variable declarations must have the same type. Variable 'x2' has type 'number' at tests/cases/compiler/duplicateClassElements.ts 28:8, but here has type 'any'. +tests/cases/compiler/duplicateClassElements.ts(34,12): error TS2717: Subsequent property declarations must have the same type. Property 'x2' has type 'number' at tests/cases/compiler/duplicateClassElements.ts 28:8, but here has type 'any'. tests/cases/compiler/duplicateClassElements.ts(36,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/duplicateClassElements.ts(36,9): error TS2300: Duplicate identifier 'z2'. tests/cases/compiler/duplicateClassElements.ts(39,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -96,7 +96,7 @@ tests/cases/compiler/duplicateClassElements.ts(41,12): error TS2300: Duplicate i ~~ !!! error TS2300: Duplicate identifier 'x2'. ~~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x2' has type 'number' at tests/cases/compiler/duplicateClassElements.ts 28:8, but here has type 'any'. +!!! error TS2717: Subsequent property declarations must have the same type. Property 'x2' has type 'number' at tests/cases/compiler/duplicateClassElements.ts 28:8, but here has type 'any'. get z2() { ~~ diff --git a/tests/baselines/reference/duplicateIdentifierComputedName.symbols b/tests/baselines/reference/duplicateIdentifierComputedName.symbols index 0f5753e0eb6bd..efe01b6a34940 100644 --- a/tests/baselines/reference/duplicateIdentifierComputedName.symbols +++ b/tests/baselines/reference/duplicateIdentifierComputedName.symbols @@ -3,9 +3,9 @@ class C { >C : Symbol(C, Decl(duplicateIdentifierComputedName.ts, 0, 0)) ["a"]: string; ->"a" : Symbol(C[["a"]], Decl(duplicateIdentifierComputedName.ts, 0, 9), Decl(duplicateIdentifierComputedName.ts, 1, 18)) +>"a" : Symbol(C["a"], Decl(duplicateIdentifierComputedName.ts, 0, 9), Decl(duplicateIdentifierComputedName.ts, 1, 18)) ["a"]: string; ->"a" : Symbol(C[["a"]], Decl(duplicateIdentifierComputedName.ts, 0, 9), Decl(duplicateIdentifierComputedName.ts, 1, 18)) +>"a" : Symbol(C["a"], Decl(duplicateIdentifierComputedName.ts, 0, 9), Decl(duplicateIdentifierComputedName.ts, 1, 18)) } diff --git a/tests/baselines/reference/duplicateIdentifierDifferentSpelling.js b/tests/baselines/reference/duplicateIdentifierDifferentSpelling.js index 9f139ff857233..10155af12e2f8 100644 --- a/tests/baselines/reference/duplicateIdentifierDifferentSpelling.js +++ b/tests/baselines/reference/duplicateIdentifierDifferentSpelling.js @@ -10,7 +10,7 @@ var X = { 0b11: '', 3: '' }; //// [duplicateIdentifierDifferentSpelling.js] var A = /** @class */ (function () { function A() { - this[0b11] = ''; + this[3] = ''; this[3] = ''; } return A; diff --git a/tests/baselines/reference/dynamicNames.js b/tests/baselines/reference/dynamicNames.js new file mode 100644 index 0000000000000..6582dab44d47d --- /dev/null +++ b/tests/baselines/reference/dynamicNames.js @@ -0,0 +1,244 @@ +//// [tests/cases/compiler/dynamicNames.ts] //// + +//// [module.ts] +export const c0 = "a"; +export const c1 = 1; +export const s0 = Symbol(); +export interface T0 { + [c0]: number; + [c1]: string; + [s0]: boolean; +} +export declare class T1 implements T2 { + [c0]: number; + [c1]: string; + [s0]: boolean; +} +export declare class T2 extends T1 { +} +export declare type T3 = { + [c0]: number; + [c1]: string; + [s0]: boolean; +}; + +//// [main.ts] +import { c0, c1, s0, T0, T1, T2, T3 } from "./module"; +import * as M from "./module"; + +namespace N { + export const c2 = "a"; + export const c3 = 1; + export const s1: typeof s0 = s0; + + export interface T4 { + [N.c2]: number; + [N.c3]: string; + [N.s1]: boolean; + } + export declare class T5 implements T4 { + [N.c2]: number; + [N.c3]: string; + [N.s1]: boolean; + } + export declare class T6 extends T5 { + } + export declare type T7 = { + [N.c2]: number; + [N.c3]: string; + [N.s1]: boolean; + }; +} + +export const c4 = "a"; +export const c5 = 1; +export const s2: typeof s0 = s0; + +interface T8 { + [c4]: number; + [c5]: string; + [s2]: boolean; +} +declare class T9 implements T8 { + [c4]: number; + [c5]: string; + [s2]: boolean; +} +declare class T10 extends T9 { +} +declare type T11 = { + [c4]: number; + [c5]: string; + [s2]: boolean; +}; + +interface T12 { + a: number; + 1: string; + [s2]: boolean; +} +declare class T13 implements T2 { + a: number; + 1: string; + [s2]: boolean; +} +declare class T14 extends T13 { +} +declare type T15 = { + a: number; + 1: string; + [s2]: boolean; +}; + +declare class C { + static a: number; + static 1: string; + static [s2]: boolean; +} + +let t0: T0; +let t1: T1; +let t2: T2; +let t3: T3; +let t0_1: M.T0; +let t1_1: M.T1; +let t2_1: M.T2; +let t3_1: M.T3; +let t4: N.T4; +let t5: N.T5; +let t6: N.T6; +let t7: N.T7; +let t8: T8; +let t9: T9; +let t10: T10; +let t11: T11; +let t12: T12; +let t13: T13; +let t14: T14; +let t15: T15; + +// assignability +t0 = t1, t0 = t2, t0 = t3, t1 = t0, t1 = t2, t1 = t3, t2 = t0, t2 = t1, t2 = t3, t3 = t0, t3 = t1, t3 = t2; +t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4, t7 = t5, t7 = t6; +t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0, t13 = t0, t14 = t0, t15 = t0; +t0 = C; // static side + +// object literals +export const o1 = { + [c4]: 1, + [c5]: "a", + [s2]: true +}; + +// check element access types +export const o1_c4 = o1[c4]; +export const o1_c5 = o1[c5]; +export const o1_s2 = o1[s2]; + +export const o2: T0 = o1; + +// recursive declarations +declare const rI: RI; +interface RI { + x: "a"; + [rI.x]: "b"; +} + +declare const rC: RC; +declare class RC { + x: "a"; + [rC.x]: "b"; +} + +//// [module.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.c0 = "a"; +exports.c1 = 1; +exports.s0 = Symbol(); +//// [main.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const module_1 = require("./module"); +var N; +(function (N) { + N.c2 = "a"; + N.c3 = 1; + N.s1 = module_1.s0; +})(N || (N = {})); +exports.c4 = "a"; +exports.c5 = 1; +exports.s2 = module_1.s0; +let t0; +let t1; +let t2; +let t3; +let t0_1; +let t1_1; +let t2_1; +let t3_1; +let t4; +let t5; +let t6; +let t7; +let t8; +let t9; +let t10; +let t11; +let t12; +let t13; +let t14; +let t15; +// assignability +t0 = t1, t0 = t2, t0 = t3, t1 = t0, t1 = t2, t1 = t3, t2 = t0, t2 = t1, t2 = t3, t3 = t0, t3 = t1, t3 = t2; +t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4, t7 = t5, t7 = t6; +t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0, t13 = t0, t14 = t0, t15 = t0; +t0 = C; // static side +// object literals +exports.o1 = { + [exports.c4]: 1, + [exports.c5]: "a", + [exports.s2]: true +}; +// check element access types +exports.o1_c4 = exports.o1[exports.c4]; +exports.o1_c5 = exports.o1[exports.c5]; +exports.o1_s2 = exports.o1[exports.s2]; +exports.o2 = exports.o1; + + +//// [module.d.ts] +export declare const c0 = "a"; +export declare const c1 = 1; +export declare const s0: unique symbol; +export interface T0 { + [c0]: number; + [c1]: string; + [s0]: boolean; +} +export declare class T1 implements T2 { + [c0]: number; + [c1]: string; + [s0]: boolean; +} +export declare class T2 extends T1 { +} +export declare type T3 = { + [c0]: number; + [c1]: string; + [s0]: boolean; +}; +//// [main.d.ts] +import { s0, T0 } from "./module"; +export declare const c4 = "a"; +export declare const c5 = 1; +export declare const s2: typeof s0; +export declare const o1: { + [c4]: number; + [c5]: string; + [s2]: boolean; +}; +export declare const o1_c4: number; +export declare const o1_c5: string; +export declare const o1_s2: boolean; +export declare const o2: T0; diff --git a/tests/baselines/reference/dynamicNames.symbols b/tests/baselines/reference/dynamicNames.symbols new file mode 100644 index 0000000000000..e030a9686e5e0 --- /dev/null +++ b/tests/baselines/reference/dynamicNames.symbols @@ -0,0 +1,476 @@ +=== tests/cases/compiler/module.ts === +export const c0 = "a"; +>c0 : Symbol(c0, Decl(module.ts, 0, 12)) + +export const c1 = 1; +>c1 : Symbol(c1, Decl(module.ts, 1, 12)) + +export const s0 = Symbol(); +>s0 : Symbol(s0, Decl(module.ts, 2, 12)) +>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) + +export interface T0 { +>T0 : Symbol(T0, Decl(module.ts, 2, 27)) + + [c0]: number; +>c0 : Symbol(c0, Decl(module.ts, 0, 12)) + + [c1]: string; +>c1 : Symbol(c1, Decl(module.ts, 1, 12)) + + [s0]: boolean; +>s0 : Symbol(s0, Decl(module.ts, 2, 12)) +} +export declare class T1 implements T2 { +>T1 : Symbol(T1, Decl(module.ts, 7, 1)) +>T2 : Symbol(T2, Decl(module.ts, 12, 1)) + + [c0]: number; +>c0 : Symbol(c0, Decl(module.ts, 0, 12)) + + [c1]: string; +>c1 : Symbol(c1, Decl(module.ts, 1, 12)) + + [s0]: boolean; +>s0 : Symbol(s0, Decl(module.ts, 2, 12)) +} +export declare class T2 extends T1 { +>T2 : Symbol(T2, Decl(module.ts, 12, 1)) +>T1 : Symbol(T1, Decl(module.ts, 7, 1)) +} +export declare type T3 = { +>T3 : Symbol(T3, Decl(module.ts, 14, 1)) + + [c0]: number; +>c0 : Symbol(c0, Decl(module.ts, 0, 12)) + + [c1]: string; +>c1 : Symbol(c1, Decl(module.ts, 1, 12)) + + [s0]: boolean; +>s0 : Symbol(s0, Decl(module.ts, 2, 12)) + +}; + +=== tests/cases/compiler/main.ts === +import { c0, c1, s0, T0, T1, T2, T3 } from "./module"; +>c0 : Symbol(c0, Decl(main.ts, 0, 8)) +>c1 : Symbol(c1, Decl(main.ts, 0, 12)) +>s0 : Symbol(s0, Decl(main.ts, 0, 16)) +>T0 : Symbol(T0, Decl(main.ts, 0, 20)) +>T1 : Symbol(T1, Decl(main.ts, 0, 24)) +>T2 : Symbol(T2, Decl(main.ts, 0, 28)) +>T3 : Symbol(T3, Decl(main.ts, 0, 32)) + +import * as M from "./module"; +>M : Symbol(M, Decl(main.ts, 1, 6)) + +namespace N { +>N : Symbol(N, Decl(main.ts, 1, 30)) + + export const c2 = "a"; +>c2 : Symbol(c2, Decl(main.ts, 4, 16)) + + export const c3 = 1; +>c3 : Symbol(c3, Decl(main.ts, 5, 16)) + + export const s1: typeof s0 = s0; +>s1 : Symbol(s1, Decl(main.ts, 6, 16)) +>s0 : Symbol(s0, Decl(main.ts, 0, 16)) +>s0 : Symbol(s0, Decl(main.ts, 0, 16)) + + export interface T4 { +>T4 : Symbol(T4, Decl(main.ts, 6, 36)) + + [N.c2]: number; +>N.c2 : Symbol(c2, Decl(main.ts, 4, 16)) +>N : Symbol(N, Decl(main.ts, 1, 30)) +>c2 : Symbol(c2, Decl(main.ts, 4, 16)) + + [N.c3]: string; +>N.c3 : Symbol(c3, Decl(main.ts, 5, 16)) +>N : Symbol(N, Decl(main.ts, 1, 30)) +>c3 : Symbol(c3, Decl(main.ts, 5, 16)) + + [N.s1]: boolean; +>N.s1 : Symbol(s1, Decl(main.ts, 6, 16)) +>N : Symbol(N, Decl(main.ts, 1, 30)) +>s1 : Symbol(s1, Decl(main.ts, 6, 16)) + } + export declare class T5 implements T4 { +>T5 : Symbol(T5, Decl(main.ts, 12, 5)) +>T4 : Symbol(T4, Decl(main.ts, 6, 36)) + + [N.c2]: number; +>N.c2 : Symbol(c2, Decl(main.ts, 4, 16)) +>N : Symbol(N, Decl(main.ts, 1, 30)) +>c2 : Symbol(c2, Decl(main.ts, 4, 16)) + + [N.c3]: string; +>N.c3 : Symbol(c3, Decl(main.ts, 5, 16)) +>N : Symbol(N, Decl(main.ts, 1, 30)) +>c3 : Symbol(c3, Decl(main.ts, 5, 16)) + + [N.s1]: boolean; +>N.s1 : Symbol(s1, Decl(main.ts, 6, 16)) +>N : Symbol(N, Decl(main.ts, 1, 30)) +>s1 : Symbol(s1, Decl(main.ts, 6, 16)) + } + export declare class T6 extends T5 { +>T6 : Symbol(T6, Decl(main.ts, 17, 5)) +>T5 : Symbol(T5, Decl(main.ts, 12, 5)) + } + export declare type T7 = { +>T7 : Symbol(T7, Decl(main.ts, 19, 5)) + + [N.c2]: number; +>N.c2 : Symbol(c2, Decl(main.ts, 4, 16)) +>N : Symbol(N, Decl(main.ts, 1, 30)) +>c2 : Symbol(c2, Decl(main.ts, 4, 16)) + + [N.c3]: string; +>N.c3 : Symbol(c3, Decl(main.ts, 5, 16)) +>N : Symbol(N, Decl(main.ts, 1, 30)) +>c3 : Symbol(c3, Decl(main.ts, 5, 16)) + + [N.s1]: boolean; +>N.s1 : Symbol(s1, Decl(main.ts, 6, 16)) +>N : Symbol(N, Decl(main.ts, 1, 30)) +>s1 : Symbol(s1, Decl(main.ts, 6, 16)) + + }; +} + +export const c4 = "a"; +>c4 : Symbol(c4, Decl(main.ts, 27, 12)) + +export const c5 = 1; +>c5 : Symbol(c5, Decl(main.ts, 28, 12)) + +export const s2: typeof s0 = s0; +>s2 : Symbol(s2, Decl(main.ts, 29, 12)) +>s0 : Symbol(s0, Decl(main.ts, 0, 16)) +>s0 : Symbol(s0, Decl(main.ts, 0, 16)) + +interface T8 { +>T8 : Symbol(T8, Decl(main.ts, 29, 32)) + + [c4]: number; +>c4 : Symbol(c4, Decl(main.ts, 27, 12)) + + [c5]: string; +>c5 : Symbol(c5, Decl(main.ts, 28, 12)) + + [s2]: boolean; +>s2 : Symbol(s2, Decl(main.ts, 29, 12)) +} +declare class T9 implements T8 { +>T9 : Symbol(T9, Decl(main.ts, 35, 1)) +>T8 : Symbol(T8, Decl(main.ts, 29, 32)) + + [c4]: number; +>c4 : Symbol(c4, Decl(main.ts, 27, 12)) + + [c5]: string; +>c5 : Symbol(c5, Decl(main.ts, 28, 12)) + + [s2]: boolean; +>s2 : Symbol(s2, Decl(main.ts, 29, 12)) +} +declare class T10 extends T9 { +>T10 : Symbol(T10, Decl(main.ts, 40, 1)) +>T9 : Symbol(T9, Decl(main.ts, 35, 1)) +} +declare type T11 = { +>T11 : Symbol(T11, Decl(main.ts, 42, 1)) + + [c4]: number; +>c4 : Symbol(c4, Decl(main.ts, 27, 12)) + + [c5]: string; +>c5 : Symbol(c5, Decl(main.ts, 28, 12)) + + [s2]: boolean; +>s2 : Symbol(s2, Decl(main.ts, 29, 12)) + +}; + +interface T12 { +>T12 : Symbol(T12, Decl(main.ts, 47, 2)) + + a: number; +>a : Symbol(T12.a, Decl(main.ts, 49, 15)) + + 1: string; + [s2]: boolean; +>s2 : Symbol(s2, Decl(main.ts, 29, 12)) +} +declare class T13 implements T2 { +>T13 : Symbol(T13, Decl(main.ts, 53, 1)) +>T2 : Symbol(T2, Decl(main.ts, 0, 28)) + + a: number; +>a : Symbol(T13.a, Decl(main.ts, 54, 33)) + + 1: string; + [s2]: boolean; +>s2 : Symbol(s2, Decl(main.ts, 29, 12)) +} +declare class T14 extends T13 { +>T14 : Symbol(T14, Decl(main.ts, 58, 1)) +>T13 : Symbol(T13, Decl(main.ts, 53, 1)) +} +declare type T15 = { +>T15 : Symbol(T15, Decl(main.ts, 60, 1)) + + a: number; +>a : Symbol(a, Decl(main.ts, 61, 20)) + + 1: string; + [s2]: boolean; +>s2 : Symbol(s2, Decl(main.ts, 29, 12)) + +}; + +declare class C { +>C : Symbol(C, Decl(main.ts, 65, 2)) + + static a: number; +>a : Symbol(C.a, Decl(main.ts, 67, 17)) + + static 1: string; + static [s2]: boolean; +>s2 : Symbol(s2, Decl(main.ts, 29, 12)) +} + +let t0: T0; +>t0 : Symbol(t0, Decl(main.ts, 73, 3)) +>T0 : Symbol(T0, Decl(main.ts, 0, 20)) + +let t1: T1; +>t1 : Symbol(t1, Decl(main.ts, 74, 3)) +>T1 : Symbol(T1, Decl(main.ts, 0, 24)) + +let t2: T2; +>t2 : Symbol(t2, Decl(main.ts, 75, 3)) +>T2 : Symbol(T2, Decl(main.ts, 0, 28)) + +let t3: T3; +>t3 : Symbol(t3, Decl(main.ts, 76, 3)) +>T3 : Symbol(T3, Decl(main.ts, 0, 32)) + +let t0_1: M.T0; +>t0_1 : Symbol(t0_1, Decl(main.ts, 77, 3)) +>M : Symbol(M, Decl(main.ts, 1, 6)) +>T0 : Symbol(T0, Decl(module.ts, 2, 27)) + +let t1_1: M.T1; +>t1_1 : Symbol(t1_1, Decl(main.ts, 78, 3)) +>M : Symbol(M, Decl(main.ts, 1, 6)) +>T1 : Symbol(T1, Decl(module.ts, 7, 1)) + +let t2_1: M.T2; +>t2_1 : Symbol(t2_1, Decl(main.ts, 79, 3)) +>M : Symbol(M, Decl(main.ts, 1, 6)) +>T2 : Symbol(T2, Decl(module.ts, 12, 1)) + +let t3_1: M.T3; +>t3_1 : Symbol(t3_1, Decl(main.ts, 80, 3)) +>M : Symbol(M, Decl(main.ts, 1, 6)) +>T3 : Symbol(T3, Decl(module.ts, 14, 1)) + +let t4: N.T4; +>t4 : Symbol(t4, Decl(main.ts, 81, 3)) +>N : Symbol(N, Decl(main.ts, 1, 30)) +>T4 : Symbol(N.T4, Decl(main.ts, 6, 36)) + +let t5: N.T5; +>t5 : Symbol(t5, Decl(main.ts, 82, 3)) +>N : Symbol(N, Decl(main.ts, 1, 30)) +>T5 : Symbol(N.T5, Decl(main.ts, 12, 5)) + +let t6: N.T6; +>t6 : Symbol(t6, Decl(main.ts, 83, 3)) +>N : Symbol(N, Decl(main.ts, 1, 30)) +>T6 : Symbol(N.T6, Decl(main.ts, 17, 5)) + +let t7: N.T7; +>t7 : Symbol(t7, Decl(main.ts, 84, 3)) +>N : Symbol(N, Decl(main.ts, 1, 30)) +>T7 : Symbol(N.T7, Decl(main.ts, 19, 5)) + +let t8: T8; +>t8 : Symbol(t8, Decl(main.ts, 85, 3)) +>T8 : Symbol(T8, Decl(main.ts, 29, 32)) + +let t9: T9; +>t9 : Symbol(t9, Decl(main.ts, 86, 3)) +>T9 : Symbol(T9, Decl(main.ts, 35, 1)) + +let t10: T10; +>t10 : Symbol(t10, Decl(main.ts, 87, 3)) +>T10 : Symbol(T10, Decl(main.ts, 40, 1)) + +let t11: T11; +>t11 : Symbol(t11, Decl(main.ts, 88, 3)) +>T11 : Symbol(T11, Decl(main.ts, 42, 1)) + +let t12: T12; +>t12 : Symbol(t12, Decl(main.ts, 89, 3)) +>T12 : Symbol(T12, Decl(main.ts, 47, 2)) + +let t13: T13; +>t13 : Symbol(t13, Decl(main.ts, 90, 3)) +>T13 : Symbol(T13, Decl(main.ts, 53, 1)) + +let t14: T14; +>t14 : Symbol(t14, Decl(main.ts, 91, 3)) +>T14 : Symbol(T14, Decl(main.ts, 58, 1)) + +let t15: T15; +>t15 : Symbol(t15, Decl(main.ts, 92, 3)) +>T15 : Symbol(T15, Decl(main.ts, 60, 1)) + +// assignability +t0 = t1, t0 = t2, t0 = t3, t1 = t0, t1 = t2, t1 = t3, t2 = t0, t2 = t1, t2 = t3, t3 = t0, t3 = t1, t3 = t2; +>t0 : Symbol(t0, Decl(main.ts, 73, 3)) +>t1 : Symbol(t1, Decl(main.ts, 74, 3)) +>t0 : Symbol(t0, Decl(main.ts, 73, 3)) +>t2 : Symbol(t2, Decl(main.ts, 75, 3)) +>t0 : Symbol(t0, Decl(main.ts, 73, 3)) +>t3 : Symbol(t3, Decl(main.ts, 76, 3)) +>t1 : Symbol(t1, Decl(main.ts, 74, 3)) +>t0 : Symbol(t0, Decl(main.ts, 73, 3)) +>t1 : Symbol(t1, Decl(main.ts, 74, 3)) +>t2 : Symbol(t2, Decl(main.ts, 75, 3)) +>t1 : Symbol(t1, Decl(main.ts, 74, 3)) +>t3 : Symbol(t3, Decl(main.ts, 76, 3)) +>t2 : Symbol(t2, Decl(main.ts, 75, 3)) +>t0 : Symbol(t0, Decl(main.ts, 73, 3)) +>t2 : Symbol(t2, Decl(main.ts, 75, 3)) +>t1 : Symbol(t1, Decl(main.ts, 74, 3)) +>t2 : Symbol(t2, Decl(main.ts, 75, 3)) +>t3 : Symbol(t3, Decl(main.ts, 76, 3)) +>t3 : Symbol(t3, Decl(main.ts, 76, 3)) +>t0 : Symbol(t0, Decl(main.ts, 73, 3)) +>t3 : Symbol(t3, Decl(main.ts, 76, 3)) +>t1 : Symbol(t1, Decl(main.ts, 74, 3)) +>t3 : Symbol(t3, Decl(main.ts, 76, 3)) +>t2 : Symbol(t2, Decl(main.ts, 75, 3)) + +t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4, t7 = t5, t7 = t6; +>t4 : Symbol(t4, Decl(main.ts, 81, 3)) +>t5 : Symbol(t5, Decl(main.ts, 82, 3)) +>t4 : Symbol(t4, Decl(main.ts, 81, 3)) +>t6 : Symbol(t6, Decl(main.ts, 83, 3)) +>t4 : Symbol(t4, Decl(main.ts, 81, 3)) +>t7 : Symbol(t7, Decl(main.ts, 84, 3)) +>t5 : Symbol(t5, Decl(main.ts, 82, 3)) +>t4 : Symbol(t4, Decl(main.ts, 81, 3)) +>t5 : Symbol(t5, Decl(main.ts, 82, 3)) +>t6 : Symbol(t6, Decl(main.ts, 83, 3)) +>t5 : Symbol(t5, Decl(main.ts, 82, 3)) +>t7 : Symbol(t7, Decl(main.ts, 84, 3)) +>t6 : Symbol(t6, Decl(main.ts, 83, 3)) +>t4 : Symbol(t4, Decl(main.ts, 81, 3)) +>t6 : Symbol(t6, Decl(main.ts, 83, 3)) +>t5 : Symbol(t5, Decl(main.ts, 82, 3)) +>t6 : Symbol(t6, Decl(main.ts, 83, 3)) +>t7 : Symbol(t7, Decl(main.ts, 84, 3)) +>t7 : Symbol(t7, Decl(main.ts, 84, 3)) +>t4 : Symbol(t4, Decl(main.ts, 81, 3)) +>t7 : Symbol(t7, Decl(main.ts, 84, 3)) +>t5 : Symbol(t5, Decl(main.ts, 82, 3)) +>t7 : Symbol(t7, Decl(main.ts, 84, 3)) +>t6 : Symbol(t6, Decl(main.ts, 83, 3)) + +t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0, t13 = t0, t14 = t0, t15 = t0; +>t0 : Symbol(t0, Decl(main.ts, 73, 3)) +>t12 : Symbol(t12, Decl(main.ts, 89, 3)) +>t0 : Symbol(t0, Decl(main.ts, 73, 3)) +>t13 : Symbol(t13, Decl(main.ts, 90, 3)) +>t0 : Symbol(t0, Decl(main.ts, 73, 3)) +>t14 : Symbol(t14, Decl(main.ts, 91, 3)) +>t0 : Symbol(t0, Decl(main.ts, 73, 3)) +>t15 : Symbol(t15, Decl(main.ts, 92, 3)) +>t12 : Symbol(t12, Decl(main.ts, 89, 3)) +>t0 : Symbol(t0, Decl(main.ts, 73, 3)) +>t13 : Symbol(t13, Decl(main.ts, 90, 3)) +>t0 : Symbol(t0, Decl(main.ts, 73, 3)) +>t14 : Symbol(t14, Decl(main.ts, 91, 3)) +>t0 : Symbol(t0, Decl(main.ts, 73, 3)) +>t15 : Symbol(t15, Decl(main.ts, 92, 3)) +>t0 : Symbol(t0, Decl(main.ts, 73, 3)) + +t0 = C; // static side +>t0 : Symbol(t0, Decl(main.ts, 73, 3)) +>C : Symbol(C, Decl(main.ts, 65, 2)) + +// object literals +export const o1 = { +>o1 : Symbol(o1, Decl(main.ts, 101, 12)) + + [c4]: 1, +>c4 : Symbol(c4, Decl(main.ts, 27, 12)) + + [c5]: "a", +>c5 : Symbol(c5, Decl(main.ts, 28, 12)) + + [s2]: true +>s2 : Symbol(s2, Decl(main.ts, 29, 12)) + +}; + +// check element access types +export const o1_c4 = o1[c4]; +>o1_c4 : Symbol(o1_c4, Decl(main.ts, 108, 12)) +>o1 : Symbol(o1, Decl(main.ts, 101, 12)) +>c4 : Symbol(c4, Decl(main.ts, 27, 12)) + +export const o1_c5 = o1[c5]; +>o1_c5 : Symbol(o1_c5, Decl(main.ts, 109, 12)) +>o1 : Symbol(o1, Decl(main.ts, 101, 12)) +>c5 : Symbol(c5, Decl(main.ts, 28, 12)) + +export const o1_s2 = o1[s2]; +>o1_s2 : Symbol(o1_s2, Decl(main.ts, 110, 12)) +>o1 : Symbol(o1, Decl(main.ts, 101, 12)) +>s2 : Symbol(s2, Decl(main.ts, 29, 12)) + +export const o2: T0 = o1; +>o2 : Symbol(o2, Decl(main.ts, 112, 12)) +>T0 : Symbol(T0, Decl(main.ts, 0, 20)) +>o1 : Symbol(o1, Decl(main.ts, 101, 12)) + +// recursive declarations +declare const rI: RI; +>rI : Symbol(rI, Decl(main.ts, 115, 13)) +>RI : Symbol(RI, Decl(main.ts, 115, 21)) + +interface RI { +>RI : Symbol(RI, Decl(main.ts, 115, 21)) + + x: "a"; +>x : Symbol(RI.x, Decl(main.ts, 116, 14)) + + [rI.x]: "b"; +>rI.x : Symbol(RI.x, Decl(main.ts, 116, 14)) +>rI : Symbol(rI, Decl(main.ts, 115, 13)) +>x : Symbol(RI.x, Decl(main.ts, 116, 14)) +} + +declare const rC: RC; +>rC : Symbol(rC, Decl(main.ts, 121, 13)) +>RC : Symbol(RC, Decl(main.ts, 121, 21)) + +declare class RC { +>RC : Symbol(RC, Decl(main.ts, 121, 21)) + + x: "a"; +>x : Symbol(RC.x, Decl(main.ts, 122, 18)) + + [rC.x]: "b"; +>rC.x : Symbol(RC.x, Decl(main.ts, 122, 18)) +>rC : Symbol(rC, Decl(main.ts, 121, 13)) +>x : Symbol(RC.x, Decl(main.ts, 122, 18)) +} diff --git a/tests/baselines/reference/dynamicNames.types b/tests/baselines/reference/dynamicNames.types new file mode 100644 index 0000000000000..b2125d673069c --- /dev/null +++ b/tests/baselines/reference/dynamicNames.types @@ -0,0 +1,552 @@ +=== tests/cases/compiler/module.ts === +export const c0 = "a"; +>c0 : "a" +>"a" : "a" + +export const c1 = 1; +>c1 : 1 +>1 : 1 + +export const s0 = Symbol(); +>s0 : unique symbol +>Symbol() : unique symbol +>Symbol : SymbolConstructor + +export interface T0 { +>T0 : T0 + + [c0]: number; +>c0 : "a" + + [c1]: string; +>c1 : 1 + + [s0]: boolean; +>s0 : unique symbol +} +export declare class T1 implements T2 { +>T1 : T1 +>T2 : T2 + + [c0]: number; +>c0 : "a" + + [c1]: string; +>c1 : 1 + + [s0]: boolean; +>s0 : unique symbol +} +export declare class T2 extends T1 { +>T2 : T2 +>T1 : T1 +} +export declare type T3 = { +>T3 : T3 + + [c0]: number; +>c0 : "a" + + [c1]: string; +>c1 : 1 + + [s0]: boolean; +>s0 : unique symbol + +}; + +=== tests/cases/compiler/main.ts === +import { c0, c1, s0, T0, T1, T2, T3 } from "./module"; +>c0 : "a" +>c1 : 1 +>s0 : unique symbol +>T0 : any +>T1 : typeof T1 +>T2 : typeof T2 +>T3 : any + +import * as M from "./module"; +>M : typeof M + +namespace N { +>N : typeof N + + export const c2 = "a"; +>c2 : "a" +>"a" : "a" + + export const c3 = 1; +>c3 : 1 +>1 : 1 + + export const s1: typeof s0 = s0; +>s1 : unique symbol +>s0 : unique symbol +>s0 : unique symbol + + export interface T4 { +>T4 : T4 + + [N.c2]: number; +>N.c2 : "a" +>N : typeof N +>c2 : "a" + + [N.c3]: string; +>N.c3 : 1 +>N : typeof N +>c3 : 1 + + [N.s1]: boolean; +>N.s1 : unique symbol +>N : typeof N +>s1 : unique symbol + } + export declare class T5 implements T4 { +>T5 : T5 +>T4 : T4 + + [N.c2]: number; +>N.c2 : "a" +>N : typeof N +>c2 : "a" + + [N.c3]: string; +>N.c3 : 1 +>N : typeof N +>c3 : 1 + + [N.s1]: boolean; +>N.s1 : unique symbol +>N : typeof N +>s1 : unique symbol + } + export declare class T6 extends T5 { +>T6 : T6 +>T5 : T5 + } + export declare type T7 = { +>T7 : { [N.c2]: number; [N.c3]: string; [N.s1]: boolean; } + + [N.c2]: number; +>N.c2 : "a" +>N : typeof N +>c2 : "a" + + [N.c3]: string; +>N.c3 : 1 +>N : typeof N +>c3 : 1 + + [N.s1]: boolean; +>N.s1 : unique symbol +>N : typeof N +>s1 : unique symbol + + }; +} + +export const c4 = "a"; +>c4 : "a" +>"a" : "a" + +export const c5 = 1; +>c5 : 1 +>1 : 1 + +export const s2: typeof s0 = s0; +>s2 : unique symbol +>s0 : unique symbol +>s0 : unique symbol + +interface T8 { +>T8 : T8 + + [c4]: number; +>c4 : "a" + + [c5]: string; +>c5 : 1 + + [s2]: boolean; +>s2 : unique symbol +} +declare class T9 implements T8 { +>T9 : T9 +>T8 : T8 + + [c4]: number; +>c4 : "a" + + [c5]: string; +>c5 : 1 + + [s2]: boolean; +>s2 : unique symbol +} +declare class T10 extends T9 { +>T10 : T10 +>T9 : T9 +} +declare type T11 = { +>T11 : { [c4]: number; [c5]: string; [s2]: boolean; } + + [c4]: number; +>c4 : "a" + + [c5]: string; +>c5 : 1 + + [s2]: boolean; +>s2 : unique symbol + +}; + +interface T12 { +>T12 : T12 + + a: number; +>a : number + + 1: string; + [s2]: boolean; +>s2 : unique symbol +} +declare class T13 implements T2 { +>T13 : T13 +>T2 : T2 + + a: number; +>a : number + + 1: string; + [s2]: boolean; +>s2 : unique symbol +} +declare class T14 extends T13 { +>T14 : T14 +>T13 : T13 +} +declare type T15 = { +>T15 : { a: number; 1: string; [s2]: boolean; } + + a: number; +>a : number + + 1: string; + [s2]: boolean; +>s2 : unique symbol + +}; + +declare class C { +>C : C + + static a: number; +>a : number + + static 1: string; + static [s2]: boolean; +>s2 : unique symbol +} + +let t0: T0; +>t0 : T0 +>T0 : T0 + +let t1: T1; +>t1 : T1 +>T1 : T1 + +let t2: T2; +>t2 : T2 +>T2 : T2 + +let t3: T3; +>t3 : T3 +>T3 : T3 + +let t0_1: M.T0; +>t0_1 : T0 +>M : any +>T0 : T0 + +let t1_1: M.T1; +>t1_1 : T1 +>M : any +>T1 : T1 + +let t2_1: M.T2; +>t2_1 : T2 +>M : any +>T2 : T2 + +let t3_1: M.T3; +>t3_1 : T3 +>M : any +>T3 : T3 + +let t4: N.T4; +>t4 : N.T4 +>N : any +>T4 : N.T4 + +let t5: N.T5; +>t5 : N.T5 +>N : any +>T5 : N.T5 + +let t6: N.T6; +>t6 : N.T6 +>N : any +>T6 : N.T6 + +let t7: N.T7; +>t7 : { [N.c2]: number; [N.c3]: string; [N.s1]: boolean; } +>N : any +>T7 : { [N.c2]: number; [N.c3]: string; [N.s1]: boolean; } + +let t8: T8; +>t8 : T8 +>T8 : T8 + +let t9: T9; +>t9 : T9 +>T9 : T9 + +let t10: T10; +>t10 : T10 +>T10 : T10 + +let t11: T11; +>t11 : { [c4]: number; [c5]: string; [s2]: boolean; } +>T11 : { [c4]: number; [c5]: string; [s2]: boolean; } + +let t12: T12; +>t12 : T12 +>T12 : T12 + +let t13: T13; +>t13 : T13 +>T13 : T13 + +let t14: T14; +>t14 : T14 +>T14 : T14 + +let t15: T15; +>t15 : { a: number; 1: string; [s2]: boolean; } +>T15 : { a: number; 1: string; [s2]: boolean; } + +// assignability +t0 = t1, t0 = t2, t0 = t3, t1 = t0, t1 = t2, t1 = t3, t2 = t0, t2 = t1, t2 = t3, t3 = t0, t3 = t1, t3 = t2; +>t0 = t1, t0 = t2, t0 = t3, t1 = t0, t1 = t2, t1 = t3, t2 = t0, t2 = t1, t2 = t3, t3 = t0, t3 = t1, t3 = t2 : T2 +>t0 = t1, t0 = t2, t0 = t3, t1 = t0, t1 = t2, t1 = t3, t2 = t0, t2 = t1, t2 = t3, t3 = t0, t3 = t1 : T1 +>t0 = t1, t0 = t2, t0 = t3, t1 = t0, t1 = t2, t1 = t3, t2 = t0, t2 = t1, t2 = t3, t3 = t0 : T0 +>t0 = t1, t0 = t2, t0 = t3, t1 = t0, t1 = t2, t1 = t3, t2 = t0, t2 = t1, t2 = t3 : T3 +>t0 = t1, t0 = t2, t0 = t3, t1 = t0, t1 = t2, t1 = t3, t2 = t0, t2 = t1 : T1 +>t0 = t1, t0 = t2, t0 = t3, t1 = t0, t1 = t2, t1 = t3, t2 = t0 : T0 +>t0 = t1, t0 = t2, t0 = t3, t1 = t0, t1 = t2, t1 = t3 : T3 +>t0 = t1, t0 = t2, t0 = t3, t1 = t0, t1 = t2 : T2 +>t0 = t1, t0 = t2, t0 = t3, t1 = t0 : T0 +>t0 = t1, t0 = t2, t0 = t3 : T3 +>t0 = t1, t0 = t2 : T2 +>t0 = t1 : T1 +>t0 : T0 +>t1 : T1 +>t0 = t2 : T2 +>t0 : T0 +>t2 : T2 +>t0 = t3 : T3 +>t0 : T0 +>t3 : T3 +>t1 = t0 : T0 +>t1 : T1 +>t0 : T0 +>t1 = t2 : T2 +>t1 : T1 +>t2 : T2 +>t1 = t3 : T3 +>t1 : T1 +>t3 : T3 +>t2 = t0 : T0 +>t2 : T2 +>t0 : T0 +>t2 = t1 : T1 +>t2 : T2 +>t1 : T1 +>t2 = t3 : T3 +>t2 : T2 +>t3 : T3 +>t3 = t0 : T0 +>t3 : T3 +>t0 : T0 +>t3 = t1 : T1 +>t3 : T3 +>t1 : T1 +>t3 = t2 : T2 +>t3 : T3 +>t2 : T2 + +t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4, t7 = t5, t7 = t6; +>t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4, t7 = t5, t7 = t6 : N.T6 +>t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4, t7 = t5 : N.T5 +>t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4 : N.T4 +>t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7 : { [N.c2]: number; [N.c3]: string; [N.s1]: boolean; } +>t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5 : N.T5 +>t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4 : N.T4 +>t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7 : { [N.c2]: number; [N.c3]: string; [N.s1]: boolean; } +>t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6 : N.T6 +>t4 = t5, t4 = t6, t4 = t7, t5 = t4 : N.T4 +>t4 = t5, t4 = t6, t4 = t7 : { [N.c2]: number; [N.c3]: string; [N.s1]: boolean; } +>t4 = t5, t4 = t6 : N.T6 +>t4 = t5 : N.T5 +>t4 : N.T4 +>t5 : N.T5 +>t4 = t6 : N.T6 +>t4 : N.T4 +>t6 : N.T6 +>t4 = t7 : { [N.c2]: number; [N.c3]: string; [N.s1]: boolean; } +>t4 : N.T4 +>t7 : { [N.c2]: number; [N.c3]: string; [N.s1]: boolean; } +>t5 = t4 : N.T4 +>t5 : N.T5 +>t4 : N.T4 +>t5 = t6 : N.T6 +>t5 : N.T5 +>t6 : N.T6 +>t5 = t7 : { [N.c2]: number; [N.c3]: string; [N.s1]: boolean; } +>t5 : N.T5 +>t7 : { [N.c2]: number; [N.c3]: string; [N.s1]: boolean; } +>t6 = t4 : N.T4 +>t6 : N.T6 +>t4 : N.T4 +>t6 = t5 : N.T5 +>t6 : N.T6 +>t5 : N.T5 +>t6 = t7 : { [N.c2]: number; [N.c3]: string; [N.s1]: boolean; } +>t6 : N.T6 +>t7 : { [N.c2]: number; [N.c3]: string; [N.s1]: boolean; } +>t7 = t4 : N.T4 +>t7 : { [N.c2]: number; [N.c3]: string; [N.s1]: boolean; } +>t4 : N.T4 +>t7 = t5 : N.T5 +>t7 : { [N.c2]: number; [N.c3]: string; [N.s1]: boolean; } +>t5 : N.T5 +>t7 = t6 : N.T6 +>t7 : { [N.c2]: number; [N.c3]: string; [N.s1]: boolean; } +>t6 : N.T6 + +t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0, t13 = t0, t14 = t0, t15 = t0; +>t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0, t13 = t0, t14 = t0, t15 = t0 : T0 +>t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0, t13 = t0, t14 = t0 : T0 +>t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0, t13 = t0 : T0 +>t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0 : T0 +>t0 = t12, t0 = t13, t0 = t14, t0 = t15 : { a: number; 1: string; [s2]: boolean; } +>t0 = t12, t0 = t13, t0 = t14 : T14 +>t0 = t12, t0 = t13 : T13 +>t0 = t12 : T12 +>t0 : T0 +>t12 : T12 +>t0 = t13 : T13 +>t0 : T0 +>t13 : T13 +>t0 = t14 : T14 +>t0 : T0 +>t14 : T14 +>t0 = t15 : { a: number; 1: string; [s2]: boolean; } +>t0 : T0 +>t15 : { a: number; 1: string; [s2]: boolean; } +>t12 = t0 : T0 +>t12 : T12 +>t0 : T0 +>t13 = t0 : T0 +>t13 : T13 +>t0 : T0 +>t14 = t0 : T0 +>t14 : T14 +>t0 : T0 +>t15 = t0 : T0 +>t15 : { a: number; 1: string; [s2]: boolean; } +>t0 : T0 + +t0 = C; // static side +>t0 = C : typeof C +>t0 : T0 +>C : typeof C + +// object literals +export const o1 = { +>o1 : { [c4]: number; [c5]: string; [s2]: boolean; } +>{ [c4]: 1, [c5]: "a", [s2]: true} : { [c4]: number; [c5]: string; [s2]: boolean; } + + [c4]: 1, +>c4 : "a" +>1 : 1 + + [c5]: "a", +>c5 : 1 +>"a" : "a" + + [s2]: true +>s2 : unique symbol +>true : true + +}; + +// check element access types +export const o1_c4 = o1[c4]; +>o1_c4 : number +>o1[c4] : number +>o1 : { [c4]: number; [c5]: string; [s2]: boolean; } +>c4 : "a" + +export const o1_c5 = o1[c5]; +>o1_c5 : string +>o1[c5] : string +>o1 : { [c4]: number; [c5]: string; [s2]: boolean; } +>c5 : 1 + +export const o1_s2 = o1[s2]; +>o1_s2 : boolean +>o1[s2] : boolean +>o1 : { [c4]: number; [c5]: string; [s2]: boolean; } +>s2 : unique symbol + +export const o2: T0 = o1; +>o2 : T0 +>T0 : T0 +>o1 : { [c4]: number; [c5]: string; [s2]: boolean; } + +// recursive declarations +declare const rI: RI; +>rI : RI +>RI : RI + +interface RI { +>RI : RI + + x: "a"; +>x : "a" + + [rI.x]: "b"; +>rI.x : "a" +>rI : RI +>x : "a" +} + +declare const rC: RC; +>rC : RC +>RC : RC + +declare class RC { +>RC : RC + + x: "a"; +>x : "a" + + [rC.x]: "b"; +>rC.x : "a" +>rC : RC +>x : "a" +} diff --git a/tests/baselines/reference/dynamicNamesErrors.errors.txt b/tests/baselines/reference/dynamicNamesErrors.errors.txt new file mode 100644 index 0000000000000..15722ed1a4982 --- /dev/null +++ b/tests/baselines/reference/dynamicNamesErrors.errors.txt @@ -0,0 +1,133 @@ +tests/cases/compiler/dynamicNamesErrors.ts(5,5): error TS2718: Duplicate declaration '[c0]'. +tests/cases/compiler/dynamicNamesErrors.ts(6,5): error TS2718: Duplicate declaration '[c0]'. +tests/cases/compiler/dynamicNamesErrors.ts(19,5): error TS2717: Subsequent property declarations must have the same type. Property '[c1]' has type 'number' at tests/cases/compiler/dynamicNamesErrors.ts 17:4, but here has type 'string'. +tests/cases/compiler/dynamicNamesErrors.ts(24,1): error TS2322: Type 'T2' is not assignable to type 'T1'. + Types of property '[c0]' are incompatible. + Type 'string' is not assignable to type 'number'. +tests/cases/compiler/dynamicNamesErrors.ts(25,1): error TS2322: Type 'T1' is not assignable to type 'T2'. + Types of property '[c0]' are incompatible. + Type 'number' is not assignable to type 'string'. +tests/cases/compiler/dynamicNamesErrors.ts(33,6): error TS4033: Property '[x]' of exported interface has or is using private name 'x'. +tests/cases/compiler/dynamicNamesErrors.ts(34,6): error TS4102: Method '[y]' of exported interface has or is using private name 'y'. +tests/cases/compiler/dynamicNamesErrors.ts(38,13): error TS4028: Public static property '[x]' of exported class has or is using private name 'x'. +tests/cases/compiler/dynamicNamesErrors.ts(39,13): error TS4097: Public static method '[y]' of exported class has or is using private name 'y'. +tests/cases/compiler/dynamicNamesErrors.ts(40,17): error TS4028: Public static property '[z]' of exported class has or is using private name 'z'. +tests/cases/compiler/dynamicNamesErrors.ts(41,17): error TS4028: Public static property '[w]' of exported class has or is using private name 'w'. +tests/cases/compiler/dynamicNamesErrors.ts(43,6): error TS4031: Public property '[x]' of exported class has or is using private name 'x'. +tests/cases/compiler/dynamicNamesErrors.ts(44,6): error TS4100: Public method '[y]' of exported class has or is using private name 'y'. +tests/cases/compiler/dynamicNamesErrors.ts(45,10): error TS4031: Public property '[z]' of exported class has or is using private name 'z'. +tests/cases/compiler/dynamicNamesErrors.ts(46,10): error TS4031: Public property '[w]' of exported class has or is using private name 'w'. +tests/cases/compiler/dynamicNamesErrors.ts(50,6): error TS4033: Property '[x]' of exported interface has or is using private name 'x'. +tests/cases/compiler/dynamicNamesErrors.ts(51,6): error TS4102: Method '[y]' of exported interface has or is using private name 'y'. +tests/cases/compiler/dynamicNamesErrors.ts(54,14): error TS4025: Exported variable 'ObjectLiteralVisibility' has or is using private name 'w'. +tests/cases/compiler/dynamicNamesErrors.ts(54,14): error TS4025: Exported variable 'ObjectLiteralVisibility' has or is using private name 'x'. +tests/cases/compiler/dynamicNamesErrors.ts(54,14): error TS4025: Exported variable 'ObjectLiteralVisibility' has or is using private name 'y'. +tests/cases/compiler/dynamicNamesErrors.ts(54,14): error TS4025: Exported variable 'ObjectLiteralVisibility' has or is using private name 'z'. + + +==== tests/cases/compiler/dynamicNamesErrors.ts (21 errors) ==== + const c0 = "1"; + const c1 = 1; + + interface T0 { + [c0]: number; + ~~~~ +!!! error TS2718: Duplicate declaration '[c0]'. + 1: number; + ~ +!!! error TS2718: Duplicate declaration '[c0]'. + } + + interface T1 { + [c0]: number; + } + + interface T2 { + [c0]: string; + } + + interface T3 { + [c0]: number; + [c1]: string; + ~~~~ +!!! error TS2717: Subsequent property declarations must have the same type. Property '[c1]' has type 'number' at tests/cases/compiler/dynamicNamesErrors.ts 17:4, but here has type 'string'. + } + + let t1: T1; + let t2: T2; + t1 = t2; + ~~ +!!! error TS2322: Type 'T2' is not assignable to type 'T1'. +!!! error TS2322: Types of property '[c0]' are incompatible. +!!! error TS2322: Type 'string' is not assignable to type 'number'. + t2 = t1; + ~~ +!!! error TS2322: Type 'T1' is not assignable to type 'T2'. +!!! error TS2322: Types of property '[c0]' are incompatible. +!!! error TS2322: Type 'number' is not assignable to type 'string'. + + const x = Symbol(); + const y = Symbol(); + const z = Symbol(); + const w = Symbol(); + + export interface InterfaceMemberVisibility { + [x]: number; + ~ +!!! error TS4033: Property '[x]' of exported interface has or is using private name 'x'. + [y](): number; + ~ +!!! error TS4102: Method '[y]' of exported interface has or is using private name 'y'. + } + + export class ClassMemberVisibility { + static [x]: number; + ~ +!!! error TS4028: Public static property '[x]' of exported class has or is using private name 'x'. + static [y](): number { return 0; } + ~ +!!! error TS4097: Public static method '[y]' of exported class has or is using private name 'y'. + static get [z](): number { return 0; } + ~ +!!! error TS4028: Public static property '[z]' of exported class has or is using private name 'z'. + static set [w](value: number) { } + ~ +!!! error TS4028: Public static property '[w]' of exported class has or is using private name 'w'. + + [x]: number; + ~ +!!! error TS4031: Public property '[x]' of exported class has or is using private name 'x'. + [y](): number { return 0; } + ~ +!!! error TS4100: Public method '[y]' of exported class has or is using private name 'y'. + get [z](): number { return 0; } + ~ +!!! error TS4031: Public property '[z]' of exported class has or is using private name 'z'. + set [w](value: number) { } + ~ +!!! error TS4031: Public property '[w]' of exported class has or is using private name 'w'. + } + + export type ObjectTypeVisibility = { + [x]: number; + ~ +!!! error TS4033: Property '[x]' of exported interface has or is using private name 'x'. + [y](): number; + ~ +!!! error TS4102: Method '[y]' of exported interface has or is using private name 'y'. + }; + + export const ObjectLiteralVisibility = { + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS4025: Exported variable 'ObjectLiteralVisibility' has or is using private name 'w'. + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS4025: Exported variable 'ObjectLiteralVisibility' has or is using private name 'x'. + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS4025: Exported variable 'ObjectLiteralVisibility' has or is using private name 'y'. + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS4025: Exported variable 'ObjectLiteralVisibility' has or is using private name 'z'. + [x]: 0, + [y](): number { return 0; }, + get [z](): number { return 0; }, + set [w](value: number) { }, + }; \ No newline at end of file diff --git a/tests/baselines/reference/dynamicNamesErrors.js b/tests/baselines/reference/dynamicNamesErrors.js new file mode 100644 index 0000000000000..dbea91fcb0153 --- /dev/null +++ b/tests/baselines/reference/dynamicNamesErrors.js @@ -0,0 +1,89 @@ +//// [dynamicNamesErrors.ts] +const c0 = "1"; +const c1 = 1; + +interface T0 { + [c0]: number; + 1: number; +} + +interface T1 { + [c0]: number; +} + +interface T2 { + [c0]: string; +} + +interface T3 { + [c0]: number; + [c1]: string; +} + +let t1: T1; +let t2: T2; +t1 = t2; +t2 = t1; + +const x = Symbol(); +const y = Symbol(); +const z = Symbol(); +const w = Symbol(); + +export interface InterfaceMemberVisibility { + [x]: number; + [y](): number; +} + +export class ClassMemberVisibility { + static [x]: number; + static [y](): number { return 0; } + static get [z](): number { return 0; } + static set [w](value: number) { } + + [x]: number; + [y](): number { return 0; } + get [z](): number { return 0; } + set [w](value: number) { } +} + +export type ObjectTypeVisibility = { + [x]: number; + [y](): number; +}; + +export const ObjectLiteralVisibility = { + [x]: 0, + [y](): number { return 0; }, + get [z](): number { return 0; }, + set [w](value: number) { }, +}; + +//// [dynamicNamesErrors.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const c0 = "1"; +const c1 = 1; +let t1; +let t2; +t1 = t2; +t2 = t1; +const x = Symbol(); +const y = Symbol(); +const z = Symbol(); +const w = Symbol(); +class ClassMemberVisibility { + static [y]() { return 0; } + static get [z]() { return 0; } + static set [w](value) { } + [y]() { return 0; } + get [z]() { return 0; } + set [w](value) { } +} +exports.ClassMemberVisibility = ClassMemberVisibility; +exports.ObjectLiteralVisibility = { + [x]: 0, + [y]() { return 0; }, + get [z]() { return 0; }, + set [w](value) { }, +}; diff --git a/tests/baselines/reference/dynamicNamesErrors.symbols b/tests/baselines/reference/dynamicNamesErrors.symbols new file mode 100644 index 0000000000000..30ba78a99a311 --- /dev/null +++ b/tests/baselines/reference/dynamicNamesErrors.symbols @@ -0,0 +1,140 @@ +=== tests/cases/compiler/dynamicNamesErrors.ts === +const c0 = "1"; +>c0 : Symbol(c0, Decl(dynamicNamesErrors.ts, 0, 5)) + +const c1 = 1; +>c1 : Symbol(c1, Decl(dynamicNamesErrors.ts, 1, 5)) + +interface T0 { +>T0 : Symbol(T0, Decl(dynamicNamesErrors.ts, 1, 13)) + + [c0]: number; +>c0 : Symbol(c0, Decl(dynamicNamesErrors.ts, 0, 5)) + + 1: number; +} + +interface T1 { +>T1 : Symbol(T1, Decl(dynamicNamesErrors.ts, 6, 1)) + + [c0]: number; +>c0 : Symbol(c0, Decl(dynamicNamesErrors.ts, 0, 5)) +} + +interface T2 { +>T2 : Symbol(T2, Decl(dynamicNamesErrors.ts, 10, 1)) + + [c0]: string; +>c0 : Symbol(c0, Decl(dynamicNamesErrors.ts, 0, 5)) +} + +interface T3 { +>T3 : Symbol(T3, Decl(dynamicNamesErrors.ts, 14, 1)) + + [c0]: number; +>c0 : Symbol(c0, Decl(dynamicNamesErrors.ts, 0, 5)) + + [c1]: string; +>c1 : Symbol(c1, Decl(dynamicNamesErrors.ts, 1, 5)) +} + +let t1: T1; +>t1 : Symbol(t1, Decl(dynamicNamesErrors.ts, 21, 3)) +>T1 : Symbol(T1, Decl(dynamicNamesErrors.ts, 6, 1)) + +let t2: T2; +>t2 : Symbol(t2, Decl(dynamicNamesErrors.ts, 22, 3)) +>T2 : Symbol(T2, Decl(dynamicNamesErrors.ts, 10, 1)) + +t1 = t2; +>t1 : Symbol(t1, Decl(dynamicNamesErrors.ts, 21, 3)) +>t2 : Symbol(t2, Decl(dynamicNamesErrors.ts, 22, 3)) + +t2 = t1; +>t2 : Symbol(t2, Decl(dynamicNamesErrors.ts, 22, 3)) +>t1 : Symbol(t1, Decl(dynamicNamesErrors.ts, 21, 3)) + +const x = Symbol(); +>x : Symbol(x, Decl(dynamicNamesErrors.ts, 26, 5)) +>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) + +const y = Symbol(); +>y : Symbol(y, Decl(dynamicNamesErrors.ts, 27, 5)) +>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) + +const z = Symbol(); +>z : Symbol(z, Decl(dynamicNamesErrors.ts, 28, 5)) +>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) + +const w = Symbol(); +>w : Symbol(w, Decl(dynamicNamesErrors.ts, 29, 5)) +>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) + +export interface InterfaceMemberVisibility { +>InterfaceMemberVisibility : Symbol(InterfaceMemberVisibility, Decl(dynamicNamesErrors.ts, 29, 19)) + + [x]: number; +>x : Symbol(x, Decl(dynamicNamesErrors.ts, 26, 5)) + + [y](): number; +>y : Symbol(y, Decl(dynamicNamesErrors.ts, 27, 5)) +} + +export class ClassMemberVisibility { +>ClassMemberVisibility : Symbol(ClassMemberVisibility, Decl(dynamicNamesErrors.ts, 34, 1)) + + static [x]: number; +>x : Symbol(x, Decl(dynamicNamesErrors.ts, 26, 5)) + + static [y](): number { return 0; } +>y : Symbol(y, Decl(dynamicNamesErrors.ts, 27, 5)) + + static get [z](): number { return 0; } +>z : Symbol(z, Decl(dynamicNamesErrors.ts, 28, 5)) + + static set [w](value: number) { } +>w : Symbol(w, Decl(dynamicNamesErrors.ts, 29, 5)) +>value : Symbol(value, Decl(dynamicNamesErrors.ts, 40, 19)) + + [x]: number; +>x : Symbol(x, Decl(dynamicNamesErrors.ts, 26, 5)) + + [y](): number { return 0; } +>y : Symbol(y, Decl(dynamicNamesErrors.ts, 27, 5)) + + get [z](): number { return 0; } +>z : Symbol(z, Decl(dynamicNamesErrors.ts, 28, 5)) + + set [w](value: number) { } +>w : Symbol(w, Decl(dynamicNamesErrors.ts, 29, 5)) +>value : Symbol(value, Decl(dynamicNamesErrors.ts, 45, 12)) +} + +export type ObjectTypeVisibility = { +>ObjectTypeVisibility : Symbol(ObjectTypeVisibility, Decl(dynamicNamesErrors.ts, 46, 1)) + + [x]: number; +>x : Symbol(x, Decl(dynamicNamesErrors.ts, 26, 5)) + + [y](): number; +>y : Symbol(y, Decl(dynamicNamesErrors.ts, 27, 5)) + +}; + +export const ObjectLiteralVisibility = { +>ObjectLiteralVisibility : Symbol(ObjectLiteralVisibility, Decl(dynamicNamesErrors.ts, 53, 12)) + + [x]: 0, +>x : Symbol(x, Decl(dynamicNamesErrors.ts, 26, 5)) + + [y](): number { return 0; }, +>y : Symbol(y, Decl(dynamicNamesErrors.ts, 27, 5)) + + get [z](): number { return 0; }, +>z : Symbol(z, Decl(dynamicNamesErrors.ts, 28, 5)) + + set [w](value: number) { }, +>w : Symbol(w, Decl(dynamicNamesErrors.ts, 29, 5)) +>value : Symbol(value, Decl(dynamicNamesErrors.ts, 57, 12)) + +}; diff --git a/tests/baselines/reference/dynamicNamesErrors.types b/tests/baselines/reference/dynamicNamesErrors.types new file mode 100644 index 0000000000000..3e3f71ec1410e --- /dev/null +++ b/tests/baselines/reference/dynamicNamesErrors.types @@ -0,0 +1,156 @@ +=== tests/cases/compiler/dynamicNamesErrors.ts === +const c0 = "1"; +>c0 : "1" +>"1" : "1" + +const c1 = 1; +>c1 : 1 +>1 : 1 + +interface T0 { +>T0 : T0 + + [c0]: number; +>c0 : "1" + + 1: number; +} + +interface T1 { +>T1 : T1 + + [c0]: number; +>c0 : "1" +} + +interface T2 { +>T2 : T2 + + [c0]: string; +>c0 : "1" +} + +interface T3 { +>T3 : T3 + + [c0]: number; +>c0 : "1" + + [c1]: string; +>c1 : 1 +} + +let t1: T1; +>t1 : T1 +>T1 : T1 + +let t2: T2; +>t2 : T2 +>T2 : T2 + +t1 = t2; +>t1 = t2 : T2 +>t1 : T1 +>t2 : T2 + +t2 = t1; +>t2 = t1 : T1 +>t2 : T2 +>t1 : T1 + +const x = Symbol(); +>x : unique symbol +>Symbol() : unique symbol +>Symbol : SymbolConstructor + +const y = Symbol(); +>y : unique symbol +>Symbol() : unique symbol +>Symbol : SymbolConstructor + +const z = Symbol(); +>z : unique symbol +>Symbol() : unique symbol +>Symbol : SymbolConstructor + +const w = Symbol(); +>w : unique symbol +>Symbol() : unique symbol +>Symbol : SymbolConstructor + +export interface InterfaceMemberVisibility { +>InterfaceMemberVisibility : InterfaceMemberVisibility + + [x]: number; +>x : unique symbol + + [y](): number; +>y : unique symbol +} + +export class ClassMemberVisibility { +>ClassMemberVisibility : ClassMemberVisibility + + static [x]: number; +>x : unique symbol + + static [y](): number { return 0; } +>y : unique symbol +>0 : 0 + + static get [z](): number { return 0; } +>z : unique symbol +>0 : 0 + + static set [w](value: number) { } +>w : unique symbol +>value : number + + [x]: number; +>x : unique symbol + + [y](): number { return 0; } +>y : unique symbol +>0 : 0 + + get [z](): number { return 0; } +>z : unique symbol +>0 : 0 + + set [w](value: number) { } +>w : unique symbol +>value : number +} + +export type ObjectTypeVisibility = { +>ObjectTypeVisibility : ObjectTypeVisibility + + [x]: number; +>x : unique symbol + + [y](): number; +>y : unique symbol + +}; + +export const ObjectLiteralVisibility = { +>ObjectLiteralVisibility : { [x]: number; [y](): number; readonly [z]: number; [w]: number; } +>{ [x]: 0, [y](): number { return 0; }, get [z](): number { return 0; }, set [w](value: number) { },} : { [x]: number; [y](): number; readonly [z]: number; [w]: number; } + + [x]: 0, +>x : unique symbol +>0 : 0 + + [y](): number { return 0; }, +>y : unique symbol +>0 : 0 + + get [z](): number { return 0; }, +>z : unique symbol +>0 : 0 + + set [w](value: number) { }, +>w : unique symbol +>value : number + +}; diff --git a/tests/baselines/reference/emitClassDeclarationWithGetterSetterInES6.symbols b/tests/baselines/reference/emitClassDeclarationWithGetterSetterInES6.symbols index 89c49123e7757..b6a267e596f52 100644 --- a/tests/baselines/reference/emitClassDeclarationWithGetterSetterInES6.symbols +++ b/tests/baselines/reference/emitClassDeclarationWithGetterSetterInES6.symbols @@ -19,27 +19,27 @@ class C { return "BYE"; } static get ["computedname"]() { ->"computedname" : Symbol(C[["computedname"]], Decl(emitClassDeclarationWithGetterSetterInES6.ts, 7, 5), Decl(emitClassDeclarationWithGetterSetterInES6.ts, 24, 33)) +>"computedname" : Symbol(C["computedname"], Decl(emitClassDeclarationWithGetterSetterInES6.ts, 7, 5), Decl(emitClassDeclarationWithGetterSetterInES6.ts, 24, 33)) return ""; } get ["computedname1"]() { ->"computedname1" : Symbol(C[["computedname1"]], Decl(emitClassDeclarationWithGetterSetterInES6.ts, 10, 5)) +>"computedname1" : Symbol(C["computedname1"], Decl(emitClassDeclarationWithGetterSetterInES6.ts, 10, 5)) return ""; } get ["computedname2"]() { ->"computedname2" : Symbol(C[["computedname2"]], Decl(emitClassDeclarationWithGetterSetterInES6.ts, 13, 5)) +>"computedname2" : Symbol(C["computedname2"], Decl(emitClassDeclarationWithGetterSetterInES6.ts, 13, 5)) return ""; } set ["computedname3"](x: any) { ->"computedname3" : Symbol(C[["computedname3"]], Decl(emitClassDeclarationWithGetterSetterInES6.ts, 16, 5)) +>"computedname3" : Symbol(C["computedname3"], Decl(emitClassDeclarationWithGetterSetterInES6.ts, 16, 5)) >x : Symbol(x, Decl(emitClassDeclarationWithGetterSetterInES6.ts, 18, 26)) } set ["computedname4"](y: string) { ->"computedname4" : Symbol(C[["computedname4"]], Decl(emitClassDeclarationWithGetterSetterInES6.ts, 19, 5)) +>"computedname4" : Symbol(C["computedname4"], Decl(emitClassDeclarationWithGetterSetterInES6.ts, 19, 5)) >y : Symbol(y, Decl(emitClassDeclarationWithGetterSetterInES6.ts, 20, 26)) } @@ -52,6 +52,6 @@ class C { >b : Symbol(b, Decl(emitClassDeclarationWithGetterSetterInES6.ts, 24, 19)) static set ["computedname"](b: string) { } ->"computedname" : Symbol(C[["computedname"]], Decl(emitClassDeclarationWithGetterSetterInES6.ts, 7, 5), Decl(emitClassDeclarationWithGetterSetterInES6.ts, 24, 33)) +>"computedname" : Symbol(C["computedname"], Decl(emitClassDeclarationWithGetterSetterInES6.ts, 7, 5), Decl(emitClassDeclarationWithGetterSetterInES6.ts, 24, 33)) >b : Symbol(b, Decl(emitClassDeclarationWithGetterSetterInES6.ts, 25, 32)) } diff --git a/tests/baselines/reference/emitClassDeclarationWithMethodInES6.symbols b/tests/baselines/reference/emitClassDeclarationWithMethodInES6.symbols index 54522c5834ad0..5328b892ded81 100644 --- a/tests/baselines/reference/emitClassDeclarationWithMethodInES6.symbols +++ b/tests/baselines/reference/emitClassDeclarationWithMethodInES6.symbols @@ -9,14 +9,14 @@ class D { >foo : Symbol(D.foo, Decl(emitClassDeclarationWithMethodInES6.ts, 1, 17)) ["computedName1"]() { } ->"computedName1" : Symbol(D[["computedName1"]], Decl(emitClassDeclarationWithMethodInES6.ts, 2, 13)) +>"computedName1" : Symbol(D["computedName1"], Decl(emitClassDeclarationWithMethodInES6.ts, 2, 13)) ["computedName2"](a: string) { } ->"computedName2" : Symbol(D[["computedName2"]], Decl(emitClassDeclarationWithMethodInES6.ts, 3, 27)) +>"computedName2" : Symbol(D["computedName2"], Decl(emitClassDeclarationWithMethodInES6.ts, 3, 27)) >a : Symbol(a, Decl(emitClassDeclarationWithMethodInES6.ts, 4, 22)) ["computedName3"](a: string): number { return 1; } ->"computedName3" : Symbol(D[["computedName3"]], Decl(emitClassDeclarationWithMethodInES6.ts, 4, 36)) +>"computedName3" : Symbol(D["computedName3"], Decl(emitClassDeclarationWithMethodInES6.ts, 4, 36)) >a : Symbol(a, Decl(emitClassDeclarationWithMethodInES6.ts, 5, 22)) bar(): string { @@ -35,14 +35,14 @@ class D { return "HELLO"; } static ["computedname4"]() { } ->"computedname4" : Symbol(D[["computedname4"]], Decl(emitClassDeclarationWithMethodInES6.ts, 11, 5)) +>"computedname4" : Symbol(D["computedname4"], Decl(emitClassDeclarationWithMethodInES6.ts, 11, 5)) static ["computedname5"](a: string) { } ->"computedname5" : Symbol(D[["computedname5"]], Decl(emitClassDeclarationWithMethodInES6.ts, 12, 34)) +>"computedname5" : Symbol(D["computedname5"], Decl(emitClassDeclarationWithMethodInES6.ts, 12, 34)) >a : Symbol(a, Decl(emitClassDeclarationWithMethodInES6.ts, 13, 29)) static ["computedname6"](a: string): boolean { return true; } ->"computedname6" : Symbol(D[["computedname6"]], Decl(emitClassDeclarationWithMethodInES6.ts, 13, 43)) +>"computedname6" : Symbol(D["computedname6"], Decl(emitClassDeclarationWithMethodInES6.ts, 13, 43)) >a : Symbol(a, Decl(emitClassDeclarationWithMethodInES6.ts, 14, 29)) static staticMethod() { diff --git a/tests/baselines/reference/emitter.asyncGenerators.classMethods.es2015.types b/tests/baselines/reference/emitter.asyncGenerators.classMethods.es2015.types index c375fb6f45522..c6d6fb6758d13 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.classMethods.es2015.types +++ b/tests/baselines/reference/emitter.asyncGenerators.classMethods.es2015.types @@ -23,7 +23,7 @@ class C3 { >C3 : C3 async * f() { ->f : () => AsyncIterableIterator<1> +>f : () => AsyncIterableIterator const x = yield 1; >x : any @@ -50,14 +50,14 @@ class C5 { >C5 : C5 async * f() { ->f : () => AsyncIterableIterator<1> +>f : () => AsyncIterableIterator 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 +>(async function*() { yield 1; }) : () => AsyncIterableIterator +>async function*() { yield 1; } : () => AsyncIterableIterator >yield 1 : any >1 : 1 } @@ -80,7 +80,7 @@ class C7 { >C7 : C7 async * f() { ->f : () => AsyncIterableIterator<1> +>f : () => AsyncIterableIterator return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.classMethods.es5.types b/tests/baselines/reference/emitter.asyncGenerators.classMethods.es5.types index e4be9f80d4ae6..5d636d2400c6f 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.classMethods.es5.types +++ b/tests/baselines/reference/emitter.asyncGenerators.classMethods.es5.types @@ -23,7 +23,7 @@ class C3 { >C3 : C3 async * f() { ->f : () => AsyncIterableIterator<1> +>f : () => AsyncIterableIterator const x = yield 1; >x : any @@ -50,14 +50,14 @@ class C5 { >C5 : C5 async * f() { ->f : () => AsyncIterableIterator<1> +>f : () => AsyncIterableIterator 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 +>(async function*() { yield 1; }) : () => AsyncIterableIterator +>async function*() { yield 1; } : () => AsyncIterableIterator >yield 1 : any >1 : 1 } @@ -80,7 +80,7 @@ class C7 { >C7 : C7 async * f() { ->f : () => AsyncIterableIterator<1> +>f : () => AsyncIterableIterator return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.classMethods.esnext.types b/tests/baselines/reference/emitter.asyncGenerators.classMethods.esnext.types index 1232130a389a3..f2f5f4d7503bd 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.classMethods.esnext.types +++ b/tests/baselines/reference/emitter.asyncGenerators.classMethods.esnext.types @@ -23,7 +23,7 @@ class C3 { >C3 : C3 async * f() { ->f : () => AsyncIterableIterator<1> +>f : () => AsyncIterableIterator const x = yield 1; >x : any @@ -50,14 +50,14 @@ class C5 { >C5 : C5 async * f() { ->f : () => AsyncIterableIterator<1> +>f : () => AsyncIterableIterator 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 +>(async function*() { yield 1; }) : () => AsyncIterableIterator +>async function*() { yield 1; } : () => AsyncIterableIterator >yield 1 : any >1 : 1 } @@ -80,7 +80,7 @@ class C7 { >C7 : C7 async * f() { ->f : () => AsyncIterableIterator<1> +>f : () => AsyncIterableIterator return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es2015.types b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es2015.types index 0e43463990629..15ff1298b21ac 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es2015.types +++ b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es2015.types @@ -12,7 +12,7 @@ async function * f2() { } === tests/cases/conformance/emitter/es2015/asyncGenerators/F3.ts === async function * f3() { ->f3 : () => AsyncIterableIterator<1> +>f3 : () => AsyncIterableIterator 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 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 +>(async function*() { yield 1; }) : () => AsyncIterableIterator +>async function*() { yield 1; } : () => AsyncIterableIterator >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 return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es5.types b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es5.types index 9ebd2659ef4ab..6220f5efd1eca 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es5.types +++ b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es5.types @@ -12,7 +12,7 @@ async function * f2() { } === tests/cases/conformance/emitter/es5/asyncGenerators/F3.ts === async function * f3() { ->f3 : () => AsyncIterableIterator<1> +>f3 : () => AsyncIterableIterator 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 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 +>(async function*() { yield 1; }) : () => AsyncIterableIterator +>async function*() { yield 1; } : () => AsyncIterableIterator >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 return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.esnext.types b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.esnext.types index 4e61c9032273c..c0d8011774655 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.esnext.types +++ b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.esnext.types @@ -12,7 +12,7 @@ async function * f2() { } === tests/cases/conformance/emitter/esnext/asyncGenerators/F3.ts === async function * f3() { ->f3 : () => AsyncIterableIterator<1> +>f3 : () => AsyncIterableIterator 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 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 +>(async function*() { yield 1; }) : () => AsyncIterableIterator +>async function*() { yield 1; } : () => AsyncIterableIterator >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 return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es2015.types b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es2015.types index 83d65ce524624..1db2126b7ed83 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es2015.types +++ b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es2015.types @@ -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 +>async function * () { const x = yield 1;} : () => AsyncIterableIterator 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 +>async function * () { const x = yield* (async function*() { yield 1; })();} : () => AsyncIterableIterator 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 +>(async function*() { yield 1; }) : () => AsyncIterableIterator +>async function*() { yield 1; } : () => AsyncIterableIterator >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 +>async function * () { return 1;} : () => AsyncIterableIterator return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es5.types b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es5.types index 7d736b2327c9a..e9da600bdbf1c 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es5.types +++ b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es5.types @@ -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 +>async function * () { const x = yield 1;} : () => AsyncIterableIterator 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 +>async function * () { const x = yield* (async function*() { yield 1; })();} : () => AsyncIterableIterator 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 +>(async function*() { yield 1; }) : () => AsyncIterableIterator +>async function*() { yield 1; } : () => AsyncIterableIterator >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 +>async function * () { return 1;} : () => AsyncIterableIterator return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.esnext.types b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.esnext.types index 6c40f9cebb169..5802bc10a2d9e 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.esnext.types +++ b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.esnext.types @@ -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 +>async function * () { const x = yield 1;} : () => AsyncIterableIterator 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 +>async function * () { const x = yield* (async function*() { yield 1; })();} : () => AsyncIterableIterator 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 +>(async function*() { yield 1; }) : () => AsyncIterableIterator +>async function*() { yield 1; } : () => AsyncIterableIterator >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 +>async function * () { return 1;} : () => AsyncIterableIterator return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es2015.types b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es2015.types index 59c5bcfa16716..9e47fc9d98932 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es2015.types +++ b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es2015.types @@ -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; } +>{ async * f() { const x = yield 1; }} : { f(): AsyncIterableIterator; } async * f() { ->f : () => AsyncIterableIterator<1> +>f : () => AsyncIterableIterator 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; } +>{ async * f() { const x = yield* (async function*() { yield 1; })(); }} : { f(): AsyncIterableIterator; } async * f() { ->f : () => AsyncIterableIterator<1> +>f : () => AsyncIterableIterator 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 +>(async function*() { yield 1; }) : () => AsyncIterableIterator +>async function*() { yield 1; } : () => AsyncIterableIterator >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; } +>{ async * f() { return 1; }} : { f(): AsyncIterableIterator; } async * f() { ->f : () => AsyncIterableIterator<1> +>f : () => AsyncIterableIterator return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es5.types b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es5.types index 3e7ead2f73796..390007605083d 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es5.types +++ b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es5.types @@ -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; } +>{ async * f() { const x = yield 1; }} : { f(): AsyncIterableIterator; } async * f() { ->f : () => AsyncIterableIterator<1> +>f : () => AsyncIterableIterator 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; } +>{ async * f() { const x = yield* (async function*() { yield 1; })(); }} : { f(): AsyncIterableIterator; } async * f() { ->f : () => AsyncIterableIterator<1> +>f : () => AsyncIterableIterator 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 +>(async function*() { yield 1; }) : () => AsyncIterableIterator +>async function*() { yield 1; } : () => AsyncIterableIterator >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; } +>{ async * f() { return 1; }} : { f(): AsyncIterableIterator; } async * f() { ->f : () => AsyncIterableIterator<1> +>f : () => AsyncIterableIterator return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.esnext.types b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.esnext.types index 9e5aad8af2367..a05b5326b2c8e 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.esnext.types +++ b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.esnext.types @@ -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; } +>{ async * f() { const x = yield 1; }} : { f(): AsyncIterableIterator; } async * f() { ->f : () => AsyncIterableIterator<1> +>f : () => AsyncIterableIterator 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; } +>{ async * f() { const x = yield* (async function*() { yield 1; })(); }} : { f(): AsyncIterableIterator; } async * f() { ->f : () => AsyncIterableIterator<1> +>f : () => AsyncIterableIterator 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 +>(async function*() { yield 1; }) : () => AsyncIterableIterator +>async function*() { yield 1; } : () => AsyncIterableIterator >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; } +>{ async * f() { return 1; }} : { f(): AsyncIterableIterator; } async * f() { ->f : () => AsyncIterableIterator<1> +>f : () => AsyncIterableIterator return 1; >1 : 1 diff --git a/tests/baselines/reference/exhaustiveSwitchImplicitReturn.errors.txt b/tests/baselines/reference/exhaustiveSwitchImplicitReturn.errors.txt new file mode 100644 index 0000000000000..43b5467f0d20f --- /dev/null +++ b/tests/baselines/reference/exhaustiveSwitchImplicitReturn.errors.txt @@ -0,0 +1,47 @@ +tests/cases/compiler/exhaustiveSwitchImplicitReturn.ts(35,32): error TS7030: Not all code paths return a value. + + +==== tests/cases/compiler/exhaustiveSwitchImplicitReturn.ts (1 errors) ==== + function foo1(bar: "a"): number { + switch(bar) { + case "a": + return 1; + } + } + + function foo2(bar: "a"): number { + switch(bar) { + case "a": + return 1; + } + + let unusedVariable; + } + + function foo3(bar: "a"): number { + switch(bar) { + case "a": + return 1; + } + + function neverCalled() {} + } + + function foo4(bar: "a"): number { + switch(bar) { + case "a": + return 1; + } + + foo3(bar); + } + + function foo5(bar: "a" | "b"): number { + ~~~~~~ +!!! error TS7030: Not all code paths return a value. + switch(bar) { + case "a": + return 1; + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/exhaustiveSwitchImplicitReturn.js b/tests/baselines/reference/exhaustiveSwitchImplicitReturn.js new file mode 100644 index 0000000000000..5f8bf348c5f40 --- /dev/null +++ b/tests/baselines/reference/exhaustiveSwitchImplicitReturn.js @@ -0,0 +1,77 @@ +//// [exhaustiveSwitchImplicitReturn.ts] +function foo1(bar: "a"): number { + switch(bar) { + case "a": + return 1; + } +} + +function foo2(bar: "a"): number { + switch(bar) { + case "a": + return 1; + } + + let unusedVariable; +} + +function foo3(bar: "a"): number { + switch(bar) { + case "a": + return 1; + } + + function neverCalled() {} +} + +function foo4(bar: "a"): number { + switch(bar) { + case "a": + return 1; + } + + foo3(bar); +} + +function foo5(bar: "a" | "b"): number { + switch(bar) { + case "a": + return 1; + } +} + + +//// [exhaustiveSwitchImplicitReturn.js] +function foo1(bar) { + switch (bar) { + case "a": + return 1; + } +} +function foo2(bar) { + switch (bar) { + case "a": + return 1; + } + var unusedVariable; +} +function foo3(bar) { + switch (bar) { + case "a": + return 1; + } + function neverCalled() { } +} +function foo4(bar) { + switch (bar) { + case "a": + return 1; + } + foo3(bar); +} +function foo5(bar) { + switch (bar) { + case "a": + return 1; + } +} diff --git a/tests/baselines/reference/exhaustiveSwitchImplicitReturn.symbols b/tests/baselines/reference/exhaustiveSwitchImplicitReturn.symbols new file mode 100644 index 0000000000000..d93a522836247 --- /dev/null +++ b/tests/baselines/reference/exhaustiveSwitchImplicitReturn.symbols @@ -0,0 +1,71 @@ +=== tests/cases/compiler/exhaustiveSwitchImplicitReturn.ts === +function foo1(bar: "a"): number { +>foo1 : Symbol(foo1, Decl(exhaustiveSwitchImplicitReturn.ts, 0, 0)) +>bar : Symbol(bar, Decl(exhaustiveSwitchImplicitReturn.ts, 0, 14)) + + switch(bar) { +>bar : Symbol(bar, Decl(exhaustiveSwitchImplicitReturn.ts, 0, 14)) + + case "a": + return 1; + } +} + +function foo2(bar: "a"): number { +>foo2 : Symbol(foo2, Decl(exhaustiveSwitchImplicitReturn.ts, 5, 1)) +>bar : Symbol(bar, Decl(exhaustiveSwitchImplicitReturn.ts, 7, 14)) + + switch(bar) { +>bar : Symbol(bar, Decl(exhaustiveSwitchImplicitReturn.ts, 7, 14)) + + case "a": + return 1; + } + + let unusedVariable; +>unusedVariable : Symbol(unusedVariable, Decl(exhaustiveSwitchImplicitReturn.ts, 13, 7)) +} + +function foo3(bar: "a"): number { +>foo3 : Symbol(foo3, Decl(exhaustiveSwitchImplicitReturn.ts, 14, 1)) +>bar : Symbol(bar, Decl(exhaustiveSwitchImplicitReturn.ts, 16, 14)) + + switch(bar) { +>bar : Symbol(bar, Decl(exhaustiveSwitchImplicitReturn.ts, 16, 14)) + + case "a": + return 1; + } + + function neverCalled() {} +>neverCalled : Symbol(neverCalled, Decl(exhaustiveSwitchImplicitReturn.ts, 20, 5)) +} + +function foo4(bar: "a"): number { +>foo4 : Symbol(foo4, Decl(exhaustiveSwitchImplicitReturn.ts, 23, 1)) +>bar : Symbol(bar, Decl(exhaustiveSwitchImplicitReturn.ts, 25, 14)) + + switch(bar) { +>bar : Symbol(bar, Decl(exhaustiveSwitchImplicitReturn.ts, 25, 14)) + + case "a": + return 1; + } + + foo3(bar); +>foo3 : Symbol(foo3, Decl(exhaustiveSwitchImplicitReturn.ts, 14, 1)) +>bar : Symbol(bar, Decl(exhaustiveSwitchImplicitReturn.ts, 25, 14)) +} + +function foo5(bar: "a" | "b"): number { +>foo5 : Symbol(foo5, Decl(exhaustiveSwitchImplicitReturn.ts, 32, 1)) +>bar : Symbol(bar, Decl(exhaustiveSwitchImplicitReturn.ts, 34, 14)) + + switch(bar) { +>bar : Symbol(bar, Decl(exhaustiveSwitchImplicitReturn.ts, 34, 14)) + + case "a": + return 1; + } +} + diff --git a/tests/baselines/reference/exhaustiveSwitchImplicitReturn.types b/tests/baselines/reference/exhaustiveSwitchImplicitReturn.types new file mode 100644 index 0000000000000..c868aa99b8f1d --- /dev/null +++ b/tests/baselines/reference/exhaustiveSwitchImplicitReturn.types @@ -0,0 +1,87 @@ +=== tests/cases/compiler/exhaustiveSwitchImplicitReturn.ts === +function foo1(bar: "a"): number { +>foo1 : (bar: "a") => number +>bar : "a" + + switch(bar) { +>bar : "a" + + case "a": +>"a" : "a" + + return 1; +>1 : 1 + } +} + +function foo2(bar: "a"): number { +>foo2 : (bar: "a") => number +>bar : "a" + + switch(bar) { +>bar : "a" + + case "a": +>"a" : "a" + + return 1; +>1 : 1 + } + + let unusedVariable; +>unusedVariable : any +} + +function foo3(bar: "a"): number { +>foo3 : (bar: "a") => number +>bar : "a" + + switch(bar) { +>bar : "a" + + case "a": +>"a" : "a" + + return 1; +>1 : 1 + } + + function neverCalled() {} +>neverCalled : () => void +} + +function foo4(bar: "a"): number { +>foo4 : (bar: "a") => number +>bar : "a" + + switch(bar) { +>bar : "a" + + case "a": +>"a" : "a" + + return 1; +>1 : 1 + } + + foo3(bar); +>foo3(bar) : number +>foo3 : (bar: "a") => number +>bar : never +} + +function foo5(bar: "a" | "b"): number { +>foo5 : (bar: "a" | "b") => number +>bar : "a" | "b" + + switch(bar) { +>bar : "a" | "b" + + case "a": +>"a" : "a" + + return 1; +>1 : 1 + } +} + diff --git a/tests/baselines/reference/generatorES6_2.types b/tests/baselines/reference/generatorES6_2.types index 61a2adbc697fa..a95a0008d4fe4 100644 --- a/tests/baselines/reference/generatorES6_2.types +++ b/tests/baselines/reference/generatorES6_2.types @@ -3,7 +3,7 @@ class C { >C : C public * foo() { ->foo : () => IterableIterator<1> +>foo : () => IterableIterator yield 1 >yield 1 : any diff --git a/tests/baselines/reference/generatorES6_3.types b/tests/baselines/reference/generatorES6_3.types index 9ecd01d6e23bb..e237cbd3510a2 100644 --- a/tests/baselines/reference/generatorES6_3.types +++ b/tests/baselines/reference/generatorES6_3.types @@ -1,7 +1,7 @@ === tests/cases/compiler/generatorES6_3.ts === var v = function*() { ->v : () => IterableIterator<0> ->function*() { yield 0} : () => IterableIterator<0> +>v : () => IterableIterator +>function*() { yield 0} : () => IterableIterator yield 0 >yield 0 : any diff --git a/tests/baselines/reference/generatorES6_4.types b/tests/baselines/reference/generatorES6_4.types index 786e7b64020fd..fa19d8f3ae2d5 100644 --- a/tests/baselines/reference/generatorES6_4.types +++ b/tests/baselines/reference/generatorES6_4.types @@ -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; } +>{ *foo() { yield 0 }} : { foo(): IterableIterator; } *foo() { ->foo : () => IterableIterator<0> +>foo : () => IterableIterator yield 0 >yield 0 : any diff --git a/tests/baselines/reference/generatorTypeCheck15.types b/tests/baselines/reference/generatorTypeCheck15.types index 3851d8e56a416..33537836c120f 100644 --- a/tests/baselines/reference/generatorTypeCheck15.types +++ b/tests/baselines/reference/generatorTypeCheck15.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck15.ts === function* g() { ->g : () => IterableIterator<""> +>g : () => IterableIterator return ""; >"" : "" diff --git a/tests/baselines/reference/generatorTypeCheck33.types b/tests/baselines/reference/generatorTypeCheck33.types index 707bf7beccda2..d6b29936530d6 100644 --- a/tests/baselines/reference/generatorTypeCheck33.types +++ b/tests/baselines/reference/generatorTypeCheck33.types @@ -1,13 +1,13 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck33.ts === function* g() { ->g : () => IterableIterator<0> +>g : () => IterableIterator yield 0; >yield 0 : any >0 : 0 function* g2() { ->g2 : () => IterableIterator<""> +>g2 : () => IterableIterator yield ""; >yield "" : any diff --git a/tests/baselines/reference/generatorTypeCheck34.types b/tests/baselines/reference/generatorTypeCheck34.types index 239c5ff14936d..f25eefb72f7be 100644 --- a/tests/baselines/reference/generatorTypeCheck34.types +++ b/tests/baselines/reference/generatorTypeCheck34.types @@ -1,13 +1,13 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck34.ts === function* g() { ->g : () => IterableIterator<0> +>g : () => IterableIterator yield 0; >yield 0 : any >0 : 0 function* g2() { ->g2 : () => IterableIterator<""> +>g2 : () => IterableIterator return ""; >"" : "" diff --git a/tests/baselines/reference/generatorTypeCheck35.types b/tests/baselines/reference/generatorTypeCheck35.types index dcd5ab4be84bf..333b653a50148 100644 --- a/tests/baselines/reference/generatorTypeCheck35.types +++ b/tests/baselines/reference/generatorTypeCheck35.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck35.ts === function* g() { ->g : () => IterableIterator<0> +>g : () => IterableIterator yield 0; >yield 0 : any diff --git a/tests/baselines/reference/generatorTypeCheck38.types b/tests/baselines/reference/generatorTypeCheck38.types index 31fe452e65639..15b8528b345a6 100644 --- a/tests/baselines/reference/generatorTypeCheck38.types +++ b/tests/baselines/reference/generatorTypeCheck38.types @@ -3,7 +3,7 @@ var yield; >yield : any function* g() { ->g : () => IterableIterator<0> +>g : () => IterableIterator yield 0; >yield 0 : any diff --git a/tests/baselines/reference/generatorTypeCheck41.types b/tests/baselines/reference/generatorTypeCheck41.types index 1a9ea21f9786b..8e59ce188602e 100644 --- a/tests/baselines/reference/generatorTypeCheck41.types +++ b/tests/baselines/reference/generatorTypeCheck41.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck41.ts === function* g() { ->g : () => IterableIterator<0> +>g : () => IterableIterator let x = { >x : { [x: number]: number; } diff --git a/tests/baselines/reference/generatorTypeCheck42.types b/tests/baselines/reference/generatorTypeCheck42.types index 79b2516051e79..f7281d60afe1b 100644 --- a/tests/baselines/reference/generatorTypeCheck42.types +++ b/tests/baselines/reference/generatorTypeCheck42.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck42.ts === function* g() { ->g : () => IterableIterator<0> +>g : () => IterableIterator let x = { >x : { [x: number]: () => void; } diff --git a/tests/baselines/reference/generatorTypeCheck43.types b/tests/baselines/reference/generatorTypeCheck43.types index 754d3fee814c8..3e8ec02672a2f 100644 --- a/tests/baselines/reference/generatorTypeCheck43.types +++ b/tests/baselines/reference/generatorTypeCheck43.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck43.ts === function* g() { ->g : () => IterableIterator<0> +>g : () => IterableIterator let x = { >x : { [x: number]: () => IterableIterator; } diff --git a/tests/baselines/reference/generatorTypeCheck44.types b/tests/baselines/reference/generatorTypeCheck44.types index e06b8961ca07a..381feb30f3c67 100644 --- a/tests/baselines/reference/generatorTypeCheck44.types +++ b/tests/baselines/reference/generatorTypeCheck44.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck44.ts === function* g() { ->g : () => IterableIterator<0> +>g : () => IterableIterator let x = { >x : { [x: number]: number; } diff --git a/tests/baselines/reference/generatorTypeCheck49.types b/tests/baselines/reference/generatorTypeCheck49.types index 6ac2b6acce861..f73978d1a095a 100644 --- a/tests/baselines/reference/generatorTypeCheck49.types +++ b/tests/baselines/reference/generatorTypeCheck49.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck49.ts === function* g() { ->g : () => IterableIterator<0> +>g : () => IterableIterator yield 0; >yield 0 : any diff --git a/tests/baselines/reference/generatorTypeCheck51.types b/tests/baselines/reference/generatorTypeCheck51.types index ca50f640301d4..1563ee5e7d317 100644 --- a/tests/baselines/reference/generatorTypeCheck51.types +++ b/tests/baselines/reference/generatorTypeCheck51.types @@ -3,7 +3,7 @@ function* g() { >g : () => IterableIterator function* h() { ->h : () => IterableIterator<0> +>h : () => IterableIterator yield 0; >yield 0 : any diff --git a/tests/baselines/reference/generatorTypeCheck63.errors.txt b/tests/baselines/reference/generatorTypeCheck63.errors.txt index 1466530dd0c65..2a1935fd90633 100644 --- a/tests/baselines/reference/generatorTypeCheck63.errors.txt +++ b/tests/baselines/reference/generatorTypeCheck63.errors.txt @@ -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' 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'. - Type 'IterableIterator<1>' is not assignable to type 'IterableIterator'. - 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' is not assignable to parameter of type '(a: State) => IterableIterator'. + Type 'IterableIterator' is not assignable to type 'IterableIterator'. + 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' is not assignable to parameter of type '(a: StrategicState) => IterableIterator'. Type 'IterableIterator' is not assignable to type 'IterableIterator'. @@ -51,9 +51,9 @@ tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(36,62): err export const Nothing2: Strategy = strategy("Nothing", function* (state: State) { ~~~~~~~~ -!!! error TS2345: Argument of type '(state: State) => IterableIterator<1>' is not assignable to parameter of type '(a: State) => IterableIterator'. -!!! error TS2345: Type 'IterableIterator<1>' is not assignable to type 'IterableIterator'. -!!! error TS2345: Type '1' is not assignable to type 'State'. +!!! error TS2345: Argument of type '(state: State) => IterableIterator' is not assignable to parameter of type '(a: State) => IterableIterator'. +!!! error TS2345: Type 'IterableIterator' is not assignable to type 'IterableIterator'. +!!! error TS2345: Type 'number' is not assignable to type 'State'. return 1; }); diff --git a/tests/baselines/reference/generatorTypeCheck63.types b/tests/baselines/reference/generatorTypeCheck63.types index cd41a1776b865..8fc2054bd6e74 100644 --- a/tests/baselines/reference/generatorTypeCheck63.types +++ b/tests/baselines/reference/generatorTypeCheck63.types @@ -107,7 +107,7 @@ export const Nothing2: Strategy = strategy("Nothing", function* (state: S >strategy("Nothing", function* (state: State) { return 1;}) : any >strategy : (stratName: string, gen: (a: T) => IterableIterator) => (a: T) => IterableIterator >"Nothing" : "Nothing" ->function* (state: State) { return 1;} : (state: State) => IterableIterator<1> +>function* (state: State) { return 1;} : (state: State) => IterableIterator >state : State >State : State diff --git a/tests/baselines/reference/gettersAndSettersErrors.errors.txt b/tests/baselines/reference/gettersAndSettersErrors.errors.txt index 3d762c6270f99..594c9d0bf621f 100644 --- a/tests/baselines/reference/gettersAndSettersErrors.errors.txt +++ b/tests/baselines/reference/gettersAndSettersErrors.errors.txt @@ -1,7 +1,7 @@ tests/cases/compiler/gettersAndSettersErrors.ts(2,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/gettersAndSettersErrors.ts(3,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/gettersAndSettersErrors.ts(5,12): error TS2300: Duplicate identifier 'Foo'. -tests/cases/compiler/gettersAndSettersErrors.ts(5,12): error TS2403: Subsequent variable declarations must have the same type. Variable 'Foo' has type 'string' at tests/cases/compiler/gettersAndSettersErrors.ts 1:15, but here has type 'number'. +tests/cases/compiler/gettersAndSettersErrors.ts(5,12): error TS2717: Subsequent property declarations must have the same type. Property 'Foo' has type 'string' at tests/cases/compiler/gettersAndSettersErrors.ts 1:15, but here has type 'number'. tests/cases/compiler/gettersAndSettersErrors.ts(6,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/gettersAndSettersErrors.ts(7,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/gettersAndSettersErrors.ts(11,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -23,7 +23,7 @@ tests/cases/compiler/gettersAndSettersErrors.ts(12,16): error TS2379: Getter and ~~~ !!! error TS2300: Duplicate identifier 'Foo'. ~~~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Foo' has type 'string' at tests/cases/compiler/gettersAndSettersErrors.ts 1:15, but here has type 'number'. +!!! error TS2717: Subsequent property declarations must have the same type. Property 'Foo' has type 'string' at tests/cases/compiler/gettersAndSettersErrors.ts 1:15, but here has type 'number'. public get Goo(v:string):string {return null;} // error - getters must not have a parameter ~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. diff --git a/tests/baselines/reference/giant.errors.txt b/tests/baselines/reference/giant.errors.txt index 809ae03635824..eb899ff132e6d 100644 --- a/tests/baselines/reference/giant.errors.txt +++ b/tests/baselines/reference/giant.errors.txt @@ -16,7 +16,7 @@ tests/cases/compiler/giant.ts(33,16): error TS2300: Duplicate identifier 'tsF'. tests/cases/compiler/giant.ts(34,12): error TS2300: Duplicate identifier 'tgF'. tests/cases/compiler/giant.ts(35,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(35,16): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(60,5): error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +tests/cases/compiler/giant.ts(60,5): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/giant.ts(60,6): error TS2304: Cannot find name 'p'. tests/cases/compiler/giant.ts(61,5): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(62,6): error TS1096: An index signature must have exactly one parameter. @@ -39,7 +39,7 @@ tests/cases/compiler/giant.ts(97,20): error TS2300: Duplicate identifier 'tsF'. tests/cases/compiler/giant.ts(98,16): error TS2300: Duplicate identifier 'tgF'. tests/cases/compiler/giant.ts(99,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(99,20): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(124,9): error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +tests/cases/compiler/giant.ts(124,9): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/giant.ts(124,10): error TS2304: Cannot find name 'p'. tests/cases/compiler/giant.ts(125,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(126,10): error TS1096: An index signature must have exactly one parameter. @@ -63,7 +63,7 @@ tests/cases/compiler/giant.ts(176,20): error TS2300: Duplicate identifier 'tsF'. tests/cases/compiler/giant.ts(177,16): error TS2300: Duplicate identifier 'tgF'. tests/cases/compiler/giant.ts(178,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(178,20): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(203,9): error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +tests/cases/compiler/giant.ts(203,9): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/giant.ts(203,10): error TS2304: Cannot find name 'p'. tests/cases/compiler/giant.ts(204,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(205,10): error TS1096: An index signature must have exactly one parameter. @@ -119,7 +119,7 @@ tests/cases/compiler/giant.ts(291,16): error TS2300: Duplicate identifier 'tsF'. tests/cases/compiler/giant.ts(292,12): error TS2300: Duplicate identifier 'tgF'. tests/cases/compiler/giant.ts(293,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(293,16): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(318,5): error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +tests/cases/compiler/giant.ts(318,5): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/giant.ts(318,6): error TS2304: Cannot find name 'p'. tests/cases/compiler/giant.ts(319,5): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(320,6): error TS1096: An index signature must have exactly one parameter. @@ -142,7 +142,7 @@ tests/cases/compiler/giant.ts(355,20): error TS2300: Duplicate identifier 'tsF'. tests/cases/compiler/giant.ts(356,16): error TS2300: Duplicate identifier 'tgF'. tests/cases/compiler/giant.ts(357,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(357,20): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(382,9): error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +tests/cases/compiler/giant.ts(382,9): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/giant.ts(382,10): error TS2304: Cannot find name 'p'. tests/cases/compiler/giant.ts(383,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(384,10): error TS1096: An index signature must have exactly one parameter. @@ -166,7 +166,7 @@ tests/cases/compiler/giant.ts(434,20): error TS2300: Duplicate identifier 'tsF'. tests/cases/compiler/giant.ts(435,16): error TS2300: Duplicate identifier 'tgF'. tests/cases/compiler/giant.ts(436,20): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/giant.ts(436,20): error TS2300: Duplicate identifier 'tgF'. -tests/cases/compiler/giant.ts(461,9): error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +tests/cases/compiler/giant.ts(461,9): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/giant.ts(461,10): error TS2304: Cannot find name 'p'. tests/cases/compiler/giant.ts(462,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(463,10): error TS1096: An index signature must have exactly one parameter. @@ -238,7 +238,7 @@ tests/cases/compiler/giant.ts(555,21): error TS1036: Statements are not allowed tests/cases/compiler/giant.ts(557,24): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(560,21): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(562,21): error TS1183: An implementation cannot be declared in ambient contexts. -tests/cases/compiler/giant.ts(586,9): error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +tests/cases/compiler/giant.ts(586,9): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/giant.ts(586,10): error TS2304: Cannot find name 'p'. tests/cases/compiler/giant.ts(587,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(588,10): error TS1096: An index signature must have exactly one parameter. @@ -255,7 +255,7 @@ tests/cases/compiler/giant.ts(620,26): error TS1183: An implementation cannot be tests/cases/compiler/giant.ts(622,24): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(625,21): error TS1183: An implementation cannot be declared in ambient contexts. tests/cases/compiler/giant.ts(627,21): error TS1183: An implementation cannot be declared in ambient contexts. -tests/cases/compiler/giant.ts(652,9): error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +tests/cases/compiler/giant.ts(652,9): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/giant.ts(652,10): error TS2304: Cannot find name 'p'. tests/cases/compiler/giant.ts(653,9): error TS1021: An index signature must have a type annotation. tests/cases/compiler/giant.ts(654,10): error TS1096: An index signature must have exactly one parameter. @@ -363,7 +363,7 @@ tests/cases/compiler/giant.ts(675,30): error TS1183: An implementation cannot be //Index Signature [p]; ~~~ -!!! error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'p'. [p1: string]; @@ -473,7 +473,7 @@ tests/cases/compiler/giant.ts(675,30): error TS1183: An implementation cannot be //Index Signature [p]; ~~~ -!!! error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'p'. [p1: string]; @@ -600,7 +600,7 @@ tests/cases/compiler/giant.ts(675,30): error TS1183: An implementation cannot be //Index Signature [p]; ~~~ -!!! error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'p'. [p1: string]; @@ -827,7 +827,7 @@ tests/cases/compiler/giant.ts(675,30): error TS1183: An implementation cannot be //Index Signature [p]; ~~~ -!!! error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'p'. [p1: string]; @@ -937,7 +937,7 @@ tests/cases/compiler/giant.ts(675,30): error TS1183: An implementation cannot be //Index Signature [p]; ~~~ -!!! error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'p'. [p1: string]; @@ -1064,7 +1064,7 @@ tests/cases/compiler/giant.ts(675,30): error TS1183: An implementation cannot be //Index Signature [p]; ~~~ -!!! error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'p'. [p1: string]; @@ -1333,7 +1333,7 @@ tests/cases/compiler/giant.ts(675,30): error TS1183: An implementation cannot be //Index Signature [p]; ~~~ -!!! error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'p'. [p1: string]; @@ -1433,7 +1433,7 @@ tests/cases/compiler/giant.ts(675,30): error TS1183: An implementation cannot be //Index Signature [p]; ~~~ -!!! error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'p'. [p1: string]; diff --git a/tests/baselines/reference/indexSignatureMustHaveTypeAnnotation.errors.txt b/tests/baselines/reference/indexSignatureMustHaveTypeAnnotation.errors.txt index 88e09d7746b92..bc18e0fb08486 100644 --- a/tests/baselines/reference/indexSignatureMustHaveTypeAnnotation.errors.txt +++ b/tests/baselines/reference/indexSignatureMustHaveTypeAnnotation.errors.txt @@ -1,7 +1,7 @@ -tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(3,5): error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(3,5): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(3,6): error TS2304: Cannot find name 'x'. tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(4,5): error TS1021: An index signature must have a type annotation. -tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(9,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(9,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(9,6): error TS2304: Cannot find name 'x'. tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(14,5): error TS1021: An index signature must have a type annotation. @@ -11,7 +11,7 @@ tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(14,5): error TS1021 // Used to be indexer, now it is a computed property [x]: string; ~~~ -!!! error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'x'. [x: string]; @@ -23,7 +23,7 @@ tests/cases/compiler/indexSignatureMustHaveTypeAnnotation.ts(14,5): error TS1021 // Used to be indexer, now it is a computed property [x]: string ~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'x'. diff --git a/tests/baselines/reference/indexSignatureWithInitializer.errors.txt b/tests/baselines/reference/indexSignatureWithInitializer.errors.txt index 4a49de69393ac..a2e78df0ed83f 100644 --- a/tests/baselines/reference/indexSignatureWithInitializer.errors.txt +++ b/tests/baselines/reference/indexSignatureWithInitializer.errors.txt @@ -1,6 +1,6 @@ -tests/cases/compiler/indexSignatureWithInitializer.ts(3,5): error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +tests/cases/compiler/indexSignatureWithInitializer.ts(3,5): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/indexSignatureWithInitializer.ts(3,6): error TS2304: Cannot find name 'x'. -tests/cases/compiler/indexSignatureWithInitializer.ts(7,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/compiler/indexSignatureWithInitializer.ts(7,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/indexSignatureWithInitializer.ts(7,6): error TS2304: Cannot find name 'x'. @@ -9,7 +9,7 @@ tests/cases/compiler/indexSignatureWithInitializer.ts(7,6): error TS2304: Cannot interface I { [x = '']: string; ~~~~~~~~ -!!! error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'x'. } @@ -17,7 +17,7 @@ tests/cases/compiler/indexSignatureWithInitializer.ts(7,6): error TS2304: Cannot class C { [x = 0]: string ~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'x'. } \ No newline at end of file diff --git a/tests/baselines/reference/indexWithoutParamType2.errors.txt b/tests/baselines/reference/indexWithoutParamType2.errors.txt index 7e72b7804e29c..5463980d66d68 100644 --- a/tests/baselines/reference/indexWithoutParamType2.errors.txt +++ b/tests/baselines/reference/indexWithoutParamType2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/indexWithoutParamType2.ts(3,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/compiler/indexWithoutParamType2.ts(3,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/indexWithoutParamType2.ts(3,6): error TS2304: Cannot find name 'x'. @@ -7,7 +7,7 @@ tests/cases/compiler/indexWithoutParamType2.ts(3,6): error TS2304: Cannot find n // Used to be indexer, now it is a computed property [x]: string ~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'x'. } \ No newline at end of file diff --git a/tests/baselines/reference/inferObjectTypeFromStringLiteralToKeyof.js b/tests/baselines/reference/inferObjectTypeFromStringLiteralToKeyof.js new file mode 100644 index 0000000000000..6a9a081ae6056 --- /dev/null +++ b/tests/baselines/reference/inferObjectTypeFromStringLiteralToKeyof.js @@ -0,0 +1,8 @@ +//// [inferObjectTypeFromStringLiteralToKeyof.ts] +declare function inference(target: T, name: keyof T): void; +declare var two: "a" | "d"; +inference({ a: 1, b: 2, c: 3, d(n) { return n } }, two); + + +//// [inferObjectTypeFromStringLiteralToKeyof.js] +inference({ a: 1, b: 2, c: 3, d: function (n) { return n; } }, two); diff --git a/tests/baselines/reference/inferObjectTypeFromStringLiteralToKeyof.symbols b/tests/baselines/reference/inferObjectTypeFromStringLiteralToKeyof.symbols new file mode 100644 index 0000000000000..aa3c9e89f9a42 --- /dev/null +++ b/tests/baselines/reference/inferObjectTypeFromStringLiteralToKeyof.symbols @@ -0,0 +1,22 @@ +=== tests/cases/compiler/inferObjectTypeFromStringLiteralToKeyof.ts === +declare function inference(target: T, name: keyof T): void; +>inference : Symbol(inference, Decl(inferObjectTypeFromStringLiteralToKeyof.ts, 0, 0)) +>T : Symbol(T, Decl(inferObjectTypeFromStringLiteralToKeyof.ts, 0, 27)) +>target : Symbol(target, Decl(inferObjectTypeFromStringLiteralToKeyof.ts, 0, 30)) +>T : Symbol(T, Decl(inferObjectTypeFromStringLiteralToKeyof.ts, 0, 27)) +>name : Symbol(name, Decl(inferObjectTypeFromStringLiteralToKeyof.ts, 0, 40)) +>T : Symbol(T, Decl(inferObjectTypeFromStringLiteralToKeyof.ts, 0, 27)) + +declare var two: "a" | "d"; +>two : Symbol(two, Decl(inferObjectTypeFromStringLiteralToKeyof.ts, 1, 11)) + +inference({ a: 1, b: 2, c: 3, d(n) { return n } }, two); +>inference : Symbol(inference, Decl(inferObjectTypeFromStringLiteralToKeyof.ts, 0, 0)) +>a : Symbol(a, Decl(inferObjectTypeFromStringLiteralToKeyof.ts, 2, 11)) +>b : Symbol(b, Decl(inferObjectTypeFromStringLiteralToKeyof.ts, 2, 17)) +>c : Symbol(c, Decl(inferObjectTypeFromStringLiteralToKeyof.ts, 2, 23)) +>d : Symbol(d, Decl(inferObjectTypeFromStringLiteralToKeyof.ts, 2, 29)) +>n : Symbol(n, Decl(inferObjectTypeFromStringLiteralToKeyof.ts, 2, 32)) +>n : Symbol(n, Decl(inferObjectTypeFromStringLiteralToKeyof.ts, 2, 32)) +>two : Symbol(two, Decl(inferObjectTypeFromStringLiteralToKeyof.ts, 1, 11)) + diff --git a/tests/baselines/reference/inferObjectTypeFromStringLiteralToKeyof.types b/tests/baselines/reference/inferObjectTypeFromStringLiteralToKeyof.types new file mode 100644 index 0000000000000..39c4bb84196b8 --- /dev/null +++ b/tests/baselines/reference/inferObjectTypeFromStringLiteralToKeyof.types @@ -0,0 +1,27 @@ +=== tests/cases/compiler/inferObjectTypeFromStringLiteralToKeyof.ts === +declare function inference(target: T, name: keyof T): void; +>inference : (target: T, name: keyof T) => void +>T : T +>target : T +>T : T +>name : keyof T +>T : T + +declare var two: "a" | "d"; +>two : "a" | "d" + +inference({ a: 1, b: 2, c: 3, d(n) { return n } }, two); +>inference({ a: 1, b: 2, c: 3, d(n) { return n } }, two) : void +>inference : (target: T, name: keyof T) => void +>{ a: 1, b: 2, c: 3, d(n) { return n } } : { a: number; b: number; c: number; d(n: any): any; } +>a : number +>1 : 1 +>b : number +>2 : 2 +>c : number +>3 : 3 +>d : (n: any) => any +>n : any +>n : any +>two : "a" | "d" + diff --git a/tests/baselines/reference/interfaceDeclaration1.errors.txt b/tests/baselines/reference/interfaceDeclaration1.errors.txt index 7a31aec7c6a3f..86e4647edde1c 100644 --- a/tests/baselines/reference/interfaceDeclaration1.errors.txt +++ b/tests/baselines/reference/interfaceDeclaration1.errors.txt @@ -2,7 +2,7 @@ tests/cases/compiler/interfaceDeclaration1.ts(2,5): error TS2300: Duplicate iden tests/cases/compiler/interfaceDeclaration1.ts(3,5): error TS2300: Duplicate identifier 'item'. tests/cases/compiler/interfaceDeclaration1.ts(7,5): error TS2300: Duplicate identifier 'item'. tests/cases/compiler/interfaceDeclaration1.ts(8,5): error TS2300: Duplicate identifier 'item'. -tests/cases/compiler/interfaceDeclaration1.ts(8,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'item' has type 'any' at tests/cases/compiler/interfaceDeclaration1.ts 6:4, but here has type 'number'. +tests/cases/compiler/interfaceDeclaration1.ts(8,5): error TS2717: Subsequent property declarations must have the same type. Property 'item' has type 'any' at tests/cases/compiler/interfaceDeclaration1.ts 6:4, but here has type 'number'. tests/cases/compiler/interfaceDeclaration1.ts(22,11): error TS2310: Type 'I5' recursively references itself as a base type. tests/cases/compiler/interfaceDeclaration1.ts(35,7): error TS2420: Class 'C1' incorrectly implements interface 'I3'. Property 'prototype' is missing in type 'C1'. @@ -29,7 +29,7 @@ tests/cases/compiler/interfaceDeclaration1.ts(52,11): error TS2320: Interface 'i ~~~~ !!! error TS2300: Duplicate identifier 'item'. ~~~~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'item' has type 'any' at tests/cases/compiler/interfaceDeclaration1.ts 6:4, but here has type 'number'. +!!! error TS2717: Subsequent property declarations must have the same type. Property 'item' has type 'any' at tests/cases/compiler/interfaceDeclaration1.ts 6:4, but here has type 'number'. } interface I3 { diff --git a/tests/baselines/reference/iteratorSpreadInCall.errors.txt b/tests/baselines/reference/iteratorSpreadInCall.errors.txt index 1831013b6e77b..93a4f4df01adb 100644 --- a/tests/baselines/reference/iteratorSpreadInCall.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInCall.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts(15,1): error TS2556: Expected 1 arguments, but got a minimum of 0. +tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts(15,1): error TS2556: Expected 1 arguments, but got 0 or more. ==== tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts (1 errors) ==== @@ -18,4 +18,4 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts(15,1): error TS2556: foo(...new SymbolIterator); ~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2556: Expected 1 arguments, but got a minimum of 0. \ No newline at end of file +!!! error TS2556: Expected 1 arguments, but got 0 or more. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInCall10.errors.txt b/tests/baselines/reference/iteratorSpreadInCall10.errors.txt index 0d10c9f25e509..2012a878549bd 100644 --- a/tests/baselines/reference/iteratorSpreadInCall10.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInCall10.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts(15,1): error TS2556: Expected 1 arguments, but got a minimum of 0. +tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts(15,1): error TS2556: Expected 1 arguments, but got 0 or more. ==== tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts (1 errors) ==== @@ -18,4 +18,4 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts(15,1): error TS2556 foo(...new SymbolIterator); ~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2556: Expected 1 arguments, but got a minimum of 0. \ No newline at end of file +!!! error TS2556: Expected 1 arguments, but got 0 or more. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInCall2.errors.txt b/tests/baselines/reference/iteratorSpreadInCall2.errors.txt index 03cc296b8abe4..32559883e6719 100644 --- a/tests/baselines/reference/iteratorSpreadInCall2.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInCall2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts(15,1): error TS2556: Expected 1 arguments, but got a minimum of 0. +tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts(15,1): error TS2556: Expected 1 arguments, but got 0 or more. ==== tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts (1 errors) ==== @@ -18,4 +18,4 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts(15,1): error TS2556: foo(...new SymbolIterator); ~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2556: Expected 1 arguments, but got a minimum of 0. \ No newline at end of file +!!! error TS2556: Expected 1 arguments, but got 0 or more. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInCall4.errors.txt b/tests/baselines/reference/iteratorSpreadInCall4.errors.txt index 899ac1d9e90a6..17a76cce148a5 100644 --- a/tests/baselines/reference/iteratorSpreadInCall4.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInCall4.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInCall4.ts(15,1): error TS2557: Expected at least 1 arguments, but got a minimum of 0. +tests/cases/conformance/es6/spread/iteratorSpreadInCall4.ts(15,1): error TS2557: Expected at least 1 arguments, but got 0 or more. ==== tests/cases/conformance/es6/spread/iteratorSpreadInCall4.ts (1 errors) ==== @@ -18,4 +18,4 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall4.ts(15,1): error TS2557: foo(...new SymbolIterator); ~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2557: Expected at least 1 arguments, but got a minimum of 0. \ No newline at end of file +!!! error TS2557: Expected at least 1 arguments, but got 0 or more. \ No newline at end of file diff --git a/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.js b/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.js index acc590418e980..fbe8df0c1c411 100644 --- a/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.js +++ b/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.js @@ -9,7 +9,7 @@ * @param {...*} args The arguments to invoke `func` with. * @returns {*} Returns the result of `func`. */ -function apply(func, thisArg, args) { +function apply(func, thisArg, ...args) { var length = args.length; switch (length) { case 0: return func.call(thisArg); @@ -36,7 +36,11 @@ define("_apply", ["require", "exports"], function (require, exports) { * @param {...*} args The arguments to invoke `func` with. * @returns {*} Returns the result of `func`. */ - function apply(func, thisArg, args) { + function apply(func, thisArg) { + var args = []; + for (var _i = 2; _i < arguments.length; _i++) { + args[_i - 2] = arguments[_i]; + } var length = args.length; switch (length) { case 0: return func.call(thisArg); diff --git a/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.symbols b/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.symbols index e7589f6ce5571..fc70ae01a6cf7 100644 --- a/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.symbols +++ b/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.symbols @@ -9,7 +9,7 @@ * @param {...*} args The arguments to invoke `func` with. * @returns {*} Returns the result of `func`. */ -function apply(func, thisArg, args) { +function apply(func, thisArg, ...args) { >apply : Symbol(apply, Decl(_apply.js, 0, 0)) >func : Symbol(func, Decl(_apply.js, 10, 15)) >thisArg : Symbol(thisArg, Decl(_apply.js, 10, 20)) diff --git a/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.types b/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.types index 72c3388f2262b..c0247bb045fe1 100644 --- a/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.types +++ b/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.types @@ -9,8 +9,8 @@ * @param {...*} args The arguments to invoke `func` with. * @returns {*} Returns the result of `func`. */ -function apply(func, thisArg, args) { ->apply : (func: Function, thisArg: any, args: any[]) => any +function apply(func, thisArg, ...args) { +>apply : (func: Function, thisArg: any, ...args: any[]) => any >func : Function >thisArg : any >args : any[] @@ -84,5 +84,5 @@ function apply(func, thisArg, args) { } export default apply; ->apply : (func: Function, thisArg: any, args: any[]) => any +>apply : (func: Function, thisArg: any, ...args: any[]) => any diff --git a/tests/baselines/reference/jsdocDisallowedInTypescript.errors.txt b/tests/baselines/reference/jsdocDisallowedInTypescript.errors.txt index d176e1aa22e68..2823981cc95b0 100644 --- a/tests/baselines/reference/jsdocDisallowedInTypescript.errors.txt +++ b/tests/baselines/reference/jsdocDisallowedInTypescript.errors.txt @@ -7,7 +7,10 @@ tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(11,12): error TS255 tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(13,14): error TS8020: JSDoc types can only be used inside documentation comments. tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(14,11): error TS8020: JSDoc types can only be used inside documentation comments. tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(15,8): error TS8020: JSDoc types can only be used inside documentation comments. +tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(16,5): error TS2322: Type 'boolean[]' is not assignable to type 'boolean | undefined'. + Type 'boolean[]' is not assignable to type 'false'. tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(16,15): error TS8020: JSDoc types can only be used inside documentation comments. +tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(16,15): error TS8028: JSDoc '...' may only appear in the last parameter of a signature. tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(17,11): error TS8020: JSDoc types can only be used inside documentation comments. tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(18,17): error TS8020: JSDoc types can only be used inside documentation comments. tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(19,5): error TS2322: Type 'undefined' is not assignable to type 'number | null'. @@ -16,9 +19,10 @@ tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(21,16): error TS802 tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(22,16): error TS8020: JSDoc types can only be used inside documentation comments. tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(23,17): error TS8020: JSDoc types can only be used inside documentation comments. tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(24,17): error TS8020: JSDoc types can only be used inside documentation comments. +tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(24,17): error TS8028: JSDoc '...' may only appear in the last parameter of a signature. -==== tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts (18 errors) ==== +==== tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts (21 errors) ==== // grammar error from checker var ara: Array. = [1,2,3]; ~ @@ -53,8 +57,13 @@ tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(24,17): error TS802 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8020: JSDoc types can only be used inside documentation comments. var variadic: ...boolean = [true, false, true]; + ~~~~~~~~ +!!! error TS2322: Type 'boolean[]' is not assignable to type 'boolean | undefined'. +!!! error TS2322: Type 'boolean[]' is not assignable to type 'false'. ~~~~~~~~~~ !!! error TS8020: JSDoc types can only be used inside documentation comments. + ~~~~~~~~~~ +!!! error TS8028: JSDoc '...' may only appear in the last parameter of a signature. var most: !string = 'definite'; ~~~~~~~ !!! error TS8020: JSDoc types can only be used inside documentation comments. @@ -79,5 +88,7 @@ tests/cases/conformance/jsdoc/jsdocDisallowedInTypescript.ts(24,17): error TS802 var vars: Array<...number>; ~~~~~~~~~ !!! error TS8020: JSDoc types can only be used inside documentation comments. + ~~~~~~~~~ +!!! error TS8028: JSDoc '...' may only appear in the last parameter of a signature. \ No newline at end of file diff --git a/tests/baselines/reference/jsdocDisallowedInTypescript.types b/tests/baselines/reference/jsdocDisallowedInTypescript.types index 49f16acfd1958..8fe4a032f206b 100644 --- a/tests/baselines/reference/jsdocDisallowedInTypescript.types +++ b/tests/baselines/reference/jsdocDisallowedInTypescript.types @@ -65,7 +65,7 @@ var g: function(number, number): number = (n,m) => n + m; >m : number var variadic: ...boolean = [true, false, true]; ->variadic : boolean[] +>variadic : boolean | undefined >[true, false, true] : boolean[] >true : true >false : false @@ -96,7 +96,7 @@ var anys: Array<*>; >Array : T[] var vars: Array<...number>; ->vars : number[][] +>vars : (number | undefined)[] >Array : T[] diff --git a/tests/baselines/reference/jsdocPrefixPostfixParsing.errors.txt b/tests/baselines/reference/jsdocPrefixPostfixParsing.errors.txt new file mode 100644 index 0000000000000..2b3d0b1647cc7 --- /dev/null +++ b/tests/baselines/reference/jsdocPrefixPostfixParsing.errors.txt @@ -0,0 +1,43 @@ +tests/cases/conformance/jsdoc/prefixPostfix.js(8,13): error TS8028: JSDoc '...' may only appear in the last parameter of a signature. +tests/cases/conformance/jsdoc/prefixPostfix.js(9,12): error TS1014: A rest parameter must be last in a parameter list. +tests/cases/conformance/jsdoc/prefixPostfix.js(10,12): error TS1014: A rest parameter must be last in a parameter list. +tests/cases/conformance/jsdoc/prefixPostfix.js(11,12): error TS1014: A rest parameter must be last in a parameter list. +tests/cases/conformance/jsdoc/prefixPostfix.js(12,12): error TS1014: A rest parameter must be last in a parameter list. +tests/cases/conformance/jsdoc/prefixPostfix.js(13,12): error TS1014: A rest parameter must be last in a parameter list. +tests/cases/conformance/jsdoc/prefixPostfix.js(14,12): error TS1014: A rest parameter must be last in a parameter list. + + +==== tests/cases/conformance/jsdoc/prefixPostfix.js (7 errors) ==== + /** + * @param {number![]} x - number[] + * @param {!number[]} y - number[] + * @param {(number[])!} z - number[] + * @param {number?[]} a - (number | null)[] + * @param {?number[]} b - number[] | null + * @param {(number[])?} c - number[] | null + * @param {?...number} d - number[] | null + ~~~~~~~~~ +!!! error TS8028: JSDoc '...' may only appear in the last parameter of a signature. + * @param {...?number} e - (number | null)[] + ~~~~~~~~~~ +!!! error TS1014: A rest parameter must be last in a parameter list. + * @param {...number?} f - number[] | null + ~~~~~~~~~~ +!!! error TS1014: A rest parameter must be last in a parameter list. + * @param {...number!?} g - number[] | null + ~~~~~~~~~~~ +!!! error TS1014: A rest parameter must be last in a parameter list. + * @param {...number?!} h - number[] | null + ~~~~~~~~~~~ +!!! error TS1014: A rest parameter must be last in a parameter list. + * @param {...number[]} i - number[][] + ~~~~~~~~~~~ +!!! error TS1014: A rest parameter must be last in a parameter list. + * @param {...number![]?} j - number[][] | null + ~~~~~~~~~~~~~ +!!! error TS1014: A rest parameter must be last in a parameter list. + * @param {...number?[]!} k - (number[] | null)[] + */ + function f(x, y, z, a, b, c, d, e, f, g, h, i, j, k) { + } + \ No newline at end of file diff --git a/tests/baselines/reference/jsdocPrefixPostfixParsing.types b/tests/baselines/reference/jsdocPrefixPostfixParsing.types index 9961af48e27cb..cf69cf9d40c09 100644 --- a/tests/baselines/reference/jsdocPrefixPostfixParsing.types +++ b/tests/baselines/reference/jsdocPrefixPostfixParsing.types @@ -16,20 +16,20 @@ * @param {...number?[]!} k - (number[] | null)[] */ function f(x, y, z, a, b, c, d, e, f, g, h, i, j, k) { ->f : (x: number[], y: number[], z: number[], a: (number | null)[], b: number[] | null, c: number[] | null, d: number[] | null, e: (number | null)[], f: number[] | null, g: number[] | null, h: number[] | null, i: number[][], j: number[][] | null, k: (number[] | null)[]) => void +>f : (x: number[], y: number[], z: number[], a: (number | null)[], b: number[] | null, c: number[] | null, d: number | null | undefined, e: number | null | undefined, f: number | null | undefined, g: number | null | undefined, h: number | null | undefined, i: number[] | undefined, j: number[] | null | undefined, ...args: (number | null)[][]) => void >x : number[] >y : number[] >z : number[] >a : (number | null)[] >b : number[] | null >c : number[] | null ->d : number[] | null ->e : (number | null)[] ->f : number[] | null ->g : number[] | null ->h : number[] | null ->i : number[][] ->j : number[][] | null ->k : (number[] | null)[] +>d : number | null | undefined +>e : number | null | undefined +>f : number | null | undefined +>g : number | null | undefined +>h : number | null | undefined +>i : number[] | undefined +>j : number[] | null | undefined +>k : (number | null)[] | undefined } diff --git a/tests/baselines/reference/jsdocRestParameter.errors.txt b/tests/baselines/reference/jsdocRestParameter.errors.txt new file mode 100644 index 0000000000000..ec34bcdcb2050 --- /dev/null +++ b/tests/baselines/reference/jsdocRestParameter.errors.txt @@ -0,0 +1,19 @@ +/a.js(7,3): error TS2345: Argument of type 'number[]' is not assignable to parameter of type 'number'. +/a.js(8,6): error TS2345: Argument of type '"2"' is not assignable to parameter of type 'number'. + + +==== /a.js (2 errors) ==== + /** @param {...number} a */ + function f(a) { + a; // number | undefined + // Ideally this would be a number. But currently checker.ts has only one `argumentsSymbol`, so it's `any`. + arguments[0]; + } + f([1, 2]); // Error + ~~~~~~ +!!! error TS2345: Argument of type 'number[]' is not assignable to parameter of type 'number'. + f(1, "2"); // Error + ~~~ +!!! error TS2345: Argument of type '"2"' is not assignable to parameter of type 'number'. + f(1, 2); + \ No newline at end of file diff --git a/tests/baselines/reference/jsdocRestParameter.symbols b/tests/baselines/reference/jsdocRestParameter.symbols new file mode 100644 index 0000000000000..24e7c4635e922 --- /dev/null +++ b/tests/baselines/reference/jsdocRestParameter.symbols @@ -0,0 +1,22 @@ +=== /a.js === +/** @param {...number} a */ +function f(a) { +>f : Symbol(f, Decl(a.js, 0, 0)) +>a : Symbol(a, Decl(a.js, 1, 11)) + + a; // number | undefined +>a : Symbol(a, Decl(a.js, 1, 11)) + + // Ideally this would be a number. But currently checker.ts has only one `argumentsSymbol`, so it's `any`. + arguments[0]; +>arguments : Symbol(arguments) +} +f([1, 2]); // Error +>f : Symbol(f, Decl(a.js, 0, 0)) + +f(1, "2"); // Error +>f : Symbol(f, Decl(a.js, 0, 0)) + +f(1, 2); +>f : Symbol(f, Decl(a.js, 0, 0)) + diff --git a/tests/baselines/reference/jsdocRestParameter.types b/tests/baselines/reference/jsdocRestParameter.types new file mode 100644 index 0000000000000..51b12c37fad48 --- /dev/null +++ b/tests/baselines/reference/jsdocRestParameter.types @@ -0,0 +1,34 @@ +=== /a.js === +/** @param {...number} a */ +function f(a) { +>f : (...args: number[]) => void +>a : number | undefined + + a; // number | undefined +>a : number | undefined + + // Ideally this would be a number. But currently checker.ts has only one `argumentsSymbol`, so it's `any`. + arguments[0]; +>arguments[0] : any +>arguments : IArguments +>0 : 0 +} +f([1, 2]); // Error +>f([1, 2]) : void +>f : (...args: number[]) => void +>[1, 2] : number[] +>1 : 1 +>2 : 2 + +f(1, "2"); // Error +>f(1, "2") : void +>f : (...args: number[]) => void +>1 : 1 +>"2" : "2" + +f(1, 2); +>f(1, 2) : void +>f : (...args: number[]) => void +>1 : 1 +>2 : 2 + diff --git a/tests/baselines/reference/jsdocRestParameter_es6.symbols b/tests/baselines/reference/jsdocRestParameter_es6.symbols new file mode 100644 index 0000000000000..c82eaad37a23a --- /dev/null +++ b/tests/baselines/reference/jsdocRestParameter_es6.symbols @@ -0,0 +1,10 @@ +=== /a.js === +/** @param {...number} a */ +function f(...a) { +>f : Symbol(f, Decl(a.js, 0, 0)) +>a : Symbol(a, Decl(a.js, 1, 11)) + + a; // number[] +>a : Symbol(a, Decl(a.js, 1, 11)) +} + diff --git a/tests/baselines/reference/jsdocRestParameter_es6.types b/tests/baselines/reference/jsdocRestParameter_es6.types new file mode 100644 index 0000000000000..b07d7d931f109 --- /dev/null +++ b/tests/baselines/reference/jsdocRestParameter_es6.types @@ -0,0 +1,10 @@ +=== /a.js === +/** @param {...number} a */ +function f(...a) { +>f : (...a: number[]) => void +>a : number[] + + a; // number[] +>a : number[] +} + diff --git a/tests/baselines/reference/literalsInComputedProperties1.symbols b/tests/baselines/reference/literalsInComputedProperties1.symbols index e0f22d39e8d32..501b969706ab7 100644 --- a/tests/baselines/reference/literalsInComputedProperties1.symbols +++ b/tests/baselines/reference/literalsInComputedProperties1.symbols @@ -39,11 +39,11 @@ interface A { 1:number; [2]:number; ->2 : Symbol(A[[2]], Decl(literalsInComputedProperties1.ts, 12, 13)) +>2 : Symbol(A[2], Decl(literalsInComputedProperties1.ts, 12, 13)) "3":number; ["4"]:number; ->"4" : Symbol(A[["4"]], Decl(literalsInComputedProperties1.ts, 14, 15)) +>"4" : Symbol(A["4"], Decl(literalsInComputedProperties1.ts, 14, 15)) } let y:A; @@ -59,7 +59,7 @@ y[1].toExponential(); y[2].toExponential(); >y[2].toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --)) >y : Symbol(y, Decl(literalsInComputedProperties1.ts, 18, 3)) ->2 : Symbol(A[[2]], Decl(literalsInComputedProperties1.ts, 12, 13)) +>2 : Symbol(A[2], Decl(literalsInComputedProperties1.ts, 12, 13)) >toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --)) y[3].toExponential(); @@ -71,7 +71,7 @@ y[3].toExponential(); y[4].toExponential(); >y[4].toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --)) >y : Symbol(y, Decl(literalsInComputedProperties1.ts, 18, 3)) ->4 : Symbol(A[["4"]], Decl(literalsInComputedProperties1.ts, 14, 15)) +>4 : Symbol(A["4"], Decl(literalsInComputedProperties1.ts, 14, 15)) >toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --)) class C { @@ -79,11 +79,11 @@ class C { 1:number; [2]:number; ->2 : Symbol(C[[2]], Decl(literalsInComputedProperties1.ts, 25, 13)) +>2 : Symbol(C[2], Decl(literalsInComputedProperties1.ts, 25, 13)) "3":number; ["4"]:number; ->"4" : Symbol(C[["4"]], Decl(literalsInComputedProperties1.ts, 27, 15)) +>"4" : Symbol(C["4"], Decl(literalsInComputedProperties1.ts, 27, 15)) } let z:C; @@ -99,7 +99,7 @@ z[1].toExponential(); z[2].toExponential(); >z[2].toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --)) >z : Symbol(z, Decl(literalsInComputedProperties1.ts, 31, 3)) ->2 : Symbol(C[[2]], Decl(literalsInComputedProperties1.ts, 25, 13)) +>2 : Symbol(C[2], Decl(literalsInComputedProperties1.ts, 25, 13)) >toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --)) z[3].toExponential(); @@ -111,7 +111,7 @@ z[3].toExponential(); z[4].toExponential(); >z[4].toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --)) >z : Symbol(z, Decl(literalsInComputedProperties1.ts, 31, 3)) ->4 : Symbol(C[["4"]], Decl(literalsInComputedProperties1.ts, 27, 15)) +>4 : Symbol(C["4"], Decl(literalsInComputedProperties1.ts, 27, 15)) >toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --)) enum X { @@ -119,15 +119,15 @@ enum X { 1 = 1, [2] = 2, ->2 : Symbol(X[[2]], Decl(literalsInComputedProperties1.ts, 38, 10)) +>2 : Symbol(X[2], Decl(literalsInComputedProperties1.ts, 38, 10)) "3" = 3, ["4"] = 4, ->"4" : Symbol(X[["4"]], Decl(literalsInComputedProperties1.ts, 40, 12)) +>"4" : Symbol(X["4"], Decl(literalsInComputedProperties1.ts, 40, 12)) "foo" = 5, ["bar"] = 6 ->"bar" : Symbol(X[["bar"]], Decl(literalsInComputedProperties1.ts, 42, 14)) +>"bar" : Symbol(X["bar"], Decl(literalsInComputedProperties1.ts, 42, 14)) } let a = X["foo"]; @@ -138,6 +138,6 @@ let a = X["foo"]; let a0 = X["bar"]; >a0 : Symbol(a0, Decl(literalsInComputedProperties1.ts, 47, 3)) >X : Symbol(X, Decl(literalsInComputedProperties1.ts, 35, 21)) ->"bar" : Symbol(X[["bar"]], Decl(literalsInComputedProperties1.ts, 42, 14)) +>"bar" : Symbol(X["bar"], Decl(literalsInComputedProperties1.ts, 42, 14)) // TODO: make sure that enum still disallow template literals as member names diff --git a/tests/baselines/reference/mergedInterfacesWithConflictingPropertyNames.errors.txt b/tests/baselines/reference/mergedInterfacesWithConflictingPropertyNames.errors.txt index c4a6cb926d6d1..6bfdc149a6d04 100644 --- a/tests/baselines/reference/mergedInterfacesWithConflictingPropertyNames.errors.txt +++ b/tests/baselines/reference/mergedInterfacesWithConflictingPropertyNames.errors.txt @@ -1,6 +1,6 @@ -tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithConflictingPropertyNames.ts(6,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' has type 'string' at tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithConflictingPropertyNames.ts 1:4, but here has type 'number'. -tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithConflictingPropertyNames.ts(15,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' has type 'T' at tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithConflictingPropertyNames.ts 10:8, but here has type 'number'. -tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithConflictingPropertyNames.ts(39,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' has type 'T' at tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithConflictingPropertyNames.ts 32:8, but here has type 'number'. +tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithConflictingPropertyNames.ts(6,5): error TS2717: Subsequent property declarations must have the same type. Property 'x' has type 'string' at tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithConflictingPropertyNames.ts 1:4, but here has type 'number'. +tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithConflictingPropertyNames.ts(15,9): error TS2717: Subsequent property declarations must have the same type. Property 'x' has type 'T' at tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithConflictingPropertyNames.ts 10:8, but here has type 'number'. +tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithConflictingPropertyNames.ts(39,9): error TS2717: Subsequent property declarations must have the same type. Property 'x' has type 'T' at tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithConflictingPropertyNames.ts 32:8, but here has type 'number'. ==== tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithConflictingPropertyNames.ts (3 errors) ==== @@ -11,7 +11,7 @@ tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithConfli interface A { x: number; ~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' has type 'string' at tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithConflictingPropertyNames.ts 1:4, but here has type 'number'. +!!! error TS2717: Subsequent property declarations must have the same type. Property 'x' has type 'string' at tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithConflictingPropertyNames.ts 1:4, but here has type 'number'. } module M { @@ -22,7 +22,7 @@ tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithConfli interface A { x: number; // error ~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' has type 'T' at tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithConflictingPropertyNames.ts 10:8, but here has type 'number'. +!!! error TS2717: Subsequent property declarations must have the same type. Property 'x' has type 'T' at tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithConflictingPropertyNames.ts 10:8, but here has type 'number'. } } @@ -48,6 +48,6 @@ tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithConfli export interface A { x: number; // error ~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' has type 'T' at tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithConflictingPropertyNames.ts 32:8, but here has type 'number'. +!!! error TS2717: Subsequent property declarations must have the same type. Property 'x' has type 'T' at tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithConflictingPropertyNames.ts 32:8, but here has type 'number'. } } \ No newline at end of file diff --git a/tests/baselines/reference/numericStringNamedPropertyEquivalence.errors.txt b/tests/baselines/reference/numericStringNamedPropertyEquivalence.errors.txt index 172576cdde1da..87e491fbd5da6 100644 --- a/tests/baselines/reference/numericStringNamedPropertyEquivalence.errors.txt +++ b/tests/baselines/reference/numericStringNamedPropertyEquivalence.errors.txt @@ -3,7 +3,7 @@ tests/cases/conformance/types/objectTypeLiteral/propertySignatures/numericString tests/cases/conformance/types/objectTypeLiteral/propertySignatures/numericStringNamedPropertyEquivalence.ts(12,5): error TS2300: Duplicate identifier '1'. tests/cases/conformance/types/objectTypeLiteral/propertySignatures/numericStringNamedPropertyEquivalence.ts(16,5): error TS2300: Duplicate identifier '1'. tests/cases/conformance/types/objectTypeLiteral/propertySignatures/numericStringNamedPropertyEquivalence.ts(17,5): error TS2300: Duplicate identifier '1'. -tests/cases/conformance/types/objectTypeLiteral/propertySignatures/numericStringNamedPropertyEquivalence.ts(17,5): error TS2403: Subsequent variable declarations must have the same type. Variable '1.0' has type 'number' at tests/cases/conformance/types/objectTypeLiteral/propertySignatures/numericStringNamedPropertyEquivalence.ts 15:4, but here has type 'string'. +tests/cases/conformance/types/objectTypeLiteral/propertySignatures/numericStringNamedPropertyEquivalence.ts(17,5): error TS2717: Subsequent property declarations must have the same type. Property '1.0' has type 'number' at tests/cases/conformance/types/objectTypeLiteral/propertySignatures/numericStringNamedPropertyEquivalence.ts 15:4, but here has type 'string'. tests/cases/conformance/types/objectTypeLiteral/propertySignatures/numericStringNamedPropertyEquivalence.ts(22,5): error TS2300: Duplicate identifier '0'. @@ -36,7 +36,7 @@ tests/cases/conformance/types/objectTypeLiteral/propertySignatures/numericString ~~~ !!! error TS2300: Duplicate identifier '1'. ~~~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable '1.0' has type 'number' at tests/cases/conformance/types/objectTypeLiteral/propertySignatures/numericStringNamedPropertyEquivalence.ts 15:4, but here has type 'string'. +!!! error TS2717: Subsequent property declarations must have the same type. Property '1.0' has type 'number' at tests/cases/conformance/types/objectTypeLiteral/propertySignatures/numericStringNamedPropertyEquivalence.ts 15:4, but here has type 'string'. } var b = { diff --git a/tests/baselines/reference/parser.asyncGenerators.classMethods.esnext.types b/tests/baselines/reference/parser.asyncGenerators.classMethods.esnext.types index ad6d810b0cb11..254d983caaa80 100644 --- a/tests/baselines/reference/parser.asyncGenerators.classMethods.esnext.types +++ b/tests/baselines/reference/parser.asyncGenerators.classMethods.esnext.types @@ -151,7 +151,7 @@ class C14 { >C14 : C14 async * f() { ->f : () => AsyncIterableIterator<1> +>f : () => AsyncIterableIterator yield 1; >yield 1 : any @@ -175,7 +175,7 @@ class C16 { >C16 : C16 async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncIterableIterator yield * []; >yield * [] : any diff --git a/tests/baselines/reference/parser.asyncGenerators.functionDeclarations.esnext.types b/tests/baselines/reference/parser.asyncGenerators.functionDeclarations.esnext.types index 772de158358ea..c27e9209611f2 100644 --- a/tests/baselines/reference/parser.asyncGenerators.functionDeclarations.esnext.types +++ b/tests/baselines/reference/parser.asyncGenerators.functionDeclarations.esnext.types @@ -95,7 +95,7 @@ async function * f13() { } === tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldWithValueIsOk.ts === async function * f14() { ->f14 : () => AsyncIterableIterator<1> +>f14 : () => AsyncIterableIterator 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 +>f16 : () => AsyncIterableIterator yield * []; >yield * [] : any diff --git a/tests/baselines/reference/parser.asyncGenerators.functionExpressions.esnext.types b/tests/baselines/reference/parser.asyncGenerators.functionExpressions.esnext.types index 6524ee9008caf..7b9ddf152d599 100644 --- a/tests/baselines/reference/parser.asyncGenerators.functionExpressions.esnext.types +++ b/tests/baselines/reference/parser.asyncGenerators.functionExpressions.esnext.types @@ -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 +>async function * () { yield 1;} : () => AsyncIterableIterator 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 ->async function * () { yield * [];} : () => AsyncIterableIterator +>f16 : () => AsyncIterableIterator +>async function * () { yield * [];} : () => AsyncIterableIterator yield * []; >yield * [] : any diff --git a/tests/baselines/reference/parser.asyncGenerators.objectLiteralMethods.esnext.types b/tests/baselines/reference/parser.asyncGenerators.objectLiteralMethods.esnext.types index d352b54158549..59ed6e16745a5 100644 --- a/tests/baselines/reference/parser.asyncGenerators.objectLiteralMethods.esnext.types +++ b/tests/baselines/reference/parser.asyncGenerators.objectLiteralMethods.esnext.types @@ -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; } +>{ async * f() { yield 1; }} : { f(): AsyncIterableIterator; } async * f() { ->f : () => AsyncIterableIterator<1> +>f : () => AsyncIterableIterator yield 1; >yield 1 : any @@ -189,11 +189,11 @@ const o15 = { }; === tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldStarWithValueIsOk.ts === const o16 = { ->o16 : { f(): AsyncIterableIterator; } ->{ async * f() { yield * []; }} : { f(): AsyncIterableIterator; } +>o16 : { f(): AsyncIterableIterator; } +>{ async * f() { yield * []; }} : { f(): AsyncIterableIterator; } async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncIterableIterator yield * []; >yield * [] : any diff --git a/tests/baselines/reference/parserArrowFunctionExpression6.errors.txt b/tests/baselines/reference/parserArrowFunctionExpression6.errors.txt deleted file mode 100644 index 03312b634389a..0000000000000 --- a/tests/baselines/reference/parserArrowFunctionExpression6.errors.txt +++ /dev/null @@ -1,37 +0,0 @@ -tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts(2,23): error TS2300: Duplicate identifier '(Missing)'. -tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts(2,24): error TS1005: ',' expected. -tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts(2,29): error TS1138: Parameter declaration expected. -tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts(2,30): error TS2300: Duplicate identifier '(Missing)'. -tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts(2,31): error TS1003: Identifier expected. -tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts(2,40): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. -tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts(2,41): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. -tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts(2,55): error TS1138: Parameter declaration expected. -tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts(2,66): error TS1005: '=>' expected. -tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts(2,69): error TS1005: ':' expected. - - -==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts (10 errors) ==== - function foo(q: string, b: number) { - return true ? (q ? true : false) : (b = q.length, function() { }); - -!!! error TS2300: Duplicate identifier '(Missing)'. - ~~~~ -!!! error TS1005: ',' expected. - ~ -!!! error TS1138: Parameter declaration expected. - -!!! error TS2300: Duplicate identifier '(Missing)'. - ~~~~~ -!!! error TS1003: Identifier expected. - ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. - ~~~~~~~~~~~~ -!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. - ~~~~~~~~ -!!! error TS1138: Parameter declaration expected. - ~ -!!! error TS1005: '=>' expected. - ~ -!!! error TS1005: ':' expected. - }; - \ No newline at end of file diff --git a/tests/baselines/reference/parserArrowFunctionExpression6.js b/tests/baselines/reference/parserArrowFunctionExpression6.js index 75824704b16b4..1de3035cc76d5 100644 --- a/tests/baselines/reference/parserArrowFunctionExpression6.js +++ b/tests/baselines/reference/parserArrowFunctionExpression6.js @@ -6,7 +6,6 @@ function foo(q: string, b: number) { //// [parserArrowFunctionExpression6.js] function foo(q, b) { - return true ? function (q, , ) { } : ; - ; + return true ? (q ? true : false) : (b = q.length, function () { }); } ; diff --git a/tests/baselines/reference/parserArrowFunctionExpression6.symbols b/tests/baselines/reference/parserArrowFunctionExpression6.symbols index 3cf5f44877f65..9b3afdbb95065 100644 --- a/tests/baselines/reference/parserArrowFunctionExpression6.symbols +++ b/tests/baselines/reference/parserArrowFunctionExpression6.symbols @@ -5,11 +5,11 @@ function foo(q: string, b: number) { >b : Symbol(b, Decl(parserArrowFunctionExpression6.ts, 0, 23)) return true ? (q ? true : false) : (b = q.length, function() { }); ->q : Symbol(q, Decl(parserArrowFunctionExpression6.ts, 1, 19)) -> : Symbol((Missing), Decl(parserArrowFunctionExpression6.ts, 1, 22)) -> : Symbol((Missing), Decl(parserArrowFunctionExpression6.ts, 1, 29)) ->b : Symbol(b, Decl(parserArrowFunctionExpression6.ts, 1, 40)) ->q : Symbol(q, Decl(parserArrowFunctionExpression6.ts, 1, 19)) +>q : Symbol(q, Decl(parserArrowFunctionExpression6.ts, 0, 13)) +>b : Symbol(b, Decl(parserArrowFunctionExpression6.ts, 0, 23)) +>q.length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>q : Symbol(q, Decl(parserArrowFunctionExpression6.ts, 0, 13)) +>length : Symbol(String.length, Decl(lib.d.ts, --, --)) }; diff --git a/tests/baselines/reference/parserArrowFunctionExpression6.types b/tests/baselines/reference/parserArrowFunctionExpression6.types index 990670eea63a2..6cc4f16e216cb 100644 --- a/tests/baselines/reference/parserArrowFunctionExpression6.types +++ b/tests/baselines/reference/parserArrowFunctionExpression6.types @@ -1,21 +1,25 @@ === tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts === function foo(q: string, b: number) { ->foo : (q: string, b: number) => any +>foo : (q: string, b: number) => boolean | (() => void) >q : string >b : number return true ? (q ? true : false) : (b = q.length, function() { }); ->true ? (q ? true : false) : (b = q.length, function() { } : any +>true ? (q ? true : false) : (b = q.length, function() { }) : boolean | (() => void) >true : true ->(q ? true : false) : (b = q.length, function() { } : (q?: any, : any, : any) => (b?: any) => () => any ->q : any -> : any -> : any ->b : any ->q.length : any ->q : any ->length : any -> : any +>(q ? true : false) : boolean +>q ? true : false : boolean +>q : string +>true : true +>false : false +>(b = q.length, function() { }) : () => void +>b = q.length, function() { } : () => void +>b = q.length : number +>b : number +>q.length : number +>q : string +>length : number +>function() { } : () => void }; diff --git a/tests/baselines/reference/parserComputedPropertyName10.errors.txt b/tests/baselines/reference/parserComputedPropertyName10.errors.txt index a9b5396781aa5..c8ca89f400214 100644 --- a/tests/baselines/reference/parserComputedPropertyName10.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName10.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName10.ts(2,4): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName10.ts(2,4): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName10.ts(2,5): error TS2304: Cannot find name 'e'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP class C { [e] = 1 ~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName11.errors.txt b/tests/baselines/reference/parserComputedPropertyName11.errors.txt index 2a7a606f4bfcb..abbb667723b7e 100644 --- a/tests/baselines/reference/parserComputedPropertyName11.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName11.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName11.ts(2,4): error TS1168: A computed property name in a method overload must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName11.ts(2,4): error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName11.ts(2,5): error TS2304: Cannot find name 'e'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP class C { [e](); ~~~ -!!! error TS1168: A computed property name in a method overload must directly refer to a built-in symbol. +!!! error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName13.errors.txt b/tests/baselines/reference/parserComputedPropertyName13.errors.txt index a7a77cf12440f..65fa109c34878 100644 --- a/tests/baselines/reference/parserComputedPropertyName13.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName13.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName13.ts(1,10): error TS1170: A computed property name in a type literal must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName13.ts(1,10): error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName13.ts(1,11): error TS2304: Cannot find name 'e'. ==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName13.ts (2 errors) ==== var v: { [e]: number }; ~~~ -!!! error TS1170: A computed property name in a type literal must directly refer to a built-in symbol. +!!! error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName14.errors.txt b/tests/baselines/reference/parserComputedPropertyName14.errors.txt index 50a6d1bc689ac..668e1542c6250 100644 --- a/tests/baselines/reference/parserComputedPropertyName14.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName14.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName14.ts(1,10): error TS1170: A computed property name in a type literal must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName14.ts(1,10): error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName14.ts(1,11): error TS2304: Cannot find name 'e'. ==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName14.ts (2 errors) ==== var v: { [e](): number }; ~~~ -!!! error TS1170: A computed property name in a type literal must directly refer to a built-in symbol. +!!! error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName15.errors.txt b/tests/baselines/reference/parserComputedPropertyName15.errors.txt index 9635178af1673..2311fcafc348c 100644 --- a/tests/baselines/reference/parserComputedPropertyName15.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName15.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName15.ts(1,31): error TS1170: A computed property name in a type literal must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName15.ts(1,31): error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName15.ts(1,32): error TS2304: Cannot find name 'e'. ==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName15.ts (2 errors) ==== var v: { [e: number]: string; [e]: number }; ~~~ -!!! error TS1170: A computed property name in a type literal must directly refer to a built-in symbol. +!!! error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName18.errors.txt b/tests/baselines/reference/parserComputedPropertyName18.errors.txt index 9e64ddd0d28db..8730dd6077468 100644 --- a/tests/baselines/reference/parserComputedPropertyName18.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName18.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName18.ts(1,10): error TS1170: A computed property name in a type literal must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName18.ts(1,10): error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName18.ts(1,11): error TS2304: Cannot find name 'e'. ==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName18.ts (2 errors) ==== var v: { [e]?(): number }; ~~~ -!!! error TS1170: A computed property name in a type literal must directly refer to a built-in symbol. +!!! error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName19.errors.txt b/tests/baselines/reference/parserComputedPropertyName19.errors.txt index 86bb591011e36..d7b2e25377d20 100644 --- a/tests/baselines/reference/parserComputedPropertyName19.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName19.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName19.ts(1,10): error TS1170: A computed property name in a type literal must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName19.ts(1,10): error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName19.ts(1,11): error TS2304: Cannot find name 'e'. ==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName19.ts (2 errors) ==== var v: { [e]? }; ~~~ -!!! error TS1170: A computed property name in a type literal must directly refer to a built-in symbol. +!!! error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName20.errors.txt b/tests/baselines/reference/parserComputedPropertyName20.errors.txt index 035e494af332c..972457d8fbb88 100644 --- a/tests/baselines/reference/parserComputedPropertyName20.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName20.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName20.ts(2,5): error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName20.ts(2,5): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName20.ts(2,6): error TS2304: Cannot find name 'e'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP interface I { [e](): number ~~~ -!!! error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName21.errors.txt b/tests/baselines/reference/parserComputedPropertyName21.errors.txt index 4ebc321cc8032..52c26498999fa 100644 --- a/tests/baselines/reference/parserComputedPropertyName21.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName21.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName21.ts(2,5): error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName21.ts(2,5): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName21.ts(2,6): error TS2304: Cannot find name 'e'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP interface I { [e]: number ~~~ -!!! error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName22.errors.txt b/tests/baselines/reference/parserComputedPropertyName22.errors.txt index fd9e37970187c..866468aa53d93 100644 --- a/tests/baselines/reference/parserComputedPropertyName22.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName22.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName22.ts(2,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName22.ts(2,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName22.ts(2,6): error TS2304: Cannot find name 'e'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP declare class C { [e]: number ~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName25.errors.txt b/tests/baselines/reference/parserComputedPropertyName25.errors.txt index 0d0a2a8d8332b..d6bbb52ff7ce9 100644 --- a/tests/baselines/reference/parserComputedPropertyName25.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName25.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName25.ts(3,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName25.ts(3,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName25.ts(3,6): error TS2304: Cannot find name 'e'. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName25.ts(4,6): error TS2304: Cannot find name 'e2'. @@ -8,7 +8,7 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP // No ASI [e] = 0 ~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. [e2] = 1 diff --git a/tests/baselines/reference/parserComputedPropertyName28.errors.txt b/tests/baselines/reference/parserComputedPropertyName28.errors.txt index a84f3b7d16b96..df9202df567db 100644 --- a/tests/baselines/reference/parserComputedPropertyName28.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName28.errors.txt @@ -1,6 +1,6 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName28.ts(2,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName28.ts(2,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName28.ts(2,6): error TS2304: Cannot find name 'e'. -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName28.ts(3,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName28.ts(3,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName28.ts(3,6): error TS2304: Cannot find name 'e2'. @@ -8,12 +8,12 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP class C { [e]: number = 0; ~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. [e2]: number ~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ~~ !!! error TS2304: Cannot find name 'e2'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName29.errors.txt b/tests/baselines/reference/parserComputedPropertyName29.errors.txt index 3d886eacc5063..53800078b5eb7 100644 --- a/tests/baselines/reference/parserComputedPropertyName29.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName29.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName29.ts(3,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName29.ts(3,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName29.ts(3,6): error TS2304: Cannot find name 'e'. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName29.ts(3,11): error TS2304: Cannot find name 'id'. -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName29.ts(4,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName29.ts(4,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName29.ts(4,6): error TS2304: Cannot find name 'e2'. @@ -10,14 +10,14 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP // yes ASI [e] = id++ ~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. ~~ !!! error TS2304: Cannot find name 'id'. [e2]: number ~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ~~ !!! error TS2304: Cannot find name 'e2'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName31.errors.txt b/tests/baselines/reference/parserComputedPropertyName31.errors.txt index 4661b0797af98..57591fd4d946f 100644 --- a/tests/baselines/reference/parserComputedPropertyName31.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName31.errors.txt @@ -1,6 +1,6 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName31.ts(3,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName31.ts(3,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName31.ts(3,6): error TS2304: Cannot find name 'e'. -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName31.ts(4,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName31.ts(4,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName31.ts(4,6): error TS2304: Cannot find name 'e2'. @@ -9,12 +9,12 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP // yes ASI [e]: number ~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. [e2]: number ~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ~~ !!! error TS2304: Cannot find name 'e2'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName32.errors.txt b/tests/baselines/reference/parserComputedPropertyName32.errors.txt index 4be8d70383e19..5d762d5ecc8e8 100644 --- a/tests/baselines/reference/parserComputedPropertyName32.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName32.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName32.ts(2,5): error TS1165: A computed property name in an ambient context must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName32.ts(2,5): error TS1165: A computed property name in an ambient context must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName32.ts(2,6): error TS2304: Cannot find name 'e'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP declare class C { [e](): number ~~~ -!!! error TS1165: A computed property name in an ambient context must directly refer to a built-in symbol. +!!! error TS1165: A computed property name in an ambient context must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName36.errors.txt b/tests/baselines/reference/parserComputedPropertyName36.errors.txt index 6bcb5b5278998..9fbd7f565ad8f 100644 --- a/tests/baselines/reference/parserComputedPropertyName36.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName36.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName36.ts(2,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName36.ts(2,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName36.ts(2,6): error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName36.ts(2,6): error TS2304: Cannot find name 'public'. @@ -7,7 +7,7 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP class C { [public ]: string; ~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ~~~~~~ !!! error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode. ~~~~~~ diff --git a/tests/baselines/reference/parserComputedPropertyName7.errors.txt b/tests/baselines/reference/parserComputedPropertyName7.errors.txt index 056fa3d82fdd4..4fd7f320f266e 100644 --- a/tests/baselines/reference/parserComputedPropertyName7.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName7.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName7.ts(2,4): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName7.ts(2,4): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName7.ts(2,5): error TS2304: Cannot find name 'e'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP class C { [e] ~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName8.errors.txt b/tests/baselines/reference/parserComputedPropertyName8.errors.txt index 32bb490635357..a846f858ea78d 100644 --- a/tests/baselines/reference/parserComputedPropertyName8.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName8.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName8.ts(2,11): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName8.ts(2,11): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName8.ts(2,12): error TS2304: Cannot find name 'e'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP class C { public [e] ~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName9.errors.txt b/tests/baselines/reference/parserComputedPropertyName9.errors.txt index 9db0cbde3bd29..8d0390053f121 100644 --- a/tests/baselines/reference/parserComputedPropertyName9.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName9.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName9.ts(2,4): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName9.ts(2,4): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName9.ts(2,5): error TS2304: Cannot find name 'e'. tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName9.ts(2,9): error TS2304: Cannot find name 'Type'. @@ -7,7 +7,7 @@ tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedP class C { [e]: Type ~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. ~~~~ diff --git a/tests/baselines/reference/parserES5ComputedPropertyName1.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName1.errors.txt index 2c8f1d2ab4f0e..7b1f9cb183248 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName1.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName1.ts(2,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName1.ts(2,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName1.ts(2,6): error TS2304: Cannot find name 'e'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5Comput declare class C { [e]: number ~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName10.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName10.errors.txt index 31d3f9985abae..6fcb462d9e332 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName10.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName10.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName10.ts(2,4): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName10.ts(2,4): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName10.ts(2,5): error TS2304: Cannot find name 'e'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5Comput class C { [e] = 1 ~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName11.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName11.errors.txt index b4808607ab06d..2bd17b3f4ca10 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName11.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName11.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName11.ts(2,4): error TS1168: A computed property name in a method overload must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName11.ts(2,4): error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName11.ts(2,5): error TS2304: Cannot find name 'e'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5Comput class C { [e](); ~~~ -!!! error TS1168: A computed property name in a method overload must directly refer to a built-in symbol. +!!! error TS1168: A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName5.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName5.errors.txt index 9125ce7b58f42..3c7cdfd38a34e 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName5.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName5.ts(2,5): error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName5.ts(2,5): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName5.ts(2,6): error TS2304: Cannot find name 'e'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5Comput interface I { [e]: number ~~~ -!!! error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName7.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName7.errors.txt index 277bdcd3c94a5..487e84cccbf40 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName7.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName7.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName7.ts(2,4): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName7.ts(2,4): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName7.ts(2,5): error TS2304: Cannot find name 'e'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5Comput class C { [e] ~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName8.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName8.errors.txt index 6b674a1d2c05b..6057d4f7cd339 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName8.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName8.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName8.ts(1,10): error TS1170: A computed property name in a type literal must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName8.ts(1,10): error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName8.ts(1,11): error TS2304: Cannot find name 'e'. ==== tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName8.ts (2 errors) ==== var v: { [e]: number }; ~~~ -!!! error TS1170: A computed property name in a type literal must directly refer to a built-in symbol. +!!! error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. \ No newline at end of file diff --git a/tests/baselines/reference/parserES5ComputedPropertyName9.errors.txt b/tests/baselines/reference/parserES5ComputedPropertyName9.errors.txt index fb087a4d82fcc..cb08a497e1cd4 100644 --- a/tests/baselines/reference/parserES5ComputedPropertyName9.errors.txt +++ b/tests/baselines/reference/parserES5ComputedPropertyName9.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName9.ts(2,4): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName9.ts(2,4): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName9.ts(2,5): error TS2304: Cannot find name 'e'. tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5ComputedPropertyName9.ts(2,9): error TS2304: Cannot find name 'Type'. @@ -7,7 +7,7 @@ tests/cases/conformance/parser/ecmascript5/ComputedPropertyNames/parserES5Comput class C { [e]: Type ~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'e'. ~~~~ diff --git a/tests/baselines/reference/parserIndexSignature11.errors.txt b/tests/baselines/reference/parserIndexSignature11.errors.txt index f1f2a4a00f465..1f52552235743 100644 --- a/tests/baselines/reference/parserIndexSignature11.errors.txt +++ b/tests/baselines/reference/parserIndexSignature11.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature11.ts(2,9): error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature11.ts(2,9): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature11.ts(2,10): error TS2304: Cannot find name 'p'. tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature11.ts(3,9): error TS1021: An index signature must have a type annotation. tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature11.ts(4,10): error TS1096: An index signature must have exactly one parameter. @@ -8,7 +8,7 @@ tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature1 interface I { [p]; // Used to be indexer, now it is a computed property ~~~ -!!! error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'p'. [p1: string]; diff --git a/tests/baselines/reference/parserIndexSignature4.errors.txt b/tests/baselines/reference/parserIndexSignature4.errors.txt index bd73b4d2bf451..8bc0d9c40eac6 100644 --- a/tests/baselines/reference/parserIndexSignature4.errors.txt +++ b/tests/baselines/reference/parserIndexSignature4.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature4.ts(2,3): error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature4.ts(2,3): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature4.ts(2,4): error TS2304: Cannot find name 'a'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature4 interface I { [a = 0] // Used to be indexer, now it is a computed property ~~~~~~~ -!!! error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'a'. } \ No newline at end of file diff --git a/tests/baselines/reference/parserIndexSignature5.errors.txt b/tests/baselines/reference/parserIndexSignature5.errors.txt index 54ccd05f4f99f..c868ecc48e312 100644 --- a/tests/baselines/reference/parserIndexSignature5.errors.txt +++ b/tests/baselines/reference/parserIndexSignature5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature5.ts(2,3): error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature5.ts(2,3): error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature5.ts(2,4): error TS2304: Cannot find name 'a'. @@ -6,7 +6,7 @@ tests/cases/conformance/parser/ecmascript5/IndexSignatures/parserIndexSignature5 interface I { [a] // Used to be indexer, now it is a computed property ~~~ -!!! error TS1169: A computed property name in an interface must directly refer to a built-in symbol. +!!! error TS1169: A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ !!! error TS2304: Cannot find name 'a'. } \ No newline at end of file diff --git a/tests/baselines/reference/propertyAssignment.errors.txt b/tests/baselines/reference/propertyAssignment.errors.txt index 6aa34c15ac90e..cb1b31ddb4d4c 100644 --- a/tests/baselines/reference/propertyAssignment.errors.txt +++ b/tests/baselines/reference/propertyAssignment.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/propertyAssignment.ts(4,13): error TS1170: A computed property name in a type literal must directly refer to a built-in symbol. +tests/cases/compiler/propertyAssignment.ts(4,13): error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type. tests/cases/compiler/propertyAssignment.ts(4,14): error TS2304: Cannot find name 'index'. tests/cases/compiler/propertyAssignment.ts(12,1): error TS2322: Type '{ x: number; }' is not assignable to type 'new () => any'. Type '{ x: number; }' provides no match for the signature 'new (): any'. @@ -12,7 +12,7 @@ tests/cases/compiler/propertyAssignment.ts(14,1): error TS2322: Type '{ x: numbe var foo2: { [index]; } // should be an error, used to be indexer, now it is a computed property ~~~~~~~ -!!! error TS1170: A computed property name in a type literal must directly refer to a built-in symbol. +!!! error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type. ~~~~~ !!! error TS2304: Cannot find name 'index'. var bar2: { x : number; } diff --git a/tests/baselines/reference/reassignStaticProp.errors.txt b/tests/baselines/reference/reassignStaticProp.errors.txt index 4a698eddab760..bc54e6a7b35b6 100644 --- a/tests/baselines/reference/reassignStaticProp.errors.txt +++ b/tests/baselines/reference/reassignStaticProp.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/reassignStaticProp.ts(5,12): error TS2300: Duplicate identifier 'bar'. -tests/cases/compiler/reassignStaticProp.ts(5,12): error TS2403: Subsequent variable declarations must have the same type. Variable 'bar' has type 'number' at tests/cases/compiler/reassignStaticProp.ts 2:11, but here has type 'string'. +tests/cases/compiler/reassignStaticProp.ts(5,12): error TS2717: Subsequent property declarations must have the same type. Property 'bar' has type 'number' at tests/cases/compiler/reassignStaticProp.ts 2:11, but here has type 'string'. ==== tests/cases/compiler/reassignStaticProp.ts (2 errors) ==== @@ -11,7 +11,7 @@ tests/cases/compiler/reassignStaticProp.ts(5,12): error TS2403: Subsequent varia ~~~ !!! error TS2300: Duplicate identifier 'bar'. ~~~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'bar' has type 'number' at tests/cases/compiler/reassignStaticProp.ts 2:11, but here has type 'string'. +!!! error TS2717: Subsequent property declarations must have the same type. Property 'bar' has type 'number' at tests/cases/compiler/reassignStaticProp.ts 2:11, but here has type 'string'. } diff --git a/tests/baselines/reference/symbolProperty7.errors.txt b/tests/baselines/reference/symbolProperty7.errors.txt index 652f637d852d0..bf6065a89d9ed 100644 --- a/tests/baselines/reference/symbolProperty7.errors.txt +++ b/tests/baselines/reference/symbolProperty7.errors.txt @@ -1,15 +1,15 @@ -tests/cases/conformance/es6/Symbols/symbolProperty7.ts(2,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/conformance/es6/Symbols/symbolProperty7.ts(3,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +tests/cases/conformance/es6/Symbols/symbolProperty7.ts(2,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. +tests/cases/conformance/es6/Symbols/symbolProperty7.ts(3,5): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ==== tests/cases/conformance/es6/Symbols/symbolProperty7.ts (2 errors) ==== class C { [Symbol()] = 0; ~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. [Symbol()]: number; ~~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. +!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. [Symbol()]() { } get [Symbol()]() { return 0; diff --git a/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.types b/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.types index e4496aa4e8ba8..dfd4e522def17 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.types +++ b/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeywordES6.ts === function* gen() { ->gen : () => IterableIterator<10> +>gen : () => IterableIterator // Once this is supported, yield *must* be parenthesized. var x = `abc${ yield 10 }def`; diff --git a/tests/baselines/reference/thisTypeInFunctions3.js b/tests/baselines/reference/thisTypeInFunctions3.js new file mode 100644 index 0000000000000..68af387c25118 --- /dev/null +++ b/tests/baselines/reference/thisTypeInFunctions3.js @@ -0,0 +1,33 @@ +//// [thisTypeInFunctions3.ts] +declare class Base { + check(prop: TProp): boolean; +} + +class Test extends Base { + m() { + this.check(this); + } +} + + +//// [thisTypeInFunctions3.js] +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var Test = /** @class */ (function (_super) { + __extends(Test, _super); + function Test() { + return _super !== null && _super.apply(this, arguments) || this; + } + Test.prototype.m = function () { + this.check(this); + }; + return Test; +}(Base)); diff --git a/tests/baselines/reference/thisTypeInFunctions3.symbols b/tests/baselines/reference/thisTypeInFunctions3.symbols new file mode 100644 index 0000000000000..061a33fd63d1b --- /dev/null +++ b/tests/baselines/reference/thisTypeInFunctions3.symbols @@ -0,0 +1,26 @@ +=== tests/cases/conformance/types/thisType/thisTypeInFunctions3.ts === +declare class Base { +>Base : Symbol(Base, Decl(thisTypeInFunctions3.ts, 0, 0)) + + check(prop: TProp): boolean; +>check : Symbol(Base.check, Decl(thisTypeInFunctions3.ts, 0, 20)) +>TProp : Symbol(TProp, Decl(thisTypeInFunctions3.ts, 1, 10)) +>prop : Symbol(prop, Decl(thisTypeInFunctions3.ts, 1, 30)) +>TProp : Symbol(TProp, Decl(thisTypeInFunctions3.ts, 1, 10)) +} + +class Test extends Base { +>Test : Symbol(Test, Decl(thisTypeInFunctions3.ts, 2, 1)) +>Base : Symbol(Base, Decl(thisTypeInFunctions3.ts, 0, 0)) + + m() { +>m : Symbol(Test.m, Decl(thisTypeInFunctions3.ts, 4, 25)) + + this.check(this); +>this.check : Symbol(Base.check, Decl(thisTypeInFunctions3.ts, 0, 20)) +>this : Symbol(Test, Decl(thisTypeInFunctions3.ts, 2, 1)) +>check : Symbol(Base.check, Decl(thisTypeInFunctions3.ts, 0, 20)) +>this : Symbol(Test, Decl(thisTypeInFunctions3.ts, 2, 1)) + } +} + diff --git a/tests/baselines/reference/thisTypeInFunctions3.types b/tests/baselines/reference/thisTypeInFunctions3.types new file mode 100644 index 0000000000000..563d6488704b5 --- /dev/null +++ b/tests/baselines/reference/thisTypeInFunctions3.types @@ -0,0 +1,27 @@ +=== tests/cases/conformance/types/thisType/thisTypeInFunctions3.ts === +declare class Base { +>Base : Base + + check(prop: TProp): boolean; +>check : (prop: TProp) => boolean +>TProp : TProp +>prop : TProp +>TProp : TProp +} + +class Test extends Base { +>Test : Test +>Base : Base + + m() { +>m : () => void + + this.check(this); +>this.check(this) : boolean +>this.check : (prop: TProp) => boolean +>this : this +>check : (prop: TProp) => boolean +>this : this + } +} + diff --git a/tests/baselines/reference/types.asyncGenerators.esnext.1.types b/tests/baselines/reference/types.asyncGenerators.esnext.1.types index 1a72da228e762..6e29e9cc95cab 100644 --- a/tests/baselines/reference/types.asyncGenerators.esnext.1.types +++ b/tests/baselines/reference/types.asyncGenerators.esnext.1.types @@ -9,7 +9,7 @@ async function * inferReturnType2() { >yield : any } async function * inferReturnType3() { ->inferReturnType3 : () => AsyncIterableIterator<1> +>inferReturnType3 : () => AsyncIterableIterator yield 1; >yield 1 : any @@ -63,20 +63,20 @@ async function * inferReturnType7() { >1 : 1 } async function * inferReturnType8() { ->inferReturnType8 : () => AsyncIterableIterator<1> +>inferReturnType8 : () => AsyncIterableIterator 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 +>(async function * () { yield 1; }) : () => AsyncIterableIterator +>async function * () { yield 1; } : () => AsyncIterableIterator >yield 1 : any >1 : 1 } const assignability1: () => AsyncIterableIterator = async function * () { >assignability1 : () => AsyncIterableIterator >AsyncIterableIterator : AsyncIterableIterator ->async function * () { yield 1;} : () => AsyncIterableIterator<1> +>async function * () { yield 1;} : () => AsyncIterableIterator yield 1; >yield 1 : any @@ -127,13 +127,13 @@ const assignability4: () => AsyncIterableIterator = async function * () const assignability5: () => AsyncIterableIterator = async function * () { >assignability5 : () => AsyncIterableIterator >AsyncIterableIterator : AsyncIterableIterator ->async function * () { yield* (async function * () { yield 1; })();} : () => AsyncIterableIterator<1> +>async function * () { yield* (async function * () { yield 1; })();} : () => AsyncIterableIterator 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 +>(async function * () { yield 1; }) : () => AsyncIterableIterator +>async function * () { yield 1; } : () => AsyncIterableIterator >yield 1 : any >1 : 1 @@ -141,7 +141,7 @@ const assignability5: () => AsyncIterableIterator = async function * () const assignability6: () => AsyncIterable = async function * () { >assignability6 : () => AsyncIterable >AsyncIterable : AsyncIterable ->async function * () { yield 1;} : () => AsyncIterableIterator<1> +>async function * () { yield 1;} : () => AsyncIterableIterator yield 1; >yield 1 : any @@ -192,13 +192,13 @@ const assignability9: () => AsyncIterable = async function * () { const assignability10: () => AsyncIterable = async function * () { >assignability10 : () => AsyncIterable >AsyncIterable : AsyncIterable ->async function * () { yield* (async function * () { yield 1; })();} : () => AsyncIterableIterator<1> +>async function * () { yield* (async function * () { yield 1; })();} : () => AsyncIterableIterator 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 +>(async function * () { yield 1; }) : () => AsyncIterableIterator +>async function * () { yield 1; } : () => AsyncIterableIterator >yield 1 : any >1 : 1 @@ -206,7 +206,7 @@ const assignability10: () => AsyncIterable = async function * () { const assignability11: () => AsyncIterator = async function * () { >assignability11 : () => AsyncIterator >AsyncIterator : AsyncIterator ->async function * () { yield 1;} : () => AsyncIterableIterator<1> +>async function * () { yield 1;} : () => AsyncIterableIterator yield 1; >yield 1 : any @@ -257,13 +257,13 @@ const assignability14: () => AsyncIterator = async function * () { const assignability15: () => AsyncIterator = async function * () { >assignability15 : () => AsyncIterator >AsyncIterator : AsyncIterator ->async function * () { yield* (async function * () { yield 1; })();} : () => AsyncIterableIterator<1> +>async function * () { yield* (async function * () { yield 1; })();} : () => AsyncIterableIterator 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 +>(async function * () { yield 1; }) : () => AsyncIterableIterator +>async function * () { yield 1; } : () => AsyncIterableIterator >yield 1 : any >1 : 1 @@ -317,9 +317,9 @@ async function * explicitReturnType5(): AsyncIterableIterator { 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 +>(async function * () { yield 1; }) : () => AsyncIterableIterator +>async function * () { yield 1; } : () => AsyncIterableIterator >yield 1 : any >1 : 1 } @@ -372,9 +372,9 @@ async function * explicitReturnType10(): AsyncIterable { 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 +>(async function * () { yield 1; }) : () => AsyncIterableIterator +>async function * () { yield 1; } : () => AsyncIterableIterator >yield 1 : any >1 : 1 } @@ -427,9 +427,9 @@ async function * explicitReturnType15(): AsyncIterator { 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 +>(async function * () { yield 1; }) : () => AsyncIterableIterator +>async function * () { yield 1; } : () => AsyncIterableIterator >yield 1 : any >1 : 1 } diff --git a/tests/baselines/reference/types.asyncGenerators.esnext.2.errors.txt b/tests/baselines/reference/types.asyncGenerators.esnext.2.errors.txt index 64d7980578c28..a6a0243ded606 100644 --- a/tests/baselines/reference/types.asyncGenerators.esnext.2.errors.txt +++ b/tests/baselines/reference/types.asyncGenerators.esnext.2.errors.txt @@ -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'. - Type 'AsyncIterableIterator<"a">' is not assignable to type 'AsyncIterableIterator'. - Type '"a"' is not assignable to type 'number'. -tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(13,7): error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterableIterator'. +tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(10,7): error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterableIterator'. Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterableIterator'. 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'. - Type 'AsyncIterableIterator<"a">' is not assignable to type 'AsyncIterableIterator'. -tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(19,7): error TS2322: Type '() => AsyncIterableIterator<"a">' is not assignable to type '() => AsyncIterable'. - Type 'AsyncIterableIterator<"a">' is not assignable to type 'AsyncIterable'. - Types of property '[Symbol.asyncIterator]' are incompatible. - Type '() => AsyncIterableIterator<"a">' is not assignable to type '() => AsyncIterator'. - Type 'AsyncIterableIterator<"a">' is not assignable to type 'AsyncIterator'. - Types of property 'next' are incompatible. - Type '(value?: any) => Promise>' is not assignable to type '(value?: any) => Promise>'. - Type 'Promise>' is not assignable to type 'Promise>'. - Type 'IteratorResult<"a">' is not assignable to type 'IteratorResult'. - Type '"a"' is not assignable to type 'number'. -tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(22,7): error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterable'. +tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(13,7): error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterableIterator'. + Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterableIterator'. +tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(16,7): error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterableIterator'. + Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterableIterator'. +tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(19,7): error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterable'. Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterable'. Types of property '[Symbol.asyncIterator]' are incompatible. Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterator'. @@ -28,23 +17,25 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts( Type 'Promise>' is not assignable to type 'Promise>'. Type 'IteratorResult' is not assignable to type 'IteratorResult'. 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'. - Type 'AsyncIterableIterator<"a">' is not assignable to type 'AsyncIterable'. -tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(28,7): error TS2322: Type '() => AsyncIterableIterator<"a">' is not assignable to type '() => AsyncIterator'. - Type 'AsyncIterableIterator<"a">' is not assignable to type 'AsyncIterator'. +tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(22,7): error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterable'. + Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterable'. +tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(25,7): error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterable'. + Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterable'. +tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(28,7): error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterator'. + Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterator'. tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(31,7): error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterator'. Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterator'. -tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(34,7): error TS2322: Type '() => AsyncIterableIterator<"a">' is not assignable to type '() => AsyncIterator'. - Type 'AsyncIterableIterator<"a">' is not assignable to type 'AsyncIterator'. +tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(34,7): error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterator'. + Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterator'. 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' is not assignable to type 'IterableIterator'. Property '[Symbol.iterator]' is missing in type 'AsyncIterableIterator'. tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts(67,42): error TS2322: Type 'AsyncIterableIterator' is not assignable to type 'Iterable'. @@ -73,40 +64,25 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts( } const assignability1: () => AsyncIterableIterator = async function * () { ~~~~~~~~~~~~~~ -!!! error TS2322: Type '() => AsyncIterableIterator<"a">' is not assignable to type '() => AsyncIterableIterator'. -!!! error TS2322: Type 'AsyncIterableIterator<"a">' is not assignable to type 'AsyncIterableIterator'. -!!! error TS2322: Type '"a"' is not assignable to type 'number'. +!!! error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterableIterator'. +!!! error TS2322: Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterableIterator'. +!!! error TS2322: Type 'string' is not assignable to type 'number'. yield "a"; }; const assignability2: () => AsyncIterableIterator = async function * () { ~~~~~~~~~~~~~~ !!! error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterableIterator'. !!! error TS2322: Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterableIterator'. -!!! error TS2322: Type 'string' is not assignable to type 'number'. yield* ["a", "b"]; }; const assignability3: () => AsyncIterableIterator = async function * () { ~~~~~~~~~~~~~~ -!!! error TS2322: Type '() => AsyncIterableIterator<"a">' is not assignable to type '() => AsyncIterableIterator'. -!!! error TS2322: Type 'AsyncIterableIterator<"a">' is not assignable to type 'AsyncIterableIterator'. +!!! error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterableIterator'. +!!! error TS2322: Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterableIterator'. yield* (async function * () { yield "a"; })(); }; const assignability4: () => AsyncIterable = async function * () { ~~~~~~~~~~~~~~ -!!! error TS2322: Type '() => AsyncIterableIterator<"a">' is not assignable to type '() => AsyncIterable'. -!!! error TS2322: Type 'AsyncIterableIterator<"a">' is not assignable to type 'AsyncIterable'. -!!! error TS2322: Types of property '[Symbol.asyncIterator]' are incompatible. -!!! error TS2322: Type '() => AsyncIterableIterator<"a">' is not assignable to type '() => AsyncIterator'. -!!! error TS2322: Type 'AsyncIterableIterator<"a">' is not assignable to type 'AsyncIterator'. -!!! error TS2322: Types of property 'next' are incompatible. -!!! error TS2322: Type '(value?: any) => Promise>' is not assignable to type '(value?: any) => Promise>'. -!!! error TS2322: Type 'Promise>' is not assignable to type 'Promise>'. -!!! error TS2322: Type 'IteratorResult<"a">' is not assignable to type 'IteratorResult'. -!!! error TS2322: Type '"a"' is not assignable to type 'number'. - yield "a"; - }; - const assignability5: () => AsyncIterable = async function * () { - ~~~~~~~~~~~~~~ !!! error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterable'. !!! error TS2322: Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterable'. !!! 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>' is not assignable to type 'Promise>'. !!! error TS2322: Type 'IteratorResult' is not assignable to type 'IteratorResult'. !!! error TS2322: Type 'string' is not assignable to type 'number'. + yield "a"; + }; + const assignability5: () => AsyncIterable = async function * () { + ~~~~~~~~~~~~~~ +!!! error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterable'. +!!! error TS2322: Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterable'. yield* ["a", "b"]; }; const assignability6: () => AsyncIterable = async function * () { ~~~~~~~~~~~~~~ -!!! error TS2322: Type '() => AsyncIterableIterator<"a">' is not assignable to type '() => AsyncIterable'. -!!! error TS2322: Type 'AsyncIterableIterator<"a">' is not assignable to type 'AsyncIterable'. +!!! error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterable'. +!!! error TS2322: Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterable'. yield* (async function * () { yield "a"; })(); }; const assignability7: () => AsyncIterator = async function * () { ~~~~~~~~~~~~~~ -!!! error TS2322: Type '() => AsyncIterableIterator<"a">' is not assignable to type '() => AsyncIterator'. -!!! error TS2322: Type 'AsyncIterableIterator<"a">' is not assignable to type 'AsyncIterator'. +!!! error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterator'. +!!! error TS2322: Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterator'. yield "a"; }; const assignability8: () => AsyncIterator = async function * () { @@ -139,8 +121,8 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts( }; const assignability9: () => AsyncIterator = async function * () { ~~~~~~~~~~~~~~ -!!! error TS2322: Type '() => AsyncIterableIterator<"a">' is not assignable to type '() => AsyncIterator'. -!!! error TS2322: Type 'AsyncIterableIterator<"a">' is not assignable to type 'AsyncIterator'. +!!! error TS2322: Type '() => AsyncIterableIterator' is not assignable to type '() => AsyncIterator'. +!!! error TS2322: Type 'AsyncIterableIterator' is not assignable to type 'AsyncIterator'. yield* (async function * () { yield "a"; })(); }; async function * explicitReturnType1(): AsyncIterableIterator { @@ -156,7 +138,7 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts( async function * explicitReturnType3(): AsyncIterableIterator { 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 { yield "a"; @@ -171,7 +153,7 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts( async function * explicitReturnType6(): AsyncIterable { 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 { yield "a"; @@ -186,7 +168,7 @@ tests/cases/conformance/types/asyncGenerators/types.asyncGenerators.esnext.2.ts( async function * explicitReturnType9(): AsyncIterator { 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 { ~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/types.asyncGenerators.esnext.2.types b/tests/baselines/reference/types.asyncGenerators.esnext.2.types index 2d29f5a7e1d97..c9f8e9216c4a8 100644 --- a/tests/baselines/reference/types.asyncGenerators.esnext.2.types +++ b/tests/baselines/reference/types.asyncGenerators.esnext.2.types @@ -30,7 +30,7 @@ async function * inferReturnType3() { const assignability1: () => AsyncIterableIterator = async function * () { >assignability1 : () => AsyncIterableIterator >AsyncIterableIterator : AsyncIterableIterator ->async function * () { yield "a";} : () => AsyncIterableIterator<"a"> +>async function * () { yield "a";} : () => AsyncIterableIterator yield "a"; >yield "a" : any @@ -52,13 +52,13 @@ const assignability2: () => AsyncIterableIterator = async function * () const assignability3: () => AsyncIterableIterator = async function * () { >assignability3 : () => AsyncIterableIterator >AsyncIterableIterator : AsyncIterableIterator ->async function * () { yield* (async function * () { yield "a"; })();} : () => AsyncIterableIterator<"a"> +>async function * () { yield* (async function * () { yield "a"; })();} : () => AsyncIterableIterator 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 +>(async function * () { yield "a"; }) : () => AsyncIterableIterator +>async function * () { yield "a"; } : () => AsyncIterableIterator >yield "a" : any >"a" : "a" @@ -66,7 +66,7 @@ const assignability3: () => AsyncIterableIterator = async function * () const assignability4: () => AsyncIterable = async function * () { >assignability4 : () => AsyncIterable >AsyncIterable : AsyncIterable ->async function * () { yield "a";} : () => AsyncIterableIterator<"a"> +>async function * () { yield "a";} : () => AsyncIterableIterator yield "a"; >yield "a" : any @@ -88,13 +88,13 @@ const assignability5: () => AsyncIterable = async function * () { const assignability6: () => AsyncIterable = async function * () { >assignability6 : () => AsyncIterable >AsyncIterable : AsyncIterable ->async function * () { yield* (async function * () { yield "a"; })();} : () => AsyncIterableIterator<"a"> +>async function * () { yield* (async function * () { yield "a"; })();} : () => AsyncIterableIterator 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 +>(async function * () { yield "a"; }) : () => AsyncIterableIterator +>async function * () { yield "a"; } : () => AsyncIterableIterator >yield "a" : any >"a" : "a" @@ -102,7 +102,7 @@ const assignability6: () => AsyncIterable = async function * () { const assignability7: () => AsyncIterator = async function * () { >assignability7 : () => AsyncIterator >AsyncIterator : AsyncIterator ->async function * () { yield "a";} : () => AsyncIterableIterator<"a"> +>async function * () { yield "a";} : () => AsyncIterableIterator yield "a"; >yield "a" : any @@ -124,13 +124,13 @@ const assignability8: () => AsyncIterator = async function * () { const assignability9: () => AsyncIterator = async function * () { >assignability9 : () => AsyncIterator >AsyncIterator : AsyncIterator ->async function * () { yield* (async function * () { yield "a"; })();} : () => AsyncIterableIterator<"a"> +>async function * () { yield* (async function * () { yield "a"; })();} : () => AsyncIterableIterator 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 +>(async function * () { yield "a"; }) : () => AsyncIterableIterator +>async function * () { yield "a"; } : () => AsyncIterableIterator >yield "a" : any >"a" : "a" @@ -159,9 +159,9 @@ async function * explicitReturnType3(): AsyncIterableIterator { 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 +>(async function * () { yield "a"; }) : () => AsyncIterableIterator +>async function * () { yield "a"; } : () => AsyncIterableIterator >yield "a" : any >"a" : "a" } @@ -189,9 +189,9 @@ async function * explicitReturnType6(): AsyncIterable { 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 +>(async function * () { yield "a"; }) : () => AsyncIterableIterator +>async function * () { yield "a"; } : () => AsyncIterableIterator >yield "a" : any >"a" : "a" } @@ -219,9 +219,9 @@ async function * explicitReturnType9(): AsyncIterator { 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 +>(async function * () { yield "a"; }) : () => AsyncIterableIterator +>async function * () { yield "a"; } : () => AsyncIterableIterator >yield "a" : any >"a" : "a" } diff --git a/tests/baselines/reference/uniqueSymbols.js b/tests/baselines/reference/uniqueSymbols.js new file mode 100644 index 0000000000000..6c723c8dec17d --- /dev/null +++ b/tests/baselines/reference/uniqueSymbols.js @@ -0,0 +1,450 @@ +//// [uniqueSymbols.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 { 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(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(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 { + static [s]: "a"; + static [N.s]: "b"; + + [s]: "a"; + [N.s]: "b"; +} + +// contextual types + +interface Context { + method1(): typeof s; + method2(): Promise; + method3(): AsyncIterableIterator; + method4(): IterableIterator; + 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 +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 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; + }, +}; +// allowed when not emitting declarations +const o4 = { + method1(p) { + return p; + }, + method2(p) { + return p; + } +}; +const ce0 = class { + method1(p) { + return p; + } + method2(p) { + return p; + } +}; +function funcInferredReturnType(obj) { + return obj; +} diff --git a/tests/baselines/reference/uniqueSymbols.symbols b/tests/baselines/reference/uniqueSymbols.symbols new file mode 100644 index 0000000000000..e798011683ae2 --- /dev/null +++ b/tests/baselines/reference/uniqueSymbols.symbols @@ -0,0 +1,850 @@ +=== tests/cases/conformance/types/uniqueSymbol/uniqueSymbols.ts === +// declarations with call initializer +const constCall = Symbol(); +>constCall : Symbol(constCall, Decl(uniqueSymbols.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(uniqueSymbols.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(uniqueSymbols.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(uniqueSymbols.ts, 6, 13)) + +// declaration with type and call initializer +const constTypeAndCall: unique symbol = Symbol(); +>constTypeAndCall : Symbol(constTypeAndCall, Decl(uniqueSymbols.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(uniqueSymbols.ts, 12, 5)) +>constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) + +const constInitToLetCall = letCall; +>constInitToLetCall : Symbol(constInitToLetCall, Decl(uniqueSymbols.ts, 13, 5)) +>letCall : Symbol(letCall, Decl(uniqueSymbols.ts, 2, 3)) + +const constInitToVarCall = varCall; +>constInitToVarCall : Symbol(constInitToVarCall, Decl(uniqueSymbols.ts, 14, 5)) +>varCall : Symbol(varCall, Decl(uniqueSymbols.ts, 3, 3)) + +const constInitToConstDeclAmbient = constType; +>constInitToConstDeclAmbient : Symbol(constInitToConstDeclAmbient, Decl(uniqueSymbols.ts, 15, 5)) +>constType : Symbol(constType, Decl(uniqueSymbols.ts, 6, 13)) + +let letInitToConstCall = constCall; +>letInitToConstCall : Symbol(letInitToConstCall, Decl(uniqueSymbols.ts, 16, 3)) +>constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) + +let letInitToLetCall = letCall; +>letInitToLetCall : Symbol(letInitToLetCall, Decl(uniqueSymbols.ts, 17, 3)) +>letCall : Symbol(letCall, Decl(uniqueSymbols.ts, 2, 3)) + +let letInitToVarCall = varCall; +>letInitToVarCall : Symbol(letInitToVarCall, Decl(uniqueSymbols.ts, 18, 3)) +>varCall : Symbol(varCall, Decl(uniqueSymbols.ts, 3, 3)) + +let letInitToConstDeclAmbient = constType; +>letInitToConstDeclAmbient : Symbol(letInitToConstDeclAmbient, Decl(uniqueSymbols.ts, 19, 3)) +>constType : Symbol(constType, Decl(uniqueSymbols.ts, 6, 13)) + +var varInitToConstCall = constCall; +>varInitToConstCall : Symbol(varInitToConstCall, Decl(uniqueSymbols.ts, 20, 3)) +>constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) + +var varInitToLetCall = letCall; +>varInitToLetCall : Symbol(varInitToLetCall, Decl(uniqueSymbols.ts, 21, 3)) +>letCall : Symbol(letCall, Decl(uniqueSymbols.ts, 2, 3)) + +var varInitToVarCall = varCall; +>varInitToVarCall : Symbol(varInitToVarCall, Decl(uniqueSymbols.ts, 22, 3)) +>varCall : Symbol(varCall, Decl(uniqueSymbols.ts, 3, 3)) + +var varInitToConstDeclAmbient = constType; +>varInitToConstDeclAmbient : Symbol(varInitToConstDeclAmbient, Decl(uniqueSymbols.ts, 23, 3)) +>constType : Symbol(constType, Decl(uniqueSymbols.ts, 6, 13)) + +// declaration from initializer with type query +const constInitToConstCallWithTypeQuery: typeof constCall = constCall; +>constInitToConstCallWithTypeQuery : Symbol(constInitToConstCallWithTypeQuery, Decl(uniqueSymbols.ts, 26, 5)) +>constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) +>constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) + +const constInitToConstDeclAmbientWithTypeQuery: typeof constType = constType; +>constInitToConstDeclAmbientWithTypeQuery : Symbol(constInitToConstDeclAmbientWithTypeQuery, Decl(uniqueSymbols.ts, 27, 5)) +>constType : Symbol(constType, Decl(uniqueSymbols.ts, 6, 13)) +>constType : Symbol(constType, Decl(uniqueSymbols.ts, 6, 13)) + +// function return inference +function funcReturnConstCall() { return constCall; } +>funcReturnConstCall : Symbol(funcReturnConstCall, Decl(uniqueSymbols.ts, 27, 77)) +>constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) + +function funcReturnLetCall() { return letCall; } +>funcReturnLetCall : Symbol(funcReturnLetCall, Decl(uniqueSymbols.ts, 30, 52)) +>letCall : Symbol(letCall, Decl(uniqueSymbols.ts, 2, 3)) + +function funcReturnVarCall() { return varCall; } +>funcReturnVarCall : Symbol(funcReturnVarCall, Decl(uniqueSymbols.ts, 31, 48)) +>varCall : Symbol(varCall, Decl(uniqueSymbols.ts, 3, 3)) + +// function return value with type query +function funcReturnConstCallWithTypeQuery(): typeof constCall { return constCall; } +>funcReturnConstCallWithTypeQuery : Symbol(funcReturnConstCallWithTypeQuery, Decl(uniqueSymbols.ts, 32, 48)) +>constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) +>constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) + +// generator function yield inference +function* genFuncYieldConstCall() { yield constCall; } +>genFuncYieldConstCall : Symbol(genFuncYieldConstCall, Decl(uniqueSymbols.ts, 35, 83)) +>constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) + +function* genFuncYieldLetCall() { yield letCall; } +>genFuncYieldLetCall : Symbol(genFuncYieldLetCall, Decl(uniqueSymbols.ts, 38, 54)) +>letCall : Symbol(letCall, Decl(uniqueSymbols.ts, 2, 3)) + +function* genFuncYieldVarCall() { yield varCall; } +>genFuncYieldVarCall : Symbol(genFuncYieldVarCall, Decl(uniqueSymbols.ts, 39, 50)) +>varCall : Symbol(varCall, Decl(uniqueSymbols.ts, 3, 3)) + +// generator function yield with return type query +function* genFuncYieldConstCallWithTypeQuery(): IterableIterator { yield constCall; } +>genFuncYieldConstCallWithTypeQuery : Symbol(genFuncYieldConstCallWithTypeQuery, Decl(uniqueSymbols.ts, 40, 50)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.es2015.iterable.d.ts, --, --)) +>constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) +>constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) + +// async function return inference +async function asyncFuncReturnConstCall() { return constCall; } +>asyncFuncReturnConstCall : Symbol(asyncFuncReturnConstCall, Decl(uniqueSymbols.ts, 43, 103)) +>constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) + +async function asyncFuncReturnLetCall() { return letCall; } +>asyncFuncReturnLetCall : Symbol(asyncFuncReturnLetCall, Decl(uniqueSymbols.ts, 46, 63)) +>letCall : Symbol(letCall, Decl(uniqueSymbols.ts, 2, 3)) + +async function asyncFuncReturnVarCall() { return varCall; } +>asyncFuncReturnVarCall : Symbol(asyncFuncReturnVarCall, Decl(uniqueSymbols.ts, 47, 59)) +>varCall : Symbol(varCall, Decl(uniqueSymbols.ts, 3, 3)) + +// async generator function yield inference +async function* asyncGenFuncYieldConstCall() { yield constCall; } +>asyncGenFuncYieldConstCall : Symbol(asyncGenFuncYieldConstCall, Decl(uniqueSymbols.ts, 48, 59)) +>constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) + +async function* asyncGenFuncYieldLetCall() { yield letCall; } +>asyncGenFuncYieldLetCall : Symbol(asyncGenFuncYieldLetCall, Decl(uniqueSymbols.ts, 51, 65)) +>letCall : Symbol(letCall, Decl(uniqueSymbols.ts, 2, 3)) + +async function* asyncGenFuncYieldVarCall() { yield varCall; } +>asyncGenFuncYieldVarCall : Symbol(asyncGenFuncYieldVarCall, Decl(uniqueSymbols.ts, 52, 61)) +>varCall : Symbol(varCall, Decl(uniqueSymbols.ts, 3, 3)) + +// classes +class C { +>C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) + + static readonly readonlyStaticCall = Symbol(); +>readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbols.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(uniqueSymbols.ts, 57, 50)) + + static readonly readonlyStaticTypeAndCall: unique symbol = Symbol(); +>readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.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(uniqueSymbols.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(uniqueSymbols.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(uniqueSymbols.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(uniqueSymbols.ts, 65, 13)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) + +const constInitToCReadonlyStaticCall = C.readonlyStaticCall; +>constInitToCReadonlyStaticCall : Symbol(constInitToCReadonlyStaticCall, Decl(uniqueSymbols.ts, 67, 5)) +>C.readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbols.ts, 56, 9)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) +>readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbols.ts, 56, 9)) + +const constInitToCReadonlyStaticType = C.readonlyStaticType; +>constInitToCReadonlyStaticType : Symbol(constInitToCReadonlyStaticType, Decl(uniqueSymbols.ts, 68, 5)) +>C.readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbols.ts, 57, 50)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) +>readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbols.ts, 57, 50)) + +const constInitToCReadonlyStaticTypeAndCall = C.readonlyStaticTypeAndCall; +>constInitToCReadonlyStaticTypeAndCall : Symbol(constInitToCReadonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 69, 5)) +>C.readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 58, 54)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) +>readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 58, 54)) + +const constInitToCReadwriteStaticCall = C.readwriteStaticCall; +>constInitToCReadwriteStaticCall : Symbol(constInitToCReadwriteStaticCall, Decl(uniqueSymbols.ts, 70, 5)) +>C.readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 59, 72)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) +>readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 59, 72)) + +const constInitToCReadonlyStaticCallWithTypeQuery: typeof C.readonlyStaticCall = C.readonlyStaticCall; +>constInitToCReadonlyStaticCallWithTypeQuery : Symbol(constInitToCReadonlyStaticCallWithTypeQuery, Decl(uniqueSymbols.ts, 72, 5)) +>C.readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbols.ts, 56, 9)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) +>readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbols.ts, 56, 9)) +>C.readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbols.ts, 56, 9)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) +>readonlyStaticCall : Symbol(C.readonlyStaticCall, Decl(uniqueSymbols.ts, 56, 9)) + +const constInitToCReadonlyStaticTypeWithTypeQuery: typeof C.readonlyStaticType = C.readonlyStaticType; +>constInitToCReadonlyStaticTypeWithTypeQuery : Symbol(constInitToCReadonlyStaticTypeWithTypeQuery, Decl(uniqueSymbols.ts, 73, 5)) +>C.readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbols.ts, 57, 50)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) +>readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbols.ts, 57, 50)) +>C.readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbols.ts, 57, 50)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) +>readonlyStaticType : Symbol(C.readonlyStaticType, Decl(uniqueSymbols.ts, 57, 50)) + +const constInitToCReadonlyStaticTypeAndCallWithTypeQuery: typeof C.readonlyStaticTypeAndCall = C.readonlyStaticTypeAndCall; +>constInitToCReadonlyStaticTypeAndCallWithTypeQuery : Symbol(constInitToCReadonlyStaticTypeAndCallWithTypeQuery, Decl(uniqueSymbols.ts, 74, 5)) +>C.readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 58, 54)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) +>readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 58, 54)) +>C.readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 58, 54)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) +>readonlyStaticTypeAndCall : Symbol(C.readonlyStaticTypeAndCall, Decl(uniqueSymbols.ts, 58, 54)) + +const constInitToCReadwriteStaticCallWithTypeQuery: typeof C.readwriteStaticCall = C.readwriteStaticCall; +>constInitToCReadwriteStaticCallWithTypeQuery : Symbol(constInitToCReadwriteStaticCallWithTypeQuery, Decl(uniqueSymbols.ts, 75, 5)) +>C.readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 59, 72)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) +>readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 59, 72)) +>C.readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 59, 72)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) +>readwriteStaticCall : Symbol(C.readwriteStaticCall, Decl(uniqueSymbols.ts, 59, 72)) + +const constInitToCReadonlyCall = c.readonlyCall; +>constInitToCReadonlyCall : Symbol(constInitToCReadonlyCall, Decl(uniqueSymbols.ts, 77, 5)) +>c.readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 60, 42)) +>c : Symbol(c, Decl(uniqueSymbols.ts, 65, 13)) +>readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 60, 42)) + +const constInitToCReadwriteCall = c.readwriteCall; +>constInitToCReadwriteCall : Symbol(constInitToCReadwriteCall, Decl(uniqueSymbols.ts, 78, 5)) +>c.readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 62, 37)) +>c : Symbol(c, Decl(uniqueSymbols.ts, 65, 13)) +>readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 62, 37)) + +const constInitToCReadonlyCallWithTypeQuery: typeof c.readonlyCall = c.readonlyCall; +>constInitToCReadonlyCallWithTypeQuery : Symbol(constInitToCReadonlyCallWithTypeQuery, Decl(uniqueSymbols.ts, 79, 5)) +>c.readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 60, 42)) +>c : Symbol(c, Decl(uniqueSymbols.ts, 65, 13)) +>readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 60, 42)) +>c.readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 60, 42)) +>c : Symbol(c, Decl(uniqueSymbols.ts, 65, 13)) +>readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 60, 42)) + +const constInitToCReadwriteCallWithTypeQuery: typeof c.readwriteCall = c.readwriteCall; +>constInitToCReadwriteCallWithTypeQuery : Symbol(constInitToCReadwriteCallWithTypeQuery, Decl(uniqueSymbols.ts, 80, 5)) +>c.readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 62, 37)) +>c : Symbol(c, Decl(uniqueSymbols.ts, 65, 13)) +>readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 62, 37)) +>c.readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 62, 37)) +>c : Symbol(c, Decl(uniqueSymbols.ts, 65, 13)) +>readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 62, 37)) + +const constInitToCReadonlyCallWithIndexedAccess: C["readonlyCall"] = c.readonlyCall; +>constInitToCReadonlyCallWithIndexedAccess : Symbol(constInitToCReadonlyCallWithIndexedAccess, Decl(uniqueSymbols.ts, 81, 5)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) +>c.readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 60, 42)) +>c : Symbol(c, Decl(uniqueSymbols.ts, 65, 13)) +>readonlyCall : Symbol(C.readonlyCall, Decl(uniqueSymbols.ts, 60, 42)) + +const constInitToCReadwriteCallWithIndexedAccess: C["readwriteCall"] = c.readwriteCall; +>constInitToCReadwriteCallWithIndexedAccess : Symbol(constInitToCReadwriteCallWithIndexedAccess, Decl(uniqueSymbols.ts, 82, 5)) +>C : Symbol(C, Decl(uniqueSymbols.ts, 53, 61)) +>c.readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 62, 37)) +>c : Symbol(c, Decl(uniqueSymbols.ts, 65, 13)) +>readwriteCall : Symbol(C.readwriteCall, Decl(uniqueSymbols.ts, 62, 37)) + +// interfaces +interface I { +>I : Symbol(I, Decl(uniqueSymbols.ts, 82, 87)) + + readonly readonlyType: unique symbol; +>readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 85, 13)) +} +declare const i: I; +>i : Symbol(i, Decl(uniqueSymbols.ts, 88, 13)) +>I : Symbol(I, Decl(uniqueSymbols.ts, 82, 87)) + +const constInitToIReadonlyType = i.readonlyType; +>constInitToIReadonlyType : Symbol(constInitToIReadonlyType, Decl(uniqueSymbols.ts, 90, 5)) +>i.readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 85, 13)) +>i : Symbol(i, Decl(uniqueSymbols.ts, 88, 13)) +>readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 85, 13)) + +const constInitToIReadonlyTypeWithTypeQuery: typeof i.readonlyType = i.readonlyType; +>constInitToIReadonlyTypeWithTypeQuery : Symbol(constInitToIReadonlyTypeWithTypeQuery, Decl(uniqueSymbols.ts, 91, 5)) +>i.readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 85, 13)) +>i : Symbol(i, Decl(uniqueSymbols.ts, 88, 13)) +>readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 85, 13)) +>i.readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 85, 13)) +>i : Symbol(i, Decl(uniqueSymbols.ts, 88, 13)) +>readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 85, 13)) + +const constInitToIReadonlyTypeWithIndexedAccess: I["readonlyType"] = i.readonlyType; +>constInitToIReadonlyTypeWithIndexedAccess : Symbol(constInitToIReadonlyTypeWithIndexedAccess, Decl(uniqueSymbols.ts, 92, 5)) +>I : Symbol(I, Decl(uniqueSymbols.ts, 82, 87)) +>i.readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 85, 13)) +>i : Symbol(i, Decl(uniqueSymbols.ts, 88, 13)) +>readonlyType : Symbol(I.readonlyType, Decl(uniqueSymbols.ts, 85, 13)) + +// type literals +type L = { +>L : Symbol(L, Decl(uniqueSymbols.ts, 92, 84)) + + readonly readonlyType: unique symbol; +>readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 95, 10)) + + nested: { +>nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 41)) + + readonly readonlyNestedType: unique symbol; +>readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 97, 13)) + } +}; +declare const l: L; +>l : Symbol(l, Decl(uniqueSymbols.ts, 101, 13)) +>L : Symbol(L, Decl(uniqueSymbols.ts, 92, 84)) + +const constInitToLReadonlyType = l.readonlyType; +>constInitToLReadonlyType : Symbol(constInitToLReadonlyType, Decl(uniqueSymbols.ts, 103, 5)) +>l.readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 95, 10)) +>l : Symbol(l, Decl(uniqueSymbols.ts, 101, 13)) +>readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 95, 10)) + +const constInitToLReadonlyNestedType = l.nested.readonlyNestedType; +>constInitToLReadonlyNestedType : Symbol(constInitToLReadonlyNestedType, Decl(uniqueSymbols.ts, 104, 5)) +>l.nested.readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 97, 13)) +>l.nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 41)) +>l : Symbol(l, Decl(uniqueSymbols.ts, 101, 13)) +>nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 41)) +>readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 97, 13)) + +const constInitToLReadonlyTypeWithTypeQuery: typeof l.readonlyType = l.readonlyType; +>constInitToLReadonlyTypeWithTypeQuery : Symbol(constInitToLReadonlyTypeWithTypeQuery, Decl(uniqueSymbols.ts, 105, 5)) +>l.readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 95, 10)) +>l : Symbol(l, Decl(uniqueSymbols.ts, 101, 13)) +>readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 95, 10)) +>l.readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 95, 10)) +>l : Symbol(l, Decl(uniqueSymbols.ts, 101, 13)) +>readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 95, 10)) + +const constInitToLReadonlyNestedTypeWithTypeQuery: typeof l.nested.readonlyNestedType = l.nested.readonlyNestedType; +>constInitToLReadonlyNestedTypeWithTypeQuery : Symbol(constInitToLReadonlyNestedTypeWithTypeQuery, Decl(uniqueSymbols.ts, 106, 5)) +>l.nested.readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 97, 13)) +>l.nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 41)) +>l : Symbol(l, Decl(uniqueSymbols.ts, 101, 13)) +>nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 41)) +>readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 97, 13)) +>l.nested.readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 97, 13)) +>l.nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 41)) +>l : Symbol(l, Decl(uniqueSymbols.ts, 101, 13)) +>nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 41)) +>readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 97, 13)) + +const constInitToLReadonlyTypeWithIndexedAccess: L["readonlyType"] = l.readonlyType; +>constInitToLReadonlyTypeWithIndexedAccess : Symbol(constInitToLReadonlyTypeWithIndexedAccess, Decl(uniqueSymbols.ts, 107, 5)) +>L : Symbol(L, Decl(uniqueSymbols.ts, 92, 84)) +>l.readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 95, 10)) +>l : Symbol(l, Decl(uniqueSymbols.ts, 101, 13)) +>readonlyType : Symbol(readonlyType, Decl(uniqueSymbols.ts, 95, 10)) + +const constInitToLReadonlyNestedTypeWithIndexedAccess: L["nested"]["readonlyNestedType"] = l.nested.readonlyNestedType; +>constInitToLReadonlyNestedTypeWithIndexedAccess : Symbol(constInitToLReadonlyNestedTypeWithIndexedAccess, Decl(uniqueSymbols.ts, 108, 5)) +>L : Symbol(L, Decl(uniqueSymbols.ts, 92, 84)) +>l.nested.readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 97, 13)) +>l.nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 41)) +>l : Symbol(l, Decl(uniqueSymbols.ts, 101, 13)) +>nested : Symbol(nested, Decl(uniqueSymbols.ts, 96, 41)) +>readonlyNestedType : Symbol(readonlyNestedType, Decl(uniqueSymbols.ts, 97, 13)) + +// type argument inference +const promiseForConstCall = Promise.resolve(constCall); +>promiseForConstCall : Symbol(promiseForConstCall, Decl(uniqueSymbols.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(uniqueSymbols.ts, 1, 5)) + +const arrayOfConstCall = [constCall]; +>arrayOfConstCall : Symbol(arrayOfConstCall, Decl(uniqueSymbols.ts, 112, 5)) +>constCall : Symbol(constCall, Decl(uniqueSymbols.ts, 1, 5)) + +// unique symbol widening in expressions +declare const s: unique symbol; +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + +declare namespace N { const s: unique symbol; } +>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 116, 27)) + +declare const o: { [s]: "a", [N.s]: "b" }; +>o : Symbol(o, Decl(uniqueSymbols.ts, 117, 13)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>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)) + +declare function f(x: T): T; +>f : Symbol(f, Decl(uniqueSymbols.ts, 117, 42)) +>T : Symbol(T, Decl(uniqueSymbols.ts, 118, 19)) +>x : Symbol(x, Decl(uniqueSymbols.ts, 118, 22)) +>T : Symbol(T, Decl(uniqueSymbols.ts, 118, 19)) +>T : Symbol(T, Decl(uniqueSymbols.ts, 118, 19)) + +declare function g(x: typeof s): void; +>g : Symbol(g, Decl(uniqueSymbols.ts, 118, 31), Decl(uniqueSymbols.ts, 119, 38)) +>x : Symbol(x, Decl(uniqueSymbols.ts, 119, 19)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + +declare function g(x: typeof N.s): void; +>g : Symbol(g, Decl(uniqueSymbols.ts, 118, 31), Decl(uniqueSymbols.ts, 119, 38)) +>x : Symbol(x, Decl(uniqueSymbols.ts, 120, 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)) + +// widening positions + +// argument inference +f(s); +>f : Symbol(f, Decl(uniqueSymbols.ts, 117, 42)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + +f(N.s); +>f : Symbol(f, Decl(uniqueSymbols.ts, 117, 42)) +>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(f, Decl(uniqueSymbols.ts, 117, 42)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) + +// array literal elements +[s]; +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + +[N.s]; +>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)) + +[N["s"]]; +>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) + +// property assignments/methods +const o2 = { +>o2 : Symbol(o2, Decl(uniqueSymbols.ts, 135, 5)) + + a: s, +>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, 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, 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, 145, 2)) + + static readonly a = s; +>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, 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, 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, 151, 31)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + + static e = N.s; +>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, 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, 155, 22)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + + readonly b = N.s; +>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, 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, 159, 24)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + + e = N.s; +>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, 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 + +// element access +o[s]; +>o : Symbol(o, Decl(uniqueSymbols.ts, 117, 13)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + +o[N.s]; +>o : Symbol(o, Decl(uniqueSymbols.ts, 117, 13)) +>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)) + +o[N["s"]]; +>o : Symbol(o, Decl(uniqueSymbols.ts, 117, 13)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) + +// arguments (no-inference) +f(s); +>f : Symbol(f, Decl(uniqueSymbols.ts, 117, 42)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + +f(N.s); +>f : Symbol(f, Decl(uniqueSymbols.ts, 117, 42)) +>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)) +>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(f, Decl(uniqueSymbols.ts, 117, 42)) +>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)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) + +g(s); +>g : Symbol(g, Decl(uniqueSymbols.ts, 118, 31), Decl(uniqueSymbols.ts, 119, 38)) +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + +g(N.s); +>g : Symbol(g, Decl(uniqueSymbols.ts, 118, 31), Decl(uniqueSymbols.ts, 119, 38)) +>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)) + +g(N["s"]); +>g : Symbol(g, Decl(uniqueSymbols.ts, 118, 31), Decl(uniqueSymbols.ts, 119, 38)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) + +// falsy expressions +s || ""; +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + +N.s || ""; +>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)) + +N["s"] || ""; +>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbols.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(uniqueSymbols.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(uniqueSymbols.ts, 116, 27)) +>N : Symbol(N, Decl(uniqueSymbols.ts, 115, 31)) +>s : Symbol(N.s, Decl(uniqueSymbols.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(uniqueSymbols.ts, 115, 31)) +>"s" : Symbol(N.s, Decl(uniqueSymbols.ts, 116, 27)) + +// computed property names +({ + [s]: "a", +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + + [N.s]: "b", +>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)) + +}); + +class C1 { +>C1 : Symbol(C1, Decl(uniqueSymbols.ts, 201, 3)) + + static [s]: "a"; +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + + static [N.s]: "b"; +>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)) + + [s]: "a"; +>s : Symbol(s, Decl(uniqueSymbols.ts, 115, 13)) + + [N.s]: "b"; +>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)) +} + +// 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; +>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; +>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; +>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)) +} + diff --git a/tests/baselines/reference/uniqueSymbols.types b/tests/baselines/reference/uniqueSymbols.types new file mode 100644 index 0000000000000..6516ee25dd06b --- /dev/null +++ b/tests/baselines/reference/uniqueSymbols.types @@ -0,0 +1,931 @@ +=== tests/cases/conformance/types/uniqueSymbol/uniqueSymbols.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 +>yield constCall : any +>constCall : unique symbol + +function* genFuncYieldLetCall() { yield letCall; } +>genFuncYieldLetCall : () => IterableIterator +>yield letCall : any +>letCall : symbol + +function* genFuncYieldVarCall() { yield varCall; } +>genFuncYieldVarCall : () => IterableIterator +>yield varCall : any +>varCall : symbol + +// generator function yield with return type query +function* genFuncYieldConstCallWithTypeQuery(): IterableIterator { yield constCall; } +>genFuncYieldConstCallWithTypeQuery : () => IterableIterator +>IterableIterator : IterableIterator +>constCall : unique symbol +>yield constCall : any +>constCall : unique symbol + +// async function return inference +async function asyncFuncReturnConstCall() { return constCall; } +>asyncFuncReturnConstCall : () => Promise +>constCall : unique symbol + +async function asyncFuncReturnLetCall() { return letCall; } +>asyncFuncReturnLetCall : () => Promise +>letCall : symbol + +async function asyncFuncReturnVarCall() { return varCall; } +>asyncFuncReturnVarCall : () => Promise +>varCall : symbol + +// async generator function yield inference +async function* asyncGenFuncYieldConstCall() { yield constCall; } +>asyncGenFuncYieldConstCall : () => AsyncIterableIterator +>yield constCall : any +>constCall : unique symbol + +async function* asyncGenFuncYieldLetCall() { yield letCall; } +>asyncGenFuncYieldLetCall : () => AsyncIterableIterator +>yield letCall : any +>letCall : symbol + +async function* asyncGenFuncYieldVarCall() { yield varCall; } +>asyncGenFuncYieldVarCall : () => AsyncIterableIterator +>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 +>Promise.resolve(constCall) : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>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(x: T): T; +>f : (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 : (x: T) => T +>s : unique symbol + +f(N.s); +>f(N.s) : symbol +>f : (x: T) => T +>N.s : unique symbol +>N : typeof N +>s : unique symbol + +f(N["s"]); +>f(N["s"]) : symbol +>f : (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; method3(): AsyncIterableIterator; method4(): IterableIterator; 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; method3(): AsyncIterableIterator; method4(): IterableIterator; 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 +>s : unique symbol + + async * method3() { yield s; }, +>method3 : () => AsyncIterableIterator +>yield s : any +>s : unique symbol + + * method4() { yield s; }, +>method4 : () => IterableIterator +>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 +>s : unique symbol + + async * method3() { yield s; } +>method3 : () => AsyncIterableIterator +>yield s : any +>s : unique symbol + + * method4() { yield s; } +>method4 : () => IterableIterator +>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(s); +>f(s) : unique symbol +>f : (x: T) => T +>s : unique symbol +>s : unique symbol + +f(N.s); +>f(N.s) : unique symbol +>f : (x: T) => T +>N.s : unique symbol +>N : typeof N +>s : unique symbol +>N.s : unique symbol +>N : typeof N +>s : unique symbol + +f(N["s"]); +>f(N["s"]) : unique symbol +>f : (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; +>method2 : () => Promise +>Promise : Promise +>s : unique symbol + + method3(): AsyncIterableIterator; +>method3 : () => AsyncIterableIterator +>AsyncIterableIterator : AsyncIterableIterator +>s : unique symbol + + method4(): IterableIterator; +>method4 : () => IterableIterator +>IterableIterator : IterableIterator +>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; method3(): AsyncIterableIterator; method4(): IterableIterator; 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 + + return s; // return type should not widen due to contextual type +>s : unique symbol + + }, + async * method3() { +>method3 : () => AsyncIterableIterator + + yield s; // yield type should not widen due to contextual type +>yield s : any +>s : unique symbol + + }, + * method4() { +>method4 : () => IterableIterator + + 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; } +} + diff --git a/tests/baselines/reference/uniqueSymbolsDeclarations.js b/tests/baselines/reference/uniqueSymbolsDeclarations.js new file mode 100644 index 0000000000000..6b52b2109772f --- /dev/null +++ b/tests/baselines/reference/uniqueSymbolsDeclarations.js @@ -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 { 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(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(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 { + static [s]: "a"; + static [N.s]: "b"; + + [s]: "a"; + [N.s]: "b"; +} + +// contextual types + +interface Context { + method1(): typeof s; + method2(): Promise; + method3(): AsyncIterableIterator; + method4(): IterableIterator; + 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; +declare function genFuncYieldLetCall(): IterableIterator; +declare function genFuncYieldVarCall(): IterableIterator; +declare function genFuncYieldConstCallWithTypeQuery(): IterableIterator; +declare function asyncFuncReturnConstCall(): Promise; +declare function asyncFuncReturnLetCall(): Promise; +declare function asyncFuncReturnVarCall(): Promise; +declare function asyncGenFuncYieldConstCall(): AsyncIterableIterator; +declare function asyncGenFuncYieldLetCall(): AsyncIterableIterator; +declare function asyncGenFuncYieldVarCall(): AsyncIterableIterator; +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; +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(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; + method3(): AsyncIterableIterator; + method4(): IterableIterator; + 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; + method3(): AsyncIterableIterator; + method4(): IterableIterator; + 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; + method3(): AsyncIterableIterator; + method4(): IterableIterator; + method5(p?: typeof s): typeof s; +} +declare const o4: Context; diff --git a/tests/baselines/reference/uniqueSymbolsDeclarations.symbols b/tests/baselines/reference/uniqueSymbolsDeclarations.symbols new file mode 100644 index 0000000000000..ff433aa19d071 --- /dev/null +++ b/tests/baselines/reference/uniqueSymbolsDeclarations.symbols @@ -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 { 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(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(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(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(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; +>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; +>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; +>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)) + } +}; diff --git a/tests/baselines/reference/uniqueSymbolsDeclarations.types b/tests/baselines/reference/uniqueSymbolsDeclarations.types new file mode 100644 index 0000000000000..c4975d497cc11 --- /dev/null +++ b/tests/baselines/reference/uniqueSymbolsDeclarations.types @@ -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 +>yield constCall : any +>constCall : unique symbol + +function* genFuncYieldLetCall() { yield letCall; } +>genFuncYieldLetCall : () => IterableIterator +>yield letCall : any +>letCall : symbol + +function* genFuncYieldVarCall() { yield varCall; } +>genFuncYieldVarCall : () => IterableIterator +>yield varCall : any +>varCall : symbol + +// generator function yield with return type query +function* genFuncYieldConstCallWithTypeQuery(): IterableIterator { yield constCall; } +>genFuncYieldConstCallWithTypeQuery : () => IterableIterator +>IterableIterator : IterableIterator +>constCall : unique symbol +>yield constCall : any +>constCall : unique symbol + +// async function return inference +async function asyncFuncReturnConstCall() { return constCall; } +>asyncFuncReturnConstCall : () => Promise +>constCall : unique symbol + +async function asyncFuncReturnLetCall() { return letCall; } +>asyncFuncReturnLetCall : () => Promise +>letCall : symbol + +async function asyncFuncReturnVarCall() { return varCall; } +>asyncFuncReturnVarCall : () => Promise +>varCall : symbol + +// async generator function yield inference +async function* asyncGenFuncYieldConstCall() { yield constCall; } +>asyncGenFuncYieldConstCall : () => AsyncIterableIterator +>yield constCall : any +>constCall : unique symbol + +async function* asyncGenFuncYieldLetCall() { yield letCall; } +>asyncGenFuncYieldLetCall : () => AsyncIterableIterator +>yield letCall : any +>letCall : symbol + +async function* asyncGenFuncYieldVarCall() { yield varCall; } +>asyncGenFuncYieldVarCall : () => AsyncIterableIterator +>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 +>Promise.resolve(constCall) : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>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(x: T): T; +>f : (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 : (x: T) => T +>s : unique symbol + +f(N.s); +>f(N.s) : symbol +>f : (x: T) => T +>N.s : unique symbol +>N : typeof N +>s : unique symbol + +f(N["s"]); +>f(N["s"]) : symbol +>f : (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; method3(): AsyncIterableIterator; method4(): IterableIterator; 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; method3(): AsyncIterableIterator; method4(): IterableIterator; 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 +>s : unique symbol + + async * method3() { yield s; }, +>method3 : () => AsyncIterableIterator +>yield s : any +>s : unique symbol + + * method4() { yield s; }, +>method4 : () => IterableIterator +>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 +>s : unique symbol + + async * method3() { yield s; } +>method3 : () => AsyncIterableIterator +>yield s : any +>s : unique symbol + + * method4() { yield s; } +>method4 : () => IterableIterator +>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(s); +>f(s) : unique symbol +>f : (x: T) => T +>s : unique symbol +>s : unique symbol + +f(N.s); +>f(N.s) : unique symbol +>f : (x: T) => T +>N.s : unique symbol +>N : typeof N +>s : unique symbol +>N.s : unique symbol +>N : typeof N +>s : unique symbol + +f(N["s"]); +>f(N["s"]) : unique symbol +>f : (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; +>method2 : () => Promise +>Promise : Promise +>s : unique symbol + + method3(): AsyncIterableIterator; +>method3 : () => AsyncIterableIterator +>AsyncIterableIterator : AsyncIterableIterator +>s : unique symbol + + method4(): IterableIterator; +>method4 : () => IterableIterator +>IterableIterator : IterableIterator +>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; method3(): AsyncIterableIterator; method4(): IterableIterator; 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 + + return s; // return type should not widen due to contextual type +>s : unique symbol + + }, + async * method3() { +>method3 : () => AsyncIterableIterator + + yield s; // yield type should not widen due to contextual type +>yield s : any +>s : unique symbol + + }, + * method4() { +>method4 : () => IterableIterator + + 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 + } +}; diff --git a/tests/baselines/reference/uniqueSymbolsDeclarationsErrors.errors.txt b/tests/baselines/reference/uniqueSymbolsDeclarationsErrors.errors.txt new file mode 100644 index 0000000000000..f7769db1077a6 --- /dev/null +++ b/tests/baselines/reference/uniqueSymbolsDeclarationsErrors.errors.txt @@ -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'. + } \ No newline at end of file diff --git a/tests/baselines/reference/uniqueSymbolsDeclarationsErrors.js b/tests/baselines/reference/uniqueSymbolsDeclarationsErrors.js new file mode 100644 index 0000000000000..a446a6712a4d0 --- /dev/null +++ b/tests/baselines/reference/uniqueSymbolsDeclarationsErrors.js @@ -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; diff --git a/tests/baselines/reference/uniqueSymbolsDeclarationsErrors.symbols b/tests/baselines/reference/uniqueSymbolsDeclarationsErrors.symbols new file mode 100644 index 0000000000000..45275c60a1712 --- /dev/null +++ b/tests/baselines/reference/uniqueSymbolsDeclarationsErrors.symbols @@ -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)) +} diff --git a/tests/baselines/reference/uniqueSymbolsDeclarationsErrors.types b/tests/baselines/reference/uniqueSymbolsDeclarationsErrors.types new file mode 100644 index 0000000000000..ff3101193b4f3 --- /dev/null +++ b/tests/baselines/reference/uniqueSymbolsDeclarationsErrors.types @@ -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 +} diff --git a/tests/baselines/reference/uniqueSymbolsErrors.errors.txt b/tests/baselines/reference/uniqueSymbolsErrors.errors.txt new file mode 100644 index 0000000000000..4f49e7b096c13 --- /dev/null +++ b/tests/baselines/reference/uniqueSymbolsErrors.errors.txt @@ -0,0 +1,269 @@ +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(2,41): error TS1005: 'symbol' expected. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(3,19): error TS1333: 'unique symbol' types may not be used on a variable declaration with a binding name. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(4,13): error TS1332: A variable whose type is a 'unique symbol' type must be 'const'. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(5,13): error TS1332: A variable whose type is a 'unique symbol' type must be 'const'. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(8,38): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(9,46): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(10,39): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(11,40): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(12,53): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(13,59): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(14,50): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(18,44): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(20,14): error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(21,5): error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(22,25): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(23,34): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(24,26): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(25,27): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(26,40): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(27,46): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(28,37): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(29,26): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(30,28): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(32,12): error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(33,38): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(34,47): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(35,39): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(36,40): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(37,53): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(38,59): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(39,50): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(40,39): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(41,41): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(46,5): error TS1330: A property of an interface or type literal whose type is a 'unique symbol' type must be 'readonly'. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(47,25): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(48,34): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(49,26): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(50,27): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(51,40): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(52,46): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(53,37): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(58,5): error TS1330: A property of an interface or type literal whose type is a 'unique symbol' type must be 'readonly'. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(59,25): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(60,34): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(61,26): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(62,27): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(63,40): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(64,46): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(65,37): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(69,21): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(70,52): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(71,49): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(74,44): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(75,34): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(76,34): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(79,51): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(82,29): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(82,45): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(83,36): error TS1335: 'unique symbol' types are not allowed here. +tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts(83,52): error TS1335: 'unique symbol' types are not allowed here. + + +==== tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts (60 errors) ==== + // declarations + declare const invalidUniqueType: unique number; + ~~~~~~ +!!! error TS1005: 'symbol' expected. + declare const {}: unique symbol; + ~~~~~~~~~~~~~ +!!! error TS1333: 'unique symbol' types may not be used on a variable declaration with a binding name. + declare let invalidLetType: unique symbol; + ~~~~~~~~~~~~~~ +!!! error TS1332: A variable whose type is a 'unique symbol' type must be 'const'. + declare var invalidVarType: unique symbol; + ~~~~~~~~~~~~~~ +!!! error TS1332: A variable whose type is a 'unique symbol' type must be 'const'. + + // function arguments and return types + declare function invalidArgType(arg: unique symbol): void; + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + declare function invalidRestArgType(...arg: (unique symbol)[]): void; + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + declare function invalidReturnType(): unique symbol; + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + declare function invalidThisType(this: unique symbol): void; + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + declare function invalidTypePredicate(n: any): n is unique symbol; + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + declare function invalidTypeParameterConstraint(): void; + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + declare function invalidTypeParameterDefault(): void; + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + + // classes + class InvalidClass { + constructor(invalidConstructorArgType: unique symbol) {} + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + + readonly invalidReadonlyPropertyType: unique symbol; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. + invalidPropertyType: unique symbol; + ~~~~~~~~~~~~~~~~~~~ +!!! error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. + invalidArgType(arg: unique symbol): void { return; } + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + invalidRestArgType(...args: (unique symbol)[]): void { return; } + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + invalidReturnType(): unique symbol { return; } + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + invalidThisType(this: unique symbol): void { return; } + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + invalidTypePredicate(n: any): n is unique symbol { return; } + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + invalidTypeParameterConstraint(): void { return; } + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + invalidTypeParameterDefault(): void { return; } + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + get invalidGetter(): unique symbol { return; } + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + set invalidSetter(arg: unique symbol) { return; } + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + + static invalidStaticPropertyType: unique symbol; + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. + static invalidStaticArgType(arg: unique symbol): void { return; } + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + static invalidStaticRestArgType(...args: (unique symbol)[]): void { return; } + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + static invalidStaticReturnType(): unique symbol { return; } + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + static invalidStaticThisType(this: unique symbol): void { return; } + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + static invalidStaticTypePredicate(n: any): n is unique symbol { return; } + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + static invalidStaticTypeParameterConstraint(): void { return; } + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + static invalidStaticTypeParameterDefault(): void { return; } + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + static get invalidStaticGetter(): unique symbol { return; } + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + static set invalidStaticSetter(arg: unique symbol) { return; } + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + } + + // interfaces + interface InvalidInterface { + invalidPropertyType: unique symbol; + ~~~~~~~~~~~~~~~~~~~ +!!! error TS1330: A property of an interface or type literal whose type is a 'unique symbol' type must be 'readonly'. + invalidArgType(arg: unique symbol): void; + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + invalidRestArgType(...args: (unique symbol)[]): void; + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + invalidReturnType(): unique symbol; + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + invalidThisType(this: unique symbol); + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + invalidTypePredicate(n: any): n is unique symbol + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + invalidTypeParameterConstraint(): void; + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + invalidTypeParameterDefault(): void; + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + } + + // type literals + type InvalidTypeLiteral = { + invalidPropertyType: unique symbol; + ~~~~~~~~~~~~~~~~~~~ +!!! error TS1330: A property of an interface or type literal whose type is a 'unique symbol' type must be 'readonly'. + invalidArgType(arg: unique symbol): void; + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + invalidRestArgType(...args: (unique symbol)[]): void; + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + invalidReturnType(): unique symbol; + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + invalidThisType(this: unique symbol); + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + invalidTypePredicate(n: any): n is unique symbol + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + invalidTypeParameterConstraint(): void; + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + invalidTypeParameterDefault(): void; + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + }; + + // type alias + type InvalidAlias = unique symbol; + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + type InvalidAliasTypeParameterConstraint = never; + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + type InvalidAliasTypeParameterDefault = never; + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + + // type references + declare const invalidTypeArgument: Promise; + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + declare const invalidArrayType: (unique symbol)[]; + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + declare const invalidTupleType: [unique symbol]; + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + + // mapped types + declare const invalidMappedType: { [P in string]: unique symbol }; + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + + // unions/intersection + declare const invalidUnion: unique symbol | unique symbol; + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + declare const invalidIntersection: unique symbol | unique symbol; + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + ~~~~~~~~~~~~~ +!!! error TS1335: 'unique symbol' types are not allowed here. + + + \ No newline at end of file diff --git a/tests/baselines/reference/uniqueSymbolsErrors.js b/tests/baselines/reference/uniqueSymbolsErrors.js new file mode 100644 index 0000000000000..f1e1bfaacdcde --- /dev/null +++ b/tests/baselines/reference/uniqueSymbolsErrors.js @@ -0,0 +1,111 @@ +//// [uniqueSymbolsErrors.ts] +// declarations +declare const invalidUniqueType: unique number; +declare const {}: unique symbol; +declare let invalidLetType: unique symbol; +declare var invalidVarType: unique symbol; + +// function arguments and return types +declare function invalidArgType(arg: unique symbol): void; +declare function invalidRestArgType(...arg: (unique symbol)[]): void; +declare function invalidReturnType(): unique symbol; +declare function invalidThisType(this: unique symbol): void; +declare function invalidTypePredicate(n: any): n is unique symbol; +declare function invalidTypeParameterConstraint(): void; +declare function invalidTypeParameterDefault(): void; + +// classes +class InvalidClass { + constructor(invalidConstructorArgType: unique symbol) {} + + readonly invalidReadonlyPropertyType: unique symbol; + invalidPropertyType: unique symbol; + invalidArgType(arg: unique symbol): void { return; } + invalidRestArgType(...args: (unique symbol)[]): void { return; } + invalidReturnType(): unique symbol { return; } + invalidThisType(this: unique symbol): void { return; } + invalidTypePredicate(n: any): n is unique symbol { return; } + invalidTypeParameterConstraint(): void { return; } + invalidTypeParameterDefault(): void { return; } + get invalidGetter(): unique symbol { return; } + set invalidSetter(arg: unique symbol) { return; } + + static invalidStaticPropertyType: unique symbol; + static invalidStaticArgType(arg: unique symbol): void { return; } + static invalidStaticRestArgType(...args: (unique symbol)[]): void { return; } + static invalidStaticReturnType(): unique symbol { return; } + static invalidStaticThisType(this: unique symbol): void { return; } + static invalidStaticTypePredicate(n: any): n is unique symbol { return; } + static invalidStaticTypeParameterConstraint(): void { return; } + static invalidStaticTypeParameterDefault(): void { return; } + static get invalidStaticGetter(): unique symbol { return; } + static set invalidStaticSetter(arg: unique symbol) { return; } +} + +// interfaces +interface InvalidInterface { + invalidPropertyType: unique symbol; + invalidArgType(arg: unique symbol): void; + invalidRestArgType(...args: (unique symbol)[]): void; + invalidReturnType(): unique symbol; + invalidThisType(this: unique symbol); + invalidTypePredicate(n: any): n is unique symbol + invalidTypeParameterConstraint(): void; + invalidTypeParameterDefault(): void; +} + +// type literals +type InvalidTypeLiteral = { + invalidPropertyType: unique symbol; + invalidArgType(arg: unique symbol): void; + invalidRestArgType(...args: (unique symbol)[]): void; + invalidReturnType(): unique symbol; + invalidThisType(this: unique symbol); + invalidTypePredicate(n: any): n is unique symbol + invalidTypeParameterConstraint(): void; + invalidTypeParameterDefault(): void; +}; + +// type alias +type InvalidAlias = unique symbol; +type InvalidAliasTypeParameterConstraint = never; +type InvalidAliasTypeParameterDefault = never; + +// type references +declare const invalidTypeArgument: Promise; +declare const invalidArrayType: (unique symbol)[]; +declare const invalidTupleType: [unique symbol]; + +// mapped types +declare const invalidMappedType: { [P in string]: unique symbol }; + +// unions/intersection +declare const invalidUnion: unique symbol | unique symbol; +declare const invalidIntersection: unique symbol | unique symbol; + + + + +//// [uniqueSymbolsErrors.js] +// classes +class InvalidClass { + constructor(invalidConstructorArgType) { } + invalidArgType(arg) { return; } + invalidRestArgType(...args) { return; } + invalidReturnType() { return; } + invalidThisType() { return; } + invalidTypePredicate(n) { return; } + invalidTypeParameterConstraint() { return; } + invalidTypeParameterDefault() { return; } + get invalidGetter() { return; } + set invalidSetter(arg) { return; } + static invalidStaticArgType(arg) { return; } + static invalidStaticRestArgType(...args) { return; } + static invalidStaticReturnType() { return; } + static invalidStaticThisType() { return; } + static invalidStaticTypePredicate(n) { return; } + static invalidStaticTypeParameterConstraint() { return; } + static invalidStaticTypeParameterDefault() { return; } + static get invalidStaticGetter() { return; } + static set invalidStaticSetter(arg) { return; } +} diff --git a/tests/baselines/reference/uniqueSymbolsErrors.symbols b/tests/baselines/reference/uniqueSymbolsErrors.symbols new file mode 100644 index 0000000000000..2788870bf7c7d --- /dev/null +++ b/tests/baselines/reference/uniqueSymbolsErrors.symbols @@ -0,0 +1,238 @@ +=== tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts === +// declarations +declare const invalidUniqueType: unique number; +>invalidUniqueType : Symbol(invalidUniqueType, Decl(uniqueSymbolsErrors.ts, 1, 13)) + +declare const {}: unique symbol; +declare let invalidLetType: unique symbol; +>invalidLetType : Symbol(invalidLetType, Decl(uniqueSymbolsErrors.ts, 3, 11)) + +declare var invalidVarType: unique symbol; +>invalidVarType : Symbol(invalidVarType, Decl(uniqueSymbolsErrors.ts, 4, 11)) + +// function arguments and return types +declare function invalidArgType(arg: unique symbol): void; +>invalidArgType : Symbol(invalidArgType, Decl(uniqueSymbolsErrors.ts, 4, 42)) +>arg : Symbol(arg, Decl(uniqueSymbolsErrors.ts, 7, 32)) + +declare function invalidRestArgType(...arg: (unique symbol)[]): void; +>invalidRestArgType : Symbol(invalidRestArgType, Decl(uniqueSymbolsErrors.ts, 7, 58)) +>arg : Symbol(arg, Decl(uniqueSymbolsErrors.ts, 8, 36)) + +declare function invalidReturnType(): unique symbol; +>invalidReturnType : Symbol(invalidReturnType, Decl(uniqueSymbolsErrors.ts, 8, 69)) + +declare function invalidThisType(this: unique symbol): void; +>invalidThisType : Symbol(invalidThisType, Decl(uniqueSymbolsErrors.ts, 9, 52)) +>this : Symbol(this, Decl(uniqueSymbolsErrors.ts, 10, 33)) + +declare function invalidTypePredicate(n: any): n is unique symbol; +>invalidTypePredicate : Symbol(invalidTypePredicate, Decl(uniqueSymbolsErrors.ts, 10, 60)) +>n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 11, 38)) +>n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 11, 38)) + +declare function invalidTypeParameterConstraint(): void; +>invalidTypeParameterConstraint : Symbol(invalidTypeParameterConstraint, Decl(uniqueSymbolsErrors.ts, 11, 66)) +>T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 12, 48)) + +declare function invalidTypeParameterDefault(): void; +>invalidTypeParameterDefault : Symbol(invalidTypeParameterDefault, Decl(uniqueSymbolsErrors.ts, 12, 81)) +>T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 13, 45)) + +// classes +class InvalidClass { +>InvalidClass : Symbol(InvalidClass, Decl(uniqueSymbolsErrors.ts, 13, 72)) + + constructor(invalidConstructorArgType: unique symbol) {} +>invalidConstructorArgType : Symbol(invalidConstructorArgType, Decl(uniqueSymbolsErrors.ts, 17, 16)) + + readonly invalidReadonlyPropertyType: unique symbol; +>invalidReadonlyPropertyType : Symbol(InvalidClass.invalidReadonlyPropertyType, Decl(uniqueSymbolsErrors.ts, 17, 60)) + + invalidPropertyType: unique symbol; +>invalidPropertyType : Symbol(InvalidClass.invalidPropertyType, Decl(uniqueSymbolsErrors.ts, 19, 56)) + + invalidArgType(arg: unique symbol): void { return; } +>invalidArgType : Symbol(InvalidClass.invalidArgType, Decl(uniqueSymbolsErrors.ts, 20, 39)) +>arg : Symbol(arg, Decl(uniqueSymbolsErrors.ts, 21, 19)) + + invalidRestArgType(...args: (unique symbol)[]): void { return; } +>invalidRestArgType : Symbol(InvalidClass.invalidRestArgType, Decl(uniqueSymbolsErrors.ts, 21, 56)) +>args : Symbol(args, Decl(uniqueSymbolsErrors.ts, 22, 23)) + + invalidReturnType(): unique symbol { return; } +>invalidReturnType : Symbol(InvalidClass.invalidReturnType, Decl(uniqueSymbolsErrors.ts, 22, 68)) + + invalidThisType(this: unique symbol): void { return; } +>invalidThisType : Symbol(InvalidClass.invalidThisType, Decl(uniqueSymbolsErrors.ts, 23, 50)) +>this : Symbol(this, Decl(uniqueSymbolsErrors.ts, 24, 20)) + + invalidTypePredicate(n: any): n is unique symbol { return; } +>invalidTypePredicate : Symbol(InvalidClass.invalidTypePredicate, Decl(uniqueSymbolsErrors.ts, 24, 58)) +>n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 25, 25)) +>n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 25, 25)) + + invalidTypeParameterConstraint(): void { return; } +>invalidTypeParameterConstraint : Symbol(InvalidClass.invalidTypeParameterConstraint, Decl(uniqueSymbolsErrors.ts, 25, 64)) +>T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 26, 35)) + + invalidTypeParameterDefault(): void { return; } +>invalidTypeParameterDefault : Symbol(InvalidClass.invalidTypeParameterDefault, Decl(uniqueSymbolsErrors.ts, 26, 79)) +>T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 27, 32)) + + get invalidGetter(): unique symbol { return; } +>invalidGetter : Symbol(InvalidClass.invalidGetter, Decl(uniqueSymbolsErrors.ts, 27, 70)) + + set invalidSetter(arg: unique symbol) { return; } +>invalidSetter : Symbol(InvalidClass.invalidSetter, Decl(uniqueSymbolsErrors.ts, 28, 50)) +>arg : Symbol(arg, Decl(uniqueSymbolsErrors.ts, 29, 22)) + + static invalidStaticPropertyType: unique symbol; +>invalidStaticPropertyType : Symbol(InvalidClass.invalidStaticPropertyType, Decl(uniqueSymbolsErrors.ts, 29, 53)) + + static invalidStaticArgType(arg: unique symbol): void { return; } +>invalidStaticArgType : Symbol(InvalidClass.invalidStaticArgType, Decl(uniqueSymbolsErrors.ts, 31, 52)) +>arg : Symbol(arg, Decl(uniqueSymbolsErrors.ts, 32, 32)) + + static invalidStaticRestArgType(...args: (unique symbol)[]): void { return; } +>invalidStaticRestArgType : Symbol(InvalidClass.invalidStaticRestArgType, Decl(uniqueSymbolsErrors.ts, 32, 69)) +>args : Symbol(args, Decl(uniqueSymbolsErrors.ts, 33, 36)) + + static invalidStaticReturnType(): unique symbol { return; } +>invalidStaticReturnType : Symbol(InvalidClass.invalidStaticReturnType, Decl(uniqueSymbolsErrors.ts, 33, 81)) + + static invalidStaticThisType(this: unique symbol): void { return; } +>invalidStaticThisType : Symbol(InvalidClass.invalidStaticThisType, Decl(uniqueSymbolsErrors.ts, 34, 63)) +>this : Symbol(this, Decl(uniqueSymbolsErrors.ts, 35, 33)) + + static invalidStaticTypePredicate(n: any): n is unique symbol { return; } +>invalidStaticTypePredicate : Symbol(InvalidClass.invalidStaticTypePredicate, Decl(uniqueSymbolsErrors.ts, 35, 71)) +>n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 36, 38)) +>n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 36, 38)) + + static invalidStaticTypeParameterConstraint(): void { return; } +>invalidStaticTypeParameterConstraint : Symbol(InvalidClass.invalidStaticTypeParameterConstraint, Decl(uniqueSymbolsErrors.ts, 36, 77)) +>T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 37, 48)) + + static invalidStaticTypeParameterDefault(): void { return; } +>invalidStaticTypeParameterDefault : Symbol(InvalidClass.invalidStaticTypeParameterDefault, Decl(uniqueSymbolsErrors.ts, 37, 92)) +>T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 38, 45)) + + static get invalidStaticGetter(): unique symbol { return; } +>invalidStaticGetter : Symbol(InvalidClass.invalidStaticGetter, Decl(uniqueSymbolsErrors.ts, 38, 83)) + + static set invalidStaticSetter(arg: unique symbol) { return; } +>invalidStaticSetter : Symbol(InvalidClass.invalidStaticSetter, Decl(uniqueSymbolsErrors.ts, 39, 63)) +>arg : Symbol(arg, Decl(uniqueSymbolsErrors.ts, 40, 35)) +} + +// interfaces +interface InvalidInterface { +>InvalidInterface : Symbol(InvalidInterface, Decl(uniqueSymbolsErrors.ts, 41, 1)) + + invalidPropertyType: unique symbol; +>invalidPropertyType : Symbol(InvalidInterface.invalidPropertyType, Decl(uniqueSymbolsErrors.ts, 44, 28)) + + invalidArgType(arg: unique symbol): void; +>invalidArgType : Symbol(InvalidInterface.invalidArgType, Decl(uniqueSymbolsErrors.ts, 45, 39)) +>arg : Symbol(arg, Decl(uniqueSymbolsErrors.ts, 46, 19)) + + invalidRestArgType(...args: (unique symbol)[]): void; +>invalidRestArgType : Symbol(InvalidInterface.invalidRestArgType, Decl(uniqueSymbolsErrors.ts, 46, 45)) +>args : Symbol(args, Decl(uniqueSymbolsErrors.ts, 47, 23)) + + invalidReturnType(): unique symbol; +>invalidReturnType : Symbol(InvalidInterface.invalidReturnType, Decl(uniqueSymbolsErrors.ts, 47, 57)) + + invalidThisType(this: unique symbol); +>invalidThisType : Symbol(InvalidInterface.invalidThisType, Decl(uniqueSymbolsErrors.ts, 48, 39)) +>this : Symbol(this, Decl(uniqueSymbolsErrors.ts, 49, 20)) + + invalidTypePredicate(n: any): n is unique symbol +>invalidTypePredicate : Symbol(InvalidInterface.invalidTypePredicate, Decl(uniqueSymbolsErrors.ts, 49, 41)) +>n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 50, 25)) +>n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 50, 25)) + + invalidTypeParameterConstraint(): void; +>invalidTypeParameterConstraint : Symbol(InvalidInterface.invalidTypeParameterConstraint, Decl(uniqueSymbolsErrors.ts, 50, 52)) +>T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 51, 35)) + + invalidTypeParameterDefault(): void; +>invalidTypeParameterDefault : Symbol(InvalidInterface.invalidTypeParameterDefault, Decl(uniqueSymbolsErrors.ts, 51, 68)) +>T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 52, 32)) +} + +// type literals +type InvalidTypeLiteral = { +>InvalidTypeLiteral : Symbol(InvalidTypeLiteral, Decl(uniqueSymbolsErrors.ts, 53, 1)) + + invalidPropertyType: unique symbol; +>invalidPropertyType : Symbol(invalidPropertyType, Decl(uniqueSymbolsErrors.ts, 56, 27)) + + invalidArgType(arg: unique symbol): void; +>invalidArgType : Symbol(invalidArgType, Decl(uniqueSymbolsErrors.ts, 57, 39)) +>arg : Symbol(arg, Decl(uniqueSymbolsErrors.ts, 58, 19)) + + invalidRestArgType(...args: (unique symbol)[]): void; +>invalidRestArgType : Symbol(invalidRestArgType, Decl(uniqueSymbolsErrors.ts, 58, 45)) +>args : Symbol(args, Decl(uniqueSymbolsErrors.ts, 59, 23)) + + invalidReturnType(): unique symbol; +>invalidReturnType : Symbol(invalidReturnType, Decl(uniqueSymbolsErrors.ts, 59, 57)) + + invalidThisType(this: unique symbol); +>invalidThisType : Symbol(invalidThisType, Decl(uniqueSymbolsErrors.ts, 60, 39)) +>this : Symbol(this, Decl(uniqueSymbolsErrors.ts, 61, 20)) + + invalidTypePredicate(n: any): n is unique symbol +>invalidTypePredicate : Symbol(invalidTypePredicate, Decl(uniqueSymbolsErrors.ts, 61, 41)) +>n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 62, 25)) +>n : Symbol(n, Decl(uniqueSymbolsErrors.ts, 62, 25)) + + invalidTypeParameterConstraint(): void; +>invalidTypeParameterConstraint : Symbol(invalidTypeParameterConstraint, Decl(uniqueSymbolsErrors.ts, 62, 52)) +>T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 63, 35)) + + invalidTypeParameterDefault(): void; +>invalidTypeParameterDefault : Symbol(invalidTypeParameterDefault, Decl(uniqueSymbolsErrors.ts, 63, 68)) +>T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 64, 32)) + +}; + +// type alias +type InvalidAlias = unique symbol; +>InvalidAlias : Symbol(InvalidAlias, Decl(uniqueSymbolsErrors.ts, 65, 2)) + +type InvalidAliasTypeParameterConstraint = never; +>InvalidAliasTypeParameterConstraint : Symbol(InvalidAliasTypeParameterConstraint, Decl(uniqueSymbolsErrors.ts, 68, 34)) +>T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 69, 41)) + +type InvalidAliasTypeParameterDefault = never; +>InvalidAliasTypeParameterDefault : Symbol(InvalidAliasTypeParameterDefault, Decl(uniqueSymbolsErrors.ts, 69, 74)) +>T : Symbol(T, Decl(uniqueSymbolsErrors.ts, 70, 38)) + +// type references +declare const invalidTypeArgument: Promise; +>invalidTypeArgument : Symbol(invalidTypeArgument, Decl(uniqueSymbolsErrors.ts, 73, 13)) +>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, --, --)) + +declare const invalidArrayType: (unique symbol)[]; +>invalidArrayType : Symbol(invalidArrayType, Decl(uniqueSymbolsErrors.ts, 74, 13)) + +declare const invalidTupleType: [unique symbol]; +>invalidTupleType : Symbol(invalidTupleType, Decl(uniqueSymbolsErrors.ts, 75, 13)) + +// mapped types +declare const invalidMappedType: { [P in string]: unique symbol }; +>invalidMappedType : Symbol(invalidMappedType, Decl(uniqueSymbolsErrors.ts, 78, 13)) +>P : Symbol(P, Decl(uniqueSymbolsErrors.ts, 78, 36)) + +// unions/intersection +declare const invalidUnion: unique symbol | unique symbol; +>invalidUnion : Symbol(invalidUnion, Decl(uniqueSymbolsErrors.ts, 81, 13)) + +declare const invalidIntersection: unique symbol | unique symbol; +>invalidIntersection : Symbol(invalidIntersection, Decl(uniqueSymbolsErrors.ts, 82, 13)) + + + diff --git a/tests/baselines/reference/uniqueSymbolsErrors.types b/tests/baselines/reference/uniqueSymbolsErrors.types new file mode 100644 index 0000000000000..20eda66b9ef8f --- /dev/null +++ b/tests/baselines/reference/uniqueSymbolsErrors.types @@ -0,0 +1,238 @@ +=== tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts === +// declarations +declare const invalidUniqueType: unique number; +>invalidUniqueType : any + +declare const {}: unique symbol; +declare let invalidLetType: unique symbol; +>invalidLetType : symbol + +declare var invalidVarType: unique symbol; +>invalidVarType : symbol + +// function arguments and return types +declare function invalidArgType(arg: unique symbol): void; +>invalidArgType : (arg: symbol) => void +>arg : symbol + +declare function invalidRestArgType(...arg: (unique symbol)[]): void; +>invalidRestArgType : (...arg: symbol[]) => void +>arg : symbol[] + +declare function invalidReturnType(): unique symbol; +>invalidReturnType : () => symbol + +declare function invalidThisType(this: unique symbol): void; +>invalidThisType : (this: symbol) => void +>this : symbol + +declare function invalidTypePredicate(n: any): n is unique symbol; +>invalidTypePredicate : (n: any) => n is symbol +>n : any +>n : any + +declare function invalidTypeParameterConstraint(): void; +>invalidTypeParameterConstraint : () => void +>T : T + +declare function invalidTypeParameterDefault(): void; +>invalidTypeParameterDefault : () => void +>T : T + +// classes +class InvalidClass { +>InvalidClass : InvalidClass + + constructor(invalidConstructorArgType: unique symbol) {} +>invalidConstructorArgType : symbol + + readonly invalidReadonlyPropertyType: unique symbol; +>invalidReadonlyPropertyType : symbol + + invalidPropertyType: unique symbol; +>invalidPropertyType : symbol + + invalidArgType(arg: unique symbol): void { return; } +>invalidArgType : (arg: symbol) => void +>arg : symbol + + invalidRestArgType(...args: (unique symbol)[]): void { return; } +>invalidRestArgType : (...args: symbol[]) => void +>args : symbol[] + + invalidReturnType(): unique symbol { return; } +>invalidReturnType : () => symbol + + invalidThisType(this: unique symbol): void { return; } +>invalidThisType : (this: symbol) => void +>this : symbol + + invalidTypePredicate(n: any): n is unique symbol { return; } +>invalidTypePredicate : (n: any) => n is symbol +>n : any +>n : any + + invalidTypeParameterConstraint(): void { return; } +>invalidTypeParameterConstraint : () => void +>T : T + + invalidTypeParameterDefault(): void { return; } +>invalidTypeParameterDefault : () => void +>T : T + + get invalidGetter(): unique symbol { return; } +>invalidGetter : symbol + + set invalidSetter(arg: unique symbol) { return; } +>invalidSetter : symbol +>arg : symbol + + static invalidStaticPropertyType: unique symbol; +>invalidStaticPropertyType : symbol + + static invalidStaticArgType(arg: unique symbol): void { return; } +>invalidStaticArgType : (arg: symbol) => void +>arg : symbol + + static invalidStaticRestArgType(...args: (unique symbol)[]): void { return; } +>invalidStaticRestArgType : (...args: symbol[]) => void +>args : symbol[] + + static invalidStaticReturnType(): unique symbol { return; } +>invalidStaticReturnType : () => symbol + + static invalidStaticThisType(this: unique symbol): void { return; } +>invalidStaticThisType : (this: symbol) => void +>this : symbol + + static invalidStaticTypePredicate(n: any): n is unique symbol { return; } +>invalidStaticTypePredicate : (n: any) => n is symbol +>n : any +>n : any + + static invalidStaticTypeParameterConstraint(): void { return; } +>invalidStaticTypeParameterConstraint : () => void +>T : T + + static invalidStaticTypeParameterDefault(): void { return; } +>invalidStaticTypeParameterDefault : () => void +>T : T + + static get invalidStaticGetter(): unique symbol { return; } +>invalidStaticGetter : symbol + + static set invalidStaticSetter(arg: unique symbol) { return; } +>invalidStaticSetter : symbol +>arg : symbol +} + +// interfaces +interface InvalidInterface { +>InvalidInterface : InvalidInterface + + invalidPropertyType: unique symbol; +>invalidPropertyType : symbol + + invalidArgType(arg: unique symbol): void; +>invalidArgType : (arg: symbol) => void +>arg : symbol + + invalidRestArgType(...args: (unique symbol)[]): void; +>invalidRestArgType : (...args: symbol[]) => void +>args : symbol[] + + invalidReturnType(): unique symbol; +>invalidReturnType : () => symbol + + invalidThisType(this: unique symbol); +>invalidThisType : (this: symbol) => any +>this : symbol + + invalidTypePredicate(n: any): n is unique symbol +>invalidTypePredicate : (n: any) => n is symbol +>n : any +>n : any + + invalidTypeParameterConstraint(): void; +>invalidTypeParameterConstraint : () => void +>T : T + + invalidTypeParameterDefault(): void; +>invalidTypeParameterDefault : () => void +>T : T +} + +// type literals +type InvalidTypeLiteral = { +>InvalidTypeLiteral : InvalidTypeLiteral + + invalidPropertyType: unique symbol; +>invalidPropertyType : symbol + + invalidArgType(arg: unique symbol): void; +>invalidArgType : (arg: symbol) => void +>arg : symbol + + invalidRestArgType(...args: (unique symbol)[]): void; +>invalidRestArgType : (...args: symbol[]) => void +>args : symbol[] + + invalidReturnType(): unique symbol; +>invalidReturnType : () => symbol + + invalidThisType(this: unique symbol); +>invalidThisType : (this: symbol) => any +>this : symbol + + invalidTypePredicate(n: any): n is unique symbol +>invalidTypePredicate : (n: any) => n is symbol +>n : any +>n : any + + invalidTypeParameterConstraint(): void; +>invalidTypeParameterConstraint : () => void +>T : T + + invalidTypeParameterDefault(): void; +>invalidTypeParameterDefault : () => void +>T : T + +}; + +// type alias +type InvalidAlias = unique symbol; +>InvalidAlias : symbol + +type InvalidAliasTypeParameterConstraint = never; +>InvalidAliasTypeParameterConstraint : never +>T : T + +type InvalidAliasTypeParameterDefault = never; +>InvalidAliasTypeParameterDefault : never +>T : T + +// type references +declare const invalidTypeArgument: Promise; +>invalidTypeArgument : Promise +>Promise : Promise + +declare const invalidArrayType: (unique symbol)[]; +>invalidArrayType : symbol[] + +declare const invalidTupleType: [unique symbol]; +>invalidTupleType : [symbol] + +// mapped types +declare const invalidMappedType: { [P in string]: unique symbol }; +>invalidMappedType : { [x: string]: symbol; } +>P : P + +// unions/intersection +declare const invalidUnion: unique symbol | unique symbol; +>invalidUnion : symbol + +declare const invalidIntersection: unique symbol | unique symbol; +>invalidIntersection : symbol + + + diff --git a/tests/baselines/reference/user/chrome-devtools-frontend.log b/tests/baselines/reference/user/chrome-devtools-frontend.log new file mode 100644 index 0000000000000..ffb5e7c0b6cbf --- /dev/null +++ b/tests/baselines/reference/user/chrome-devtools-frontend.log @@ -0,0 +1,250 @@ +Exit Code: 1 +Standard output: +node_modules/chrome-devtools-frontend/front_end/Runtime.js(398,24): error TS1138: Parameter declaration expected. +node_modules/chrome-devtools-frontend/front_end/Runtime.js(527,55): error TS1005: '{' expected. +node_modules/chrome-devtools-frontend/front_end/accessibility/AXBreadcrumbsPane.js(314,15): error TS1005: '{' expected. +node_modules/chrome-devtools-frontend/front_end/animation/AnimationModel.js(810,65): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/audits/AuditRules.js(488,2): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/audits/AuditsPanel.js(513,28): error TS1005: '>' expected. +node_modules/chrome-devtools-frontend/front_end/audits2/Audits2Panel.js(531,97): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/category-renderer.js(510,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/crc-details-renderer.js(188,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/crc-details-renderer.js(197,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/crc-details-renderer.js(220,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/details-renderer.js(294,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/details-renderer.js(302,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/details-renderer.js(311,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/details-renderer.js(321,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/details-renderer.js(330,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/details-renderer.js(339,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/details-renderer.js(349,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/details-renderer.js(358,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/details-renderer.js(366,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/details-renderer.js(374,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/report-renderer.js(155,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/report-renderer.js(179,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/report-renderer.js(191,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/audits2/lighthouse/renderer/report-renderer.js(199,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/audits2_worker/Audits2Service.js(33,31): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/bindings/BlackboxManager.js(22,21): error TS1005: '>' expected. +node_modules/chrome-devtools-frontend/front_end/bindings/FileUtils.js(194,23): error TS1005: '>' expected. +node_modules/chrome-devtools-frontend/front_end/bindings/TempFile.js(185,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/changes/ChangesHighlighter.js(9,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/changes/ChangesHighlighter.js(169,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/changes/ChangesView.js(295,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/color_picker/Spectrum.js(836,77): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/common/ModuleExtensionInterfaces.js(39,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/common/Object.js(103,14): error TS1110: Type expected. +node_modules/chrome-devtools-frontend/front_end/common/Object.js(118,2): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/common/Object.js(123,2): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/common/Object.js(133,2): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/common/Object.js(178,14): error TS1110: Type expected. +node_modules/chrome-devtools-frontend/front_end/common/Throttler.js(92,34): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/components/DOMBreakpointsSidebarPane.js(233,106): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/components/Linkifier.js(621,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/components/Linkifier.js(636,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/components/Linkifier.js(655,2): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/console/ConsoleView.js(1521,2): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/console_test_runner/ConsoleTestRunner.js(10,73): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/cookie_table/CookiesTable.js(39,36): error TS1138: Parameter declaration expected. +node_modules/chrome-devtools-frontend/front_end/coverage/CoverageDecorationManager.js(7,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/coverage/CoverageDecorationManager.js(258,34): error TS1005: '{' expected. +node_modules/chrome-devtools-frontend/front_end/coverage/CoverageModel.js(5,72): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/coverage/CoverageModel.js(8,57): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/coverage/CoverageView.js(231,59): error TS1005: '{' expected. +node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(1200,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/devices/DevicesView.js(890,194): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/devices/DevicesView.js(893,105): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/devtools_compatibility.js(20,34): error TS1005: '>' expected. +node_modules/chrome-devtools-frontend/front_end/devtools_compatibility.js(56,63): error TS1005: '>' expected. +node_modules/chrome-devtools-frontend/front_end/diff/Diff.js(91,70): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js(1651,100): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeOutline.js(1432,53): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(2964,107): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/emulation/EmulatedDevices.js(45,18): error TS1110: Type expected. +node_modules/chrome-devtools-frontend/front_end/emulation/EmulatedDevices.js(333,90): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/emulation/EmulatedDevices.js(336,99): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/event_listeners/EventListenersUtils.js(4,95): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/event_listeners/EventListenersUtils.js(7,106): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/event_listeners/EventListenersUtils.js(286,116): error TS1005: '>' expected. +node_modules/chrome-devtools-frontend/front_end/event_listeners/EventListenersUtils.js(286,126): error TS1005: ';' expected. +node_modules/chrome-devtools-frontend/front_end/event_listeners/EventListenersView.js(6,2): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/extensions/ExtensionAPI.js(153,19): error TS1110: Type expected. +node_modules/chrome-devtools-frontend/front_end/extensions/ExtensionServer.js(1065,2): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/externs.js(219,83): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/externs.js(327,75): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/externs.js(329,183): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/externs.js(331,154): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/externs.js(333,41): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/externs.js(335,49): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/externs.js(337,68): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/externs.js(339,65): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/externs.js(341,31): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/externs.js(345,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/externs.js(417,14): error TS1110: Type expected. +node_modules/chrome-devtools-frontend/front_end/externs.js(418,14): error TS1110: Type expected. +node_modules/chrome-devtools-frontend/front_end/externs.js(453,15): error TS1110: Type expected. +node_modules/chrome-devtools-frontend/front_end/externs.js(464,15): error TS1110: Type expected. +node_modules/chrome-devtools-frontend/front_end/externs.js(500,15): error TS1110: Type expected. +node_modules/chrome-devtools-frontend/front_end/externs.js(511,15): error TS1110: Type expected. +node_modules/chrome-devtools-frontend/front_end/externs.js(550,130): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/externs.js(553,126): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/externs.js(697,2): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/externs.js(702,2): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/externs.js(707,2): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/formatter/FormatterWorkerPool.js(264,70): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/formatter/FormatterWorkerPool.js(267,93): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/formatter/FormatterWorkerPool.js(285,2): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/formatter/FormatterWorkerPool.js(322,2): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/formatter/FormatterWorkerPool.js(327,2): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/formatter_worker/FormatterWorker.js(32,30): error TS1138: Parameter declaration expected. +node_modules/chrome-devtools-frontend/front_end/formatter_worker/FormatterWorker.js(58,26): error TS1005: '{' expected. +node_modules/chrome-devtools-frontend/front_end/formatter_worker/RelaxedJSONParser.js(180,2): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(1370,4): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(2118,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/help/Help.js(52,65): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/help/Help.js(57,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/host/InspectorFrontendHostAPI.js(16,4): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/host/InspectorFrontendHostAPI.js(23,4): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/inline_editor/BezierEditor.js(270,103): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/layer_viewer/Layers3DView.js(68,15): error TS1005: '{' expected. +node_modules/chrome-devtools-frontend/front_end/layer_viewer/Layers3DView.js(761,67): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/mobile_throttling/ThrottlingPresets.js(14,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/mobile_throttling/ThrottlingPresets.js(56,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/mobile_throttling/ThrottlingPresets.js(68,80): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/mobile_throttling/ThrottlingPresets.js(71,118): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/mobile_throttling/ThrottlingPresets.js(74,93): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/network/EventSourceMessagesView.js(104,29): error TS1005: '>' expected. +node_modules/chrome-devtools-frontend/front_end/network/NetworkDataGridNode.js(273,4): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/network/NetworkDataGridNode.js(279,96): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/network/NetworkLogView.js(1797,55): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/network/NetworkLogViewColumns.js(600,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/network/NetworkOverview.js(278,45): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/network/NetworkWaterfallColumn.js(610,113): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/network/NetworkWaterfallColumn.js(613,54): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/network/RequestTimingView.js(376,83): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/network_log/HAREntry.js(316,4): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/network_log/NetworkLog.js(461,95): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/network_log/NetworkLog.js(470,133): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/object_ui/CustomPreviewComponent.js(140,16): error TS1110: Type expected. +node_modules/chrome-devtools-frontend/front_end/object_ui/CustomPreviewComponent.js(141,16): error TS1110: Type expected. +node_modules/chrome-devtools-frontend/front_end/object_ui/JavaScriptAutocomplete.js(7,64): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/perf_ui/FlameChart.js(907,17): error TS1005: '{' expected. +node_modules/chrome-devtools-frontend/front_end/perf_ui/FlameChart.js(1167,15): error TS1005: '{' expected. +node_modules/chrome-devtools-frontend/front_end/perf_ui/FlameChart.js(1387,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/perf_ui/FlameChart.js(1397,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/perf_ui/TimelineGrid.js(266,89): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/persistence/IsolatedFileSystemManager.js(40,29): error TS1005: '>' expected. +node_modules/chrome-devtools-frontend/front_end/persistence/IsolatedFileSystemManager.js(319,97): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/persistence/IsolatedFileSystemManager.js(322,88): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/persistence/Persistence.js(21,51): error TS1005: '>' expected. +node_modules/chrome-devtools-frontend/front_end/persistence/Persistence.js(58,23): error TS1138: Parameter declaration expected. +node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(30,58): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(835,29): error TS1005: '>' expected. +node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(954,29): error TS1005: '>' expected. +node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(1424,31): error TS1110: Type expected. +node_modules/chrome-devtools-frontend/front_end/product_registry/BadgePool.js(11,31): error TS1005: '>' expected. +node_modules/chrome-devtools-frontend/front_end/product_registry/ProductRegistry.js(71,47): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotProxy.js(43,29): error TS1005: '>' expected. +node_modules/chrome-devtools-frontend/front_end/protocol/InspectorBackend.js(31,23): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/protocol/InspectorBackend.js(201,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/protocol/InspectorBackend.js(209,2): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/quick_open/QuickOpen.js(9,29): error TS1005: '>' expected. +node_modules/chrome-devtools-frontend/front_end/resources/IndexedDBModel.js(52,4): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/sdk/CPUProfilerModel.js(173,183): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/sdk/CSSModel.js(752,112): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/sdk/CSSModel.js(755,136): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/sdk/DOMDebuggerModel.js(275,55): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/sdk/DOMModel.js(943,66): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/sdk/DebuggerModel.js(847,78): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/sdk/DebuggerModel.js(907,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/sdk/DebuggerModel.js(954,14): error TS1110: Type expected. +node_modules/chrome-devtools-frontend/front_end/sdk/DebuggerModel.js(979,14): error TS1110: Type expected. +node_modules/chrome-devtools-frontend/front_end/sdk/LayerTreeBase.js(8,1): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/sdk/NetworkManager.js(182,71): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/sdk/NetworkManager.js(198,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/sdk/NetworkManager.js(238,48): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/sdk/NetworkManager.js(1197,86): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/sdk/NetworkRequest.js(1117,47): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/sdk/NetworkRequest.js(1127,122): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/sdk/NetworkRequest.js(1130,82): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/sdk/NetworkRequest.js(1133,70): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/sdk/PaintProfiler.js(72,2): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/sdk/PaintProfiler.js(126,2): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/sdk/RemoteObject.js(32,2): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/sdk/RemoteObject.js(333,39): error TS1110: Type expected. +node_modules/chrome-devtools-frontend/front_end/sdk/RemoteObject.js(342,39): error TS1110: Type expected. +node_modules/chrome-devtools-frontend/front_end/sdk/RemoteObject.js(369,39): error TS1110: Type expected. +node_modules/chrome-devtools-frontend/front_end/sdk/RemoteObject.js(378,39): error TS1110: Type expected. +node_modules/chrome-devtools-frontend/front_end/sdk/RemoteObject.js(703,39): error TS1110: Type expected. +node_modules/chrome-devtools-frontend/front_end/sdk/RemoteObject.js(1135,39): error TS1110: Type expected. +node_modules/chrome-devtools-frontend/front_end/sdk/RuntimeModel.js(484,81): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/sdk/RuntimeModel.js(488,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/sdk/RuntimeModel.js(495,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/sdk/RuntimeModel.js(506,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/sdk/RuntimeModel.js(514,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/sdk/RuntimeModel.js(522,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/sdk/Target.js(171,20): error TS1005: '>' expected. +node_modules/chrome-devtools-frontend/front_end/sdk/Target.js(271,17): error TS1005: '>' expected. +node_modules/chrome-devtools-frontend/front_end/sdk/TargetManager.js(17,21): error TS1005: '>' expected. +node_modules/chrome-devtools-frontend/front_end/sdk/TracingManager.js(118,2): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/security/SecurityPanel.js(339,23): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/security/SecurityPanel.js(344,2): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/services/ServiceManager.js(65,29): error TS1005: '>' expected. +node_modules/chrome-devtools-frontend/front_end/services/ServiceManager.js(166,29): error TS1005: '>' expected. +node_modules/chrome-devtools-frontend/front_end/source_frame/SourcesTextEditor.js(593,52): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/sources/CallStackSidebarPane.js(372,65): error TS1138: Parameter declaration expected. +node_modules/chrome-devtools-frontend/front_end/sources/CallStackSidebarPane.js(384,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/sources/EventListenerBreakpointsSidebarPane.js(125,64): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/sources/SourceMapNamesResolver.js(525,39): error TS1110: Type expected. +node_modules/chrome-devtools-frontend/front_end/sources/SourceMapNamesResolver.js(535,39): error TS1110: Type expected. +node_modules/chrome-devtools-frontend/front_end/sources/SourcesView.js(131,65): error TS1138: Parameter declaration expected. +node_modules/chrome-devtools-frontend/front_end/test_runner/TestRunner.js(99,19): error TS1005: '>' expected. +node_modules/chrome-devtools-frontend/front_end/test_runner/TestRunner.js(642,2): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/test_runner/TestRunner.js(944,19): error TS1005: '>' expected. +node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(1677,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorUtils.js(125,32): error TS1138: Parameter declaration expected. +node_modules/chrome-devtools-frontend/front_end/text_utils/Text.js(121,59): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/text_utils/TextUtils.js(242,112): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/text_utils/TextUtils.js(340,32): error TS1138: Parameter declaration expected. +node_modules/chrome-devtools-frontend/front_end/timeline/PerformanceMonitor.js(394,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/timeline/PerformanceMonitor.js(406,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/timeline/TimelineController.js(283,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/timeline/TimelineDetailsView.js(34,15): error TS1005: '{' expected. +node_modules/chrome-devtools-frontend/front_end/timeline/TimelineHistoryManager.js(255,86): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/timeline/TimelinePanel.js(1087,106): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/timeline/TimelineUIUtils.js(2113,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/timeline_model/TimelineModel.js(1246,99): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/timeline_model/TimelineModel.js(1420,82): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/timeline_model/TimelineModelFilter.js(43,22): error TS1005: '{' expected. +node_modules/chrome-devtools-frontend/front_end/timeline_model/TracingLayerTree.js(17,1): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/timeline_model/TracingLayerTree.js(26,1): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/ui/Context.js(14,33): error TS1110: Type expected. +node_modules/chrome-devtools-frontend/front_end/ui/Context.js(31,33): error TS1110: Type expected. +node_modules/chrome-devtools-frontend/front_end/ui/Context.js(49,38): error TS1110: Type expected. +node_modules/chrome-devtools-frontend/front_end/ui/Context.js(63,38): error TS1110: Type expected. +node_modules/chrome-devtools-frontend/front_end/ui/Context.js(77,33): error TS1110: Type expected. +node_modules/chrome-devtools-frontend/front_end/ui/Context.js(86,21): error TS1005: '>' expected. +node_modules/chrome-devtools-frontend/front_end/ui/FilterBar.js(374,73): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/ui/Icon.js(104,85): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/ui/Icon.js(107,73): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/ui/InplaceEditor.js(184,2): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/ui/KeyboardShortcut.js(215,73): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/ui/KeyboardShortcut.js(288,45): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/ui/ListWidget.js(300,23): error TS1005: '>' expected. +node_modules/chrome-devtools-frontend/front_end/ui/ListWidget.js(324,34): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/ui/ListWidget.js(324,35): error TS1138: Parameter declaration expected. +node_modules/chrome-devtools-frontend/front_end/ui/ListWidget.js(341,34): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/ui/ListWidget.js(341,35): error TS1138: Parameter declaration expected. +node_modules/chrome-devtools-frontend/front_end/ui/Popover.js(253,113): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/ui/SplitWidget.js(907,49): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/ui/SuggestBox.js(393,2): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/ui/SuggestBox.js(398,2): error TS1003: Identifier expected. +node_modules/chrome-devtools-frontend/front_end/ui/TextEditor.js(91,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/ui/TextEditor.js(105,2): error TS1131: Property or signature expected. +node_modules/chrome-devtools-frontend/front_end/workspace/FileManager.js(37,29): error TS1005: '>' expected. +node_modules/chrome-devtools-frontend/front_end/workspace/SearchConfig.js(176,55): error TS1003: Identifier expected. + + + +Standard error: diff --git a/tests/cases/compiler/dynamicNames.ts b/tests/cases/compiler/dynamicNames.ts new file mode 100644 index 0000000000000..9562685b08f7a --- /dev/null +++ b/tests/cases/compiler/dynamicNames.ts @@ -0,0 +1,153 @@ +// @target: esnext +// @lib: esnext +// @module: commonjs +// @declaration: true +// @filename: module.ts +export const c0 = "a"; +export const c1 = 1; +export const s0 = Symbol(); +export interface T0 { + [c0]: number; + [c1]: string; + [s0]: boolean; +} +export declare class T1 implements T2 { + [c0]: number; + [c1]: string; + [s0]: boolean; +} +export declare class T2 extends T1 { +} +export declare type T3 = { + [c0]: number; + [c1]: string; + [s0]: boolean; +}; + +// @filename: main.ts +import { c0, c1, s0, T0, T1, T2, T3 } from "./module"; +import * as M from "./module"; + +namespace N { + export const c2 = "a"; + export const c3 = 1; + export const s1: typeof s0 = s0; + + export interface T4 { + [N.c2]: number; + [N.c3]: string; + [N.s1]: boolean; + } + export declare class T5 implements T4 { + [N.c2]: number; + [N.c3]: string; + [N.s1]: boolean; + } + export declare class T6 extends T5 { + } + export declare type T7 = { + [N.c2]: number; + [N.c3]: string; + [N.s1]: boolean; + }; +} + +export const c4 = "a"; +export const c5 = 1; +export const s2: typeof s0 = s0; + +interface T8 { + [c4]: number; + [c5]: string; + [s2]: boolean; +} +declare class T9 implements T8 { + [c4]: number; + [c5]: string; + [s2]: boolean; +} +declare class T10 extends T9 { +} +declare type T11 = { + [c4]: number; + [c5]: string; + [s2]: boolean; +}; + +interface T12 { + a: number; + 1: string; + [s2]: boolean; +} +declare class T13 implements T2 { + a: number; + 1: string; + [s2]: boolean; +} +declare class T14 extends T13 { +} +declare type T15 = { + a: number; + 1: string; + [s2]: boolean; +}; + +declare class C { + static a: number; + static 1: string; + static [s2]: boolean; +} + +let t0: T0; +let t1: T1; +let t2: T2; +let t3: T3; +let t0_1: M.T0; +let t1_1: M.T1; +let t2_1: M.T2; +let t3_1: M.T3; +let t4: N.T4; +let t5: N.T5; +let t6: N.T6; +let t7: N.T7; +let t8: T8; +let t9: T9; +let t10: T10; +let t11: T11; +let t12: T12; +let t13: T13; +let t14: T14; +let t15: T15; + +// assignability +t0 = t1, t0 = t2, t0 = t3, t1 = t0, t1 = t2, t1 = t3, t2 = t0, t2 = t1, t2 = t3, t3 = t0, t3 = t1, t3 = t2; +t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4, t7 = t5, t7 = t6; +t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0, t13 = t0, t14 = t0, t15 = t0; +t0 = C; // static side + +// object literals +export const o1 = { + [c4]: 1, + [c5]: "a", + [s2]: true +}; + +// check element access types +export const o1_c4 = o1[c4]; +export const o1_c5 = o1[c5]; +export const o1_s2 = o1[s2]; + +export const o2: T0 = o1; + +// recursive declarations +declare const rI: RI; +interface RI { + x: "a"; + [rI.x]: "b"; +} + +declare const rC: RC; +declare class RC { + x: "a"; + [rC.x]: "b"; +} \ No newline at end of file diff --git a/tests/cases/compiler/dynamicNamesErrors.ts b/tests/cases/compiler/dynamicNamesErrors.ts new file mode 100644 index 0000000000000..daeb5cb600b93 --- /dev/null +++ b/tests/cases/compiler/dynamicNamesErrors.ts @@ -0,0 +1,62 @@ +// @target: esnext +// @module: commonjs +// @declaration: true +const c0 = "1"; +const c1 = 1; + +interface T0 { + [c0]: number; + 1: number; +} + +interface T1 { + [c0]: number; +} + +interface T2 { + [c0]: string; +} + +interface T3 { + [c0]: number; + [c1]: string; +} + +let t1: T1; +let t2: T2; +t1 = t2; +t2 = t1; + +const x = Symbol(); +const y = Symbol(); +const z = Symbol(); +const w = Symbol(); + +export interface InterfaceMemberVisibility { + [x]: number; + [y](): number; +} + +export class ClassMemberVisibility { + static [x]: number; + static [y](): number { return 0; } + static get [z](): number { return 0; } + static set [w](value: number) { } + + [x]: number; + [y](): number { return 0; } + get [z](): number { return 0; } + set [w](value: number) { } +} + +export type ObjectTypeVisibility = { + [x]: number; + [y](): number; +}; + +export const ObjectLiteralVisibility = { + [x]: 0, + [y](): number { return 0; }, + get [z](): number { return 0; }, + set [w](value: number) { }, +}; \ No newline at end of file diff --git a/tests/cases/compiler/exhaustiveSwitchImplicitReturn.ts b/tests/cases/compiler/exhaustiveSwitchImplicitReturn.ts new file mode 100644 index 0000000000000..b87baffdaf95a --- /dev/null +++ b/tests/cases/compiler/exhaustiveSwitchImplicitReturn.ts @@ -0,0 +1,42 @@ +// @noImplicitReturns: true + +function foo1(bar: "a"): number { + switch(bar) { + case "a": + return 1; + } +} + +function foo2(bar: "a"): number { + switch(bar) { + case "a": + return 1; + } + + let unusedVariable; +} + +function foo3(bar: "a"): number { + switch(bar) { + case "a": + return 1; + } + + function neverCalled() {} +} + +function foo4(bar: "a"): number { + switch(bar) { + case "a": + return 1; + } + + foo3(bar); +} + +function foo5(bar: "a" | "b"): number { + switch(bar) { + case "a": + return 1; + } +} diff --git a/tests/cases/compiler/inferObjectTypeFromStringLiteralToKeyof.ts b/tests/cases/compiler/inferObjectTypeFromStringLiteralToKeyof.ts new file mode 100644 index 0000000000000..86acbf93a70e8 --- /dev/null +++ b/tests/cases/compiler/inferObjectTypeFromStringLiteralToKeyof.ts @@ -0,0 +1,3 @@ +declare function inference(target: T, name: keyof T): void; +declare var two: "a" | "d"; +inference({ a: 1, b: 2, c: 3, d(n) { return n } }, two); diff --git a/tests/cases/compiler/jsFileCompilationRestParamJsDocFunction.ts b/tests/cases/compiler/jsFileCompilationRestParamJsDocFunction.ts index 03ad2d1b2ff9b..3588a7399481a 100644 --- a/tests/cases/compiler/jsFileCompilationRestParamJsDocFunction.ts +++ b/tests/cases/compiler/jsFileCompilationRestParamJsDocFunction.ts @@ -13,7 +13,7 @@ * @param {...*} args The arguments to invoke `func` with. * @returns {*} Returns the result of `func`. */ -function apply(func, thisArg, args) { +function apply(func, thisArg, ...args) { var length = args.length; switch (length) { case 0: return func.call(thisArg); diff --git a/tests/cases/compiler/jsdocRestParameter.ts b/tests/cases/compiler/jsdocRestParameter.ts new file mode 100644 index 0000000000000..e67ce1faafc0a --- /dev/null +++ b/tests/cases/compiler/jsdocRestParameter.ts @@ -0,0 +1,15 @@ +// @allowJs: true +// @checkJs: true +// @strict: true +// @noEmit: true + +// @Filename: /a.js +/** @param {...number} a */ +function f(a) { + a; // number | undefined + // Ideally this would be a number. But currently checker.ts has only one `argumentsSymbol`, so it's `any`. + arguments[0]; +} +f([1, 2]); // Error +f(1, "2"); // Error +f(1, 2); diff --git a/tests/cases/compiler/jsdocRestParameter_es6.ts b/tests/cases/compiler/jsdocRestParameter_es6.ts new file mode 100644 index 0000000000000..0a4db35c998db --- /dev/null +++ b/tests/cases/compiler/jsdocRestParameter_es6.ts @@ -0,0 +1,10 @@ +// @allowJs: true +// @checkJs: true +// @strict: true +// @noEmit: true + +// @Filename: /a.js +/** @param {...number} a */ +function f(...a) { + a; // number[] +} diff --git a/tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts b/tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts index 9151f52f00d73..abf445a700eb9 100644 --- a/tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts +++ b/tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts @@ -18,13 +18,9 @@ prefix("a", ...ns) rest("d", ...ns) -// this covers the arguments case +// extra arguments normal("g", ...ns) -normal("h", ...mixed) -normal("i", ...tuple) thunk(...ns) -thunk(...mixed) -thunk(...tuple) // bad all(...mixed) diff --git a/tests/cases/conformance/types/thisType/thisTypeInFunctions3.ts b/tests/cases/conformance/types/thisType/thisTypeInFunctions3.ts new file mode 100644 index 0000000000000..01d7fd0430bfa --- /dev/null +++ b/tests/cases/conformance/types/thisType/thisTypeInFunctions3.ts @@ -0,0 +1,9 @@ +declare class Base { + check(prop: TProp): boolean; +} + +class Test extends Base { + m() { + this.check(this); + } +} diff --git a/tests/cases/conformance/types/uniqueSymbol/uniqueSymbols.ts b/tests/cases/conformance/types/uniqueSymbol/uniqueSymbols.ts new file mode 100644 index 0000000000000..498a1c2904d2c --- /dev/null +++ b/tests/cases/conformance/types/uniqueSymbol/uniqueSymbols.ts @@ -0,0 +1,266 @@ +// @target: esnext +// @lib: esnext +// @declaration: false + +// 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 { 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(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(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 { + static [s]: "a"; + static [N.s]: "b"; + + [s]: "a"; + [N.s]: "b"; +} + +// contextual types + +interface Context { + method1(): typeof s; + method2(): Promise; + method3(): AsyncIterableIterator; + method4(): IterableIterator; + 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; +} diff --git a/tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarations.ts b/tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarations.ts new file mode 100644 index 0000000000000..b097e290e8fbf --- /dev/null +++ b/tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarations.ts @@ -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 { 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(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(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 { + static [s]: "a"; + static [N.s]: "b"; + + [s]: "a"; + [N.s]: "b"; +} + +// contextual types + +interface Context { + method1(): typeof s; + method2(): Promise; + method3(): AsyncIterableIterator; + method4(): IterableIterator; + 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; + } +}; \ No newline at end of file diff --git a/tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsErrors.ts b/tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsErrors.ts new file mode 100644 index 0000000000000..227dbd9c90d0e --- /dev/null +++ b/tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsDeclarationsErrors.ts @@ -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) { } +} \ No newline at end of file diff --git a/tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts b/tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts new file mode 100644 index 0000000000000..505efcc4e14ab --- /dev/null +++ b/tests/cases/conformance/types/uniqueSymbol/uniqueSymbolsErrors.ts @@ -0,0 +1,87 @@ +// @target: esnext + +// declarations +declare const invalidUniqueType: unique number; +declare const {}: unique symbol; +declare let invalidLetType: unique symbol; +declare var invalidVarType: unique symbol; + +// function arguments and return types +declare function invalidArgType(arg: unique symbol): void; +declare function invalidRestArgType(...arg: (unique symbol)[]): void; +declare function invalidReturnType(): unique symbol; +declare function invalidThisType(this: unique symbol): void; +declare function invalidTypePredicate(n: any): n is unique symbol; +declare function invalidTypeParameterConstraint(): void; +declare function invalidTypeParameterDefault(): void; + +// classes +class InvalidClass { + constructor(invalidConstructorArgType: unique symbol) {} + + readonly invalidReadonlyPropertyType: unique symbol; + invalidPropertyType: unique symbol; + invalidArgType(arg: unique symbol): void { return; } + invalidRestArgType(...args: (unique symbol)[]): void { return; } + invalidReturnType(): unique symbol { return; } + invalidThisType(this: unique symbol): void { return; } + invalidTypePredicate(n: any): n is unique symbol { return; } + invalidTypeParameterConstraint(): void { return; } + invalidTypeParameterDefault(): void { return; } + get invalidGetter(): unique symbol { return; } + set invalidSetter(arg: unique symbol) { return; } + + static invalidStaticPropertyType: unique symbol; + static invalidStaticArgType(arg: unique symbol): void { return; } + static invalidStaticRestArgType(...args: (unique symbol)[]): void { return; } + static invalidStaticReturnType(): unique symbol { return; } + static invalidStaticThisType(this: unique symbol): void { return; } + static invalidStaticTypePredicate(n: any): n is unique symbol { return; } + static invalidStaticTypeParameterConstraint(): void { return; } + static invalidStaticTypeParameterDefault(): void { return; } + static get invalidStaticGetter(): unique symbol { return; } + static set invalidStaticSetter(arg: unique symbol) { return; } +} + +// interfaces +interface InvalidInterface { + invalidPropertyType: unique symbol; + invalidArgType(arg: unique symbol): void; + invalidRestArgType(...args: (unique symbol)[]): void; + invalidReturnType(): unique symbol; + invalidThisType(this: unique symbol); + invalidTypePredicate(n: any): n is unique symbol + invalidTypeParameterConstraint(): void; + invalidTypeParameterDefault(): void; +} + +// type literals +type InvalidTypeLiteral = { + invalidPropertyType: unique symbol; + invalidArgType(arg: unique symbol): void; + invalidRestArgType(...args: (unique symbol)[]): void; + invalidReturnType(): unique symbol; + invalidThisType(this: unique symbol); + invalidTypePredicate(n: any): n is unique symbol + invalidTypeParameterConstraint(): void; + invalidTypeParameterDefault(): void; +}; + +// type alias +type InvalidAlias = unique symbol; +type InvalidAliasTypeParameterConstraint = never; +type InvalidAliasTypeParameterDefault = never; + +// type references +declare const invalidTypeArgument: Promise; +declare const invalidArrayType: (unique symbol)[]; +declare const invalidTupleType: [unique symbol]; + +// mapped types +declare const invalidMappedType: { [P in string]: unique symbol }; + +// unions/intersection +declare const invalidUnion: unique symbol | unique symbol; +declare const invalidIntersection: unique symbol | unique symbol; + + diff --git a/tests/cases/fourslash/codeFixChangeJSDocSyntax27.ts b/tests/cases/fourslash/codeFixChangeJSDocSyntax27.ts deleted file mode 100644 index 998a9ebd28aa9..0000000000000 --- a/tests/cases/fourslash/codeFixChangeJSDocSyntax27.ts +++ /dev/null @@ -1,10 +0,0 @@ -// @strict: true -/// -////type T = [|...number?|]; - -verify.codeFix({ - description: "Change '...number?' to 'number[] | null'.", - errorCode: 8020, - index: 0, - newRangeContent: "number[] | null", -}); diff --git a/tests/cases/fourslash/codeFixChangeJSDocSyntax3.ts b/tests/cases/fourslash/codeFixChangeJSDocSyntax3.ts deleted file mode 100644 index 2c804edb615b0..0000000000000 --- a/tests/cases/fourslash/codeFixChangeJSDocSyntax3.ts +++ /dev/null @@ -1,7 +0,0 @@ -/// -//// var x: [|......number[][]|] = 12; - -verify.codeFix({ - description: "Change '......number[][]' to 'number[][][][]'.", - newRangeContent: "number[][][][]", -}); diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport8.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport8.ts index 603e8d1104db7..6ba94510e90dc 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport8.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport8.ts @@ -51,5 +51,5 @@ for (const kind of kinds) { verify.completionListContains("1test"); goTo.marker(kind + "2"); - verify.completionListContains("2test"); + verify.completionListContains("2test", undefined, undefined, undefined, undefined, undefined, { allowDuplicate: true }); // TODO: GH#20042 } diff --git a/tests/cases/fourslash/completionInJSDocFunctionNew.ts b/tests/cases/fourslash/completionInJSDocFunctionNew.ts index 742627974bdbf..a3fff51a931c6 100644 --- a/tests/cases/fourslash/completionInJSDocFunctionNew.ts +++ b/tests/cases/fourslash/completionInJSDocFunctionNew.ts @@ -6,5 +6,5 @@ ////var f = function () { return new/**/; } goTo.marker(); -verify.completionListCount(117); -verify.completionListContains('new'); +verify.completionListCount(118); +verify.completionListContains('new', undefined, undefined, undefined, undefined, undefined, { allowDuplicate: true }); // TODO: GH#20042 diff --git a/tests/cases/fourslash/completionInJSDocFunctionThis.ts b/tests/cases/fourslash/completionInJSDocFunctionThis.ts index e22180aab5283..8f62680205ca9 100644 --- a/tests/cases/fourslash/completionInJSDocFunctionThis.ts +++ b/tests/cases/fourslash/completionInJSDocFunctionThis.ts @@ -5,6 +5,5 @@ ////var f = function (s) { return this/**/; } goTo.marker(); -verify.completionListCount(118); -verify.completionListContains('this'); - +verify.completionListCount(119); +verify.completionListContains('this', undefined, undefined, undefined, undefined, undefined, { allowDuplicate: true }); // TODO: GH#20042 diff --git a/tests/cases/fourslash/completionListPrimitives.ts b/tests/cases/fourslash/completionListPrimitives.ts index 21a34659c4e79..7442746fa0c4e 100644 --- a/tests/cases/fourslash/completionListPrimitives.ts +++ b/tests/cases/fourslash/completionListPrimitives.ts @@ -8,5 +8,5 @@ verify.completionListContains("boolean"); verify.completionListContains("null"); verify.completionListContains("number"); verify.completionListContains("string"); -verify.completionListContains("undefined"); -verify.completionListContains("void"); \ No newline at end of file +verify.completionListContains("undefined", undefined, undefined, undefined, undefined, undefined, { allowDuplicate: true }); // TODO: GH#20042 +verify.completionListContains("void"); diff --git a/tests/cases/fourslash/completionsImport_default_didNotExistBefore.ts b/tests/cases/fourslash/completionsImport_default_didNotExistBefore.ts index a36e4336e61f1..a4f943f68ee99 100644 --- a/tests/cases/fourslash/completionsImport_default_didNotExistBefore.ts +++ b/tests/cases/fourslash/completionsImport_default_didNotExistBefore.ts @@ -1,5 +1,7 @@ /// +// @noLib: true + // @Filename: /a.ts ////export default function foo() {} diff --git a/tests/cases/fourslash/completionsImport_ofAlias.ts b/tests/cases/fourslash/completionsImport_ofAlias.ts index 69c5041f94fd1..cb4f1255a3eb2 100644 --- a/tests/cases/fourslash/completionsImport_ofAlias.ts +++ b/tests/cases/fourslash/completionsImport_ofAlias.ts @@ -11,14 +11,19 @@ // Should not show up in completions ////export { foo } from "./a"; +// @Filename: /a_reexport_2.ts +////export * from "./a"; + // @Filename: /b.ts ////fo/**/ goTo.marker(""); const options = { includeExternalModuleExports: true, sourceDisplay: "./a" }; // TODO: https://github.com/Microsoft/TypeScript/issues/14003 +//TODO: verify that there's only one! verify.completionListContains({ name: "foo", source: "/a" }, "import foo", "", "alias", /*spanIndex*/ undefined, /*hasAction*/ true, options); verify.not.completionListContains({ name: "foo", source: "/a_reexport" }, undefined, undefined, undefined, undefined, undefined, options); +verify.not.completionListContains({ name: "foo", source: "/a_reexport_2" }, undefined, undefined, undefined, undefined, undefined, options); verify.applyCodeActionFromCompletion("", { name: "foo", diff --git a/tests/cases/fourslash/findAllRefsForComputedProperties.ts b/tests/cases/fourslash/findAllRefsForComputedProperties.ts index 72c49104dedae..6587211b76d82 100644 --- a/tests/cases/fourslash/findAllRefsForComputedProperties.ts +++ b/tests/cases/fourslash/findAllRefsForComputedProperties.ts @@ -14,13 +14,13 @@ const ranges = test.ranges(); const [r0, r1, r2] = ranges; -verify.referenceGroups(r0, [{ definition: '(property) I[["prop1"]]: () => void', ranges }]); +verify.referenceGroups(r0, [{ definition: '(property) I["prop1"]: () => void', ranges }]); verify.referenceGroups(r1, [ - { definition: '(property) I[["prop1"]]: () => void', ranges: [r0, r2] }, - { definition: '(property) C[["prop1"]]: any', ranges: [r1] } + { definition: '(property) I["prop1"]: () => void', ranges: [r0, r2] }, + { definition: '(property) C["prop1"]: any', ranges: [r1] } ]); verify.referenceGroups(r2, [ - { definition: '(property) I[["prop1"]]: () => void', ranges: [r0, r1] }, + { definition: '(property) I["prop1"]: () => void', ranges: [r0, r1] }, { definition: '(property) ["prop1"]: () => void', ranges: [r2] } ]); diff --git a/tests/cases/fourslash/findAllRefsForComputedProperties2.ts b/tests/cases/fourslash/findAllRefsForComputedProperties2.ts index 4a7a17047ec79..ef28b2f9bd7ec 100644 --- a/tests/cases/fourslash/findAllRefsForComputedProperties2.ts +++ b/tests/cases/fourslash/findAllRefsForComputedProperties2.ts @@ -14,12 +14,12 @@ const ranges = test.ranges(); const [r0, r1, r2] = ranges; -verify.referenceGroups(r0, [{ definition: "(method) I[[42]](): void", ranges }]); +verify.referenceGroups(r0, [{ definition: "(method) I[42](): void", ranges }]); verify.referenceGroups(r1, [ - { definition: "(method) I[[42]](): void", ranges: [r0, r2] }, - { definition: "(property) C[[42]]: any", ranges: [r1] } + { definition: "(method) I[42](): void", ranges: [r0, r2] }, + { definition: "(property) C[42]: any", ranges: [r1] } ]); verify.referenceGroups(r2, [ - { definition: "(method) I[[42]](): void", ranges: [r0, r1] }, + { definition: "(method) I[42](): void", ranges: [r0, r1] }, { definition: '(property) ["42"]: () => void', ranges: [r2] } ]); diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 01babe7ba3af4..ce7f365df1691 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -148,7 +148,7 @@ declare namespace FourSlashInterface { kind?: string, spanIndex?: number, hasAction?: boolean, - options?: { includeExternalModuleExports?: boolean, sourceDisplay?: string, isRecommended?: true }, + options?: { includeExternalModuleExports?: boolean, sourceDisplay?: string, isRecommended?: true, allowDuplicate?: true }, ): void; completionListItemsCountIsGreaterThan(count: number): void; completionListIsEmpty(): void; @@ -358,7 +358,7 @@ declare namespace FourSlashInterface { printCurrentFileStateWithoutCaret(): void; printCurrentQuickInfo(): void; printCurrentSignatureHelp(): void; - printCompletionListMembers(): void; + printCompletionListMembers(options?: { includeExternalModuleExports: boolean }): void; printAvailableCodeFixes(): void; printBreakpointLocation(pos: number): void; printBreakpointAtCurrentLocation(): void; diff --git a/tests/cases/fourslash/getJavaScriptCompletions2.ts b/tests/cases/fourslash/getJavaScriptCompletions2.ts index 0cb2de046a668..736762cd169f8 100644 --- a/tests/cases/fourslash/getJavaScriptCompletions2.ts +++ b/tests/cases/fourslash/getJavaScriptCompletions2.ts @@ -7,4 +7,4 @@ ////v./**/ goTo.marker(); -verify.completionListContains("valueOf", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); \ No newline at end of file +verify.completionListContains("valueOf", /*displayText:*/ undefined, /*documentation*/ undefined, "method", undefined, undefined, { allowDuplicate: true }); // TODO: GH#20042 diff --git a/tests/cases/fourslash/getJavaScriptCompletions6.ts b/tests/cases/fourslash/getJavaScriptCompletions6.ts deleted file mode 100644 index 9f9a42b5762c2..0000000000000 --- a/tests/cases/fourslash/getJavaScriptCompletions6.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// - -// @allowNonTsExtensions: true -// @Filename: Foo.js -/////** -//// * @param {...number} a -//// */ -////function foo(a) { -//// a./**/ -////} - -goTo.marker(); -verify.completionListContains("concat", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); \ No newline at end of file diff --git a/tests/cases/fourslash/getJavaScriptCompletions7.ts b/tests/cases/fourslash/getJavaScriptCompletions7.ts deleted file mode 100644 index d8b01cfb757c2..0000000000000 --- a/tests/cases/fourslash/getJavaScriptCompletions7.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// - -// @allowNonTsExtensions: true -// @Filename: Foo.js -/////** -//// * @param {...number} a -//// */ -////function foo(a) { -//// a[0]./**/ -////} - -goTo.marker(); -verify.completionListContains("toExponential", /*displayText:*/ undefined, /*documentation*/ undefined, "method"); \ No newline at end of file diff --git a/tests/cases/fourslash/importNameCodeFixNewImportIndex.ts b/tests/cases/fourslash/importNameCodeFixNewImportIndex.ts new file mode 100644 index 0000000000000..2840424c468a7 --- /dev/null +++ b/tests/cases/fourslash/importNameCodeFixNewImportIndex.ts @@ -0,0 +1,16 @@ +/// + +// @Filename: /a/index.ts +////export const foo = 0; + +// @Filename: /b.ts +////[|/**/foo;|] + +goTo.file("/a/index.ts"); +goTo.file("/b.ts"); + +verify.importFixAtPosition([ +`import { foo } from "./a"; + +foo;` +]); diff --git a/tests/cases/fourslash/importNameCodeFixNewImportIndex_notForClassicResolution.ts b/tests/cases/fourslash/importNameCodeFixNewImportIndex_notForClassicResolution.ts new file mode 100644 index 0000000000000..3fa9b91b264a4 --- /dev/null +++ b/tests/cases/fourslash/importNameCodeFixNewImportIndex_notForClassicResolution.ts @@ -0,0 +1,27 @@ +/// + +// @moduleResolution: classic + +// @Filename: /a/index.ts +////export const foo = 0; + +// @Filename: /node_modules/x/index.d.ts +////export const bar = 0; + +// @Filename: /b.ts +////[|foo;|] + +// @Filename: /c.ts +////bar; + +goTo.file("/a/index.ts"); + +goTo.file("/b.ts"); +verify.importFixAtPosition([ +`import { foo } from "./a/index"; + +foo;` +]); + +goTo.file("/c.ts"); +// TODO: GH#20050 verify.not.codeFixAvailable(); diff --git a/tests/cases/fourslash/importNameCodeFixUMDGlobalReact0.ts b/tests/cases/fourslash/importNameCodeFixUMDGlobalReact0.ts index 5b6df7a517349..cd3d25030fa5e 100644 --- a/tests/cases/fourslash/importNameCodeFixUMDGlobalReact0.ts +++ b/tests/cases/fourslash/importNameCodeFixUMDGlobalReact0.ts @@ -3,6 +3,7 @@ // @jsx: react // @allowSyntheticDefaultImports: false // @module: es2015 +// @moduleResolution: node // @Filename: /node_modules/@types/react/index.d.ts ////export = React; diff --git a/tests/cases/fourslash/importNameCodeFixUMDGlobalReact1.ts b/tests/cases/fourslash/importNameCodeFixUMDGlobalReact1.ts index 669db55342b04..9dba0f3988256 100644 --- a/tests/cases/fourslash/importNameCodeFixUMDGlobalReact1.ts +++ b/tests/cases/fourslash/importNameCodeFixUMDGlobalReact1.ts @@ -3,6 +3,7 @@ // @jsx: react // @allowSyntheticDefaultImports: false // @module: es2015 +// @moduleResolution: node // @Filename: /node_modules/@types/react/index.d.ts ////export = React; diff --git a/tests/cases/fourslash/javaScriptClass1.ts b/tests/cases/fourslash/javaScriptClass1.ts index 19f7a39b6150d..28d139405c7ee 100644 --- a/tests/cases/fourslash/javaScriptClass1.ts +++ b/tests/cases/fourslash/javaScriptClass1.ts @@ -28,4 +28,4 @@ verify.completionListContains("substr", /*displayText*/ undefined, /*documentati edit.backspace('bar.'.length); edit.insert('union.'); -verify.completionListContains("toString", /*displayText*/ undefined, /*documentation*/ undefined, "method"); \ No newline at end of file +verify.completionListContains("toString", /*displayText*/ undefined, /*documentation*/ undefined, "method", undefined, undefined, { allowDuplicate: true }); \ No newline at end of file diff --git a/tests/cases/fourslash/navigationBarFunctionPrototype.ts b/tests/cases/fourslash/navigationBarFunctionPrototype.ts new file mode 100644 index 0000000000000..5494dab9f05e1 --- /dev/null +++ b/tests/cases/fourslash/navigationBarFunctionPrototype.ts @@ -0,0 +1,42 @@ +/// + +// @Filename: foo.js +////function f() {} +////f.prototype.x = 0; + +verify.navigationTree({ + "text": "", + "kind": "script", + "childItems": [ + { + "text": "f", + "kind": "function" + }, + { + "text": "x", + "kind": "property" + } + ] +}); + +verify.navigationBar([ + { + "text": "", + "kind": "script", + "childItems": [ + { + "text": "f", + "kind": "function" + }, + { + "text": "x", + "kind": "property" + } + ] + }, + { + "text": "f", + "kind": "function", + "indent": 1 + } +]); diff --git a/tests/cases/fourslash/smartIndentStatementSwitch.ts b/tests/cases/fourslash/smartIndentStatementSwitch.ts index c2c2d09fd45b8..9e3057e9231e0 100644 --- a/tests/cases/fourslash/smartIndentStatementSwitch.ts +++ b/tests/cases/fourslash/smartIndentStatementSwitch.ts @@ -11,7 +11,7 @@ //// case 1: //// {| "indentation": 12 |} //// break; -//// {| "indentation": 12 |} // content of case clauses is always indented relatively to case clause +//// {| "indentation": 8 |} // since we just saw "break" //// } //// {| "indentation": 4 |} ////} diff --git a/tests/cases/user/TypeScript-React-Native-Starter/TypeScript-React-Native-Starter b/tests/cases/user/TypeScript-React-Native-Starter/TypeScript-React-Native-Starter index 2c62f5a4ea519..59571c0d34aa4 160000 --- a/tests/cases/user/TypeScript-React-Native-Starter/TypeScript-React-Native-Starter +++ b/tests/cases/user/TypeScript-React-Native-Starter/TypeScript-React-Native-Starter @@ -1 +1 @@ -Subproject commit 2c62f5a4ea51978e3715b475e17962cdeca75e38 +Subproject commit 59571c0d34aa48820309291b966778795d1cbebf diff --git a/tests/cases/user/TypeScript-React-Starter/TypeScript-React-Starter b/tests/cases/user/TypeScript-React-Starter/TypeScript-React-Starter index 96fb6237a9dda..68f60e1a4b947 160000 --- a/tests/cases/user/TypeScript-React-Starter/TypeScript-React-Starter +++ b/tests/cases/user/TypeScript-React-Starter/TypeScript-React-Starter @@ -1 +1 @@ -Subproject commit 96fb6237a9dda8d17059eea7fa7c22dd7db82c97 +Subproject commit 68f60e1a4b947df47418e1d420acc59dafdfef12 diff --git a/tests/cases/user/TypeScript-WeChat-Starter/TypeScript-WeChat-Starter b/tests/cases/user/TypeScript-WeChat-Starter/TypeScript-WeChat-Starter index 5fca1032edaab..3fb8b4601022f 160000 --- a/tests/cases/user/TypeScript-WeChat-Starter/TypeScript-WeChat-Starter +++ b/tests/cases/user/TypeScript-WeChat-Starter/TypeScript-WeChat-Starter @@ -1 +1 @@ -Subproject commit 5fca1032edaab5414ec1c167f42d3dc59220d9aa +Subproject commit 3fb8b4601022f7e2df899eb0ac0178f531e6f027 diff --git a/tests/cases/user/chrome-devtools-frontend/package.json b/tests/cases/user/chrome-devtools-frontend/package.json new file mode 100644 index 0000000000000..292334ea8d528 --- /dev/null +++ b/tests/cases/user/chrome-devtools-frontend/package.json @@ -0,0 +1,14 @@ +{ + "name": "chrome-devtools-frontend-test", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "Apache-2.0", + "dependencies": { + "chrome-devtools-frontend": "latest" + } +} diff --git a/tests/cases/user/chrome-devtools-frontend/tsconfig.json b/tests/cases/user/chrome-devtools-frontend/tsconfig.json new file mode 100644 index 0000000000000..18060ecdf2441 --- /dev/null +++ b/tests/cases/user/chrome-devtools-frontend/tsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "outDir": "./built", + "allowJs": true, + "checkJs": true, + "lib": ["dom", "es2017"] + }, + "include": [ + "./node_modules/chrome-devtools-frontend/front_end/**/*.js" + ] +} \ No newline at end of file