diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ca73d92e0c014..baa6cb0a4eef1 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4216,7 +4216,7 @@ namespace ts { // Return the type of a binding element parent. We check SymbolLinks first to see if a type has been // assigned by contextual typing. - function getTypeForBindingElementParent(node: VariableLikeDeclaration) { + function getTypeForBindingElementParent(node: BindingElementGrandparent) { const symbol = getSymbolOfNode(node); return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false); } @@ -4371,15 +4371,15 @@ namespace ts { } // Return the inferred type for a variable, parameter, or property declaration - function getTypeForVariableLikeDeclaration(declaration: VariableLikeDeclaration, includeOptionality: boolean): Type { + function getTypeForVariableLikeDeclaration(declaration: ParameterDeclaration | PropertyDeclaration | PropertySignature | VariableDeclaration | BindingElement, includeOptionality: boolean): Type { // A variable declared in a for..in statement is of type string, or of type keyof T when the // right hand expression is of a type parameter type. - if (declaration.parent.parent.kind === SyntaxKind.ForInStatement) { + if (isVariableDeclaration(declaration) && declaration.parent.parent.kind === SyntaxKind.ForInStatement) { const indexType = getIndexType(checkNonNullExpression((declaration.parent.parent).expression)); return indexType.flags & (TypeFlags.TypeParameter | TypeFlags.Index) ? indexType : stringType; } - if (declaration.parent.parent.kind === SyntaxKind.ForOfStatement) { + if (isVariableDeclaration(declaration) && declaration.parent.parent.kind === SyntaxKind.ForOfStatement) { // checkRightHandSideOfForOf will return undefined if the for-of expression type was // missing properties/signatures required to get its iteratedType (like // [Symbol.iterator] or next). This may be because we accessed properties from anyType, @@ -4392,11 +4392,11 @@ namespace ts { return getTypeForBindingElement(declaration); } + const isOptional = !isBindingElement(declaration) && !isVariableDeclaration(declaration) && !!declaration.questionToken && includeOptionality; // Use type from type annotation if one is present - const typeNode = getEffectiveTypeAnnotationNode(declaration); - if (typeNode) { - const declaredType = getTypeFromTypeNode(typeNode); - return addOptionality(declaredType, /*optional*/ !!declaration.questionToken && includeOptionality); + const declaredType = tryGetTypeFromEffectiveTypeNode(declaration); + if (declaredType) { + return addOptionality(declaredType, isOptional); } if ((noImplicitAny || isInJavaScriptFile(declaration)) && @@ -4440,14 +4440,14 @@ namespace ts { type = getContextuallyTypedParameterType(declaration); } if (type) { - return addOptionality(type, /*optional*/ !!declaration.questionToken && includeOptionality); + return addOptionality(type, isOptional); } } // 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, isOptional); } if (isJsxAttribute(declaration)) { @@ -4456,11 +4456,6 @@ namespace ts { return trueType; } - // If it is a short-hand property assignment, use the type of the identifier - if (declaration.kind === SyntaxKind.ShorthandPropertyAssignment) { - return checkIdentifier(declaration.name); - } - // If the declaration specifies a binding pattern, use the type implied by the binding pattern if (isBindingPattern(declaration.name)) { return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ false, /*reportErrors*/ true); @@ -4605,7 +4600,7 @@ namespace ts { // Here, the array literal [1, "one"] is contextually typed by the type [any, string], which is the implied type of the // binding pattern [x, s = ""]. Because the contextual type is a tuple type, the resulting type of [1, "one"] is the // tuple type [number, string]. Thus, the type inferred for 'x' is number and the type inferred for 's' is string. - function getWidenedTypeForVariableLikeDeclaration(declaration: VariableLikeDeclaration, reportErrors?: boolean): Type { + function getWidenedTypeForVariableLikeDeclaration(declaration: ParameterDeclaration | PropertyDeclaration | PropertySignature | VariableDeclaration | BindingElement, reportErrors?: boolean): Type { let type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true); if (type) { if (reportErrors) { @@ -4613,21 +4608,15 @@ namespace ts { } // 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)) { + if (type.flags & TypeFlags.UniqueESSymbol && (isBindingElement(declaration) || !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. - if (declaration.kind === SyntaxKind.PropertyAssignment) { - return type; - } return getWidenedType(type); } // Rest parameters default to type any[], other parameters default to type any - type = declaration.dotDotDotToken ? anyArrayType : anyType; + type = isParameter(declaration) && declaration.dotDotDotToken ? anyArrayType : anyType; // Report implicit any errors unless this is a private property within an ambient declaration if (reportErrors && noImplicitAny) { @@ -4644,6 +4633,13 @@ namespace ts { return isPrivateWithinAmbient(memberDeclaration); } + function tryGetTypeFromEffectiveTypeNode(declaration: Declaration) { + const typeNode = getEffectiveTypeAnnotationNode(declaration); + if (typeNode) { + return getTypeFromTypeNode(typeNode); + } + } + function getTypeOfVariableOrParameterOrProperty(symbol: Symbol): Type { const links = getSymbolLinks(symbol); if (!links.type) { @@ -4678,8 +4674,33 @@ namespace ts { declaration.kind === SyntaxKind.PropertyAccessExpression && declaration.parent.kind === SyntaxKind.BinaryExpression) { type = getWidenedTypeFromJSSpecialPropertyDeclarations(symbol); } + else if (isJSDocPropertyTag(declaration) + || isPropertyAccessExpression(declaration) + || isMethodDeclaration(declaration) && !isObjectLiteralMethod(declaration)) { + // TODO: Mimics old behavior from incorrect usage of getWidenedTypeForVariableLikeDeclaration, but seems incorrect + type = tryGetTypeFromEffectiveTypeNode(declaration) || anyType; + } + else if (isPropertyAssignment(declaration)) { + type = tryGetTypeFromEffectiveTypeNode(declaration) || checkPropertyAssignment(declaration); + } + else if (isJsxAttribute(declaration)) { + type = tryGetTypeFromEffectiveTypeNode(declaration) || checkJsxAttribute(declaration); + } + else if (isShorthandPropertyAssignment(declaration)) { + type = tryGetTypeFromEffectiveTypeNode(declaration) || checkExpressionForMutableLocation(declaration.name, CheckMode.Normal); + } + else if (isObjectLiteralMethod(declaration)) { + type = tryGetTypeFromEffectiveTypeNode(declaration) || checkObjectLiteralMethod(declaration, CheckMode.Normal); + } + else if (isParameter(declaration) + || isPropertyDeclaration(declaration) + || isPropertySignature(declaration) + || isVariableDeclaration(declaration) + || isBindingElement(declaration)) { + type = getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true); + } else { - type = getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true); + Debug.fail("Unhandled declaration kind! " + (ts as any).SyntaxKind[declaration.kind]); } if (!popTypeResolution()) { @@ -5451,7 +5472,7 @@ namespace ts { */ function isThislessVariableLikeDeclaration(node: VariableLikeDeclaration): boolean { const typeNode = getEffectiveTypeAnnotationNode(node); - return typeNode ? isThislessType(typeNode) : !node.initializer; + return typeNode ? isThislessType(typeNode) : !hasInitializer(node); } /** @@ -13892,7 +13913,7 @@ namespace ts { // the contextual type of an initializer expression is the type annotation of the containing declaration, if present. function getContextualTypeForInitializerExpression(node: Expression): Type { const declaration = node.parent; - if (node === declaration.initializer || node.kind === SyntaxKind.EqualsToken) { + if (hasInitializer(declaration) && node === declaration.initializer || node.kind === SyntaxKind.EqualsToken) { const typeNode = getEffectiveTypeAnnotationNode(declaration); if (typeNode) { return getTypeFromTypeNode(typeNode); @@ -13908,7 +13929,7 @@ namespace ts { } if (isBindingPattern(declaration.parent)) { const parentDeclaration = declaration.parent.parent; - const name = declaration.propertyName || declaration.name; + const name = (declaration as BindingElement).propertyName || (declaration as BindingElement).name; if (parentDeclaration.kind !== SyntaxKind.BindingElement) { const parentTypeNode = getEffectiveTypeAnnotationNode(parentDeclaration); if (parentTypeNode && !isBindingPattern(name)) { @@ -17811,7 +17832,7 @@ namespace ts { const type = getTypeOfSymbol(symbol); if (strictNullChecks) { const declaration = symbol.valueDeclaration; - if (declaration && (declaration).initializer) { + if (declaration && hasInitializer(declaration)) { return getOptionalType(type); } } @@ -19095,7 +19116,7 @@ namespace ts { return node.kind === SyntaxKind.TypeAssertionExpression || node.kind === SyntaxKind.AsExpression; } - function checkDeclarationInitializer(declaration: VariableLikeDeclaration) { + function checkDeclarationInitializer(declaration: HasExpressionInitializer) { const type = getTypeOfExpression(declaration.initializer, /*cache*/ true); return getCombinedNodeFlags(declaration) & NodeFlags.Const || (getCombinedModifierFlags(declaration) & ModifierFlags.Readonly && !isParameterPropertyDeclaration(declaration)) || @@ -19777,7 +19798,7 @@ namespace ts { } } - function checkPropertyDeclaration(node: PropertyDeclaration) { + function checkPropertyDeclaration(node: PropertyDeclaration | PropertySignature) { // Grammar checking if (!checkGrammarDecoratorsAndModifiers(node) && !checkGrammarProperty(node)) checkGrammarComputedPropertyName(node.name); checkVariableLikeDeclaration(node); @@ -21458,7 +21479,7 @@ namespace ts { } // Check that a parameter initializer contains no references to parameters declared to the right of itself - function checkParameterInitializer(node: VariableLikeDeclaration): void { + function checkParameterInitializer(node: HasExpressionInitializer): void { if (getRootDeclaration(node).kind !== SyntaxKind.Parameter) { return; } @@ -21530,9 +21551,11 @@ namespace ts { } // Check variable, parameter, or property declaration - function checkVariableLikeDeclaration(node: VariableLikeDeclaration) { + function checkVariableLikeDeclaration(node: ParameterDeclaration | PropertyDeclaration | PropertySignature | VariableDeclaration | BindingElement) { checkDecorators(node); - checkSourceElement(node.type); + if (!isBindingElement(node)) { + checkSourceElement(node.type); + } // JSDoc `function(string, string): string` syntax results in parameters with no name if (!node.name) { @@ -21543,7 +21566,7 @@ namespace ts { // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. if (node.name.kind === SyntaxKind.ComputedPropertyName) { - checkComputedPropertyName(node.name); + checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } @@ -21555,11 +21578,11 @@ namespace ts { } // check computed properties inside property names of binding elements if (node.propertyName && node.propertyName.kind === SyntaxKind.ComputedPropertyName) { - checkComputedPropertyName(node.propertyName); + checkComputedPropertyName(node.propertyName); } // check private/protected variable access - const parent = (node.parent).parent; + const parent = node.parent.parent; const parentType = getTypeForBindingElementParent(parent); const name = node.propertyName || node.name; const property = getPropertyOfType(parentType, getTextOfPropertyName(name)); @@ -23697,7 +23720,7 @@ namespace ts { return checkParameter(node); case SyntaxKind.PropertyDeclaration: case SyntaxKind.PropertySignature: - return checkPropertyDeclaration(node); + return checkPropertyDeclaration(node); case SyntaxKind.FunctionType: case SyntaxKind.ConstructorType: case SyntaxKind.CallSignature: @@ -24505,7 +24528,7 @@ namespace ts { } if (isBindingPattern(node)) { - return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true); + return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true); } if (isInRightSideOfImportOrExportAssignment(node)) { @@ -26486,7 +26509,7 @@ namespace ts { } } - function checkGrammarProperty(node: PropertyDeclaration) { + function checkGrammarProperty(node: PropertyDeclaration | PropertySignature) { if (isClassLike(node.parent)) { 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; @@ -26513,7 +26536,7 @@ namespace ts { return grammarErrorOnFirstToken(node.initializer, Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } - if (node.exclamationToken && (!isClassLike(node.parent) || !node.type || node.initializer || + if (isPropertyDeclaration(node) && node.exclamationToken && (!isClassLike(node.parent) || !node.type || node.initializer || node.flags & NodeFlags.Ambient || hasModifier(node, ModifierFlags.Static | ModifierFlags.Abstract))) { return grammarErrorOnNode(node.exclamationToken, Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); } diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index dc76e0ddf5028..b4ff7c7f641eb 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -64,7 +64,7 @@ namespace ts { let currentIdentifiers: Map; let isCurrentFileExternalModule: boolean; let reportedDeclarationError = false; - let errorNameNode: DeclarationName; + let errorNameNode: DeclarationName | QualifiedName; const emitJsDocComments = compilerOptions.removeComments ? noop : writeJsDocComments; const emit = compilerOptions.stripInternal ? stripInternal : emitNode; let needsDeclare = true; @@ -1372,7 +1372,7 @@ namespace ts { // if this is property of type literal, // or is parameter of method/call/construct/index signature of type literal // emit only if type is specified - if (node.type) { + if (hasType(node)) { write(": "); emitType(node.type); } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 52776f8e6a237..ce4115b08d439 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -88,20 +88,48 @@ namespace ts { case SyntaxKind.SpreadAssignment: return visitNode(cbNode, (node).expression); case SyntaxKind.Parameter: + return visitNodes(cbNode, cbNodes, node.decorators) || + visitNodes(cbNode, cbNodes, node.modifiers) || + visitNode(cbNode, (node).dotDotDotToken) || + visitNode(cbNode, (node).name) || + visitNode(cbNode, (node).questionToken) || + visitNode(cbNode, (node).type) || + visitNode(cbNode, (node).initializer); case SyntaxKind.PropertyDeclaration: + return visitNodes(cbNode, cbNodes, node.decorators) || + visitNodes(cbNode, cbNodes, node.modifiers) || + visitNode(cbNode, (node).name) || + visitNode(cbNode, (node).questionToken) || + visitNode(cbNode, (node).exclamationToken) || + visitNode(cbNode, (node).type) || + visitNode(cbNode, (node).initializer); case SyntaxKind.PropertySignature: + return visitNodes(cbNode, cbNodes, node.decorators) || + visitNodes(cbNode, cbNodes, node.modifiers) || + visitNode(cbNode, (node).name) || + visitNode(cbNode, (node).questionToken) || + visitNode(cbNode, (node).type) || + visitNode(cbNode, (node).initializer); case SyntaxKind.PropertyAssignment: + return visitNodes(cbNode, cbNodes, node.decorators) || + visitNodes(cbNode, cbNodes, node.modifiers) || + visitNode(cbNode, (node).name) || + visitNode(cbNode, (node).questionToken) || + visitNode(cbNode, (node).initializer); case SyntaxKind.VariableDeclaration: + return visitNodes(cbNode, cbNodes, node.decorators) || + visitNodes(cbNode, cbNodes, node.modifiers) || + visitNode(cbNode, (node).name) || + visitNode(cbNode, (node).exclamationToken) || + visitNode(cbNode, (node).type) || + visitNode(cbNode, (node).initializer); case SyntaxKind.BindingElement: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || - visitNode(cbNode, (node).propertyName) || - visitNode(cbNode, (node).dotDotDotToken) || - visitNode(cbNode, (node).name) || - visitNode(cbNode, (node).questionToken) || - visitNode(cbNode, (node).exclamationToken) || - visitNode(cbNode, (node).type) || - visitNode(cbNode, (node).initializer); + visitNode(cbNode, (node).propertyName) || + visitNode(cbNode, (node).dotDotDotToken) || + visitNode(cbNode, (node).name) || + visitNode(cbNode, (node).initializer); case SyntaxKind.FunctionType: case SyntaxKind.ConstructorType: case SyntaxKind.CallSignature: diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 54f2ebfae420d..51465a6baf569 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -584,6 +584,40 @@ namespace ts { | JSDocFunctionType | EndOfFileToken; + export type HasType = + | SignatureDeclaration + | VariableDeclaration + | ParameterDeclaration + | PropertySignature + | PropertyDeclaration + | TypePredicateNode + | ParenthesizedTypeNode + | TypeOperatorNode + | MappedTypeNode + | AssertionExpression + | TypeAliasDeclaration + | JSDocTypeExpression + | JSDocNonNullableType + | JSDocNullableType + | JSDocOptionalType + | JSDocVariadicType; + + export type HasInitializer = + | HasExpressionInitializer + | ForStatement + | ForInStatement + | ForOfStatement + | JsxAttribute; + + export type HasExpressionInitializer = + | VariableDeclaration + | ParameterDeclaration + | BindingElement + | PropertySignature + | PropertyDeclaration + | PropertyAssignment + | EnumMember; + /* @internal */ export type MutableNodeArray = NodeArray & T[]; @@ -793,6 +827,9 @@ namespace ts { initializer?: Expression; // Optional initializer } + /*@internal*/ + export type BindingElementGrandparent = BindingElement["parent"]["parent"]; + export interface PropertySignature extends TypeElement, JSDocContainer { kind: SyntaxKind.PropertySignature; name: PropertyName; // Declared property name @@ -848,25 +885,18 @@ namespace ts { expression: Expression; } - // SyntaxKind.VariableDeclaration - // SyntaxKind.Parameter - // SyntaxKind.BindingElement - // SyntaxKind.Property - // SyntaxKind.PropertyAssignment - // SyntaxKind.JsxAttribute - // SyntaxKind.ShorthandPropertyAssignment - // SyntaxKind.EnumMember - // SyntaxKind.JSDocPropertyTag - // SyntaxKind.JSDocParameterTag - export interface VariableLikeDeclaration extends NamedDeclaration { - propertyName?: PropertyName; - dotDotDotToken?: DotDotDotToken; - name: DeclarationName; - questionToken?: QuestionToken; - exclamationToken?: ExclamationToken; - type?: TypeNode; - initializer?: Expression; - } + export type VariableLikeDeclaration = + | VariableDeclaration + | ParameterDeclaration + | BindingElement + | PropertyDeclaration + | PropertyAssignment + | PropertySignature + | JsxAttribute + | ShorthandPropertyAssignment + | EnumMember + | JSDocPropertyTag + | JSDocParameterTag; export interface PropertyLikeDeclaration extends NamedDeclaration { name: PropertyName; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 4a7b46a8b0ee2..2a2561907f780 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -548,7 +548,7 @@ namespace ts { // Return display name of an identifier // Computed property names will just be emitted as "[]", where is the source // text of the expression in the computed property. - export function declarationNameToString(name: DeclarationName) { + export function declarationNameToString(name: DeclarationName | QualifiedName) { return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); } @@ -784,7 +784,7 @@ namespace ts { case SyntaxKind.PropertySignature: case SyntaxKind.Parameter: case SyntaxKind.VariableDeclaration: - return node === (parent).type; + return node === (parent as HasType).type; case SyntaxKind.FunctionDeclaration: case SyntaxKind.FunctionExpression: case SyntaxKind.ArrowFunction: @@ -1340,7 +1340,7 @@ namespace ts { case SyntaxKind.EnumMember: case SyntaxKind.PropertyAssignment: case SyntaxKind.BindingElement: - return (parent).initializer === node; + return (parent as HasInitializer).initializer === node; case SyntaxKind.ExpressionStatement: case SyntaxKind.IfStatement: case SyntaxKind.DoStatement: @@ -1650,7 +1650,7 @@ namespace ts { result = addRange(result, getJSDocParameterTags(node as ParameterDeclaration)); } - if (isVariableLike(node) && node.initializer && hasJSDocNodes(node.initializer)) { + if (isVariableLike(node) && hasInitializer(node) && hasJSDocNodes(node.initializer)) { result = addRange(result, node.initializer.jsDoc); } @@ -2816,8 +2816,8 @@ namespace ts { * Gets the effective type annotation of a variable, parameter, or property. If the node was * parsed in a JavaScript file, gets the type annotation from JSDoc. */ - export function getEffectiveTypeAnnotationNode(node: VariableLikeDeclaration, checkJSDoc?: boolean): TypeNode | undefined { - if (node.type) { + export function getEffectiveTypeAnnotationNode(node: Node, checkJSDoc?: boolean): TypeNode | undefined { + if (hasType(node)) { return node.type; } if (checkJSDoc || isInJavaScriptFile(node)) { @@ -5812,4 +5812,22 @@ namespace ts { export function hasJSDocNodes(node: Node): node is HasJSDoc { return !!(node as JSDocContainer).jsDoc && (node as JSDocContainer).jsDoc.length > 0; } + + /** True if has type node attached to it. */ + /* @internal */ + export function hasType(node: Node): node is HasType { + return !!(node as HasType).type; + } + + /** True if has initializer node attached to it. */ + /* @internal */ + export function hasInitializer(node: Node): node is HasInitializer { + return !!(node as HasInitializer).initializer; + } + + /** True if has initializer node attached to it. */ + /* @internal */ + export function hasOnlyExpressionInitializer(node: Node): node is HasExpressionInitializer { + return hasInitializer(node) && !isForStatement(node) && !isForInStatement(node) && !isForOfStatement(node) && !isJsxAttribute(node); + } } diff --git a/src/services/completions.ts b/src/services/completions.ts index d893f4852e4f8..a264ad10bc7e8 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -1325,7 +1325,7 @@ namespace ts.Completions { // through type declaration or inference. // Also proceed if rootDeclaration is a parameter and if its containing function expression/arrow function is contextually typed - // type of parameter will flow in from the contextual type of the function - let canGetType = rootDeclaration.initializer || rootDeclaration.type || rootDeclaration.parent.parent.kind === SyntaxKind.ForOfStatement; + let canGetType = hasInitializer(rootDeclaration) || hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === SyntaxKind.ForOfStatement; if (!canGetType && rootDeclaration.kind === SyntaxKind.Parameter) { if (isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index 59353cb8686ed..9726df1487da8 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -1060,7 +1060,7 @@ namespace ts.FindAllReferences.Core { const containingTypeReference = getContainingTypeReference(refNode); if (containingTypeReference && state.markSeenContainingTypeReference(containingTypeReference)) { const parent = containingTypeReference.parent; - if (isVariableLike(parent) && parent.type === containingTypeReference && parent.initializer && isImplementationExpression(parent.initializer)) { + if (hasType(parent) && parent.type === containingTypeReference && hasInitializer(parent) && isImplementationExpression(parent.initializer)) { addReference(parent.initializer); } else if (isFunctionLike(parent) && parent.type === containingTypeReference && (parent as FunctionLikeDeclaration).body) { @@ -1670,14 +1670,12 @@ namespace ts.FindAllReferences.Core { if (!node) { return false; } - else if (isVariableLike(node)) { - if (node.initializer) { - return true; - } - else if (node.kind === SyntaxKind.VariableDeclaration) { - const parentStatement = getParentStatementOfVariableDeclaration(node); - return parentStatement && hasModifier(parentStatement, ModifierFlags.Ambient); - } + else if (isVariableLike(node) && hasInitializer(node)) { + return true; + } + else if (node.kind === SyntaxKind.VariableDeclaration) { + const parentStatement = getParentStatementOfVariableDeclaration(node); + return parentStatement && hasModifier(parentStatement, ModifierFlags.Ambient); } else if (isFunctionLike(node)) { return !!(node as FunctionLikeDeclaration).body || hasModifier(node, ModifierFlags.Ambient); diff --git a/tests/baselines/reference/ES5For-of31.types b/tests/baselines/reference/ES5For-of31.types index ee12f3894a8bb..309c8d1cab8c5 100644 --- a/tests/baselines/reference/ES5For-of31.types +++ b/tests/baselines/reference/ES5For-of31.types @@ -5,11 +5,11 @@ var a: string, b: number; for ({ a: b = 1, b: a = ""} of []) { >{ a: b = 1, b: a = ""} : { a?: number; b?: string; } ->a : undefined +>a : number >b = 1 : 1 >b : number >1 : 1 ->b : undefined +>b : string >a = "" : "" >a : string >"" : "" diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 464e70671f4bd..d90b7cdc3a989 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -453,6 +453,9 @@ declare namespace ts { interface JSDocContainer { } type HasJSDoc = ParameterDeclaration | CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | PropertySignature | ArrowFunction | ParenthesizedExpression | SpreadAssignment | ShorthandPropertyAssignment | PropertyAssignment | FunctionExpression | LabeledStatement | ExpressionStatement | VariableStatement | FunctionDeclaration | ConstructorDeclaration | MethodDeclaration | PropertyDeclaration | AccessorDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | EnumMember | EnumDeclaration | ModuleDeclaration | ImportEqualsDeclaration | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | EndOfFileToken; + type HasType = SignatureDeclaration | VariableDeclaration | ParameterDeclaration | PropertySignature | PropertyDeclaration | TypePredicateNode | ParenthesizedTypeNode | TypeOperatorNode | MappedTypeNode | AssertionExpression | TypeAliasDeclaration | JSDocTypeExpression | JSDocNonNullableType | JSDocNullableType | JSDocOptionalType | JSDocVariadicType; + type HasInitializer = HasExpressionInitializer | ForStatement | ForInStatement | ForOfStatement | JsxAttribute; + type HasExpressionInitializer = VariableDeclaration | ParameterDeclaration | BindingElement | PropertySignature | PropertyDeclaration | PropertyAssignment | EnumMember; interface NodeArray extends ReadonlyArray, TextRange { hasTrailingComma?: boolean; } @@ -604,15 +607,7 @@ declare namespace ts { kind: SyntaxKind.SpreadAssignment; expression: Expression; } - interface VariableLikeDeclaration extends NamedDeclaration { - propertyName?: PropertyName; - dotDotDotToken?: DotDotDotToken; - name: DeclarationName; - questionToken?: QuestionToken; - exclamationToken?: ExclamationToken; - type?: TypeNode; - initializer?: Expression; - } + type VariableLikeDeclaration = VariableDeclaration | ParameterDeclaration | BindingElement | PropertyDeclaration | PropertyAssignment | PropertySignature | JsxAttribute | ShorthandPropertyAssignment | EnumMember | JSDocPropertyTag | JSDocParameterTag; interface PropertyLikeDeclaration extends NamedDeclaration { name: PropertyName; } diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index bc7115a089a89..4d06e48dc2565 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -453,6 +453,9 @@ declare namespace ts { interface JSDocContainer { } type HasJSDoc = ParameterDeclaration | CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | PropertySignature | ArrowFunction | ParenthesizedExpression | SpreadAssignment | ShorthandPropertyAssignment | PropertyAssignment | FunctionExpression | LabeledStatement | ExpressionStatement | VariableStatement | FunctionDeclaration | ConstructorDeclaration | MethodDeclaration | PropertyDeclaration | AccessorDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | EnumMember | EnumDeclaration | ModuleDeclaration | ImportEqualsDeclaration | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | EndOfFileToken; + type HasType = SignatureDeclaration | VariableDeclaration | ParameterDeclaration | PropertySignature | PropertyDeclaration | TypePredicateNode | ParenthesizedTypeNode | TypeOperatorNode | MappedTypeNode | AssertionExpression | TypeAliasDeclaration | JSDocTypeExpression | JSDocNonNullableType | JSDocNullableType | JSDocOptionalType | JSDocVariadicType; + type HasInitializer = HasExpressionInitializer | ForStatement | ForInStatement | ForOfStatement | JsxAttribute; + type HasExpressionInitializer = VariableDeclaration | ParameterDeclaration | BindingElement | PropertySignature | PropertyDeclaration | PropertyAssignment | EnumMember; interface NodeArray extends ReadonlyArray, TextRange { hasTrailingComma?: boolean; } @@ -604,15 +607,7 @@ declare namespace ts { kind: SyntaxKind.SpreadAssignment; expression: Expression; } - interface VariableLikeDeclaration extends NamedDeclaration { - propertyName?: PropertyName; - dotDotDotToken?: DotDotDotToken; - name: DeclarationName; - questionToken?: QuestionToken; - exclamationToken?: ExclamationToken; - type?: TypeNode; - initializer?: Expression; - } + type VariableLikeDeclaration = VariableDeclaration | ParameterDeclaration | BindingElement | PropertyDeclaration | PropertyAssignment | PropertySignature | JsxAttribute | ShorthandPropertyAssignment | EnumMember | JSDocPropertyTag | JSDocParameterTag; interface PropertyLikeDeclaration extends NamedDeclaration { name: PropertyName; } diff --git a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.types b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.types index d8217600a66e1..d1b7c98087feb 100644 --- a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.types +++ b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.types @@ -475,9 +475,9 @@ module TypeScriptAllInOne { for (var x in { x: 0, y: 1 }) { >x : string >{ x: 0, y: 1 } : { x: number; y: number; } ->x : string +>x : number >0 : 0 ->y : string +>y : number >1 : 1 ! diff --git a/tests/baselines/reference/contextualTypeObjectSpreadExpression.types b/tests/baselines/reference/contextualTypeObjectSpreadExpression.types index 98b700b019a43..6f7a11c4290f7 100644 --- a/tests/baselines/reference/contextualTypeObjectSpreadExpression.types +++ b/tests/baselines/reference/contextualTypeObjectSpreadExpression.types @@ -14,6 +14,6 @@ i = { ...{ a: "a" } }; >i : I >{ ...{ a: "a" } } : { a: "a"; } >{ a: "a" } : { a: "a"; } ->a : string +>a : "a" >"a" : "a" diff --git a/tests/baselines/reference/contextualTypeShouldBeLiteral.types b/tests/baselines/reference/contextualTypeShouldBeLiteral.types index 8ab09df66b832..5ab0c26d84627 100644 --- a/tests/baselines/reference/contextualTypeShouldBeLiteral.types +++ b/tests/baselines/reference/contextualTypeShouldBeLiteral.types @@ -37,11 +37,11 @@ foo({ >{ type: 'y', value: 'done', method() { this; this.type; this.value; }} : { type: "y"; value: "done"; method(): void; } type: 'y', ->type : string +>type : "y" >'y' : "y" value: 'done', ->value : string +>value : "done" >'done' : "done" method() { @@ -100,11 +100,11 @@ foo2({ >{ type2: 'y', value: 'done', method() { this; this.value; }} : { type2: "y"; value: "done"; method(): void; } type2: 'y', ->type2 : string +>type2 : "y" >'y' : "y" value: 'done', ->value : string +>value : "done" >'done' : "done" method() { @@ -153,11 +153,11 @@ let xy: X3 | Y3 = { >{ type: 'y', value: 11, ytra: 12} : { type: "y"; value: 11; ytra: number; } type: 'y', ->type : string +>type : "y" >'y' : "y" value: 11, ->value : number +>value : 11 >11 : 11 ytra: 12 @@ -209,11 +209,11 @@ let xyz: LikeA | LikeB = { >{ x: 'x', y: 'y', value: "foo", method() { this; this.x; this.y; this.value; }} : { x: "x"; y: "y"; value: string; method(): void; } x: 'x', ->x : string +>x : "x" >'x' : "x" y: 'y', ->y : string +>y : "y" >'y' : "y" value: "foo", diff --git a/tests/baselines/reference/contextuallyTypedByDiscriminableUnion.types b/tests/baselines/reference/contextuallyTypedByDiscriminableUnion.types index d62dc4b5e0c8a..92f3fe42e128d 100644 --- a/tests/baselines/reference/contextuallyTypedByDiscriminableUnion.types +++ b/tests/baselines/reference/contextuallyTypedByDiscriminableUnion.types @@ -55,7 +55,7 @@ invoke({ >{ kind: "a", method(a) { return +a; }} : { kind: "a"; method(a: string): number; } kind: "a", ->kind : string +>kind : "a" >"a" : "a" method(a) { diff --git a/tests/baselines/reference/contextuallyTypedStringLiteralsInJsxAttributes01.types b/tests/baselines/reference/contextuallyTypedStringLiteralsInJsxAttributes01.types index 209c6fb2306a2..bdbd45392e85c 100644 --- a/tests/baselines/reference/contextuallyTypedStringLiteralsInJsxAttributes01.types +++ b/tests/baselines/reference/contextuallyTypedStringLiteralsInJsxAttributes01.types @@ -31,22 +31,22 @@ const FooComponent = (props: { foo: "A" | "B" | "C" }) => {props.foo}; > : JSX.Element >FooComponent : (props: { foo: "A" | "B" | "C"; }) => JSX.Element ->foo : string +>foo : "A" >"A" : "A" ; > : JSX.Element >FooComponent : (props: { foo: "A" | "B" | "C"; }) => JSX.Element ->foo : string +>foo : "A" ; > : JSX.Element >FooComponent : (props: { foo: "A" | "B" | "C"; }) => JSX.Element ->foo : string +>foo : "f" >"f" : "f" ; > : JSX.Element >FooComponent : (props: { foo: "A" | "B" | "C"; }) => JSX.Element ->foo : string +>foo : "f" diff --git a/tests/baselines/reference/contextuallyTypedStringLiteralsInJsxAttributes02.types b/tests/baselines/reference/contextuallyTypedStringLiteralsInJsxAttributes02.types index 570ae48509e80..08920e2a74064 100644 --- a/tests/baselines/reference/contextuallyTypedStringLiteralsInJsxAttributes02.types +++ b/tests/baselines/reference/contextuallyTypedStringLiteralsInJsxAttributes02.types @@ -112,7 +112,7 @@ const b3 = ; // goTo has type"home" | "c > : JSX.Element >MainButton : { (buttonProps: ButtonProps): JSX.Element; (linkProps: LinkProps): JSX.Element; } >{goTo:"home"} : { goTo: "home"; } ->goTo : string +>goTo : "home" >"home" : "home" >extra : true @@ -120,7 +120,7 @@ const b4 = ; // goTo has type "home" | "contact >b4 : JSX.Element > : JSX.Element >MainButton : { (buttonProps: ButtonProps): JSX.Element; (linkProps: LinkProps): JSX.Element; } ->goTo : string +>goTo : "home" >extra : true export function NoOverload(buttonProps: ButtonProps): JSX.Element { return undefined } @@ -159,7 +159,7 @@ const d1 = ; // goTo has type "home" | > : JSX.Element >NoOverload1 : (linkProps: LinkProps) => JSX.Element >{goTo:"home"} : { goTo: "home"; } ->goTo : string +>goTo : "home" >"home" : "home" >extra : true diff --git a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.types b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.types index fb2c7b295b275..7e6efdf426439 100644 --- a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.types +++ b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.types @@ -100,7 +100,7 @@ function f15() { >{ a4, b4, c4 } : { a4: string; b4: number; c4: boolean; } >a4 : string >b4 : number ->c4 : true +>c4 : boolean } var { a4, b4, c4 } = f15(); >a4 : string diff --git a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern2.types b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern2.types index a86976c0d1f40..c73afd0b9cff9 100644 --- a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern2.types +++ b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern2.types @@ -39,7 +39,7 @@ function f15() { >{ a4, b4, c4 } : { a4: string; b4: number; c4: boolean; } >a4 : string >b4 : number ->c4 : true +>c4 : boolean } var { a4, b4, c4 } = f15(); >a4 : string diff --git a/tests/baselines/reference/declarationsAndAssignments.types b/tests/baselines/reference/declarationsAndAssignments.types index e03a8cc6d3861..b49868c475083 100644 --- a/tests/baselines/reference/declarationsAndAssignments.types +++ b/tests/baselines/reference/declarationsAndAssignments.types @@ -495,7 +495,7 @@ function f15() { >{ a, b, c } : { a: string; b: number; c: boolean; } >a : string >b : number ->c : true +>c : boolean } function f16() { diff --git a/tests/baselines/reference/destructuredDeclarationEmit.types b/tests/baselines/reference/destructuredDeclarationEmit.types index 94845f94885be..c3bdad1bc9c40 100644 --- a/tests/baselines/reference/destructuredDeclarationEmit.types +++ b/tests/baselines/reference/destructuredDeclarationEmit.types @@ -29,10 +29,10 @@ const arr: [0, 1, 2, ['a', 'b', 'c', [{def: 'def'}, {sec: 'sec'}]]] = [0, 1, 2, >'c' : "c" >[{def: 'def'}, {sec: 'sec'}] : [{ def: "def"; }, { sec: "sec"; }] >{def: 'def'} : { def: "def"; } ->def : string +>def : "def" >'def' : "def" >{sec: 'sec'} : { sec: "sec"; } ->sec : string +>sec : "sec" >'sec' : "sec" export { foo, arr }; diff --git a/tests/baselines/reference/discriminatedUnionErrorMessage.types b/tests/baselines/reference/discriminatedUnionErrorMessage.types index 7fb553f37a19f..0c56c1ffd254f 100644 --- a/tests/baselines/reference/discriminatedUnionErrorMessage.types +++ b/tests/baselines/reference/discriminatedUnionErrorMessage.types @@ -33,7 +33,7 @@ let shape: Shape = { >{ kind: "sq", x: 12, y: 13,} : { kind: "sq"; x: number; y: number; } kind: "sq", ->kind : string +>kind : "sq" >"sq" : "sq" x: 12, diff --git a/tests/baselines/reference/excessPropertyCheckWithUnions.types b/tests/baselines/reference/excessPropertyCheckWithUnions.types index c2086b90dae01..4ef53e35ecc5a 100644 --- a/tests/baselines/reference/excessPropertyCheckWithUnions.types +++ b/tests/baselines/reference/excessPropertyCheckWithUnions.types @@ -23,7 +23,7 @@ let wrong: ADT = { tag: "T", a1: "extra" } >wrong : ADT >ADT : ADT >{ tag: "T", a1: "extra" } : { tag: "T"; a1: string; } ->tag : string +>tag : "T" >"T" : "T" >a1 : string >"extra" : "extra" @@ -32,7 +32,7 @@ wrong = { tag: "A", d20: 12 } >wrong = { tag: "A", d20: 12 } : { tag: "A"; d20: number; } >wrong : ADT >{ tag: "A", d20: 12 } : { tag: "A"; d20: number; } ->tag : string +>tag : "A" >"A" : "A" >d20 : number >12 : 12 @@ -41,7 +41,7 @@ wrong = { tag: "D" } >wrong = { tag: "D" } : { tag: "D"; } >wrong : ADT >{ tag: "D" } : { tag: "D"; } ->tag : string +>tag : "D" >"D" : "D" type Ambiguous = { @@ -80,7 +80,7 @@ amb = { tag: "A", x: "hi" } >amb = { tag: "A", x: "hi" } : { tag: "A"; x: string; } >amb : Ambiguous >{ tag: "A", x: "hi" } : { tag: "A"; x: string; } ->tag : string +>tag : "A" >"A" : "A" >x : string >"hi" : "hi" @@ -89,7 +89,7 @@ amb = { tag: "A", y: 12 } >amb = { tag: "A", y: 12 } : { tag: "A"; y: number; } >amb : Ambiguous >{ tag: "A", y: 12 } : { tag: "A"; y: number; } ->tag : string +>tag : "A" >"A" : "A" >y : number >12 : 12 @@ -98,7 +98,7 @@ amb = { tag: "A", x: "hi", y: 12 } >amb = { tag: "A", x: "hi", y: 12 } : { tag: "A"; x: string; y: number; } >amb : Ambiguous >{ tag: "A", x: "hi", y: 12 } : { tag: "A"; x: string; y: number; } ->tag : string +>tag : "A" >"A" : "A" >x : string >"hi" : "hi" @@ -110,7 +110,7 @@ amb = { tag: "A", x: "hi", extra: 12 } >amb = { tag: "A", x: "hi", extra: 12 } : { tag: "A"; x: string; extra: number; } >amb : Ambiguous >{ tag: "A", x: "hi", extra: 12 } : { tag: "A"; x: string; extra: number; } ->tag : string +>tag : "A" >"A" : "A" >x : string >"hi" : "hi" @@ -121,7 +121,7 @@ amb = { tag: "A", y: 12, extra: 12 } >amb = { tag: "A", y: 12, extra: 12 } : { tag: "A"; y: number; extra: number; } >amb : Ambiguous >{ tag: "A", y: 12, extra: 12 } : { tag: "A"; y: number; extra: number; } ->tag : string +>tag : "A" >"A" : "A" >y : number >12 : 12 @@ -135,14 +135,14 @@ amb = { tag: "A" } >amb = { tag: "A" } : { tag: "A"; } >amb : Ambiguous >{ tag: "A" } : { tag: "A"; } ->tag : string +>tag : "A" >"A" : "A" amb = { tag: "A", z: true } >amb = { tag: "A", z: true } : { tag: "A"; z: boolean; } >amb : Ambiguous >{ tag: "A", z: true } : { tag: "A"; z: boolean; } ->tag : string +>tag : "A" >"A" : "A" >z : boolean >true : true @@ -172,9 +172,9 @@ over = { a: 1, b: 1, first: "ok", second: "error" } >over = { a: 1, b: 1, first: "ok", second: "error" } : { a: 1; b: 1; first: string; second: string; } >over : Overlapping >{ a: 1, b: 1, first: "ok", second: "error" } : { a: 1; b: 1; first: string; second: string; } ->a : number +>a : 1 >1 : 1 ->b : number +>b : 1 >1 : 1 >first : string >"ok" : "ok" @@ -185,9 +185,9 @@ over = { a: 1, b: 1, first: "ok", third: "error" } >over = { a: 1, b: 1, first: "ok", third: "error" } : { a: 1; b: 1; first: string; third: string; } >over : Overlapping >{ a: 1, b: 1, first: "ok", third: "error" } : { a: 1; b: 1; first: string; third: string; } ->a : number +>a : 1 >1 : 1 ->b : number +>b : 1 >1 : 1 >first : string >"ok" : "ok" diff --git a/tests/baselines/reference/for-inStatements.types b/tests/baselines/reference/for-inStatements.types index 8b39d7b59ac8e..97ebc291e8a51 100644 --- a/tests/baselines/reference/for-inStatements.types +++ b/tests/baselines/reference/for-inStatements.types @@ -107,12 +107,12 @@ for (var x in ((x: T) => x)) { } for (var x in function (x: string, y: number) { return x + y }) { } >x : string ->function (x: string, y: number) { return x + y } : (x: string, y: string) => string +>function (x: string, y: number) { return x + y } : (x: string, y: number) => string >x : string ->y : string +>y : number >x + y : string >x : string ->y : string +>y : number class A { >A : A diff --git a/tests/baselines/reference/for-inStatementsDestructuring4.types b/tests/baselines/reference/for-inStatementsDestructuring4.types index 67278e3d7a364..26b833a1feb66 100644 --- a/tests/baselines/reference/for-inStatementsDestructuring4.types +++ b/tests/baselines/reference/for-inStatementsDestructuring4.types @@ -5,7 +5,7 @@ var a, b; for ({a, b} in []) { } >{a, b} : { a: any; b: any; } ->a : string ->b : string +>a : any +>b : any >[] : undefined[] diff --git a/tests/baselines/reference/for-inStatementsInvalid.types b/tests/baselines/reference/for-inStatementsInvalid.types index 0fdebd738deb2..f991c47a3a424 100644 --- a/tests/baselines/reference/for-inStatementsInvalid.types +++ b/tests/baselines/reference/for-inStatementsInvalid.types @@ -93,12 +93,12 @@ for (var x in ((x: T) => x)) { } for (var x in function (x: string, y: number) { return x + y }) { } >x : string ->function (x: string, y: number) { return x + y } : (x: string, y: string) => string +>function (x: string, y: number) { return x + y } : (x: string, y: number) => string >x : string ->y : string +>y : number >x + y : string >x : string ->y : string +>y : number class A { >A : A diff --git a/tests/baselines/reference/for-of47.types b/tests/baselines/reference/for-of47.types index 5e8cd4d04ded1..9f98a2c63b409 100644 --- a/tests/baselines/reference/for-of47.types +++ b/tests/baselines/reference/for-of47.types @@ -18,8 +18,8 @@ enum E { x } for ({x, y: y = E.x} of array) { >{x, y: y = E.x} : { x: string; y?: E; } ->x : { x: string; y: boolean; } ->y : { x: string; y: boolean; } +>x : string +>y : E >y = E.x : E >y : number >E.x : E diff --git a/tests/baselines/reference/for-of48.types b/tests/baselines/reference/for-of48.types index 6bb3efeeee7d3..af93d4968f249 100644 --- a/tests/baselines/reference/for-of48.types +++ b/tests/baselines/reference/for-of48.types @@ -18,8 +18,8 @@ enum E { x } for ({x, y = E.x} of array) { >{x, y = E.x} : { x: string; y?: number; } ->x : { x: string; y: boolean; } ->y : { x: string; y: boolean; } +>x : string +>y : number >E.x : E >E : typeof E >x : E diff --git a/tests/baselines/reference/literalIntersectionYieldsLiteral.types b/tests/baselines/reference/literalIntersectionYieldsLiteral.types index b169a19aef8f6..81eb311a5a2a0 100644 --- a/tests/baselines/reference/literalIntersectionYieldsLiteral.types +++ b/tests/baselines/reference/literalIntersectionYieldsLiteral.types @@ -4,6 +4,6 @@ const x: { type: string } & { type: "string" } = { type: "string" }; >type : string >type : "string" >{ type: "string" } : { type: "string"; } ->type : string +>type : "string" >"string" : "string" diff --git a/tests/baselines/reference/literalTypes2.types b/tests/baselines/reference/literalTypes2.types index b2ec339490fc6..85775fb06e3ef 100644 --- a/tests/baselines/reference/literalTypes2.types +++ b/tests/baselines/reference/literalTypes2.types @@ -262,7 +262,7 @@ function f3() { >c6 : { kind: 123; } >kind : 123 >{ kind: 123 } : { kind: 123; } ->kind : number +>kind : 123 >123 : 123 const c7: [1 | 2, "foo" | "bar"] = [1, "bar"]; @@ -412,9 +412,9 @@ function f4() { >a : 0 | 1 >b : "foo" | "bar" >{ a: 1, b: "foo" } : { a: 1; b: "foo"; } ->a : number +>a : 1 >1 : 1 ->b : string +>b : "foo" >"foo" : "foo" let x1 = { a: 1, b: "foo" }; @@ -430,9 +430,9 @@ function f4() { >a : 0 | 1 >b : "foo" | "bar" >{ a: 1, b: "foo" } : { a: 1; b: "foo"; } ->a : number +>a : 1 >1 : 1 ->b : string +>b : "foo" >"foo" : "foo" } @@ -487,11 +487,11 @@ function f6() { >c3 : "foo" | "bar" >"foo" : "foo" >{ c1: false, c2: 1, c3: "bar" } : { c1?: false; c2?: 1; c3?: "bar"; } ->c1 : boolean +>c1 : false >false : false ->c2 : number +>c2 : 1 >1 : 1 ->c3 : string +>c3 : "bar" >"bar" : "bar" let { x1 = true, x2 = 0, x3 = "foo" } = { x1: false, x2: 1, x3: "bar" }; diff --git a/tests/baselines/reference/literalTypesAndTypeAssertions.types b/tests/baselines/reference/literalTypesAndTypeAssertions.types index 4c38f74fd723c..1730c0ac42091 100644 --- a/tests/baselines/reference/literalTypesAndTypeAssertions.types +++ b/tests/baselines/reference/literalTypesAndTypeAssertions.types @@ -40,7 +40,7 @@ let { b = "foo" as "foo" } = { b: "bar" }; >"foo" as "foo" : "foo" >"foo" : "foo" >{ b: "bar" } : { b?: "bar"; } ->b : string +>b : "bar" >"bar" : "bar" let { c = "foo" } = { c: "bar" as "bar" }; diff --git a/tests/baselines/reference/mappedTypeIndexedAccess.types b/tests/baselines/reference/mappedTypeIndexedAccess.types index 345636b86ca3c..03335c7b49c71 100644 --- a/tests/baselines/reference/mappedTypeIndexedAccess.types +++ b/tests/baselines/reference/mappedTypeIndexedAccess.types @@ -47,7 +47,7 @@ let pair1: Pair = { >{ key: "foo", value: 3} : { key: "foo"; value: number; } key: "foo", ->key : string +>key : "foo" >"foo" : "foo" value: 3 @@ -65,7 +65,7 @@ let pair2: Pairs[keyof FooBar] = { >{ key: "foo", value: 3} : { key: "foo"; value: number; } key: "foo", ->key : string +>key : "foo" >"foo" : "foo" value: 3 diff --git a/tests/baselines/reference/nestedTypeVariableInfersLiteral.types b/tests/baselines/reference/nestedTypeVariableInfersLiteral.types index ed52dbb41b5b3..f93e367584760 100644 --- a/tests/baselines/reference/nestedTypeVariableInfersLiteral.types +++ b/tests/baselines/reference/nestedTypeVariableInfersLiteral.types @@ -47,7 +47,7 @@ const nestedSingle = nested({fields: "z"}) >nested({fields: "z"}) : Record<"z", string> >nested : (a: { fields: A; }) => Record >{fields: "z"} : { fields: "z"; } ->fields : string +>fields : "z" >"z" : "z" const nestedUnionSingle = nestedUnion({fields: "z"}) @@ -55,7 +55,7 @@ const nestedUnionSingle = nestedUnion({fields: "z"}) >nestedUnion({fields: "z"}) : Record<"z", string> >nestedUnion : (a: { fields: A | A[]; }) => Record >{fields: "z"} : { fields: "z"; } ->fields : string +>fields : "z" >"z" : "z" const nestedUnionArray = nestedUnion({fields: ["z", "y"]}) diff --git a/tests/baselines/reference/objectRestForOf.types b/tests/baselines/reference/objectRestForOf.types index 43d42a045e182..30e10999bc78e 100644 --- a/tests/baselines/reference/objectRestForOf.types +++ b/tests/baselines/reference/objectRestForOf.types @@ -23,7 +23,7 @@ let rrestOff: { y: string }; for ({ x: xx, ...rrestOff } of array ) { >{ x: xx, ...rrestOff } : { y: string; x: number; } ->x : { x: number; y: string; } +>x : number >xx : number >rrestOff : { y: string; } >array : { x: number; y: string; }[] diff --git a/tests/baselines/reference/shorthand-property-es5-es6.types b/tests/baselines/reference/shorthand-property-es5-es6.types index d15c5104f9260..298aae2c58d90 100644 --- a/tests/baselines/reference/shorthand-property-es5-es6.types +++ b/tests/baselines/reference/shorthand-property-es5-es6.types @@ -10,5 +10,5 @@ const bar = { foo, baz }; >bar : { foo: any; baz: number; } >{ foo, baz } : { foo: any; baz: number; } >foo : any ->baz : 42 +>baz : number diff --git a/tests/baselines/reference/shorthand-property-es6-amd.types b/tests/baselines/reference/shorthand-property-es6-amd.types index d15c5104f9260..298aae2c58d90 100644 --- a/tests/baselines/reference/shorthand-property-es6-amd.types +++ b/tests/baselines/reference/shorthand-property-es6-amd.types @@ -10,5 +10,5 @@ const bar = { foo, baz }; >bar : { foo: any; baz: number; } >{ foo, baz } : { foo: any; baz: number; } >foo : any ->baz : 42 +>baz : number diff --git a/tests/baselines/reference/shorthand-property-es6-es6.types b/tests/baselines/reference/shorthand-property-es6-es6.types index d15c5104f9260..298aae2c58d90 100644 --- a/tests/baselines/reference/shorthand-property-es6-es6.types +++ b/tests/baselines/reference/shorthand-property-es6-es6.types @@ -10,5 +10,5 @@ const bar = { foo, baz }; >bar : { foo: any; baz: number; } >{ foo, baz } : { foo: any; baz: number; } >foo : any ->baz : 42 +>baz : number diff --git a/tests/baselines/reference/shorthandOfExportedEntity01_targetES2015_CommonJS.types b/tests/baselines/reference/shorthandOfExportedEntity01_targetES2015_CommonJS.types index 2959acfeb64ec..6cb51a8f0b4a4 100644 --- a/tests/baselines/reference/shorthandOfExportedEntity01_targetES2015_CommonJS.types +++ b/tests/baselines/reference/shorthandOfExportedEntity01_targetES2015_CommonJS.types @@ -9,6 +9,6 @@ export function foo () { const x = { test }; >x : { test: string; } >{ test } : { test: string; } ->test : "test" +>test : string } diff --git a/tests/baselines/reference/shorthandOfExportedEntity02_targetES5_CommonJS.types b/tests/baselines/reference/shorthandOfExportedEntity02_targetES5_CommonJS.types index 146a32e14a50f..80316dfb57954 100644 --- a/tests/baselines/reference/shorthandOfExportedEntity02_targetES5_CommonJS.types +++ b/tests/baselines/reference/shorthandOfExportedEntity02_targetES5_CommonJS.types @@ -9,6 +9,6 @@ export function foo () { const x = { test }; >x : { test: string; } >{ test } : { test: string; } ->test : "test" +>test : string } diff --git a/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring.types b/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring.types index 864a04d7b82a2..80d148880527b 100644 --- a/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring.types +++ b/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring.types @@ -8,7 +8,7 @@ for ({ s0 = 5 } of [{ s0: 1 }]) { >{ s0 = 5 } : { s0?: any; } ->s0 : { s0: number; } +>s0 : any >[{ s0: 1 }] : { s0: number; }[] >{ s0: 1 } : { s0: number; } >s0 : number @@ -24,7 +24,7 @@ for ({ s0:s0 = 5 } of [{ s0: 1 }]) { >{ s0:s0 = 5 } : { s0?: number; } ->s0 : { s0: number; } +>s0 : number >s0 = 5 : 5 >s0 : any >5 : 5 @@ -44,7 +44,7 @@ for ({ s1 = 5 } of [{}]) { >{ s1 = 5 } : { s1?: any; } ->s1 : {} +>s1 : any >[{}] : {}[] >{} : {} } @@ -59,7 +59,7 @@ for ({ s1:s1 = 5 } of [{}]) { >{ s1:s1 = 5 } : { s1?: number; } ->s1 : {} +>s1 : number >s1 = 5 : 5 >s1 : any >5 : 5 @@ -77,7 +77,7 @@ for ({ s2 = 5 } of [{ s2: "" }]) { >{ s2 = 5 } : { s2?: any; } ->s2 : { s2: string; } +>s2 : any >[{ s2: "" }] : { s2: string; }[] >{ s2: "" } : { s2: string; } >s2 : string @@ -94,7 +94,7 @@ for ({ s2:s2 = 5 } of [{ s2: "" }]) { >{ s2:s2 = 5 } : { s2?: number; } ->s2 : { s2: string; } +>s2 : number >s2 = 5 : 5 >s2 : any >5 : 5 @@ -114,7 +114,7 @@ for ({ s3 = 5 } of [{ s3: "" }]) { >{ s3 = 5 } : { s3?: string; } ->s3 : { s3: string; } +>s3 : string >[{ s3: "" }] : { s3: string; }[] >{ s3: "" } : { s3: string; } >s3 : string @@ -131,7 +131,7 @@ for ({ s3:s3 = 5 } of [{ s3: "" }]) { >{ s3:s3 = 5 } : { s3?: number; } ->s3 : { s3: string; } +>s3 : number >s3 = 5 : 5 >s3 : string >5 : 5 diff --git a/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring_ES6.types b/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring_ES6.types index 939d9864fd086..5e3d61d09b149 100644 --- a/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring_ES6.types +++ b/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring_ES6.types @@ -8,7 +8,7 @@ for ({ s0 = 5 } of [{ s0: 1 }]) { >{ s0 = 5 } : { s0?: any; } ->s0 : { s0: number; } +>s0 : any >[{ s0: 1 }] : { s0: number; }[] >{ s0: 1 } : { s0: number; } >s0 : number @@ -24,7 +24,7 @@ for ({ s0:s0 = 5 } of [{ s0: 1 }]) { >{ s0:s0 = 5 } : { s0?: number; } ->s0 : { s0: number; } +>s0 : number >s0 = 5 : 5 >s0 : any >5 : 5 @@ -44,7 +44,7 @@ for ({ s1 = 5 } of [{}]) { >{ s1 = 5 } : { s1?: any; } ->s1 : {} +>s1 : any >[{}] : {}[] >{} : {} } @@ -59,7 +59,7 @@ for ({ s1:s1 = 5 } of [{}]) { >{ s1:s1 = 5 } : { s1?: number; } ->s1 : {} +>s1 : number >s1 = 5 : 5 >s1 : any >5 : 5 @@ -77,7 +77,7 @@ for ({ s2 = 5 } of [{ s2: "" }]) { >{ s2 = 5 } : { s2?: any; } ->s2 : { s2: string; } +>s2 : any >[{ s2: "" }] : { s2: string; }[] >{ s2: "" } : { s2: string; } >s2 : string @@ -94,7 +94,7 @@ for ({ s2:s2 = 5 } of [{ s2: "" }]) { >{ s2:s2 = 5 } : { s2?: number; } ->s2 : { s2: string; } +>s2 : number >s2 = 5 : 5 >s2 : any >5 : 5 @@ -114,7 +114,7 @@ for ({ s3 = 5 } of [{ s3: "" }]) { >{ s3 = 5 } : { s3?: string; } ->s3 : { s3: string; } +>s3 : string >[{ s3: "" }] : { s3: string; }[] >{ s3: "" } : { s3: string; } >s3 : string @@ -131,7 +131,7 @@ for ({ s3:s3 = 5 } of [{ s3: "" }]) { >{ s3:s3 = 5 } : { s3?: number; } ->s3 : { s3: string; } +>s3 : number >s3 = 5 : 5 >s3 : string >5 : 5 diff --git a/tests/baselines/reference/sourceMapValidationDestructuringForOfObjectBindingPattern2.types b/tests/baselines/reference/sourceMapValidationDestructuringForOfObjectBindingPattern2.types index 64680d66001d9..6479900ef1a5a 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringForOfObjectBindingPattern2.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringForOfObjectBindingPattern2.types @@ -103,7 +103,7 @@ let name: string, primary: string, secondary: string, skill: string; for ({name: nameA } of robots) { >{name: nameA } : { name: string; } ->name : Robot +>name : string >nameA : string >robots : Robot[] @@ -116,7 +116,7 @@ for ({name: nameA } of robots) { } for ({name: nameA } of getRobots()) { >{name: nameA } : { name: string; } ->name : Robot +>name : string >nameA : string >getRobots() : Robot[] >getRobots : () => Robot[] @@ -130,7 +130,7 @@ for ({name: nameA } of getRobots()) { } for ({name: nameA } of [{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }]) { >{name: nameA } : { name: string; } ->name : { name: string; skill: string; } +>name : string >nameA : string >[{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }] : { name: string; skill: string; }[] >{ name: "mower", skill: "mowing" } : { name: string; skill: string; } @@ -153,7 +153,7 @@ for ({name: nameA } of [{ name: "mower", skill: "mowing" }, { name: "trimmer", s } for ({ skills: { primary: primaryA, secondary: secondaryA } } of multiRobots) { >{ skills: { primary: primaryA, secondary: secondaryA } } : { skills: { primary: string; secondary: string; }; } ->skills : MultiRobot +>skills : { primary: string; secondary: string; } >{ primary: primaryA, secondary: secondaryA } : { primary: string; secondary: string; } >primary : string >primaryA : string @@ -170,7 +170,7 @@ for ({ skills: { primary: primaryA, secondary: secondaryA } } of multiRobots) { } for ({ skills: { primary: primaryA, secondary: secondaryA } } of getMultiRobots()) { >{ skills: { primary: primaryA, secondary: secondaryA } } : { skills: { primary: string; secondary: string; }; } ->skills : MultiRobot +>skills : { primary: string; secondary: string; } >{ primary: primaryA, secondary: secondaryA } : { primary: string; secondary: string; } >primary : string >primaryA : string @@ -188,7 +188,7 @@ for ({ skills: { primary: primaryA, secondary: secondaryA } } of getMultiRobots( } for ({ skills: { primary: primaryA, secondary: secondaryA } } of [{ name: "mower", skills: { primary: "mowing", secondary: "none" } }, >{ skills: { primary: primaryA, secondary: secondaryA } } : { skills: { primary: string; secondary: string; }; } ->skills : { name: string; skills: { primary: string; secondary: string; }; } +>skills : { primary: string; secondary: string; } >{ primary: primaryA, secondary: secondaryA } : { primary: string; secondary: string; } >primary : string >primaryA : string @@ -225,7 +225,7 @@ for ({ skills: { primary: primaryA, secondary: secondaryA } } of [{ name: "mower } for ({name } of robots) { >{name } : { name: string; } ->name : Robot +>name : string >robots : Robot[] console.log(nameA); @@ -237,7 +237,7 @@ for ({name } of robots) { } for ({name } of getRobots()) { >{name } : { name: string; } ->name : Robot +>name : string >getRobots() : Robot[] >getRobots : () => Robot[] @@ -250,7 +250,7 @@ for ({name } of getRobots()) { } for ({name } of [{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }]) { >{name } : { name: string; } ->name : { name: string; skill: string; } +>name : string >[{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }] : { name: string; skill: string; }[] >{ name: "mower", skill: "mowing" } : { name: string; skill: string; } >name : string @@ -272,7 +272,7 @@ for ({name } of [{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: " } for ({ skills: { primary, secondary } } of multiRobots) { >{ skills: { primary, secondary } } : { skills: { primary: string; secondary: string; }; } ->skills : MultiRobot +>skills : { primary: string; secondary: string; } >{ primary, secondary } : { primary: string; secondary: string; } >primary : string >secondary : string @@ -287,7 +287,7 @@ for ({ skills: { primary, secondary } } of multiRobots) { } for ({ skills: { primary, secondary } } of getMultiRobots()) { >{ skills: { primary, secondary } } : { skills: { primary: string; secondary: string; }; } ->skills : MultiRobot +>skills : { primary: string; secondary: string; } >{ primary, secondary } : { primary: string; secondary: string; } >primary : string >secondary : string @@ -303,7 +303,7 @@ for ({ skills: { primary, secondary } } of getMultiRobots()) { } for ({ skills: { primary, secondary } } of [{ name: "mower", skills: { primary: "mowing", secondary: "none" } }, >{ skills: { primary, secondary } } : { skills: { primary: string; secondary: string; }; } ->skills : { name: string; skills: { primary: string; secondary: string; }; } +>skills : { primary: string; secondary: string; } >{ primary, secondary } : { primary: string; secondary: string; } >primary : string >secondary : string @@ -340,9 +340,9 @@ for ({ skills: { primary, secondary } } of [{ name: "mower", skills: { primary: for ({name: nameA, skill: skillA } of robots) { >{name: nameA, skill: skillA } : { name: string; skill: string; } ->name : Robot +>name : string >nameA : string ->skill : Robot +>skill : string >skillA : string >robots : Robot[] @@ -355,9 +355,9 @@ for ({name: nameA, skill: skillA } of robots) { } for ({name: nameA, skill: skillA } of getRobots()) { >{name: nameA, skill: skillA } : { name: string; skill: string; } ->name : Robot +>name : string >nameA : string ->skill : Robot +>skill : string >skillA : string >getRobots() : Robot[] >getRobots : () => Robot[] @@ -371,9 +371,9 @@ for ({name: nameA, skill: skillA } of getRobots()) { } for ({name: nameA, skill: skillA } of [{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }]) { >{name: nameA, skill: skillA } : { name: string; skill: string; } ->name : { name: string; skill: string; } +>name : string >nameA : string ->skill : { name: string; skill: string; } +>skill : string >skillA : string >[{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }] : { name: string; skill: string; }[] >{ name: "mower", skill: "mowing" } : { name: string; skill: string; } @@ -396,9 +396,9 @@ for ({name: nameA, skill: skillA } of [{ name: "mower", skill: "mowing" }, { nam } for ({name: nameA, skills: { primary: primaryA, secondary: secondaryA } } of multiRobots) { >{name: nameA, skills: { primary: primaryA, secondary: secondaryA } } : { name: string; skills: { primary: string; secondary: string; }; } ->name : MultiRobot +>name : string >nameA : string ->skills : MultiRobot +>skills : { primary: string; secondary: string; } >{ primary: primaryA, secondary: secondaryA } : { primary: string; secondary: string; } >primary : string >primaryA : string @@ -415,9 +415,9 @@ for ({name: nameA, skills: { primary: primaryA, secondary: secondaryA } } of mul } for ({name: nameA, skills: { primary: primaryA, secondary: secondaryA } } of getMultiRobots()) { >{name: nameA, skills: { primary: primaryA, secondary: secondaryA } } : { name: string; skills: { primary: string; secondary: string; }; } ->name : MultiRobot +>name : string >nameA : string ->skills : MultiRobot +>skills : { primary: string; secondary: string; } >{ primary: primaryA, secondary: secondaryA } : { primary: string; secondary: string; } >primary : string >primaryA : string @@ -435,9 +435,9 @@ for ({name: nameA, skills: { primary: primaryA, secondary: secondaryA } } of get } for ({name: nameA, skills: { primary: primaryA, secondary: secondaryA } } of [{ name: "mower", skills: { primary: "mowing", secondary: "none" } }, >{name: nameA, skills: { primary: primaryA, secondary: secondaryA } } : { name: string; skills: { primary: string; secondary: string; }; } ->name : { name: string; skills: { primary: string; secondary: string; }; } +>name : string >nameA : string ->skills : { name: string; skills: { primary: string; secondary: string; }; } +>skills : { primary: string; secondary: string; } >{ primary: primaryA, secondary: secondaryA } : { primary: string; secondary: string; } >primary : string >primaryA : string @@ -474,8 +474,8 @@ for ({name: nameA, skills: { primary: primaryA, secondary: secondaryA } } of [{ } for ({name, skill } of robots) { >{name, skill } : { name: string; skill: string; } ->name : Robot ->skill : Robot +>name : string +>skill : string >robots : Robot[] console.log(nameA); @@ -487,8 +487,8 @@ for ({name, skill } of robots) { } for ({name, skill } of getRobots()) { >{name, skill } : { name: string; skill: string; } ->name : Robot ->skill : Robot +>name : string +>skill : string >getRobots() : Robot[] >getRobots : () => Robot[] @@ -501,8 +501,8 @@ for ({name, skill } of getRobots()) { } for ({name, skill } of [{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }]) { >{name, skill } : { name: string; skill: string; } ->name : { name: string; skill: string; } ->skill : { name: string; skill: string; } +>name : string +>skill : string >[{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }] : { name: string; skill: string; }[] >{ name: "mower", skill: "mowing" } : { name: string; skill: string; } >name : string @@ -524,8 +524,8 @@ for ({name, skill } of [{ name: "mower", skill: "mowing" }, { name: "trimmer", s } for ({name, skills: { primary, secondary } } of multiRobots) { >{name, skills: { primary, secondary } } : { name: string; skills: { primary: string; secondary: string; }; } ->name : MultiRobot ->skills : MultiRobot +>name : string +>skills : { primary: string; secondary: string; } >{ primary, secondary } : { primary: string; secondary: string; } >primary : string >secondary : string @@ -540,8 +540,8 @@ for ({name, skills: { primary, secondary } } of multiRobots) { } for ({name, skills: { primary, secondary } } of getMultiRobots()) { >{name, skills: { primary, secondary } } : { name: string; skills: { primary: string; secondary: string; }; } ->name : MultiRobot ->skills : MultiRobot +>name : string +>skills : { primary: string; secondary: string; } >{ primary, secondary } : { primary: string; secondary: string; } >primary : string >secondary : string @@ -557,8 +557,8 @@ for ({name, skills: { primary, secondary } } of getMultiRobots()) { } for ({name, skills: { primary, secondary } } of [{ name: "mower", skills: { primary: "mowing", secondary: "none" } }, >{name, skills: { primary, secondary } } : { name: string; skills: { primary: string; secondary: string; }; } ->name : { name: string; skills: { primary: string; secondary: string; }; } ->skills : { name: string; skills: { primary: string; secondary: string; }; } +>name : string +>skills : { primary: string; secondary: string; } >{ primary, secondary } : { primary: string; secondary: string; } >primary : string >secondary : string diff --git a/tests/baselines/reference/sourceMapValidationDestructuringForOfObjectBindingPatternDefaultValues2.types b/tests/baselines/reference/sourceMapValidationDestructuringForOfObjectBindingPatternDefaultValues2.types index 6119665124d2d..c3d941870be6b 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringForOfObjectBindingPatternDefaultValues2.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringForOfObjectBindingPatternDefaultValues2.types @@ -103,7 +103,7 @@ let name: string, primary: string, secondary: string, skill: string; for ({name: nameA = "noName" } of robots) { >{name: nameA = "noName" } : { name?: string; } ->name : Robot +>name : string >nameA = "noName" : "noName" >nameA : string >"noName" : "noName" @@ -118,7 +118,7 @@ for ({name: nameA = "noName" } of robots) { } for ({name: nameA = "noName" } of getRobots()) { >{name: nameA = "noName" } : { name?: string; } ->name : Robot +>name : string >nameA = "noName" : "noName" >nameA : string >"noName" : "noName" @@ -134,7 +134,7 @@ for ({name: nameA = "noName" } of getRobots()) { } for ({name: nameA = "noName" } of [{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }]) { >{name: nameA = "noName" } : { name?: string; } ->name : { name: string; skill: string; } +>name : string >nameA = "noName" : "noName" >nameA : string >"noName" : "noName" @@ -159,7 +159,7 @@ for ({name: nameA = "noName" } of [{ name: "mower", skill: "mowing" }, { name: " } for ({ skills: { primary: primaryA = "primary", secondary: secondaryA = "secondary" } = >{ skills: { primary: primaryA = "primary", secondary: secondaryA = "secondary" } = { primary: "nosKill", secondary: "noSkill" } } : { skills?: { primary?: string; secondary?: string; }; } ->skills : MultiRobot +>skills : { primary?: string; secondary?: string; } >{ primary: primaryA = "primary", secondary: secondaryA = "secondary" } = { primary: "nosKill", secondary: "noSkill" } : { primary?: string; secondary?: string; } >{ primary: primaryA = "primary", secondary: secondaryA = "secondary" } : { primary?: string; secondary?: string; } >primary : string @@ -188,7 +188,7 @@ for ({ skills: { primary: primaryA = "primary", secondary: secondaryA = "seconda } for ({ skills: { primary: primaryA = "primary", secondary: secondaryA = "secondary" } = >{ skills: { primary: primaryA = "primary", secondary: secondaryA = "secondary" } = { primary: "nosKill", secondary: "noSkill" } } : { skills?: { primary?: string; secondary?: string; }; } ->skills : MultiRobot +>skills : { primary?: string; secondary?: string; } >{ primary: primaryA = "primary", secondary: secondaryA = "secondary" } = { primary: "nosKill", secondary: "noSkill" } : { primary?: string; secondary?: string; } >{ primary: primaryA = "primary", secondary: secondaryA = "secondary" } : { primary?: string; secondary?: string; } >primary : string @@ -218,7 +218,7 @@ for ({ skills: { primary: primaryA = "primary", secondary: secondaryA = "seconda } for ({ skills: { primary: primaryA = "primary", secondary: secondaryA = "secondary" } = >{ skills: { primary: primaryA = "primary", secondary: secondaryA = "secondary" } = { primary: "nosKill", secondary: "noSkill" } } : { skills?: { primary?: string; secondary?: string; }; } ->skills : MultiRobot +>skills : { primary?: string; secondary?: string; } >{ primary: primaryA = "primary", secondary: secondaryA = "secondary" } = { primary: "nosKill", secondary: "noSkill" } : { primary?: string; secondary?: string; } >{ primary: primaryA = "primary", secondary: secondaryA = "secondary" } : { primary?: string; secondary?: string; } >primary : string @@ -272,7 +272,7 @@ for ({ skills: { primary: primaryA = "primary", secondary: secondaryA = "seconda for ({ name = "noName" } of robots) { >{ name = "noName" } : { name?: string; } ->name : Robot +>name : string >robots : Robot[] console.log(nameA); @@ -284,7 +284,7 @@ for ({ name = "noName" } of robots) { } for ({ name = "noName" } of getRobots()) { >{ name = "noName" } : { name?: string; } ->name : Robot +>name : string >getRobots() : Robot[] >getRobots : () => Robot[] @@ -297,7 +297,7 @@ for ({ name = "noName" } of getRobots()) { } for ({ name = "noName" } of [{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }]) { >{ name = "noName" } : { name?: string; } ->name : { name: string; skill: string; } +>name : string >[{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }] : { name: string; skill: string; }[] >{ name: "mower", skill: "mowing" } : { name: string; skill: string; } >name : string @@ -321,7 +321,7 @@ for ({ >{ skills: { primary = "primary", secondary = "secondary" } = { primary: "noSkill", secondary: "noSkill" }} : { skills?: { primary?: string; secondary?: string; }; } skills: { ->skills : MultiRobot +>skills : { primary?: string; secondary?: string; } >{ primary = "primary", secondary = "secondary" } = { primary: "noSkill", secondary: "noSkill" } : { primary?: string; secondary?: string; } >{ primary = "primary", secondary = "secondary" } : { primary?: string; secondary?: string; } @@ -352,7 +352,7 @@ for ({ >{ skills: { primary = "primary", secondary = "secondary" } = { primary: "noSkill", secondary: "noSkill" }} : { skills?: { primary?: string; secondary?: string; }; } skills: { ->skills : MultiRobot +>skills : { primary?: string; secondary?: string; } >{ primary = "primary", secondary = "secondary" } = { primary: "noSkill", secondary: "noSkill" } : { primary?: string; secondary?: string; } >{ primary = "primary", secondary = "secondary" } : { primary?: string; secondary?: string; } @@ -384,7 +384,7 @@ for ({ >{ skills: { primary = "primary", secondary = "secondary" } = { primary: "noSkill", secondary: "noSkill" }} : { skills?: { primary?: string; secondary?: string; }; } skills: { ->skills : { name: string; skills: { primary: string; secondary: string; }; } +>skills : { primary?: string; secondary?: string; } >{ primary = "primary", secondary = "secondary" } = { primary: "noSkill", secondary: "noSkill" } : { primary?: string; secondary?: string; } >{ primary = "primary", secondary = "secondary" } : { primary?: string; secondary?: string; } @@ -435,11 +435,11 @@ for ({ for ({name: nameA = "noName", skill: skillA = "noSkill" } of robots) { >{name: nameA = "noName", skill: skillA = "noSkill" } : { name?: string; skill?: string; } ->name : Robot +>name : string >nameA = "noName" : "noName" >nameA : string >"noName" : "noName" ->skill : Robot +>skill : string >skillA = "noSkill" : "noSkill" >skillA : string >"noSkill" : "noSkill" @@ -454,11 +454,11 @@ for ({name: nameA = "noName", skill: skillA = "noSkill" } of robots) { } for ({name: nameA = "noName", skill: skillA = "noSkill" } of getRobots()) { >{name: nameA = "noName", skill: skillA = "noSkill" } : { name?: string; skill?: string; } ->name : Robot +>name : string >nameA = "noName" : "noName" >nameA : string >"noName" : "noName" ->skill : Robot +>skill : string >skillA = "noSkill" : "noSkill" >skillA : string >"noSkill" : "noSkill" @@ -474,11 +474,11 @@ for ({name: nameA = "noName", skill: skillA = "noSkill" } of getRobots()) { } for ({name: nameA = "noName", skill: skillA = "noSkill" } of [{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }]) { >{name: nameA = "noName", skill: skillA = "noSkill" } : { name?: string; skill?: string; } ->name : { name: string; skill: string; } +>name : string >nameA = "noName" : "noName" >nameA : string >"noName" : "noName" ->skill : { name: string; skill: string; } +>skill : string >skillA = "noSkill" : "noSkill" >skillA : string >"noSkill" : "noSkill" @@ -505,13 +505,13 @@ for ({ >{ name: nameA = "noName", skills: { primary: primaryA = "primary", secondary: secondaryA = "secondary" } = { primary: "noSkill", secondary: "noSkill" }} : { name?: string; skills?: { primary?: string; secondary?: string; }; } name: nameA = "noName", ->name : MultiRobot +>name : string >nameA = "noName" : "noName" >nameA : string >"noName" : "noName" skills: { ->skills : MultiRobot +>skills : { primary?: string; secondary?: string; } >{ primary: primaryA = "primary", secondary: secondaryA = "secondary" } = { primary: "noSkill", secondary: "noSkill" } : { primary?: string; secondary?: string; } >{ primary: primaryA = "primary", secondary: secondaryA = "secondary" } : { primary?: string; secondary?: string; } @@ -548,13 +548,13 @@ for ({ >{ name: nameA = "noName", skills: { primary: primaryA = "primary", secondary: secondaryA = "secondary" } = { primary: "noSkill", secondary: "noSkill" }} : { name?: string; skills?: { primary?: string; secondary?: string; }; } name: nameA = "noName", ->name : MultiRobot +>name : string >nameA = "noName" : "noName" >nameA : string >"noName" : "noName" skills: { ->skills : MultiRobot +>skills : { primary?: string; secondary?: string; } >{ primary: primaryA = "primary", secondary: secondaryA = "secondary" } = { primary: "noSkill", secondary: "noSkill" } : { primary?: string; secondary?: string; } >{ primary: primaryA = "primary", secondary: secondaryA = "secondary" } : { primary?: string; secondary?: string; } @@ -592,13 +592,13 @@ for ({ >{ name: nameA = "noName", skills: { primary: primaryA = "primary", secondary: secondaryA = "secondary" } = { primary: "noSkill", secondary: "noSkill" }} : { name?: string; skills?: { primary?: string; secondary?: string; }; } name: nameA = "noName", ->name : MultiRobot +>name : string >nameA = "noName" : "noName" >nameA : string >"noName" : "noName" skills: { ->skills : MultiRobot +>skills : { primary?: string; secondary?: string; } >{ primary: primaryA = "primary", secondary: secondaryA = "secondary" } = { primary: "noSkill", secondary: "noSkill" } : { primary?: string; secondary?: string; } >{ primary: primaryA = "primary", secondary: secondaryA = "secondary" } : { primary?: string; secondary?: string; } @@ -656,8 +656,8 @@ for ({ for ({ name = "noName", skill = "noSkill" } of robots) { >{ name = "noName", skill = "noSkill" } : { name?: string; skill?: string; } ->name : Robot ->skill : Robot +>name : string +>skill : string >robots : Robot[] console.log(nameA); @@ -669,8 +669,8 @@ for ({ name = "noName", skill = "noSkill" } of robots) { } for ({ name = "noName", skill = "noSkill" } of getRobots()) { >{ name = "noName", skill = "noSkill" } : { name?: string; skill?: string; } ->name : Robot ->skill : Robot +>name : string +>skill : string >getRobots() : Robot[] >getRobots : () => Robot[] @@ -683,8 +683,8 @@ for ({ name = "noName", skill = "noSkill" } of getRobots()) { } for ({ name = "noName", skill = "noSkill" } of [{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }]) { >{ name = "noName", skill = "noSkill" } : { name?: string; skill?: string; } ->name : { name: string; skill: string; } ->skill : { name: string; skill: string; } +>name : string +>skill : string >[{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }] : { name: string; skill: string; }[] >{ name: "mower", skill: "mowing" } : { name: string; skill: string; } >name : string @@ -708,10 +708,10 @@ for ({ >{ name = "noName", skills: { primary = "primary", secondary = "secondary" } = { primary: "noSkill", secondary: "noSkill" }} : { name?: string; skills?: { primary?: string; secondary?: string; }; } name = "noName", ->name : MultiRobot +>name : string skills: { ->skills : MultiRobot +>skills : { primary?: string; secondary?: string; } >{ primary = "primary", secondary = "secondary" } = { primary: "noSkill", secondary: "noSkill" } : { primary?: string; secondary?: string; } >{ primary = "primary", secondary = "secondary" } : { primary?: string; secondary?: string; } @@ -742,10 +742,10 @@ for ({ >{ name = "noName", skills: { primary = "primary", secondary = "secondary" } = { primary: "noSkill", secondary: "noSkill" }} : { name?: string; skills?: { primary?: string; secondary?: string; }; } name = "noName", ->name : MultiRobot +>name : string skills: { ->skills : MultiRobot +>skills : { primary?: string; secondary?: string; } >{ primary = "primary", secondary = "secondary" } = { primary: "noSkill", secondary: "noSkill" } : { primary?: string; secondary?: string; } >{ primary = "primary", secondary = "secondary" } : { primary?: string; secondary?: string; } @@ -777,10 +777,10 @@ for ({ >{ name = "noName", skills: { primary = "primary", secondary = "secondary" } = { primary: "noSkill", secondary: "noSkill" }} : { name?: string; skills?: { primary?: string; secondary?: string; }; } name = "noName", ->name : { name: string; skills: { primary: string; secondary: string; }; } +>name : string skills: { ->skills : { name: string; skills: { primary: string; secondary: string; }; } +>skills : { primary?: string; secondary?: string; } >{ primary = "primary", secondary = "secondary" } = { primary: "noSkill", secondary: "noSkill" } : { primary?: string; secondary?: string; } >{ primary = "primary", secondary = "secondary" } : { primary?: string; secondary?: string; } diff --git a/tests/baselines/reference/stringLiteralTypesAsTags01.types b/tests/baselines/reference/stringLiteralTypesAsTags01.types index 6caf851a72648..d7245af4978dd 100644 --- a/tests/baselines/reference/stringLiteralTypesAsTags01.types +++ b/tests/baselines/reference/stringLiteralTypesAsTags01.types @@ -78,7 +78,7 @@ let x: A = { >{ kind: "A", a: 100,} : { kind: "A"; a: number; } kind: "A", ->kind : string +>kind : "A" >"A" : "A" a: 100, diff --git a/tests/baselines/reference/stringLiteralTypesAsTags02.types b/tests/baselines/reference/stringLiteralTypesAsTags02.types index f90ea6c6a0645..13b5235050230 100644 --- a/tests/baselines/reference/stringLiteralTypesAsTags02.types +++ b/tests/baselines/reference/stringLiteralTypesAsTags02.types @@ -72,7 +72,7 @@ let x: A = { >{ kind: "A", a: 100,} : { kind: "A"; a: number; } kind: "A", ->kind : string +>kind : "A" >"A" : "A" a: 100, diff --git a/tests/baselines/reference/stringLiteralTypesAsTags03.types b/tests/baselines/reference/stringLiteralTypesAsTags03.types index 64622e28ac828..54b9b30453531 100644 --- a/tests/baselines/reference/stringLiteralTypesAsTags03.types +++ b/tests/baselines/reference/stringLiteralTypesAsTags03.types @@ -75,7 +75,7 @@ let x: A = { >{ kind: "A", a: 100,} : { kind: "A"; a: number; } kind: "A", ->kind : string +>kind : "A" >"A" : "A" a: 100, diff --git a/tests/baselines/reference/tsxAttributeQuickinfoTypesSameAsObjectLiteral.js b/tests/baselines/reference/tsxAttributeQuickinfoTypesSameAsObjectLiteral.js new file mode 100644 index 0000000000000..cbd8ab48feadf --- /dev/null +++ b/tests/baselines/reference/tsxAttributeQuickinfoTypesSameAsObjectLiteral.js @@ -0,0 +1,25 @@ +//// [tsxAttributeQuickinfoTypesSameAsObjectLiteral.tsx] +namespace JSX { + export interface IntrinsicElements { + span: {}; + } + export interface Element { + something?: any; + } +} + +const Foo = (props: { foo: "A" | "B" | "C" }) => {props.foo}; + +Foo({ + foo: "B" +}); + + + + +//// [tsxAttributeQuickinfoTypesSameAsObjectLiteral.jsx] +var Foo = function (props) { return {props.foo}; }; +Foo({ + foo: "B" +}); +; diff --git a/tests/baselines/reference/tsxAttributeQuickinfoTypesSameAsObjectLiteral.symbols b/tests/baselines/reference/tsxAttributeQuickinfoTypesSameAsObjectLiteral.symbols new file mode 100644 index 0000000000000..b531b689c1c47 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeQuickinfoTypesSameAsObjectLiteral.symbols @@ -0,0 +1,40 @@ +=== tests/cases/compiler/tsxAttributeQuickinfoTypesSameAsObjectLiteral.tsx === +namespace JSX { +>JSX : Symbol(JSX, Decl(tsxAttributeQuickinfoTypesSameAsObjectLiteral.tsx, 0, 0)) + + export interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxAttributeQuickinfoTypesSameAsObjectLiteral.tsx, 0, 15)) + + span: {}; +>span : Symbol(IntrinsicElements.span, Decl(tsxAttributeQuickinfoTypesSameAsObjectLiteral.tsx, 1, 40)) + } + export interface Element { +>Element : Symbol(Element, Decl(tsxAttributeQuickinfoTypesSameAsObjectLiteral.tsx, 3, 5)) + + something?: any; +>something : Symbol(Element.something, Decl(tsxAttributeQuickinfoTypesSameAsObjectLiteral.tsx, 4, 30)) + } +} + +const Foo = (props: { foo: "A" | "B" | "C" }) => {props.foo}; +>Foo : Symbol(Foo, Decl(tsxAttributeQuickinfoTypesSameAsObjectLiteral.tsx, 9, 5)) +>props : Symbol(props, Decl(tsxAttributeQuickinfoTypesSameAsObjectLiteral.tsx, 9, 13)) +>foo : Symbol(foo, Decl(tsxAttributeQuickinfoTypesSameAsObjectLiteral.tsx, 9, 21)) +>span : Symbol(JSX.IntrinsicElements.span, Decl(tsxAttributeQuickinfoTypesSameAsObjectLiteral.tsx, 1, 40)) +>props.foo : Symbol(foo, Decl(tsxAttributeQuickinfoTypesSameAsObjectLiteral.tsx, 9, 21)) +>props : Symbol(props, Decl(tsxAttributeQuickinfoTypesSameAsObjectLiteral.tsx, 9, 13)) +>foo : Symbol(foo, Decl(tsxAttributeQuickinfoTypesSameAsObjectLiteral.tsx, 9, 21)) +>span : Symbol(JSX.IntrinsicElements.span, Decl(tsxAttributeQuickinfoTypesSameAsObjectLiteral.tsx, 1, 40)) + +Foo({ +>Foo : Symbol(Foo, Decl(tsxAttributeQuickinfoTypesSameAsObjectLiteral.tsx, 9, 5)) + + foo: "B" +>foo : Symbol(foo, Decl(tsxAttributeQuickinfoTypesSameAsObjectLiteral.tsx, 11, 5)) + +}); + + +>Foo : Symbol(Foo, Decl(tsxAttributeQuickinfoTypesSameAsObjectLiteral.tsx, 9, 5)) +>foo : Symbol(foo, Decl(tsxAttributeQuickinfoTypesSameAsObjectLiteral.tsx, 15, 4)) + diff --git a/tests/baselines/reference/tsxAttributeQuickinfoTypesSameAsObjectLiteral.types b/tests/baselines/reference/tsxAttributeQuickinfoTypesSameAsObjectLiteral.types new file mode 100644 index 0000000000000..5c3dc77c7eedf --- /dev/null +++ b/tests/baselines/reference/tsxAttributeQuickinfoTypesSameAsObjectLiteral.types @@ -0,0 +1,46 @@ +=== tests/cases/compiler/tsxAttributeQuickinfoTypesSameAsObjectLiteral.tsx === +namespace JSX { +>JSX : any + + export interface IntrinsicElements { +>IntrinsicElements : IntrinsicElements + + span: {}; +>span : {} + } + export interface Element { +>Element : Element + + something?: any; +>something : any + } +} + +const Foo = (props: { foo: "A" | "B" | "C" }) => {props.foo}; +>Foo : (props: { foo: "A" | "B" | "C"; }) => JSX.Element +>(props: { foo: "A" | "B" | "C" }) => {props.foo} : (props: { foo: "A" | "B" | "C"; }) => JSX.Element +>props : { foo: "A" | "B" | "C"; } +>foo : "A" | "B" | "C" +>{props.foo} : JSX.Element +>span : any +>props.foo : "A" | "B" | "C" +>props : { foo: "A" | "B" | "C"; } +>foo : "A" | "B" | "C" +>span : any + +Foo({ +>Foo({ foo: "B"}) : JSX.Element +>Foo : (props: { foo: "A" | "B" | "C"; }) => JSX.Element +>{ foo: "B"} : { foo: "B"; } + + foo: "B" +>foo : "B" +>"B" : "B" + +}); + + +> : JSX.Element +>Foo : (props: { foo: "A" | "B" | "C"; }) => JSX.Element +>foo : "B" + diff --git a/tests/baselines/reference/tsxSpreadAttributesResolution10.types b/tests/baselines/reference/tsxSpreadAttributesResolution10.types index 851fa97dec2a7..09e6188a30a4e 100644 --- a/tests/baselines/reference/tsxSpreadAttributesResolution10.types +++ b/tests/baselines/reference/tsxSpreadAttributesResolution10.types @@ -37,7 +37,7 @@ const obj1: OptionProp = { >{ x: 2} : { x: 2; } x: 2 ->x : number +>x : 2 >2 : 2 } @@ -47,7 +47,7 @@ let y = ; > : JSX.Element >Opt : typeof Opt >obj : OptionProp ->x : number +>x : 3 >3 : 3 let y1 = ; @@ -62,7 +62,7 @@ let y2 = ; > : JSX.Element >Opt : typeof Opt >obj1 : OptionProp ->x : number +>x : 3 >3 : 3 let y3 = ; diff --git a/tests/baselines/reference/tsxSpreadAttributesResolution11.types b/tests/baselines/reference/tsxSpreadAttributesResolution11.types index bcf6690a60000..aa1fec2a88523 100644 --- a/tests/baselines/reference/tsxSpreadAttributesResolution11.types +++ b/tests/baselines/reference/tsxSpreadAttributesResolution11.types @@ -12,7 +12,7 @@ const obj1: { x: 2 } = { >{ x: 2} : { x: 2; } x: 2 ->x : number +>x : 2 >2 : 2 } const obj3: {y: true, overwrite: string } = { @@ -23,7 +23,7 @@ const obj3: {y: true, overwrite: string } = { >{ y: true, overwrite: "hi"} : { y: true; overwrite: string; } y: true, ->y : boolean +>y : true >true : true overwrite: "hi" @@ -86,12 +86,12 @@ let x2 = >x2 : JSX.Element > : JSX.Element >OverWriteAttr : typeof OverWriteAttr ->x : number +>x : 3 >3 : 3 >overwrite : string >obj1 : { x: 2; } >{y: true} : { y: true; } ->y : boolean +>y : true >true : true let x3 = @@ -100,12 +100,12 @@ let x3 = OverWriteAttr : typeof OverWriteAttr >overwrite : string >obj1 : { x: 2; } ->x : number +>x : 3 >3 : 3 >{y: true, x: 2, overwrite:"world"} : { y: true; x: 2; overwrite: string; } ->y : boolean +>y : true >true : true ->x : number +>x : 2 >2 : 2 >overwrite : string >"world" : "world" @@ -115,13 +115,13 @@ let x4 = > : JSX.Element >OverWriteAttr : typeof OverWriteAttr >{x: 2} : { x: 2; } ->x : number +>x : 2 >2 : 2 >{overwrite: "world"} : { overwrite: string; } >overwrite : string >"world" : "world" >{y: true} : { y: true; } ->y : boolean +>y : true >true : true let x5 = diff --git a/tests/baselines/reference/tsxSpreadAttributesResolution12.types b/tests/baselines/reference/tsxSpreadAttributesResolution12.types index bbeeac5a07385..ff6f7140d7507 100644 --- a/tests/baselines/reference/tsxSpreadAttributesResolution12.types +++ b/tests/baselines/reference/tsxSpreadAttributesResolution12.types @@ -12,7 +12,7 @@ const obj1: {x: 2} = { >{ x: 2} : { x: 2; } x: 2 ->x : number +>x : 2 >2 : 2 } const obj3: {y: false, overwrite: string} = { @@ -23,7 +23,7 @@ const obj3: {y: false, overwrite: string} = { >{ y: false, overwrite: "hi"} : { y: false; overwrite: string; } y: false, ->y : boolean +>y : false >false : false overwrite: "hi" @@ -81,10 +81,10 @@ let x1 = >OverWriteAttr : typeof OverWriteAttr >overwrite : string >obj1 : { x: 2; } ->x : number +>x : 3 >3 : 3 >{y: true} : { y: true; } ->y : boolean +>y : true >true : true let x2 = @@ -92,7 +92,7 @@ let x2 = > : JSX.Element >OverWriteAttr : typeof OverWriteAttr >anyobj : any ->x : number +>x : 3 >3 : 3 let x3 = @@ -102,7 +102,7 @@ let x3 = >overwrite : string >obj1 : { x: 2; } >{y: true} : { y: true; } ->y : boolean +>y : true >true : true diff --git a/tests/baselines/reference/tsxSpreadAttributesResolution2.types b/tests/baselines/reference/tsxSpreadAttributesResolution2.types index 92bf2118c98a9..21710567b0879 100644 --- a/tests/baselines/reference/tsxSpreadAttributesResolution2.types +++ b/tests/baselines/reference/tsxSpreadAttributesResolution2.types @@ -59,7 +59,7 @@ let w = ; >{x: 5, y: "2"} : { x: number; y: "2"; } >x : number >5 : 5 ->y : string +>y : "2" >"2" : "2" let w1 = ; @@ -69,7 +69,7 @@ let w1 = ; >{x: 5, y: "2"} : { x: number; y: "2"; } >x : number >5 : 5 ->y : string +>y : "2" >"2" : "2" >X : string diff --git a/tests/baselines/reference/tsxSpreadAttributesResolution4.types b/tests/baselines/reference/tsxSpreadAttributesResolution4.types index bf952a719f967..532e7828df98c 100644 --- a/tests/baselines/reference/tsxSpreadAttributesResolution4.types +++ b/tests/baselines/reference/tsxSpreadAttributesResolution4.types @@ -39,7 +39,7 @@ const obj: PoisonedProp = { >"hello world" : "hello world" y: 2 ->y : number +>y : 2 >2 : 2 }; diff --git a/tests/baselines/reference/tsxSpreadAttributesResolution6.types b/tests/baselines/reference/tsxSpreadAttributesResolution6.types index 1c18e87fa1767..b45fd73f2665f 100644 --- a/tests/baselines/reference/tsxSpreadAttributesResolution6.types +++ b/tests/baselines/reference/tsxSpreadAttributesResolution6.types @@ -44,7 +44,7 @@ const textProps: TextProps = { >{ editable: false} : { editable: false; } editable: false ->editable : boolean +>editable : false >false : false }; diff --git a/tests/baselines/reference/tsxSpreadAttributesResolution7.types b/tests/baselines/reference/tsxSpreadAttributesResolution7.types index 02b7a11c4241f..4275b5301f8aa 100644 --- a/tests/baselines/reference/tsxSpreadAttributesResolution7.types +++ b/tests/baselines/reference/tsxSpreadAttributesResolution7.types @@ -37,7 +37,7 @@ const textPropsFalse: TextProps = { >{ editable: false} : { editable: false; } editable: false ->editable : boolean +>editable : false >false : false }; @@ -54,7 +54,7 @@ const textPropsTrue: TextProps = { >{ editable: true, onEdit: () => {}} : { editable: true; onEdit: () => void; } editable: true, ->editable : boolean +>editable : true >true : true onEdit: () => {} diff --git a/tests/baselines/reference/tsxSpreadAttributesResolution9.types b/tests/baselines/reference/tsxSpreadAttributesResolution9.types index 2ba929cfe9d3a..dd8e154227f02 100644 --- a/tests/baselines/reference/tsxSpreadAttributesResolution9.types +++ b/tests/baselines/reference/tsxSpreadAttributesResolution9.types @@ -40,7 +40,7 @@ const obj1: OptionProp = { >{ x: 2} : { x: 2; } x: 2 ->x : number +>x : 2 >2 : 2 } @@ -73,6 +73,6 @@ let y3 = ; >y3 : JSX.Element > : JSX.Element >Opt : typeof Opt ->x : number +>x : 2 >2 : 2 diff --git a/tests/baselines/reference/tsxUnionSpread.types b/tests/baselines/reference/tsxUnionSpread.types index 11e6308fe18c4..0d3c34cb33bf0 100644 --- a/tests/baselines/reference/tsxUnionSpread.types +++ b/tests/baselines/reference/tsxUnionSpread.types @@ -39,7 +39,7 @@ function getProps(): AnimalInfo { // this may be from server or whatever ... return { type: 'Cat', subType: 'Large' }; >{ type: 'Cat', subType: 'Large' } : { type: "Cat"; subType: string; } ->type : string +>type : "Cat" >'Cat' : "Cat" >subType : string >'Large' : "Large" @@ -61,7 +61,7 @@ var props2:AnimalInfo = { type: 'Cat', subType: 'Large' }; >props2 : AnimalInfo >AnimalInfo : AnimalInfo >{ type: 'Cat', subType: 'Large' } : { type: "Cat"; subType: string; } ->type : string +>type : "Cat" >'Cat' : "Cat" >subType : string >'Large' : "Large" diff --git a/tests/cases/compiler/tsxAttributeQuickinfoTypesSameAsObjectLiteral.tsx b/tests/cases/compiler/tsxAttributeQuickinfoTypesSameAsObjectLiteral.tsx new file mode 100644 index 0000000000000..3f89d6e1cc70a --- /dev/null +++ b/tests/cases/compiler/tsxAttributeQuickinfoTypesSameAsObjectLiteral.tsx @@ -0,0 +1,19 @@ +// @jsx: preserve + + +namespace JSX { + export interface IntrinsicElements { + span: {}; + } + export interface Element { + something?: any; + } +} + +const Foo = (props: { foo: "A" | "B" | "C" }) => {props.foo}; + +Foo({ + foo: "B" +}); + + diff --git a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName06.ts b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName06.ts index c589dccacbc47..ac6efaecf5e11 100644 --- a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName06.ts +++ b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName06.ts @@ -25,5 +25,5 @@ verify.referenceGroups(r2, [ ]); verify.referenceGroups(r4, [ { definition: "(property) I.property1: number", ranges: [r0, r1, r2, r3] }, - { definition: "(property) property1: I", ranges: [r4] } + { definition: "(property) property1: any", ranges: [r4] } ]);