Fix get symbol at location to behave correctly for parameter assignments and jsx attributes (#20706)

* Fix get symbol at location to behave correctly got parameter assignments and jsx attributes

* Handle all those edge cases that weren;t explicitly handled

* Fix part of bug WRT getTypeAtLocation and for loops

* Baseline corrections pursuant to #20710

* Restore jsdoc tag interpretation

* Clean up some code, revert fourslash tests

* Cleanup types used by PR feedback
This commit is contained in:
Wesley Wigham
2017-12-15 15:50:22 -08:00
committed by GitHub
parent a3ab1ffcff
commit dd933f4413
59 changed files with 513 additions and 296 deletions
+64 -41
View File
@@ -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((<ForInStatement>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(<BindingElement>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(<ParameterDeclaration>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(<Identifier>declaration.name);
}
// If the declaration specifies a binding pattern, use the type implied by the binding pattern
if (isBindingPattern(declaration.name)) {
return getTypeFromBindingPattern(<BindingPattern>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(<VariableLikeDeclaration>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 = <VariableLikeDeclaration>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 && (<VariableLikeDeclaration>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(<ComputedPropertyName>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(<ComputedPropertyName>node.propertyName);
checkComputedPropertyName(node.propertyName);
}
// check private/protected variable access
const parent = <VariableLikeDeclaration>(<BindingPattern>node.parent).parent;
const parent = node.parent.parent;
const parentType = getTypeForBindingElementParent(parent);
const name = node.propertyName || <Identifier>node.name;
const property = getPropertyOfType(parentType, getTextOfPropertyName(name));
@@ -23697,7 +23720,7 @@ namespace ts {
return checkParameter(<ParameterDeclaration>node);
case SyntaxKind.PropertyDeclaration:
case SyntaxKind.PropertySignature:
return checkPropertyDeclaration(<PropertyDeclaration>node);
return checkPropertyDeclaration(<PropertyDeclaration | PropertySignature>node);
case SyntaxKind.FunctionType:
case SyntaxKind.ConstructorType:
case SyntaxKind.CallSignature:
@@ -24505,7 +24528,7 @@ namespace ts {
}
if (isBindingPattern(node)) {
return getTypeForVariableLikeDeclaration(<VariableLikeDeclaration>node.parent, /*includeOptionality*/ true);
return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true);
}
if (isInRightSideOfImportOrExportAssignment(<Identifier>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);
}
+2 -2
View File
@@ -64,7 +64,7 @@ namespace ts {
let currentIdentifiers: Map<string>;
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);
}
+35 -7
View File
@@ -88,20 +88,48 @@ namespace ts {
case SyntaxKind.SpreadAssignment:
return visitNode(cbNode, (<SpreadAssignment>node).expression);
case SyntaxKind.Parameter:
return visitNodes(cbNode, cbNodes, node.decorators) ||
visitNodes(cbNode, cbNodes, node.modifiers) ||
visitNode(cbNode, (<ParameterDeclaration>node).dotDotDotToken) ||
visitNode(cbNode, (<ParameterDeclaration>node).name) ||
visitNode(cbNode, (<ParameterDeclaration>node).questionToken) ||
visitNode(cbNode, (<ParameterDeclaration>node).type) ||
visitNode(cbNode, (<ParameterDeclaration>node).initializer);
case SyntaxKind.PropertyDeclaration:
return visitNodes(cbNode, cbNodes, node.decorators) ||
visitNodes(cbNode, cbNodes, node.modifiers) ||
visitNode(cbNode, (<PropertyDeclaration>node).name) ||
visitNode(cbNode, (<PropertyDeclaration>node).questionToken) ||
visitNode(cbNode, (<PropertyDeclaration>node).exclamationToken) ||
visitNode(cbNode, (<PropertyDeclaration>node).type) ||
visitNode(cbNode, (<PropertyDeclaration>node).initializer);
case SyntaxKind.PropertySignature:
return visitNodes(cbNode, cbNodes, node.decorators) ||
visitNodes(cbNode, cbNodes, node.modifiers) ||
visitNode(cbNode, (<PropertySignature>node).name) ||
visitNode(cbNode, (<PropertySignature>node).questionToken) ||
visitNode(cbNode, (<PropertySignature>node).type) ||
visitNode(cbNode, (<PropertySignature>node).initializer);
case SyntaxKind.PropertyAssignment:
return visitNodes(cbNode, cbNodes, node.decorators) ||
visitNodes(cbNode, cbNodes, node.modifiers) ||
visitNode(cbNode, (<PropertyAssignment>node).name) ||
visitNode(cbNode, (<PropertyAssignment>node).questionToken) ||
visitNode(cbNode, (<PropertyAssignment>node).initializer);
case SyntaxKind.VariableDeclaration:
return visitNodes(cbNode, cbNodes, node.decorators) ||
visitNodes(cbNode, cbNodes, node.modifiers) ||
visitNode(cbNode, (<VariableDeclaration>node).name) ||
visitNode(cbNode, (<VariableDeclaration>node).exclamationToken) ||
visitNode(cbNode, (<VariableDeclaration>node).type) ||
visitNode(cbNode, (<VariableDeclaration>node).initializer);
case SyntaxKind.BindingElement:
return visitNodes(cbNode, cbNodes, node.decorators) ||
visitNodes(cbNode, cbNodes, node.modifiers) ||
visitNode(cbNode, (<VariableLikeDeclaration>node).propertyName) ||
visitNode(cbNode, (<VariableLikeDeclaration>node).dotDotDotToken) ||
visitNode(cbNode, (<VariableLikeDeclaration>node).name) ||
visitNode(cbNode, (<VariableLikeDeclaration>node).questionToken) ||
visitNode(cbNode, (<VariableLikeDeclaration>node).exclamationToken) ||
visitNode(cbNode, (<VariableLikeDeclaration>node).type) ||
visitNode(cbNode, (<VariableLikeDeclaration>node).initializer);
visitNode(cbNode, (<BindingElement>node).propertyName) ||
visitNode(cbNode, (<BindingElement>node).dotDotDotToken) ||
visitNode(cbNode, (<BindingElement>node).name) ||
visitNode(cbNode, (<BindingElement>node).initializer);
case SyntaxKind.FunctionType:
case SyntaxKind.ConstructorType:
case SyntaxKind.CallSignature:
+49 -19
View File
@@ -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<T extends Node> = NodeArray<T> & 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;
+24 -6
View File
@@ -548,7 +548,7 @@ namespace ts {
// Return display name of an identifier
// Computed property names will just be emitted as "[<expr>]", where <expr> 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 === (<VariableLikeDeclaration>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 (<VariableLikeDeclaration>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);
}
}
+1 -1
View File
@@ -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(<Expression>rootDeclaration.parent);
+7 -9
View File
@@ -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(<VariableDeclaration>node);
return parentStatement && hasModifier(parentStatement, ModifierFlags.Ambient);
}
else if (isVariableLike(node) && hasInitializer(node)) {
return true;
}
else if (node.kind === SyntaxKind.VariableDeclaration) {
const parentStatement = getParentStatementOfVariableDeclaration(<VariableDeclaration>node);
return parentStatement && hasModifier(parentStatement, ModifierFlags.Ambient);
}
else if (isFunctionLike(node)) {
return !!(node as FunctionLikeDeclaration).body || hasModifier(node, ModifierFlags.Ambient);
+2 -2
View File
@@ -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
>"" : ""
+4 -9
View File
@@ -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<T extends Node> extends ReadonlyArray<T>, 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;
}
+4 -9
View File
@@ -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<T extends Node> extends ReadonlyArray<T>, 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;
}
@@ -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
!
@@ -14,6 +14,6 @@ i = { ...{ a: "a" } };
>i : I
>{ ...{ a: "a" } } : { a: "a"; }
>{ a: "a" } : { a: "a"; }
>a : string
>a : "a"
>"a" : "a"
@@ -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",
@@ -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) {
@@ -31,22 +31,22 @@ const FooComponent = (props: { foo: "A" | "B" | "C" }) => <span>{props.foo}</spa
<FooComponent foo={"A"} />;
><FooComponent foo={"A"} /> : JSX.Element
>FooComponent : (props: { foo: "A" | "B" | "C"; }) => JSX.Element
>foo : string
>foo : "A"
>"A" : "A"
<FooComponent foo="A" />;
><FooComponent foo="A" /> : JSX.Element
>FooComponent : (props: { foo: "A" | "B" | "C"; }) => JSX.Element
>foo : string
>foo : "A"
<FooComponent foo={"f"} />;
><FooComponent foo={"f"} /> : JSX.Element
>FooComponent : (props: { foo: "A" | "B" | "C"; }) => JSX.Element
>foo : string
>foo : "f"
>"f" : "f"
<FooComponent foo="f" />;
><FooComponent foo="f" /> : JSX.Element
>FooComponent : (props: { foo: "A" | "B" | "C"; }) => JSX.Element
>foo : string
>foo : "f"
@@ -112,7 +112,7 @@ const b3 = <MainButton {...{goTo:"home"}} extra />; // goTo has type"home" | "c
><MainButton {...{goTo:"home"}} extra /> : 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 = <MainButton goTo="home" extra />; // goTo has type "home" | "contact
>b4 : JSX.Element
><MainButton goTo="home" extra /> : 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 = <NoOverload1 {...{goTo:"home"}} extra />; // goTo has type "home" |
><NoOverload1 {...{goTo:"home"}} extra /> : JSX.Element
>NoOverload1 : (linkProps: LinkProps) => JSX.Element
>{goTo:"home"} : { goTo: "home"; }
>goTo : string
>goTo : "home"
>"home" : "home"
>extra : true
@@ -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
@@ -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
@@ -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() {
@@ -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 };
@@ -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,
@@ -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"
@@ -107,12 +107,12 @@ for (var x in (<T>(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
@@ -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[]
@@ -93,12 +93,12 @@ for (var x in (<T>(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
+2 -2
View File
@@ -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
+2 -2
View File
@@ -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
@@ -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"
@@ -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" };
@@ -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" };
@@ -47,7 +47,7 @@ let pair1: Pair<FooBar> = {
>{ 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<FooBar>[keyof FooBar] = {
>{ key: "foo", value: 3} : { key: "foo"; value: number; }
key: "foo",
>key : string
>key : "foo"
>"foo" : "foo"
value: 3
@@ -47,7 +47,7 @@ const nestedSingle = nested({fields: "z"})
>nested({fields: "z"}) : Record<"z", string>
>nested : <A extends string>(a: { fields: A; }) => Record<A, string>
>{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 extends string>(a: { fields: A | A[]; }) => Record<A, string>
>{fields: "z"} : { fields: "z"; }
>fields : string
>fields : "z"
>"z" : "z"
const nestedUnionArray = nestedUnion({fields: ["z", "y"]})
@@ -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; }[]
@@ -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
@@ -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
@@ -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
@@ -9,6 +9,6 @@ export function foo () {
const x = { test };
>x : { test: string; }
>{ test } : { test: string; }
>test : "test"
>test : string
}
@@ -9,6 +9,6 @@ export function foo () {
const x = { test };
>x : { test: string; }
>{ test } : { test: string; }
>test : "test"
>test : string
}
@@ -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
@@ -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
@@ -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
@@ -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; }
@@ -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,
@@ -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,
@@ -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,
@@ -0,0 +1,25 @@
//// [tsxAttributeQuickinfoTypesSameAsObjectLiteral.tsx]
namespace JSX {
export interface IntrinsicElements {
span: {};
}
export interface Element {
something?: any;
}
}
const Foo = (props: { foo: "A" | "B" | "C" }) => <span>{props.foo}</span>;
Foo({
foo: "B"
});
<Foo foo="B" />
//// [tsxAttributeQuickinfoTypesSameAsObjectLiteral.jsx]
var Foo = function (props) { return <span>{props.foo}</span>; };
Foo({
foo: "B"
});
<Foo foo="B"/>;
@@ -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" }) => <span>{props.foo}</span>;
>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 foo="B" />
>Foo : Symbol(Foo, Decl(tsxAttributeQuickinfoTypesSameAsObjectLiteral.tsx, 9, 5))
>foo : Symbol(foo, Decl(tsxAttributeQuickinfoTypesSameAsObjectLiteral.tsx, 15, 4))
@@ -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" }) => <span>{props.foo}</span>;
>Foo : (props: { foo: "A" | "B" | "C"; }) => JSX.Element
>(props: { foo: "A" | "B" | "C" }) => <span>{props.foo}</span> : (props: { foo: "A" | "B" | "C"; }) => JSX.Element
>props : { foo: "A" | "B" | "C"; }
>foo : "A" | "B" | "C"
><span>{props.foo}</span> : 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"
});
<Foo foo="B" />
><Foo foo="B" /> : JSX.Element
>Foo : (props: { foo: "A" | "B" | "C"; }) => JSX.Element
>foo : "B"
@@ -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 = <Opt {...obj} x={3}/>;
><Opt {...obj} x={3}/> : JSX.Element
>Opt : typeof Opt
>obj : OptionProp
>x : number
>x : 3
>3 : 3
let y1 = <Opt {...obj1} x="Hi"/>;
@@ -62,7 +62,7 @@ let y2 = <Opt {...obj1} x={3}/>;
><Opt {...obj1} x={3}/> : JSX.Element
>Opt : typeof Opt
>obj1 : OptionProp
>x : number
>x : 3
>3 : 3
let y3 = <Opt x />;
@@ -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 = <OverWriteAttr x={3} overwrite="hi" {...obj1} {...{y: true}} />
>x2 : JSX.Element
><OverWriteAttr x={3} overwrite="hi" {...obj1} {...{y: true}} /> : 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 = <OverWriteAttr overwrite="hi" {...obj1} x={3} {...{y: true, x: 2, overwrite:"world"}} />
@@ -100,12 +100,12 @@ let x3 = <OverWriteAttr overwrite="hi" {...obj1} x={3} {...{y: true, x: 2, overw
>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 = <OverWriteAttr {...{x: 2}} {...{overwrite: "world"}} {...{y: true}} />
><OverWriteAttr {...{x: 2}} {...{overwrite: "world"}} {...{y: true}} /> : 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 = <OverWriteAttr {...anyobj} />
@@ -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 overwrite="hi" {...obj1} x={3} {...{y: true}} />
>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 = <OverWriteAttr {...anyobj} x={3} />
@@ -92,7 +92,7 @@ let x2 = <OverWriteAttr {...anyobj} x={3} />
><OverWriteAttr {...anyobj} x={3} /> : JSX.Element
>OverWriteAttr : typeof OverWriteAttr
>anyobj : any
>x : number
>x : 3
>3 : 3
let x3 = <OverWriteAttr overwrite="hi" {...obj1} {...{y: true}} />
@@ -102,7 +102,7 @@ let x3 = <OverWriteAttr overwrite="hi" {...obj1} {...{y: true}} />
>overwrite : string
>obj1 : { x: 2; }
>{y: true} : { y: true; }
>y : boolean
>y : true
>true : true
@@ -59,7 +59,7 @@ let w = <Poisoned {...{x: 5, y: "2"}}/>;
>{x: 5, y: "2"} : { x: number; y: "2"; }
>x : number
>5 : 5
>y : string
>y : "2"
>"2" : "2"
let w1 = <Poisoned {...{x: 5, y: "2"}} X="hi" />;
@@ -69,7 +69,7 @@ let w1 = <Poisoned {...{x: 5, y: "2"}} X="hi" />;
>{x: 5, y: "2"} : { x: number; y: "2"; }
>x : number
>5 : 5
>y : string
>y : "2"
>"2" : "2"
>X : string
@@ -39,7 +39,7 @@ const obj: PoisonedProp = {
>"hello world" : "hello world"
y: 2
>y : number
>y : 2
>2 : 2
};
@@ -44,7 +44,7 @@ const textProps: TextProps = {
>{ editable: false} : { editable: false; }
editable: false
>editable : boolean
>editable : false
>false : false
};
@@ -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: () => {}
@@ -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 = <Opt x={2} />;
>y3 : JSX.Element
><Opt x={2} /> : JSX.Element
>Opt : typeof Opt
>x : number
>x : 2
>2 : 2
@@ -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"
@@ -0,0 +1,19 @@
// @jsx: preserve
namespace JSX {
export interface IntrinsicElements {
span: {};
}
export interface Element {
something?: any;
}
}
const Foo = (props: { foo: "A" | "B" | "C" }) => <span>{props.foo}</span>;
Foo({
foo: "B"
});
<Foo foo="B" />
@@ -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] }
]);