mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-04-17 01:49:41 -05:00
Fix circularity errors in intra-binding-pattern references (#59183)
This commit is contained in:
@@ -2278,6 +2278,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
var contextualTypes: (Type | undefined)[] = [];
|
||||
var contextualIsCache: boolean[] = [];
|
||||
var contextualTypeCount = 0;
|
||||
var contextualBindingPatterns: BindingPattern[] = [];
|
||||
|
||||
var inferenceContextNodes: Node[] = [];
|
||||
var inferenceContexts: (InferenceContext | undefined)[] = [];
|
||||
@@ -11229,6 +11230,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
parentType = getTypeWithFacts(parentType, TypeFacts.NEUndefined);
|
||||
}
|
||||
|
||||
const accessFlags = AccessFlags.ExpressionPosition | (noTupleBoundsCheck || hasDefaultValue(declaration) ? AccessFlags.AllowMissing : 0);
|
||||
let type: Type | undefined;
|
||||
if (pattern.kind === SyntaxKind.ObjectBindingPattern) {
|
||||
if (declaration.dotDotDotToken) {
|
||||
@@ -11249,7 +11251,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
// Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form)
|
||||
const name = declaration.propertyName || declaration.name as Identifier;
|
||||
const indexType = getLiteralTypeFromPropertyName(name);
|
||||
const declaredType = getIndexedAccessType(parentType, indexType, AccessFlags.ExpressionPosition, name);
|
||||
const declaredType = getIndexedAccessType(parentType, indexType, accessFlags, name);
|
||||
type = getFlowTypeOfDestructuring(declaration, declaredType);
|
||||
}
|
||||
}
|
||||
@@ -11270,7 +11272,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
}
|
||||
else if (isArrayLikeType(parentType)) {
|
||||
const indexType = getNumberLiteralType(index);
|
||||
const accessFlags = AccessFlags.ExpressionPosition | (noTupleBoundsCheck || hasDefaultValue(declaration) ? AccessFlags.NoTupleBoundsCheck : 0);
|
||||
const declaredType = getIndexedAccessTypeOrUndefined(parentType, indexType, accessFlags, declaration.name) || errorType;
|
||||
type = getFlowTypeOfDestructuring(declaration, declaredType);
|
||||
}
|
||||
@@ -11826,7 +11827,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
// contextual type or, if the element itself is a binding pattern, with the type implied by that binding
|
||||
// pattern.
|
||||
const contextualType = isBindingPattern(element.name) ? getTypeFromBindingPattern(element.name, /*includePatternInType*/ true, /*reportErrors*/ false) : unknownType;
|
||||
return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, reportErrors ? CheckMode.Normal : CheckMode.Contextual, contextualType)));
|
||||
return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, CheckMode.Normal, contextualType)));
|
||||
}
|
||||
if (isBindingPattern(element.name)) {
|
||||
return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors);
|
||||
@@ -11903,9 +11904,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
// parameter with no type annotation or initializer, the type implied by the binding pattern becomes the type of
|
||||
// the parameter.
|
||||
function getTypeFromBindingPattern(pattern: BindingPattern, includePatternInType = false, reportErrors = false): Type {
|
||||
return pattern.kind === SyntaxKind.ObjectBindingPattern
|
||||
if (includePatternInType) contextualBindingPatterns.push(pattern);
|
||||
const result = pattern.kind === SyntaxKind.ObjectBindingPattern
|
||||
? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors)
|
||||
: getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors);
|
||||
if (includePatternInType) contextualBindingPatterns.pop();
|
||||
return result;
|
||||
}
|
||||
|
||||
// Return the type associated with a variable, parameter, or property declaration. In the simple case this is the type
|
||||
@@ -12003,16 +12007,16 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
return false;
|
||||
}
|
||||
|
||||
function getTypeOfVariableOrParameterOrProperty(symbol: Symbol, checkMode?: CheckMode): Type {
|
||||
function getTypeOfVariableOrParameterOrProperty(symbol: Symbol): Type {
|
||||
const links = getSymbolLinks(symbol);
|
||||
if (!links.type) {
|
||||
const type = getTypeOfVariableOrParameterOrPropertyWorker(symbol, checkMode);
|
||||
const type = getTypeOfVariableOrParameterOrPropertyWorker(symbol);
|
||||
// For a contextually typed parameter it is possible that a type has already
|
||||
// been assigned (in assignTypeToParameterAndFixTypeParameters), and we want
|
||||
// to preserve this type. In fact, we need to _prefer_ that type, but it won't
|
||||
// be assigned until contextual typing is complete, so we need to defer in
|
||||
// cases where contextual typing may take place.
|
||||
if (!links.type && !isParameterOfContextSensitiveSignature(symbol) && !checkMode) {
|
||||
if (!links.type && !isParameterOfContextSensitiveSignature(symbol)) {
|
||||
links.type = type;
|
||||
}
|
||||
return type;
|
||||
@@ -12020,7 +12024,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
return links.type;
|
||||
}
|
||||
|
||||
function getTypeOfVariableOrParameterOrPropertyWorker(symbol: Symbol, checkMode?: CheckMode): Type {
|
||||
function getTypeOfVariableOrParameterOrPropertyWorker(symbol: Symbol): Type {
|
||||
// Handle prototype property
|
||||
if (symbol.flags & SymbolFlags.Prototype) {
|
||||
return getTypeOfPrototypeProperty(symbol);
|
||||
@@ -12063,16 +12067,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
if (symbol.flags & SymbolFlags.ValueModule && !(symbol.flags & SymbolFlags.Assignment)) {
|
||||
return getTypeOfFuncClassEnumModule(symbol);
|
||||
}
|
||||
|
||||
// When trying to get the *contextual* type of a binding element, it's possible to fall in a loop and therefore
|
||||
// end up in a circularity-like situation. This is not a true circularity so we should not report such an error.
|
||||
// For example, here the looping could happen when trying to get the type of `a` (binding element):
|
||||
//
|
||||
// const { a, b = a } = { a: 0 }
|
||||
//
|
||||
if (isBindingElement(declaration) && checkMode === CheckMode.Contextual) {
|
||||
return errorType;
|
||||
}
|
||||
return reportCircularityError(symbol);
|
||||
}
|
||||
let type: Type;
|
||||
@@ -12145,16 +12139,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
if (symbol.flags & SymbolFlags.ValueModule && !(symbol.flags & SymbolFlags.Assignment)) {
|
||||
return getTypeOfFuncClassEnumModule(symbol);
|
||||
}
|
||||
|
||||
// When trying to get the *contextual* type of a binding element, it's possible to fall in a loop and therefore
|
||||
// end up in a circularity-like situation. This is not a true circularity so we should not report such an error.
|
||||
// For example, here the looping could happen when trying to get the type of `a` (binding element):
|
||||
//
|
||||
// const { a, b = a } = { a: 0 }
|
||||
//
|
||||
if (isBindingElement(declaration) && checkMode === CheckMode.Contextual) {
|
||||
return type;
|
||||
}
|
||||
return reportCircularityError(symbol);
|
||||
}
|
||||
return type;
|
||||
@@ -12437,7 +12421,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
return getTypeOfSymbol(symbol);
|
||||
}
|
||||
|
||||
function getTypeOfSymbol(symbol: Symbol, checkMode?: CheckMode): Type {
|
||||
function getTypeOfSymbol(symbol: Symbol): Type {
|
||||
const checkFlags = getCheckFlags(symbol);
|
||||
if (checkFlags & CheckFlags.DeferredType) {
|
||||
return getTypeOfSymbolWithDeferredType(symbol);
|
||||
@@ -12452,7 +12436,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
return getTypeOfReverseMappedSymbol(symbol as ReverseMappedSymbol);
|
||||
}
|
||||
if (symbol.flags & (SymbolFlags.Variable | SymbolFlags.Property)) {
|
||||
return getTypeOfVariableOrParameterOrProperty(symbol, checkMode);
|
||||
return getTypeOfVariableOrParameterOrProperty(symbol);
|
||||
}
|
||||
if (symbol.flags & (SymbolFlags.Function | SymbolFlags.Method | SymbolFlags.Class | SymbolFlags.Enum | SymbolFlags.ValueModule)) {
|
||||
return getTypeOfFuncClassEnumModule(symbol);
|
||||
@@ -18603,7 +18587,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
}
|
||||
if (everyType(objectType, isTupleType) && isNumericLiteralName(propName)) {
|
||||
const index = +propName;
|
||||
if (accessNode && everyType(objectType, t => !((t as TupleTypeReference).target.combinedFlags & ElementFlags.Variable)) && !(accessFlags & AccessFlags.NoTupleBoundsCheck)) {
|
||||
if (accessNode && everyType(objectType, t => !((t as TupleTypeReference).target.combinedFlags & ElementFlags.Variable)) && !(accessFlags & AccessFlags.AllowMissing)) {
|
||||
const indexNode = getIndexNodeForAccessExpression(accessNode);
|
||||
if (isTupleType(objectType)) {
|
||||
if (index < 0) {
|
||||
@@ -18738,6 +18722,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
if (accessFlags & AccessFlags.AllowMissing && isObjectLiteralType(objectType)) {
|
||||
return undefinedType;
|
||||
}
|
||||
if (isJSLiteralType(objectType)) {
|
||||
return anyType;
|
||||
}
|
||||
@@ -30093,8 +30080,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
}
|
||||
}
|
||||
|
||||
function getNarrowedTypeOfSymbol(symbol: Symbol, location: Identifier, checkMode?: CheckMode) {
|
||||
const type = getTypeOfSymbol(symbol, checkMode);
|
||||
function getNarrowedTypeOfSymbol(symbol: Symbol, location: Identifier) {
|
||||
const type = getTypeOfSymbol(symbol);
|
||||
const declaration = symbol.valueDeclaration;
|
||||
if (declaration) {
|
||||
// If we have a non-rest binding element with no initializer declared as a const variable or a const-like
|
||||
@@ -30277,7 +30264,14 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
const localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol);
|
||||
let declaration = localOrExportSymbol.valueDeclaration;
|
||||
|
||||
let type = getNarrowedTypeOfSymbol(localOrExportSymbol, node, checkMode);
|
||||
// If the identifier is declared in a binding pattern for which we're currently computing the implied type and the
|
||||
// reference occurs with the same binding pattern, return the non-inferrable any type. This for example occurs in
|
||||
// 'const [a, b = a + 1] = [2]' when we're computing the contextual type for the array literal '[2]'.
|
||||
if (declaration && declaration.kind === SyntaxKind.BindingElement && contains(contextualBindingPatterns, declaration.parent) && findAncestor(node, parent => parent === declaration!.parent)) {
|
||||
return nonInferrableAnyType;
|
||||
}
|
||||
|
||||
let type = getNarrowedTypeOfSymbol(localOrExportSymbol, node);
|
||||
const assignmentKind = getAssignmentTargetKind(node);
|
||||
|
||||
if (assignmentKind) {
|
||||
@@ -32357,9 +32351,11 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
return node.isSpread ? getIndexedAccessType(node.type, numberType) : node.type;
|
||||
}
|
||||
|
||||
function hasDefaultValue(node: BindingElement | Expression): boolean {
|
||||
return (node.kind === SyntaxKind.BindingElement && !!(node as BindingElement).initializer) ||
|
||||
(node.kind === SyntaxKind.BinaryExpression && (node as BinaryExpression).operatorToken.kind === SyntaxKind.EqualsToken);
|
||||
function hasDefaultValue(node: BindingElement | ObjectLiteralElementLike | Expression): boolean {
|
||||
return node.kind === SyntaxKind.BindingElement && !!(node as BindingElement).initializer ||
|
||||
node.kind === SyntaxKind.PropertyAssignment && hasDefaultValue((node as PropertyAssignment).initializer) ||
|
||||
node.kind === SyntaxKind.ShorthandPropertyAssignment && !!(node as ShorthandPropertyAssignment).objectAssignmentInitializer ||
|
||||
node.kind === SyntaxKind.BinaryExpression && (node as BinaryExpression).operatorToken.kind === SyntaxKind.EqualsToken;
|
||||
}
|
||||
|
||||
function isSpreadIntoCallOrNew(node: ArrayLiteralExpression) {
|
||||
@@ -32624,14 +32620,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
prop.links.nameType = nameType;
|
||||
}
|
||||
|
||||
if (inDestructuringPattern) {
|
||||
if (inDestructuringPattern && hasDefaultValue(memberDecl)) {
|
||||
// If object literal is an assignment pattern and if the assignment pattern specifies a default value
|
||||
// for the property, make the property optional.
|
||||
const isOptional = (memberDecl.kind === SyntaxKind.PropertyAssignment && hasDefaultValue(memberDecl.initializer)) ||
|
||||
(memberDecl.kind === SyntaxKind.ShorthandPropertyAssignment && memberDecl.objectAssignmentInitializer);
|
||||
if (isOptional) {
|
||||
prop.flags |= SymbolFlags.Optional;
|
||||
}
|
||||
prop.flags |= SymbolFlags.Optional;
|
||||
}
|
||||
else if (contextualTypeHasPattern && !(getObjectFlags(contextualType) & ObjectFlags.ObjectLiteralPatternWithComputedProperties)) {
|
||||
// If object literal is contextually typed by the implied type of a binding pattern, and if the
|
||||
@@ -32729,35 +32721,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
}
|
||||
popContextualType();
|
||||
|
||||
// If object literal is contextually typed by the implied type of a binding pattern, augment the result
|
||||
// type with those properties for which the binding pattern specifies a default value.
|
||||
// If the object literal is spread into another object literal, skip this step and let the top-level object
|
||||
// literal handle it instead. Note that this might require full traversal to the root pattern's parent
|
||||
// as it's the guaranteed to be the common ancestor of the pattern node and the current object node.
|
||||
// It's not possible to check if the immediate parent node is a spread assignment
|
||||
// since the type flows in non-obvious ways through conditional expressions, IIFEs and more.
|
||||
if (contextualTypeHasPattern) {
|
||||
const rootPatternParent = findAncestor(contextualType.pattern!.parent, n =>
|
||||
n.kind === SyntaxKind.VariableDeclaration ||
|
||||
n.kind === SyntaxKind.BinaryExpression ||
|
||||
n.kind === SyntaxKind.Parameter);
|
||||
const spreadOrOutsideRootObject = findAncestor(node, n =>
|
||||
n === rootPatternParent ||
|
||||
n.kind === SyntaxKind.SpreadAssignment)!;
|
||||
|
||||
if (spreadOrOutsideRootObject.kind !== SyntaxKind.SpreadAssignment) {
|
||||
for (const prop of getPropertiesOfType(contextualType)) {
|
||||
if (!propertiesTable.get(prop.escapedName) && !getPropertyOfType(spread, prop.escapedName)) {
|
||||
if (!(prop.flags & SymbolFlags.Optional)) {
|
||||
error(prop.valueDeclaration || tryCast(prop, isTransientSymbol)?.links.bindingElement, Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value);
|
||||
}
|
||||
propertiesTable.set(prop.escapedName, prop);
|
||||
propertiesArray.push(prop);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isErrorType(spread)) {
|
||||
return errorType;
|
||||
}
|
||||
@@ -39155,7 +39118,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
checkPropertyAccessibility(property, /*isSuper*/ false, /*writing*/ true, objectLiteralType, prop);
|
||||
}
|
||||
}
|
||||
const elementType = getIndexedAccessType(objectLiteralType, exprType, AccessFlags.ExpressionPosition, name);
|
||||
const elementType = getIndexedAccessType(objectLiteralType, exprType, AccessFlags.ExpressionPosition | (hasDefaultValue(property) ? AccessFlags.AllowMissing : 0), name);
|
||||
const type = getFlowTypeOfDestructuring(property, elementType);
|
||||
return checkDestructuringAssignment(property.kind === SyntaxKind.ShorthandPropertyAssignment ? property : property.initializer, type);
|
||||
}
|
||||
@@ -39214,7 +39177,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
if (isArrayLikeType(sourceType)) {
|
||||
// We create a synthetic expression so that getIndexedAccessType doesn't get confused
|
||||
// when the element is a SyntaxKind.ElementAccessExpression.
|
||||
const accessFlags = AccessFlags.ExpressionPosition | (hasDefaultValue(element) ? AccessFlags.NoTupleBoundsCheck : 0);
|
||||
const accessFlags = AccessFlags.ExpressionPosition | (hasDefaultValue(element) ? AccessFlags.AllowMissing : 0);
|
||||
const elementType = getIndexedAccessTypeOrUndefined(sourceType, indexType, accessFlags, createSyntheticExpression(element, indexType)) || errorType;
|
||||
const assignedType = hasDefaultValue(element) ? getTypeWithFacts(elementType, TypeFacts.NEUndefined) : elementType;
|
||||
const type = getFlowTypeOfDestructuring(element, assignedType);
|
||||
@@ -40181,16 +40144,56 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
return checkSatisfiesExpressionWorker(initializer, typeNode, checkMode);
|
||||
}
|
||||
}
|
||||
const type = getQuickTypeOfExpression(initializer) ||
|
||||
(contextualType ?
|
||||
checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, checkMode || CheckMode.Normal)
|
||||
: checkExpressionCached(initializer, checkMode));
|
||||
return isParameter(declaration) && declaration.name.kind === SyntaxKind.ArrayBindingPattern &&
|
||||
isTupleType(type) && !(type.target.combinedFlags & ElementFlags.Variable) && getTypeReferenceArity(type) < declaration.name.elements.length ?
|
||||
padTupleType(type, declaration.name) : type;
|
||||
const type = getQuickTypeOfExpression(initializer) || (contextualType ?
|
||||
checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, checkMode || CheckMode.Normal) :
|
||||
checkExpressionCached(initializer, checkMode));
|
||||
if (isParameter(isBindingElement(declaration) ? walkUpBindingElementsAndPatterns(declaration) : declaration)) {
|
||||
if (declaration.name.kind === SyntaxKind.ObjectBindingPattern && isObjectLiteralType(type)) {
|
||||
return padObjectLiteralType(type as ObjectType, declaration.name);
|
||||
}
|
||||
if (declaration.name.kind === SyntaxKind.ArrayBindingPattern && isTupleType(type)) {
|
||||
return padTupleType(type, declaration.name);
|
||||
}
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
function padObjectLiteralType(type: ObjectType, pattern: ObjectBindingPattern): Type {
|
||||
let missingElements: BindingElement[] | undefined;
|
||||
for (const e of pattern.elements) {
|
||||
if (e.initializer) {
|
||||
const name = getPropertyNameFromBindingElement(e);
|
||||
if (name && !getPropertyOfType(type, name)) {
|
||||
missingElements = append(missingElements, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!missingElements) {
|
||||
return type;
|
||||
}
|
||||
const members = createSymbolTable();
|
||||
for (const prop of getPropertiesOfObjectType(type)) {
|
||||
members.set(prop.escapedName, prop);
|
||||
}
|
||||
for (const e of missingElements) {
|
||||
const symbol = createSymbol(SymbolFlags.Property | SymbolFlags.Optional, getPropertyNameFromBindingElement(e)!);
|
||||
symbol.links.type = getTypeFromBindingElement(e, /*includePatternInType*/ false, /*reportErrors*/ false);
|
||||
members.set(symbol.escapedName, symbol);
|
||||
}
|
||||
const result = createAnonymousType(type.symbol, members, emptyArray, emptyArray, getIndexInfosOfType(type));
|
||||
result.objectFlags = type.objectFlags;
|
||||
return result;
|
||||
}
|
||||
|
||||
function getPropertyNameFromBindingElement(e: BindingElement) {
|
||||
const exprType = getLiteralTypeFromPropertyName(e.propertyName || e.name as Identifier);
|
||||
return isTypeUsableAsPropertyName(exprType) ? getPropertyNameFromType(exprType) : undefined;
|
||||
}
|
||||
|
||||
function padTupleType(type: TupleTypeReference, pattern: ArrayBindingPattern) {
|
||||
if (type.target.combinedFlags & ElementFlags.Variable || getTypeReferenceArity(type) >= pattern.elements.length) {
|
||||
return type;
|
||||
}
|
||||
const patternElements = pattern.elements;
|
||||
const elementTypes = getElementTypes(type).slice();
|
||||
const elementFlags = type.target.elementFlags.slice();
|
||||
|
||||
@@ -2680,10 +2680,6 @@
|
||||
"category": "Error",
|
||||
"code": 2524
|
||||
},
|
||||
"Initializer provides no value for this binding element and the binding element has no default value.": {
|
||||
"category": "Error",
|
||||
"code": 2525
|
||||
},
|
||||
"A 'this' type is available only in a non-static member of a class or interface.": {
|
||||
"category": "Error",
|
||||
"code": 2526
|
||||
|
||||
@@ -6697,7 +6697,7 @@ export const enum AccessFlags {
|
||||
NoIndexSignatures = 1 << 1,
|
||||
Writing = 1 << 2,
|
||||
CacheSymbol = 1 << 3,
|
||||
NoTupleBoundsCheck = 1 << 4,
|
||||
AllowMissing = 1 << 4,
|
||||
ExpressionPosition = 1 << 5,
|
||||
ReportDeprecated = 1 << 6,
|
||||
SuppressNoImplicitAnyError = 1 << 7,
|
||||
|
||||
@@ -9,24 +9,24 @@ function Test({ b = '' } = {}) {}
|
||||
> : ^^^^^^
|
||||
>'' : ""
|
||||
> : ^^
|
||||
>{} : { b?: string; }
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
>{} : {}
|
||||
> : ^^
|
||||
|
||||
Test(({ b = '5' } = {}));
|
||||
>Test(({ b = '5' } = {})) : void
|
||||
> : ^^^^
|
||||
>Test : ({ b }?: { b?: string; }) => void
|
||||
> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>({ b = '5' } = {}) : { b?: any; }
|
||||
> : ^^^^^^^^^^^^
|
||||
>{ b = '5' } = {} : { b?: any; }
|
||||
> : ^^^^^^^^^^^^
|
||||
>({ b = '5' } = {}) : {}
|
||||
> : ^^
|
||||
>{ b = '5' } = {} : {}
|
||||
> : ^^
|
||||
>{ b = '5' } : { b?: any; }
|
||||
> : ^^^^^^^^^^^^
|
||||
>b : any
|
||||
> : ^^^
|
||||
>'5' : "5"
|
||||
> : ^^^
|
||||
>{} : { b?: any; }
|
||||
> : ^^^^^^^^^^^^
|
||||
>{} : {}
|
||||
> : ^^
|
||||
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
checkDestructuringShorthandAssigment2.ts(4,7): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
checkDestructuringShorthandAssigment2.ts(4,27): error TS2353: Object literal may only specify known properties, and '[k]' does not exist in type '{ x: any; }'.
|
||||
|
||||
|
||||
==== checkDestructuringShorthandAssigment2.ts (2 errors) ====
|
||||
==== checkDestructuringShorthandAssigment2.ts (1 errors) ====
|
||||
// GH #38175 -- should not crash while checking
|
||||
|
||||
let o: any, k: any;
|
||||
let { x } = { x: 1, ...o, [k]: 1 };
|
||||
~
|
||||
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
~~~
|
||||
!!! error TS2353: Object literal may only specify known properties, and '[k]' does not exist in type '{ x: any; }'.
|
||||
|
||||
@@ -104,8 +104,8 @@ type Something = { foo: number };
|
||||
|
||||
// inference fails here, but ideally should not
|
||||
const A = object<Something>()({
|
||||
>A : ObjectType<Something>
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^
|
||||
>A : any
|
||||
> : ^^^
|
||||
>object<Something>()({ name: "A", fields: () => ({ a: field({ type: A, resolve() { return { foo: 100, }; }, }), }),}) : ObjectType<Something>
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^
|
||||
>object<Something>() : <Fields extends { [Key in keyof Fields]: Field<Something, Key & string>; }>(config: { name: string; fields: Fields | (() => Fields); }) => ObjectType<Something>
|
||||
@@ -138,14 +138,14 @@ const A = object<Something>()({
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^
|
||||
>field : <Source, Type extends ObjectType<any>, Key extends string>(field: FieldFuncArgs<Source, Type>) => Field<Source, Key>
|
||||
> : ^ ^^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^
|
||||
>{ type: A, resolve() { return { foo: 100, }; }, } : { type: ObjectType<Something>; resolve(): { foo: number; }; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{ type: A, resolve() { return { foo: 100, }; }, } : { type: any; resolve(): { foo: number; }; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
type: A,
|
||||
>type : ObjectType<Something>
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^
|
||||
>A : ObjectType<Something>
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^
|
||||
>type : any
|
||||
> : ^^^
|
||||
>A : any
|
||||
> : ^^^
|
||||
|
||||
resolve() {
|
||||
>resolve : () => { foo: number; }
|
||||
|
||||
@@ -10,8 +10,8 @@ const fInferred = ({ a = 0 } = {}) => a;
|
||||
> : ^^^^^^
|
||||
>0 : 0
|
||||
> : ^
|
||||
>{} : { a?: number | undefined; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{} : {}
|
||||
> : ^^
|
||||
>a : number
|
||||
> : ^^^^^^
|
||||
|
||||
|
||||
@@ -53,8 +53,8 @@ try {
|
||||
> : ^^^^^^
|
||||
>1 : 1
|
||||
> : ^
|
||||
>{ } : { e?: number | undefined; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{ } : {}
|
||||
> : ^^
|
||||
|
||||
} catch {
|
||||
console.error("error");
|
||||
|
||||
@@ -11,8 +11,8 @@ declarationsAndAssignments.ts(63,13): error TS2493: Tuple type '[number]' of len
|
||||
declarationsAndAssignments.ts(63,16): error TS2493: Tuple type '[number]' of length '1' has no element at index '2'.
|
||||
declarationsAndAssignments.ts(67,9): error TS2461: Type '{}' is not an array type.
|
||||
declarationsAndAssignments.ts(68,9): error TS2461: Type '{ 0: number; 1: number; }' is not an array type.
|
||||
declarationsAndAssignments.ts(73,11): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
declarationsAndAssignments.ts(73,14): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
declarationsAndAssignments.ts(73,11): error TS2339: Property 'a' does not exist on type '{}'.
|
||||
declarationsAndAssignments.ts(73,14): error TS2339: Property 'b' does not exist on type '{}'.
|
||||
declarationsAndAssignments.ts(74,11): error TS2339: Property 'a' does not exist on type 'undefined[]'.
|
||||
declarationsAndAssignments.ts(74,14): error TS2339: Property 'b' does not exist on type 'undefined[]'.
|
||||
declarationsAndAssignments.ts(106,17): error TS2741: Property 'x' is missing in type '{ y: false; }' but required in type '{ x: any; y?: boolean; }'.
|
||||
@@ -122,9 +122,9 @@ declarationsAndAssignments.ts(138,9): error TS2322: Type 'number' is not assigna
|
||||
function f10() {
|
||||
var { a, b } = {}; // Error
|
||||
~
|
||||
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
!!! error TS2339: Property 'a' does not exist on type '{}'.
|
||||
~
|
||||
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
!!! error TS2339: Property 'b' does not exist on type '{}'.
|
||||
var { a, b } = []; // Error
|
||||
~
|
||||
!!! error TS2339: Property 'a' does not exist on type 'undefined[]'.
|
||||
|
||||
@@ -486,8 +486,8 @@ function f10() {
|
||||
> : ^^^
|
||||
>b : any
|
||||
> : ^^^
|
||||
>{} : { a: any; b: any; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
>{} : {}
|
||||
> : ^^
|
||||
|
||||
var { a, b } = []; // Error
|
||||
>a : any
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
destructuredLateBoundNameHasCorrectTypes.ts(11,21): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
destructuredLateBoundNameHasCorrectTypes.ts(11,8): error TS2339: Property 'prop2' does not exist on type '{ prop: string; }'.
|
||||
destructuredLateBoundNameHasCorrectTypes.ts(11,37): error TS2353: Object literal may only specify known properties, and 'prop' does not exist in type '{ prop2: any; }'.
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ destructuredLateBoundNameHasCorrectTypes.ts(11,37): error TS2353: Object literal
|
||||
const notPresent = "prop2";
|
||||
|
||||
let { [notPresent]: computed2 } = { prop: "b" };
|
||||
~~~~~~~~~
|
||||
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
~~~~~~~~~~
|
||||
!!! error TS2339: Property 'prop2' does not exist on type '{ prop: string; }'.
|
||||
~~~~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'prop' does not exist in type '{ prop2: any; }'.
|
||||
|
||||
@@ -54,8 +54,8 @@ let { [notPresent]: computed2 } = { prop: "b" };
|
||||
> : ^^^^^^^
|
||||
>computed2 : any
|
||||
> : ^^^
|
||||
>{ prop: "b" } : { prop: string; prop2: any; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{ prop: "b" } : { prop: string; }
|
||||
> : ^^^^^^^^^^^^^^^^^
|
||||
>prop : string
|
||||
> : ^^^^^^
|
||||
>"b" : "b"
|
||||
|
||||
@@ -30,20 +30,20 @@ const [c, d = c, e = e] = [1]; // error for e = e
|
||||
> : ^
|
||||
|
||||
const [f, g = f, h = i, i = f] = [1]; // error for h = i
|
||||
>f : any
|
||||
> : ^^^
|
||||
>g : any
|
||||
> : ^^^
|
||||
>f : any
|
||||
> : ^^^
|
||||
>h : any
|
||||
> : ^^^
|
||||
>i : any
|
||||
> : ^^^
|
||||
>i : any
|
||||
> : ^^^
|
||||
>f : any
|
||||
> : ^^^
|
||||
>f : number
|
||||
> : ^^^^^^
|
||||
>g : number
|
||||
> : ^^^^^^
|
||||
>f : number
|
||||
> : ^^^^^^
|
||||
>h : number
|
||||
> : ^^^^^^
|
||||
>i : number
|
||||
> : ^^^^^^
|
||||
>i : number
|
||||
> : ^^^^^^
|
||||
>f : number
|
||||
> : ^^^^^^
|
||||
>[1] : [number]
|
||||
> : ^^^^^^^^
|
||||
>1 : 1
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
destructuringFromUnionSpread.ts(5,9): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
destructuringFromUnionSpread.ts(5,9): error TS2339: Property 'a' does not exist on type '{ a: string; } | { b: number; }'.
|
||||
|
||||
|
||||
==== destructuringFromUnionSpread.ts (1 errors) ====
|
||||
@@ -8,5 +8,5 @@ destructuringFromUnionSpread.ts(5,9): error TS2525: Initializer provides no valu
|
||||
declare const x: A | B;
|
||||
const { a } = { ...x } // error
|
||||
~
|
||||
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
!!! error TS2339: Property 'a' does not exist on type '{ a: string; } | { b: number; }'.
|
||||
|
||||
@@ -16,8 +16,8 @@ declare const x: A | B;
|
||||
const { a } = { ...x } // error
|
||||
>a : any
|
||||
> : ^^^
|
||||
>{ ...x } : { a: any; } | { a: any; b: number; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^
|
||||
>{ ...x } : { a: string; } | { b: number; }
|
||||
> : ^^^^^ ^^^^^^^^^^^ ^^^
|
||||
>x : A | B
|
||||
> : ^^^^^
|
||||
|
||||
|
||||
@@ -2,14 +2,13 @@ destructuringObjectBindingPatternAndAssignment3.ts(2,7): error TS1005: ',' expec
|
||||
destructuringObjectBindingPatternAndAssignment3.ts(3,5): error TS2322: Type '{ i: number; }' is not assignable to type 'string | number'.
|
||||
destructuringObjectBindingPatternAndAssignment3.ts(3,6): error TS2339: Property 'i' does not exist on type 'string | number'.
|
||||
destructuringObjectBindingPatternAndAssignment3.ts(4,6): error TS2339: Property 'i1' does not exist on type 'string | number | {}'.
|
||||
destructuringObjectBindingPatternAndAssignment3.ts(5,12): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
destructuringObjectBindingPatternAndAssignment3.ts(5,21): error TS2353: Object literal may only specify known properties, and 'f212' does not exist in type '{ f21: any; }'.
|
||||
destructuringObjectBindingPatternAndAssignment3.ts(6,7): error TS1005: ':' expected.
|
||||
destructuringObjectBindingPatternAndAssignment3.ts(6,15): error TS1005: ':' expected.
|
||||
destructuringObjectBindingPatternAndAssignment3.ts(7,12): error TS1005: ':' expected.
|
||||
|
||||
|
||||
==== destructuringObjectBindingPatternAndAssignment3.ts (9 errors) ====
|
||||
==== destructuringObjectBindingPatternAndAssignment3.ts (8 errors) ====
|
||||
// Error
|
||||
var {h?} = { h?: 1 };
|
||||
~
|
||||
@@ -23,8 +22,6 @@ destructuringObjectBindingPatternAndAssignment3.ts(7,12): error TS1005: ':' expe
|
||||
~~
|
||||
!!! error TS2339: Property 'i1' does not exist on type 'string | number | {}'.
|
||||
var { f2: {f21} = { f212: "string" } }: any = undefined;
|
||||
~~~
|
||||
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
~~~~
|
||||
!!! error TS2353: Object literal may only specify known properties, and 'f212' does not exist in type '{ f21: any; }'.
|
||||
var {1} = { 1 };
|
||||
|
||||
@@ -37,8 +37,8 @@ var { f2: {f21} = { f212: "string" } }: any = undefined;
|
||||
> : ^^^
|
||||
>f21 : any
|
||||
> : ^^^
|
||||
>{ f212: "string" } : { f212: string; f21: any; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{ f212: "string" } : { f212: string; }
|
||||
> : ^^^^^^^^^^^^^^^^^
|
||||
>f212 : string
|
||||
> : ^^^^^^
|
||||
>"string" : "string"
|
||||
|
||||
@@ -13,8 +13,8 @@ function f1() {
|
||||
> : ^^^^^^
|
||||
>a1 : number
|
||||
> : ^^^^^^
|
||||
>{ a1: 1 } : { a1: number; b1?: number; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{ a1: 1 } : { a1: number; }
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
>a1 : number
|
||||
> : ^^^^^^
|
||||
>1 : 1
|
||||
@@ -31,8 +31,8 @@ function f1() {
|
||||
> : ^
|
||||
>a2 : number
|
||||
> : ^^^^^^
|
||||
>{ a2: 1 } : { a2: number; b2?: number; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{ a2: 1 } : { a2: number; }
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
>a2 : number
|
||||
> : ^^^^^^
|
||||
>1 : 1
|
||||
@@ -51,8 +51,8 @@ function f2() {
|
||||
> : ^^^^^^
|
||||
>a1 : string
|
||||
> : ^^^^^^
|
||||
>{ a1: 'hi' } : { a1: string; b1?: string; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{ a1: 'hi' } : { a1: string; }
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
>a1 : string
|
||||
> : ^^^^^^
|
||||
>'hi' : "hi"
|
||||
@@ -69,8 +69,8 @@ function f2() {
|
||||
> : ^^^^^^
|
||||
>'!' : "!"
|
||||
> : ^^^
|
||||
>{ a2: 'hi' } : { a2: string; b2?: string; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{ a2: 'hi' } : { a2: string; }
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
>a2 : string
|
||||
> : ^^^^^^
|
||||
>'hi' : "hi"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
destructuringSpread.ts(16,21): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
destructuringSpread.ts(16,21): error TS2339: Property 'g' does not exist on type '{ f: number; e: number; d: number; c: number; }'.
|
||||
|
||||
|
||||
==== destructuringSpread.ts (1 errors) ====
|
||||
@@ -19,7 +19,7 @@ destructuringSpread.ts(16,21): error TS2525: Initializer provides no value for t
|
||||
|
||||
const { c, d, e, f, g } = {
|
||||
~
|
||||
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
!!! error TS2339: Property 'g' does not exist on type '{ f: number; e: number; d: number; c: number; }'.
|
||||
...{
|
||||
...{
|
||||
...{
|
||||
|
||||
@@ -78,8 +78,8 @@ const { c, d, e, f, g } = {
|
||||
> : ^^^^^^
|
||||
>g : any
|
||||
> : ^^^
|
||||
>{ ...{ ...{ ...{ c: 0, }, d: 0 }, e: 0 }, f: 0} : { f: number; g: any; e: number; d: number; c: number; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{ ...{ ...{ ...{ c: 0, }, d: 0 }, e: 0 }, f: 0} : { f: number; e: number; d: number; c: number; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
...{
|
||||
>{ ...{ ...{ c: 0, }, d: 0 }, e: 0 } : { e: number; d: number; c: number; }
|
||||
|
||||
@@ -177,8 +177,8 @@ function f5({ x, y = 0 } = { x: 0 }) { }
|
||||
> : ^^^^^^
|
||||
>0 : 0
|
||||
> : ^
|
||||
>{ x: 0 } : { x: number; y?: number; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{ x: 0 } : { x: number; }
|
||||
> : ^^^^^^^^^^^^^^
|
||||
>x : number
|
||||
> : ^^^^^^
|
||||
>0 : 0
|
||||
@@ -230,8 +230,8 @@ function f6({ x = 0, y = 0 } = {}) { }
|
||||
> : ^^^^^^
|
||||
>0 : 0
|
||||
> : ^
|
||||
>{} : { x?: number; y?: number; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{} : {}
|
||||
> : ^^
|
||||
|
||||
f6();
|
||||
>f6() : void
|
||||
@@ -289,8 +289,8 @@ f6({ x: 1, y: 1 });
|
||||
|
||||
// (arg?: { a: { x?: number, y?: number } }) => void
|
||||
function f7({ a: { x = 0, y = 0 } } = { a: {} }) { }
|
||||
>f7 : ({ a: { x, y } }?: { a: { x?: number; y?: number; }; }) => void
|
||||
> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>f7 : ({ a: { x, y } }?: { a: {}; }) => void
|
||||
> : ^ ^^^^^^^^^^^^^^^^^^^^^^
|
||||
>a : any
|
||||
> : ^^^
|
||||
>x : number
|
||||
@@ -301,24 +301,24 @@ function f7({ a: { x = 0, y = 0 } } = { a: {} }) { }
|
||||
> : ^^^^^^
|
||||
>0 : 0
|
||||
> : ^
|
||||
>{ a: {} } : { a: { x?: number; y?: number; }; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>a : { x?: number; y?: number; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{} : { x?: number; y?: number; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{ a: {} } : { a: {}; }
|
||||
> : ^^^^^^^^^^
|
||||
>a : {}
|
||||
> : ^^
|
||||
>{} : {}
|
||||
> : ^^
|
||||
|
||||
f7();
|
||||
>f7() : void
|
||||
> : ^^^^
|
||||
>f7 : ({ a: { x, y } }?: { a: { x?: number; y?: number; }; }) => void
|
||||
> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>f7 : ({ a: { x, y } }?: { a: {}; }) => void
|
||||
> : ^ ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
f7({ a: {} });
|
||||
>f7({ a: {} }) : void
|
||||
> : ^^^^
|
||||
>f7 : ({ a: { x, y } }?: { a: { x?: number; y?: number; }; }) => void
|
||||
> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>f7 : ({ a: { x, y } }?: { a: {}; }) => void
|
||||
> : ^ ^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{ a: {} } : { a: {}; }
|
||||
> : ^^^^^^^^^^
|
||||
>a : {}
|
||||
@@ -329,8 +329,8 @@ f7({ a: {} });
|
||||
f7({ a: { x: 1 } });
|
||||
>f7({ a: { x: 1 } }) : void
|
||||
> : ^^^^
|
||||
>f7 : ({ a: { x, y } }?: { a: { x?: number; y?: number; }; }) => void
|
||||
> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>f7 : ({ a: { x, y } }?: { a: {}; }) => void
|
||||
> : ^ ^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{ a: { x: 1 } } : { a: { x: number; }; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^
|
||||
>a : { x: number; }
|
||||
@@ -345,8 +345,8 @@ f7({ a: { x: 1 } });
|
||||
f7({ a: { y: 1 } });
|
||||
>f7({ a: { y: 1 } }) : void
|
||||
> : ^^^^
|
||||
>f7 : ({ a: { x, y } }?: { a: { x?: number; y?: number; }; }) => void
|
||||
> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>f7 : ({ a: { x, y } }?: { a: {}; }) => void
|
||||
> : ^ ^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{ a: { y: 1 } } : { a: { y: number; }; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^
|
||||
>a : { y: number; }
|
||||
@@ -361,8 +361,8 @@ f7({ a: { y: 1 } });
|
||||
f7({ a: { x: 1, y: 1 } });
|
||||
>f7({ a: { x: 1, y: 1 } }) : void
|
||||
> : ^^^^
|
||||
>f7 : ({ a: { x, y } }?: { a: { x?: number; y?: number; }; }) => void
|
||||
> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>f7 : ({ a: { x, y } }?: { a: {}; }) => void
|
||||
> : ^ ^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{ a: { x: 1, y: 1 } } : { a: { x: number; y: number; }; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>a : { x: number; y: number; }
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
main.ts(8,5): error TS2538: Type 'any' cannot be used as an index type.
|
||||
main.ts(8,13): error TS2343: This syntax requires an imported helper named '__esDecorate' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
|
||||
main.ts(8,13): error TS2343: This syntax requires an imported helper named '__runInitializers' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
|
||||
main.ts(8,13): error TS2343: This syntax requires an imported helper named '__setFunctionName' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
|
||||
|
||||
|
||||
==== main.ts (4 errors) ====
|
||||
==== main.ts (3 errors) ====
|
||||
export {};
|
||||
declare var dec: any;
|
||||
declare var x: any;
|
||||
@@ -13,8 +12,6 @@ main.ts(8,13): error TS2343: This syntax requires an imported helper named '__se
|
||||
|
||||
// uses __esDecorate, __runInitializers, __setFunctionName, __propKey
|
||||
({ [x]: C = @dec class {} } = {});
|
||||
~
|
||||
!!! error TS2538: Type 'any' cannot be used as an index type.
|
||||
~~~~
|
||||
!!! error TS2343: This syntax requires an imported helper named '__esDecorate' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
|
||||
~~~~
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
intraBindingPatternReferences.ts(18,71): error TS7006: Parameter 'x' implicitly has an 'any' type.
|
||||
|
||||
|
||||
==== intraBindingPatternReferences.ts (1 errors) ====
|
||||
// https://github.com/microsoft/TypeScript/issues/59177
|
||||
|
||||
function foo() { return a }
|
||||
|
||||
const [a, b = a + 1] = [42];
|
||||
|
||||
const [c1, c2 = c1] = [123];
|
||||
const [d1, d2 = d1, d3 = d2] = [123];
|
||||
|
||||
const { e1, e2 = e1 } = { e1: 1 };
|
||||
const { f1, f2 = f1, f3 = f2 } = { f1: 1 };
|
||||
|
||||
// Example that requires padding of object literal types at depth
|
||||
const mockCallback = ({ event: { params = {} } = {} }) => {};
|
||||
|
||||
// The contextual type for the second lambda in the object literal is 'any' because of the
|
||||
// intra-binding-pattern reference in the initializer for fn2
|
||||
const { fn1 = (x: number) => 0, fn2 = fn1 } = { fn1: x => x + 1, fn2: x => x + 2 };
|
||||
~
|
||||
!!! error TS7006: Parameter 'x' implicitly has an 'any' type.
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
//// [tests/cases/compiler/intraBindingPatternReferences.ts] ////
|
||||
|
||||
=== intraBindingPatternReferences.ts ===
|
||||
// https://github.com/microsoft/TypeScript/issues/59177
|
||||
|
||||
function foo() { return a }
|
||||
>foo : Symbol(foo, Decl(intraBindingPatternReferences.ts, 0, 0))
|
||||
>a : Symbol(a, Decl(intraBindingPatternReferences.ts, 4, 7))
|
||||
|
||||
const [a, b = a + 1] = [42];
|
||||
>a : Symbol(a, Decl(intraBindingPatternReferences.ts, 4, 7))
|
||||
>b : Symbol(b, Decl(intraBindingPatternReferences.ts, 4, 9))
|
||||
>a : Symbol(a, Decl(intraBindingPatternReferences.ts, 4, 7))
|
||||
|
||||
const [c1, c2 = c1] = [123];
|
||||
>c1 : Symbol(c1, Decl(intraBindingPatternReferences.ts, 6, 7))
|
||||
>c2 : Symbol(c2, Decl(intraBindingPatternReferences.ts, 6, 10))
|
||||
>c1 : Symbol(c1, Decl(intraBindingPatternReferences.ts, 6, 7))
|
||||
|
||||
const [d1, d2 = d1, d3 = d2] = [123];
|
||||
>d1 : Symbol(d1, Decl(intraBindingPatternReferences.ts, 7, 7))
|
||||
>d2 : Symbol(d2, Decl(intraBindingPatternReferences.ts, 7, 10))
|
||||
>d1 : Symbol(d1, Decl(intraBindingPatternReferences.ts, 7, 7))
|
||||
>d3 : Symbol(d3, Decl(intraBindingPatternReferences.ts, 7, 19))
|
||||
>d2 : Symbol(d2, Decl(intraBindingPatternReferences.ts, 7, 10))
|
||||
|
||||
const { e1, e2 = e1 } = { e1: 1 };
|
||||
>e1 : Symbol(e1, Decl(intraBindingPatternReferences.ts, 9, 7))
|
||||
>e2 : Symbol(e2, Decl(intraBindingPatternReferences.ts, 9, 11))
|
||||
>e1 : Symbol(e1, Decl(intraBindingPatternReferences.ts, 9, 7))
|
||||
>e1 : Symbol(e1, Decl(intraBindingPatternReferences.ts, 9, 25))
|
||||
|
||||
const { f1, f2 = f1, f3 = f2 } = { f1: 1 };
|
||||
>f1 : Symbol(f1, Decl(intraBindingPatternReferences.ts, 10, 7))
|
||||
>f2 : Symbol(f2, Decl(intraBindingPatternReferences.ts, 10, 11))
|
||||
>f1 : Symbol(f1, Decl(intraBindingPatternReferences.ts, 10, 7))
|
||||
>f3 : Symbol(f3, Decl(intraBindingPatternReferences.ts, 10, 20))
|
||||
>f2 : Symbol(f2, Decl(intraBindingPatternReferences.ts, 10, 11))
|
||||
>f1 : Symbol(f1, Decl(intraBindingPatternReferences.ts, 10, 34))
|
||||
|
||||
// Example that requires padding of object literal types at depth
|
||||
const mockCallback = ({ event: { params = {} } = {} }) => {};
|
||||
>mockCallback : Symbol(mockCallback, Decl(intraBindingPatternReferences.ts, 13, 5))
|
||||
>event : Symbol(event)
|
||||
>params : Symbol(params, Decl(intraBindingPatternReferences.ts, 13, 32))
|
||||
|
||||
// The contextual type for the second lambda in the object literal is 'any' because of the
|
||||
// intra-binding-pattern reference in the initializer for fn2
|
||||
const { fn1 = (x: number) => 0, fn2 = fn1 } = { fn1: x => x + 1, fn2: x => x + 2 };
|
||||
>fn1 : Symbol(fn1, Decl(intraBindingPatternReferences.ts, 17, 7))
|
||||
>x : Symbol(x, Decl(intraBindingPatternReferences.ts, 17, 15))
|
||||
>fn2 : Symbol(fn2, Decl(intraBindingPatternReferences.ts, 17, 31))
|
||||
>fn1 : Symbol(fn1, Decl(intraBindingPatternReferences.ts, 17, 7))
|
||||
>fn1 : Symbol(fn1, Decl(intraBindingPatternReferences.ts, 17, 47))
|
||||
>x : Symbol(x, Decl(intraBindingPatternReferences.ts, 17, 52))
|
||||
>x : Symbol(x, Decl(intraBindingPatternReferences.ts, 17, 52))
|
||||
>fn2 : Symbol(fn2, Decl(intraBindingPatternReferences.ts, 17, 64))
|
||||
>x : Symbol(x, Decl(intraBindingPatternReferences.ts, 17, 69))
|
||||
>x : Symbol(x, Decl(intraBindingPatternReferences.ts, 17, 69))
|
||||
|
||||
144
tests/baselines/reference/intraBindingPatternReferences.types
Normal file
144
tests/baselines/reference/intraBindingPatternReferences.types
Normal file
@@ -0,0 +1,144 @@
|
||||
//// [tests/cases/compiler/intraBindingPatternReferences.ts] ////
|
||||
|
||||
=== intraBindingPatternReferences.ts ===
|
||||
// https://github.com/microsoft/TypeScript/issues/59177
|
||||
|
||||
function foo() { return a }
|
||||
>foo : () => number
|
||||
> : ^^^^^^^^^^^^
|
||||
>a : number
|
||||
> : ^^^^^^
|
||||
|
||||
const [a, b = a + 1] = [42];
|
||||
>a : number
|
||||
> : ^^^^^^
|
||||
>b : number
|
||||
> : ^^^^^^
|
||||
>a + 1 : number
|
||||
> : ^^^^^^
|
||||
>a : number
|
||||
> : ^^^^^^
|
||||
>1 : 1
|
||||
> : ^
|
||||
>[42] : [number]
|
||||
> : ^^^^^^^^
|
||||
>42 : 42
|
||||
> : ^^
|
||||
|
||||
const [c1, c2 = c1] = [123];
|
||||
>c1 : number
|
||||
> : ^^^^^^
|
||||
>c2 : number
|
||||
> : ^^^^^^
|
||||
>c1 : number
|
||||
> : ^^^^^^
|
||||
>[123] : [number]
|
||||
> : ^^^^^^^^
|
||||
>123 : 123
|
||||
> : ^^^
|
||||
|
||||
const [d1, d2 = d1, d3 = d2] = [123];
|
||||
>d1 : number
|
||||
> : ^^^^^^
|
||||
>d2 : number
|
||||
> : ^^^^^^
|
||||
>d1 : number
|
||||
> : ^^^^^^
|
||||
>d3 : number
|
||||
> : ^^^^^^
|
||||
>d2 : number
|
||||
> : ^^^^^^
|
||||
>[123] : [number]
|
||||
> : ^^^^^^^^
|
||||
>123 : 123
|
||||
> : ^^^
|
||||
|
||||
const { e1, e2 = e1 } = { e1: 1 };
|
||||
>e1 : number
|
||||
> : ^^^^^^
|
||||
>e2 : number
|
||||
> : ^^^^^^
|
||||
>e1 : number
|
||||
> : ^^^^^^
|
||||
>{ e1: 1 } : { e1: number; }
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
>e1 : number
|
||||
> : ^^^^^^
|
||||
>1 : 1
|
||||
> : ^
|
||||
|
||||
const { f1, f2 = f1, f3 = f2 } = { f1: 1 };
|
||||
>f1 : number
|
||||
> : ^^^^^^
|
||||
>f2 : number
|
||||
> : ^^^^^^
|
||||
>f1 : number
|
||||
> : ^^^^^^
|
||||
>f3 : number
|
||||
> : ^^^^^^
|
||||
>f2 : number
|
||||
> : ^^^^^^
|
||||
>{ f1: 1 } : { f1: number; }
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
>f1 : number
|
||||
> : ^^^^^^
|
||||
>1 : 1
|
||||
> : ^
|
||||
|
||||
// Example that requires padding of object literal types at depth
|
||||
const mockCallback = ({ event: { params = {} } = {} }) => {};
|
||||
>mockCallback : ({ event: { params } }: { event?: { params?: {} | undefined; } | undefined; }) => void
|
||||
> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>({ event: { params = {} } = {} }) => {} : ({ event: { params } }: { event?: { params?: {} | undefined; } | undefined; }) => void
|
||||
> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>event : any
|
||||
> : ^^^
|
||||
>params : {}
|
||||
> : ^^
|
||||
>{} : {}
|
||||
> : ^^
|
||||
>{} : {}
|
||||
> : ^^
|
||||
|
||||
// The contextual type for the second lambda in the object literal is 'any' because of the
|
||||
// intra-binding-pattern reference in the initializer for fn2
|
||||
const { fn1 = (x: number) => 0, fn2 = fn1 } = { fn1: x => x + 1, fn2: x => x + 2 };
|
||||
>fn1 : (x: number) => number
|
||||
> : ^ ^^ ^^^^^^^^^^^
|
||||
>(x: number) => 0 : (x: number) => number
|
||||
> : ^ ^^ ^^^^^^^^^^^
|
||||
>x : number
|
||||
> : ^^^^^^
|
||||
>0 : 0
|
||||
> : ^
|
||||
>fn2 : ((x: number) => number) | ((x: any) => any)
|
||||
> : ^^ ^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^
|
||||
>fn1 : (x: number) => number
|
||||
> : ^ ^^ ^^^^^^^^^^^
|
||||
>{ fn1: x => x + 1, fn2: x => x + 2 } : { fn1?: (x: number) => number; fn2?: (x: any) => any; }
|
||||
> : ^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^
|
||||
>fn1 : (x: number) => number
|
||||
> : ^ ^^^^^^^^^^^^^^^^^^^
|
||||
>x => x + 1 : (x: number) => number
|
||||
> : ^ ^^^^^^^^^^^^^^^^^^^
|
||||
>x : number
|
||||
> : ^^^^^^
|
||||
>x + 1 : number
|
||||
> : ^^^^^^
|
||||
>x : number
|
||||
> : ^^^^^^
|
||||
>1 : 1
|
||||
> : ^
|
||||
>fn2 : (x: any) => any
|
||||
> : ^ ^^^^^^^^^^^^^
|
||||
>x => x + 2 : (x: any) => any
|
||||
> : ^ ^^^^^^^^^^^^^
|
||||
>x : any
|
||||
> : ^^^
|
||||
>x + 2 : any
|
||||
> : ^^^
|
||||
>x : any
|
||||
> : ^^^
|
||||
>2 : 2
|
||||
> : ^
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
missingAndExcessProperties.ts(3,11): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
missingAndExcessProperties.ts(3,14): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
missingAndExcessProperties.ts(4,11): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'any', but here has type 'number'.
|
||||
missingAndExcessProperties.ts(4,18): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
missingAndExcessProperties.ts(5,11): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
missingAndExcessProperties.ts(5,14): error TS2403: Subsequent variable declarations must have the same type. Variable 'y' must be of type 'any', but here has type 'number'.
|
||||
missingAndExcessProperties.ts(6,11): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'any', but here has type 'number'.
|
||||
missingAndExcessProperties.ts(6,18): error TS2403: Subsequent variable declarations must have the same type. Variable 'y' must be of type 'any', but here has type 'number'.
|
||||
missingAndExcessProperties.ts(12,8): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
missingAndExcessProperties.ts(12,11): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
missingAndExcessProperties.ts(13,18): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
missingAndExcessProperties.ts(14,8): error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
missingAndExcessProperties.ts(3,11): error TS2339: Property 'x' does not exist on type '{}'.
|
||||
missingAndExcessProperties.ts(3,14): error TS2339: Property 'y' does not exist on type '{}'.
|
||||
missingAndExcessProperties.ts(4,18): error TS2339: Property 'y' does not exist on type '{}'.
|
||||
missingAndExcessProperties.ts(5,11): error TS2339: Property 'x' does not exist on type '{}'.
|
||||
missingAndExcessProperties.ts(12,8): error TS2339: Property 'x' does not exist on type '{}'.
|
||||
missingAndExcessProperties.ts(12,11): error TS2339: Property 'y' does not exist on type '{}'.
|
||||
missingAndExcessProperties.ts(13,18): error TS2339: Property 'y' does not exist on type '{}'.
|
||||
missingAndExcessProperties.ts(14,8): error TS2339: Property 'x' does not exist on type '{}'.
|
||||
missingAndExcessProperties.ts(21,25): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: any; }'.
|
||||
missingAndExcessProperties.ts(22,19): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{ y: any; }'.
|
||||
missingAndExcessProperties.ts(29,14): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'.
|
||||
@@ -18,33 +14,21 @@ missingAndExcessProperties.ts(30,22): error TS2353: Object literal may only spec
|
||||
missingAndExcessProperties.ts(31,16): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{ y: number; }'.
|
||||
|
||||
|
||||
==== missingAndExcessProperties.ts (18 errors) ====
|
||||
==== missingAndExcessProperties.ts (14 errors) ====
|
||||
// Missing properties
|
||||
function f1() {
|
||||
var { x, y } = {};
|
||||
~
|
||||
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
!!! error TS2339: Property 'x' does not exist on type '{}'.
|
||||
~
|
||||
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
!!! error TS2339: Property 'y' does not exist on type '{}'.
|
||||
var { x = 1, y } = {};
|
||||
~
|
||||
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'any', but here has type 'number'.
|
||||
!!! related TS6203 missingAndExcessProperties.ts:3:11: 'x' was also declared here.
|
||||
~
|
||||
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
!!! error TS2339: Property 'y' does not exist on type '{}'.
|
||||
var { x, y = 1 } = {};
|
||||
~
|
||||
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
~
|
||||
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'y' must be of type 'any', but here has type 'number'.
|
||||
!!! related TS6203 missingAndExcessProperties.ts:3:14: 'y' was also declared here.
|
||||
!!! error TS2339: Property 'x' does not exist on type '{}'.
|
||||
var { x = 1, y = 1 } = {};
|
||||
~
|
||||
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'any', but here has type 'number'.
|
||||
!!! related TS6203 missingAndExcessProperties.ts:3:11: 'x' was also declared here.
|
||||
~
|
||||
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'y' must be of type 'any', but here has type 'number'.
|
||||
!!! related TS6203 missingAndExcessProperties.ts:3:14: 'y' was also declared here.
|
||||
}
|
||||
|
||||
// Missing properties
|
||||
@@ -52,15 +36,15 @@ missingAndExcessProperties.ts(31,16): error TS2353: Object literal may only spec
|
||||
var x: number, y: number;
|
||||
({ x, y } = {});
|
||||
~
|
||||
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
!!! error TS2339: Property 'x' does not exist on type '{}'.
|
||||
~
|
||||
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
!!! error TS2339: Property 'y' does not exist on type '{}'.
|
||||
({ x: x = 1, y } = {});
|
||||
~
|
||||
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
!!! error TS2339: Property 'y' does not exist on type '{}'.
|
||||
({ x, y: y = 1 } = {});
|
||||
~
|
||||
!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value.
|
||||
!!! error TS2339: Property 'x' does not exist on type '{}'.
|
||||
({ x: x = 1, y: y = 1 } = {});
|
||||
}
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@ function f1() {
|
||||
> : ^^^
|
||||
>y : any
|
||||
> : ^^^
|
||||
>{} : { x: any; y: any; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
>{} : {}
|
||||
> : ^^
|
||||
|
||||
var { x = 1, y } = {};
|
||||
>x : any
|
||||
@@ -21,8 +21,8 @@ function f1() {
|
||||
> : ^
|
||||
>y : any
|
||||
> : ^^^
|
||||
>{} : { x?: number; y: any; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{} : {}
|
||||
> : ^^
|
||||
|
||||
var { x, y = 1 } = {};
|
||||
>x : any
|
||||
@@ -31,8 +31,8 @@ function f1() {
|
||||
> : ^^^
|
||||
>1 : 1
|
||||
> : ^
|
||||
>{} : { x: any; y?: number; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{} : {}
|
||||
> : ^^
|
||||
|
||||
var { x = 1, y = 1 } = {};
|
||||
>x : any
|
||||
@@ -43,8 +43,8 @@ function f1() {
|
||||
> : ^^^
|
||||
>1 : 1
|
||||
> : ^
|
||||
>{} : { x?: number; y?: number; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{} : {}
|
||||
> : ^^
|
||||
}
|
||||
|
||||
// Missing properties
|
||||
@@ -59,24 +59,24 @@ function f2() {
|
||||
> : ^^^^^^
|
||||
|
||||
({ x, y } = {});
|
||||
>({ x, y } = {}) : { x: number; y: number; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{ x, y } = {} : { x: number; y: number; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>({ x, y } = {}) : {}
|
||||
> : ^^
|
||||
>{ x, y } = {} : {}
|
||||
> : ^^
|
||||
>{ x, y } : { x: number; y: number; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>x : number
|
||||
> : ^^^^^^
|
||||
>y : number
|
||||
> : ^^^^^^
|
||||
>{} : { x: number; y: number; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{} : {}
|
||||
> : ^^
|
||||
|
||||
({ x: x = 1, y } = {});
|
||||
>({ x: x = 1, y } = {}) : { x?: number; y: number; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{ x: x = 1, y } = {} : { x?: number; y: number; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>({ x: x = 1, y } = {}) : {}
|
||||
> : ^^
|
||||
>{ x: x = 1, y } = {} : {}
|
||||
> : ^^
|
||||
>{ x: x = 1, y } : { x?: number; y: number; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>x : number
|
||||
@@ -89,14 +89,14 @@ function f2() {
|
||||
> : ^
|
||||
>y : number
|
||||
> : ^^^^^^
|
||||
>{} : { x?: number; y: number; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{} : {}
|
||||
> : ^^
|
||||
|
||||
({ x, y: y = 1 } = {});
|
||||
>({ x, y: y = 1 } = {}) : { x: number; y?: number; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{ x, y: y = 1 } = {} : { x: number; y?: number; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>({ x, y: y = 1 } = {}) : {}
|
||||
> : ^^
|
||||
>{ x, y: y = 1 } = {} : {}
|
||||
> : ^^
|
||||
>{ x, y: y = 1 } : { x: number; y?: number; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>x : number
|
||||
@@ -109,14 +109,14 @@ function f2() {
|
||||
> : ^^^^^^
|
||||
>1 : 1
|
||||
> : ^
|
||||
>{} : { x: number; y?: number; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{} : {}
|
||||
> : ^^
|
||||
|
||||
({ x: x = 1, y: y = 1 } = {});
|
||||
>({ x: x = 1, y: y = 1 } = {}) : { x?: number; y?: number; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{ x: x = 1, y: y = 1 } = {} : { x?: number; y?: number; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>({ x: x = 1, y: y = 1 } = {}) : {}
|
||||
> : ^^
|
||||
>{ x: x = 1, y: y = 1 } = {} : {}
|
||||
> : ^^
|
||||
>{ x: x = 1, y: y = 1 } : { x?: number; y?: number; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>x : number
|
||||
@@ -135,8 +135,8 @@ function f2() {
|
||||
> : ^^^^^^
|
||||
>1 : 1
|
||||
> : ^
|
||||
>{} : { x?: number; y?: number; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{} : {}
|
||||
> : ^^
|
||||
}
|
||||
|
||||
// Excess properties
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
parserForOfStatement25.ts(4,11): error TS2339: Property 'x' does not exist on type '{}'.
|
||||
|
||||
|
||||
==== parserForOfStatement25.ts (1 errors) ====
|
||||
// repro from https://github.com/microsoft/TypeScript/issues/54769
|
||||
|
||||
for (let [x = 'a' in {}] of [[]]) console.log(x)
|
||||
for (let {x = 'a' in {}} of [{}]) console.log(x)
|
||||
~
|
||||
!!! error TS2339: Property 'x' does not exist on type '{}'.
|
||||
|
||||
@@ -28,8 +28,8 @@ for (let [x = 'a' in {}] of [[]]) console.log(x)
|
||||
> : ^^^^^^^
|
||||
|
||||
for (let {x = 'a' in {}} of [{}]) console.log(x)
|
||||
>x : any
|
||||
> : ^^^
|
||||
>x : boolean
|
||||
> : ^^^^^^^
|
||||
>'a' in {} : boolean
|
||||
> : ^^^^^^^
|
||||
>'a' : "a"
|
||||
@@ -48,6 +48,6 @@ for (let {x = 'a' in {}} of [{}]) console.log(x)
|
||||
> : ^^^^^^^
|
||||
>log : (...data: any[]) => void
|
||||
> : ^^^^ ^^ ^^^^^
|
||||
>x : any
|
||||
> : ^^^
|
||||
>x : boolean
|
||||
> : ^^^^^^^
|
||||
|
||||
|
||||
@@ -46,8 +46,8 @@ for (let {x = 'a' in {}} = {}; !x; x = !x) console.log(x)
|
||||
> : ^^^
|
||||
>{} : {}
|
||||
> : ^^
|
||||
>{} : { x?: boolean; }
|
||||
> : ^^^^^^^^^^^^^^^^
|
||||
>{} : {}
|
||||
> : ^^
|
||||
>!x : boolean
|
||||
> : ^^^^^^^
|
||||
>x : boolean
|
||||
|
||||
@@ -157,10 +157,10 @@ class A {
|
||||
> : ^
|
||||
|
||||
({ a: this.#field = 1, b: [this.#field = 1] } = { b: [] });
|
||||
>({ a: this.#field = 1, b: [this.#field = 1] } = { b: [] }) : { b: []; a?: number; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{ a: this.#field = 1, b: [this.#field = 1] } = { b: [] } : { b: []; a?: number; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^
|
||||
>({ a: this.#field = 1, b: [this.#field = 1] } = { b: [] }) : { b: []; }
|
||||
> : ^^^^^^^^^^
|
||||
>{ a: this.#field = 1, b: [this.#field = 1] } = { b: [] } : { b: []; }
|
||||
> : ^^^^^^^^^^
|
||||
>{ a: this.#field = 1, b: [this.#field = 1] } : { a?: number; b: [number]; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>a : number
|
||||
@@ -185,8 +185,8 @@ class A {
|
||||
> : ^^^^
|
||||
>1 : 1
|
||||
> : ^
|
||||
>{ b: [] } : { b: []; a?: number; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{ b: [] } : { b: []; }
|
||||
> : ^^^^^^^^^^
|
||||
>b : []
|
||||
> : ^^
|
||||
>[] : []
|
||||
|
||||
@@ -157,10 +157,10 @@ class A {
|
||||
> : ^
|
||||
|
||||
({ a: this.#field = 1, b: [this.#field = 1] } = { b: [] });
|
||||
>({ a: this.#field = 1, b: [this.#field = 1] } = { b: [] }) : { b: []; a?: number; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{ a: this.#field = 1, b: [this.#field = 1] } = { b: [] } : { b: []; a?: number; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^
|
||||
>({ a: this.#field = 1, b: [this.#field = 1] } = { b: [] }) : { b: []; }
|
||||
> : ^^^^^^^^^^
|
||||
>{ a: this.#field = 1, b: [this.#field = 1] } = { b: [] } : { b: []; }
|
||||
> : ^^^^^^^^^^
|
||||
>{ a: this.#field = 1, b: [this.#field = 1] } : { a?: number; b: [number]; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>a : number
|
||||
@@ -185,8 +185,8 @@ class A {
|
||||
> : ^^^^
|
||||
>1 : 1
|
||||
> : ^
|
||||
>{ b: [] } : { b: []; a?: number; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{ b: [] } : { b: []; }
|
||||
> : ^^^^^^^^^^
|
||||
>b : []
|
||||
> : ^^
|
||||
>[] : []
|
||||
|
||||
@@ -157,10 +157,10 @@ class A {
|
||||
> : ^
|
||||
|
||||
({ a: this.#field = 1, b: [this.#field = 1] } = { b: [] });
|
||||
>({ a: this.#field = 1, b: [this.#field = 1] } = { b: [] }) : { b: []; a?: number; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{ a: this.#field = 1, b: [this.#field = 1] } = { b: [] } : { b: []; a?: number; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^
|
||||
>({ a: this.#field = 1, b: [this.#field = 1] } = { b: [] }) : { b: []; }
|
||||
> : ^^^^^^^^^^
|
||||
>{ a: this.#field = 1, b: [this.#field = 1] } = { b: [] } : { b: []; }
|
||||
> : ^^^^^^^^^^
|
||||
>{ a: this.#field = 1, b: [this.#field = 1] } : { a?: number; b: [number]; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>a : number
|
||||
@@ -185,8 +185,8 @@ class A {
|
||||
> : ^^^^
|
||||
>1 : 1
|
||||
> : ^
|
||||
>{ b: [] } : { b: []; a?: number; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{ b: [] } : { b: []; }
|
||||
> : ^^^^^^^^^^
|
||||
>b : []
|
||||
> : ^^
|
||||
>[] : []
|
||||
|
||||
@@ -155,10 +155,10 @@ class A {
|
||||
> : ^
|
||||
|
||||
({ a: A.#field = 1, b: [A.#field = 1] } = { b: [] });
|
||||
>({ a: A.#field = 1, b: [A.#field = 1] } = { b: [] }) : { b: []; a?: number; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{ a: A.#field = 1, b: [A.#field = 1] } = { b: [] } : { b: []; a?: number; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^
|
||||
>({ a: A.#field = 1, b: [A.#field = 1] } = { b: [] }) : { b: []; }
|
||||
> : ^^^^^^^^^^
|
||||
>{ a: A.#field = 1, b: [A.#field = 1] } = { b: [] } : { b: []; }
|
||||
> : ^^^^^^^^^^
|
||||
>{ a: A.#field = 1, b: [A.#field = 1] } : { a?: number; b: [number]; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>a : number
|
||||
@@ -183,8 +183,8 @@ class A {
|
||||
> : ^^^^^^^^
|
||||
>1 : 1
|
||||
> : ^
|
||||
>{ b: [] } : { b: []; a?: number; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{ b: [] } : { b: []; }
|
||||
> : ^^^^^^^^^^
|
||||
>b : []
|
||||
> : ^^
|
||||
>[] : []
|
||||
|
||||
@@ -155,10 +155,10 @@ class A {
|
||||
> : ^
|
||||
|
||||
({ a: A.#field = 1, b: [A.#field = 1] } = { b: [] });
|
||||
>({ a: A.#field = 1, b: [A.#field = 1] } = { b: [] }) : { b: []; a?: number; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{ a: A.#field = 1, b: [A.#field = 1] } = { b: [] } : { b: []; a?: number; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^
|
||||
>({ a: A.#field = 1, b: [A.#field = 1] } = { b: [] }) : { b: []; }
|
||||
> : ^^^^^^^^^^
|
||||
>{ a: A.#field = 1, b: [A.#field = 1] } = { b: [] } : { b: []; }
|
||||
> : ^^^^^^^^^^
|
||||
>{ a: A.#field = 1, b: [A.#field = 1] } : { a?: number; b: [number]; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>a : number
|
||||
@@ -183,8 +183,8 @@ class A {
|
||||
> : ^^^^^^^^
|
||||
>1 : 1
|
||||
> : ^
|
||||
>{ b: [] } : { b: []; a?: number; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{ b: [] } : { b: []; }
|
||||
> : ^^^^^^^^^^
|
||||
>b : []
|
||||
> : ^^
|
||||
>[] : []
|
||||
|
||||
@@ -155,10 +155,10 @@ class A {
|
||||
> : ^
|
||||
|
||||
({ a: A.#field = 1, b: [A.#field = 1] } = { b: [] });
|
||||
>({ a: A.#field = 1, b: [A.#field = 1] } = { b: [] }) : { b: []; a?: number; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{ a: A.#field = 1, b: [A.#field = 1] } = { b: [] } : { b: []; a?: number; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^
|
||||
>({ a: A.#field = 1, b: [A.#field = 1] } = { b: [] }) : { b: []; }
|
||||
> : ^^^^^^^^^^
|
||||
>{ a: A.#field = 1, b: [A.#field = 1] } = { b: [] } : { b: []; }
|
||||
> : ^^^^^^^^^^
|
||||
>{ a: A.#field = 1, b: [A.#field = 1] } : { a?: number; b: [number]; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>a : number
|
||||
@@ -183,8 +183,8 @@ class A {
|
||||
> : ^^^^^^^^
|
||||
>1 : 1
|
||||
> : ^
|
||||
>{ b: [] } : { b: []; a?: number; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{ b: [] } : { b: []; }
|
||||
> : ^^^^^^^^^^
|
||||
>b : []
|
||||
> : ^^
|
||||
>[] : []
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
shorthandPropertyAssignmentsInDestructuring.ts(14,9): error TS2339: Property 's1' does not exist on type '{}'.
|
||||
shorthandPropertyAssignmentsInDestructuring.ts(20,9): error TS2339: Property 's1' does not exist on type '{}'.
|
||||
shorthandPropertyAssignmentsInDestructuring.ts(38,9): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
shorthandPropertyAssignmentsInDestructuring.ts(44,12): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
shorthandPropertyAssignmentsInDestructuring.ts(70,5): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
@@ -7,14 +5,11 @@ shorthandPropertyAssignmentsInDestructuring.ts(75,8): error TS2322: Type 'number
|
||||
shorthandPropertyAssignmentsInDestructuring.ts(80,5): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
shorthandPropertyAssignmentsInDestructuring.ts(80,20): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
shorthandPropertyAssignmentsInDestructuring.ts(85,8): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
shorthandPropertyAssignmentsInDestructuring.ts(85,19): error TS2322: Type '{ x: number; }' is not assignable to type '{ x: string; }'.
|
||||
Types of property 'x' are incompatible.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
shorthandPropertyAssignmentsInDestructuring.ts(85,26): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
shorthandPropertyAssignmentsInDestructuring.ts(111,14): error TS1312: Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern.
|
||||
|
||||
|
||||
==== shorthandPropertyAssignmentsInDestructuring.ts (12 errors) ====
|
||||
==== shorthandPropertyAssignmentsInDestructuring.ts (9 errors) ====
|
||||
(function() {
|
||||
var s0;
|
||||
for ({ s0 = 5 } of [{ s0: 1 }]) {
|
||||
@@ -29,16 +24,12 @@ shorthandPropertyAssignmentsInDestructuring.ts(111,14): error TS1312: Did you me
|
||||
(function() {
|
||||
var s1;
|
||||
for ({ s1 = 5 } of [{}]) {
|
||||
~~
|
||||
!!! error TS2339: Property 's1' does not exist on type '{}'.
|
||||
}
|
||||
});
|
||||
|
||||
(function() {
|
||||
var s1;
|
||||
for ({ s1:s1 = 5 } of [{}]) {
|
||||
~~
|
||||
!!! error TS2339: Property 's1' does not exist on type '{}'.
|
||||
}
|
||||
});
|
||||
|
||||
@@ -119,10 +110,6 @@ shorthandPropertyAssignmentsInDestructuring.ts(111,14): error TS1312: Did you me
|
||||
({ y2:y2 = 5, y3:y3 = { x: 1 } } = {})
|
||||
~~
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
~~
|
||||
!!! error TS2322: Type '{ x: number; }' is not assignable to type '{ x: string; }'.
|
||||
!!! error TS2322: Types of property 'x' are incompatible.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
~
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
!!! related TS6500 shorthandPropertyAssignmentsInDestructuring.ts:84:24: The expected type comes from property 'x' which is declared here on type '{ x: string; }'
|
||||
|
||||
@@ -371,18 +371,18 @@
|
||||
> : ^^^^^^
|
||||
|
||||
({ y1 = 5 } = {})
|
||||
>({ y1 = 5 } = {}) : { y1?: string; }
|
||||
> : ^^^^^^^^^^^^^^^^
|
||||
>{ y1 = 5 } = {} : { y1?: string; }
|
||||
> : ^^^^^^^^^^^^^^^^
|
||||
>({ y1 = 5 } = {}) : {}
|
||||
> : ^^
|
||||
>{ y1 = 5 } = {} : {}
|
||||
> : ^^
|
||||
>{ y1 = 5 } : { y1?: string; }
|
||||
> : ^^^^^^^^^^^^^^^^
|
||||
>y1 : string
|
||||
> : ^^^^^^
|
||||
>5 : 5
|
||||
> : ^
|
||||
>{} : { y1?: string; }
|
||||
> : ^^^^^^^^^^^^^^^^
|
||||
>{} : {}
|
||||
> : ^^
|
||||
|
||||
});
|
||||
|
||||
@@ -397,10 +397,10 @@
|
||||
> : ^^^^^^
|
||||
|
||||
({ y1:y1 = 5 } = {})
|
||||
>({ y1:y1 = 5 } = {}) : { y1?: number; }
|
||||
> : ^^^^^^^^^^^^^^^^
|
||||
>{ y1:y1 = 5 } = {} : { y1?: number; }
|
||||
> : ^^^^^^^^^^^^^^^^
|
||||
>({ y1:y1 = 5 } = {}) : {}
|
||||
> : ^^
|
||||
>{ y1:y1 = 5 } = {} : {}
|
||||
> : ^^
|
||||
>{ y1:y1 = 5 } : { y1?: number; }
|
||||
> : ^^^^^^^^^^^^^^^^
|
||||
>y1 : number
|
||||
@@ -411,8 +411,8 @@
|
||||
> : ^^^^^^
|
||||
>5 : 5
|
||||
> : ^
|
||||
>{} : { y1?: number; }
|
||||
> : ^^^^^^^^^^^^^^^^
|
||||
>{} : {}
|
||||
> : ^^
|
||||
|
||||
});
|
||||
|
||||
@@ -431,10 +431,10 @@
|
||||
> : ^^^^^^
|
||||
|
||||
({ y2 = 5, y3 = { x: 1 } } = {})
|
||||
>({ y2 = 5, y3 = { x: 1 } } = {}) : { y2?: string; y3?: { x: string; }; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^
|
||||
>{ y2 = 5, y3 = { x: 1 } } = {} : { y2?: string; y3?: { x: string; }; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^
|
||||
>({ y2 = 5, y3 = { x: 1 } } = {}) : {}
|
||||
> : ^^
|
||||
>{ y2 = 5, y3 = { x: 1 } } = {} : {}
|
||||
> : ^^
|
||||
>{ y2 = 5, y3 = { x: 1 } } : { y2?: string; y3?: { x: string; }; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^
|
||||
>y2 : string
|
||||
@@ -449,8 +449,8 @@
|
||||
> : ^^^^^^
|
||||
>1 : 1
|
||||
> : ^
|
||||
>{} : { y2?: string; y3?: { x: string; }; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^
|
||||
>{} : {}
|
||||
> : ^^
|
||||
|
||||
});
|
||||
|
||||
@@ -469,10 +469,10 @@
|
||||
> : ^^^^^^
|
||||
|
||||
({ y2:y2 = 5, y3:y3 = { x: 1 } } = {})
|
||||
>({ y2:y2 = 5, y3:y3 = { x: 1 } } = {}) : { y2?: number; y3?: { x: number; }; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{ y2:y2 = 5, y3:y3 = { x: 1 } } = {} : { y2?: number; y3?: { x: number; }; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>({ y2:y2 = 5, y3:y3 = { x: 1 } } = {}) : {}
|
||||
> : ^^
|
||||
>{ y2:y2 = 5, y3:y3 = { x: 1 } } = {} : {}
|
||||
> : ^^
|
||||
>{ y2:y2 = 5, y3:y3 = { x: 1 } } : { y2?: number; y3?: { x: number; }; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>y2 : number
|
||||
@@ -495,8 +495,8 @@
|
||||
> : ^^^^^^
|
||||
>1 : 1
|
||||
> : ^
|
||||
>{} : { y2?: number; y3?: { x: number; }; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{} : {}
|
||||
> : ^^
|
||||
|
||||
});
|
||||
|
||||
@@ -515,10 +515,10 @@
|
||||
> : ^^^^^^
|
||||
|
||||
({ y4 = 5, y5 = { x: 1 } } = {})
|
||||
>({ y4 = 5, y5 = { x: 1 } } = {}) : { y4?: number; y5?: { x: number; }; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^
|
||||
>{ y4 = 5, y5 = { x: 1 } } = {} : { y4?: number; y5?: { x: number; }; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^
|
||||
>({ y4 = 5, y5 = { x: 1 } } = {}) : {}
|
||||
> : ^^
|
||||
>{ y4 = 5, y5 = { x: 1 } } = {} : {}
|
||||
> : ^^
|
||||
>{ y4 = 5, y5 = { x: 1 } } : { y4?: number; y5?: { x: number; }; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^
|
||||
>y4 : number
|
||||
@@ -533,8 +533,8 @@
|
||||
> : ^^^^^^
|
||||
>1 : 1
|
||||
> : ^
|
||||
>{} : { y4?: number; y5?: { x: number; }; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^
|
||||
>{} : {}
|
||||
> : ^^
|
||||
|
||||
});
|
||||
|
||||
@@ -553,10 +553,10 @@
|
||||
> : ^^^^^^
|
||||
|
||||
({ y4:y4 = 5, y5:y5 = { x: 1 } } = {})
|
||||
>({ y4:y4 = 5, y5:y5 = { x: 1 } } = {}) : { y4?: number; y5?: { x: number; }; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{ y4:y4 = 5, y5:y5 = { x: 1 } } = {} : { y4?: number; y5?: { x: number; }; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>({ y4:y4 = 5, y5:y5 = { x: 1 } } = {}) : {}
|
||||
> : ^^
|
||||
>{ y4:y4 = 5, y5:y5 = { x: 1 } } = {} : {}
|
||||
> : ^^
|
||||
>{ y4:y4 = 5, y5:y5 = { x: 1 } } : { y4?: number; y5?: { x: number; }; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>y4 : number
|
||||
@@ -579,8 +579,8 @@
|
||||
> : ^^^^^^
|
||||
>1 : 1
|
||||
> : ^
|
||||
>{} : { y4?: number; y5?: { x: number; }; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{} : {}
|
||||
> : ^^
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
shorthandPropertyAssignmentsInDestructuring_ES6.ts(14,9): error TS2339: Property 's1' does not exist on type '{}'.
|
||||
shorthandPropertyAssignmentsInDestructuring_ES6.ts(20,9): error TS2339: Property 's1' does not exist on type '{}'.
|
||||
shorthandPropertyAssignmentsInDestructuring_ES6.ts(38,9): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
shorthandPropertyAssignmentsInDestructuring_ES6.ts(44,12): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
shorthandPropertyAssignmentsInDestructuring_ES6.ts(70,5): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
@@ -7,14 +5,11 @@ shorthandPropertyAssignmentsInDestructuring_ES6.ts(75,8): error TS2322: Type 'nu
|
||||
shorthandPropertyAssignmentsInDestructuring_ES6.ts(80,5): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
shorthandPropertyAssignmentsInDestructuring_ES6.ts(80,20): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
shorthandPropertyAssignmentsInDestructuring_ES6.ts(85,8): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
shorthandPropertyAssignmentsInDestructuring_ES6.ts(85,19): error TS2322: Type '{ x: number; }' is not assignable to type '{ x: string; }'.
|
||||
Types of property 'x' are incompatible.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
shorthandPropertyAssignmentsInDestructuring_ES6.ts(85,26): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
shorthandPropertyAssignmentsInDestructuring_ES6.ts(111,14): error TS1312: Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern.
|
||||
|
||||
|
||||
==== shorthandPropertyAssignmentsInDestructuring_ES6.ts (12 errors) ====
|
||||
==== shorthandPropertyAssignmentsInDestructuring_ES6.ts (9 errors) ====
|
||||
(function() {
|
||||
var s0;
|
||||
for ({ s0 = 5 } of [{ s0: 1 }]) {
|
||||
@@ -29,16 +24,12 @@ shorthandPropertyAssignmentsInDestructuring_ES6.ts(111,14): error TS1312: Did yo
|
||||
(function() {
|
||||
var s1;
|
||||
for ({ s1 = 5 } of [{}]) {
|
||||
~~
|
||||
!!! error TS2339: Property 's1' does not exist on type '{}'.
|
||||
}
|
||||
});
|
||||
|
||||
(function() {
|
||||
var s1;
|
||||
for ({ s1:s1 = 5 } of [{}]) {
|
||||
~~
|
||||
!!! error TS2339: Property 's1' does not exist on type '{}'.
|
||||
}
|
||||
});
|
||||
|
||||
@@ -119,10 +110,6 @@ shorthandPropertyAssignmentsInDestructuring_ES6.ts(111,14): error TS1312: Did yo
|
||||
({ y2:y2 = 5, y3:y3 = { x: 1 } } = {})
|
||||
~~
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
~~
|
||||
!!! error TS2322: Type '{ x: number; }' is not assignable to type '{ x: string; }'.
|
||||
!!! error TS2322: Types of property 'x' are incompatible.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
~
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
!!! related TS6500 shorthandPropertyAssignmentsInDestructuring_ES6.ts:84:24: The expected type comes from property 'x' which is declared here on type '{ x: string; }'
|
||||
|
||||
@@ -371,18 +371,18 @@
|
||||
> : ^^^^^^
|
||||
|
||||
({ y1 = 5 } = {})
|
||||
>({ y1 = 5 } = {}) : { y1?: string; }
|
||||
> : ^^^^^^^^^^^^^^^^
|
||||
>{ y1 = 5 } = {} : { y1?: string; }
|
||||
> : ^^^^^^^^^^^^^^^^
|
||||
>({ y1 = 5 } = {}) : {}
|
||||
> : ^^
|
||||
>{ y1 = 5 } = {} : {}
|
||||
> : ^^
|
||||
>{ y1 = 5 } : { y1?: string; }
|
||||
> : ^^^^^^^^^^^^^^^^
|
||||
>y1 : string
|
||||
> : ^^^^^^
|
||||
>5 : 5
|
||||
> : ^
|
||||
>{} : { y1?: string; }
|
||||
> : ^^^^^^^^^^^^^^^^
|
||||
>{} : {}
|
||||
> : ^^
|
||||
|
||||
});
|
||||
|
||||
@@ -397,10 +397,10 @@
|
||||
> : ^^^^^^
|
||||
|
||||
({ y1:y1 = 5 } = {})
|
||||
>({ y1:y1 = 5 } = {}) : { y1?: number; }
|
||||
> : ^^^^^^^^^^^^^^^^
|
||||
>{ y1:y1 = 5 } = {} : { y1?: number; }
|
||||
> : ^^^^^^^^^^^^^^^^
|
||||
>({ y1:y1 = 5 } = {}) : {}
|
||||
> : ^^
|
||||
>{ y1:y1 = 5 } = {} : {}
|
||||
> : ^^
|
||||
>{ y1:y1 = 5 } : { y1?: number; }
|
||||
> : ^^^^^^^^^^^^^^^^
|
||||
>y1 : number
|
||||
@@ -411,8 +411,8 @@
|
||||
> : ^^^^^^
|
||||
>5 : 5
|
||||
> : ^
|
||||
>{} : { y1?: number; }
|
||||
> : ^^^^^^^^^^^^^^^^
|
||||
>{} : {}
|
||||
> : ^^
|
||||
|
||||
});
|
||||
|
||||
@@ -431,10 +431,10 @@
|
||||
> : ^^^^^^
|
||||
|
||||
({ y2 = 5, y3 = { x: 1 } } = {})
|
||||
>({ y2 = 5, y3 = { x: 1 } } = {}) : { y2?: string; y3?: { x: string; }; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^
|
||||
>{ y2 = 5, y3 = { x: 1 } } = {} : { y2?: string; y3?: { x: string; }; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^
|
||||
>({ y2 = 5, y3 = { x: 1 } } = {}) : {}
|
||||
> : ^^
|
||||
>{ y2 = 5, y3 = { x: 1 } } = {} : {}
|
||||
> : ^^
|
||||
>{ y2 = 5, y3 = { x: 1 } } : { y2?: string; y3?: { x: string; }; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^
|
||||
>y2 : string
|
||||
@@ -449,8 +449,8 @@
|
||||
> : ^^^^^^
|
||||
>1 : 1
|
||||
> : ^
|
||||
>{} : { y2?: string; y3?: { x: string; }; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^
|
||||
>{} : {}
|
||||
> : ^^
|
||||
|
||||
});
|
||||
|
||||
@@ -469,10 +469,10 @@
|
||||
> : ^^^^^^
|
||||
|
||||
({ y2:y2 = 5, y3:y3 = { x: 1 } } = {})
|
||||
>({ y2:y2 = 5, y3:y3 = { x: 1 } } = {}) : { y2?: number; y3?: { x: number; }; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{ y2:y2 = 5, y3:y3 = { x: 1 } } = {} : { y2?: number; y3?: { x: number; }; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>({ y2:y2 = 5, y3:y3 = { x: 1 } } = {}) : {}
|
||||
> : ^^
|
||||
>{ y2:y2 = 5, y3:y3 = { x: 1 } } = {} : {}
|
||||
> : ^^
|
||||
>{ y2:y2 = 5, y3:y3 = { x: 1 } } : { y2?: number; y3?: { x: number; }; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>y2 : number
|
||||
@@ -495,8 +495,8 @@
|
||||
> : ^^^^^^
|
||||
>1 : 1
|
||||
> : ^
|
||||
>{} : { y2?: number; y3?: { x: number; }; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{} : {}
|
||||
> : ^^
|
||||
|
||||
});
|
||||
|
||||
@@ -515,10 +515,10 @@
|
||||
> : ^^^^^^
|
||||
|
||||
({ y4 = 5, y5 = { x: 1 } } = {})
|
||||
>({ y4 = 5, y5 = { x: 1 } } = {}) : { y4?: number; y5?: { x: number; }; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^
|
||||
>{ y4 = 5, y5 = { x: 1 } } = {} : { y4?: number; y5?: { x: number; }; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^
|
||||
>({ y4 = 5, y5 = { x: 1 } } = {}) : {}
|
||||
> : ^^
|
||||
>{ y4 = 5, y5 = { x: 1 } } = {} : {}
|
||||
> : ^^
|
||||
>{ y4 = 5, y5 = { x: 1 } } : { y4?: number; y5?: { x: number; }; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^
|
||||
>y4 : number
|
||||
@@ -533,8 +533,8 @@
|
||||
> : ^^^^^^
|
||||
>1 : 1
|
||||
> : ^
|
||||
>{} : { y4?: number; y5?: { x: number; }; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^
|
||||
>{} : {}
|
||||
> : ^^
|
||||
|
||||
});
|
||||
|
||||
@@ -553,10 +553,10 @@
|
||||
> : ^^^^^^
|
||||
|
||||
({ y4:y4 = 5, y5:y5 = { x: 1 } } = {})
|
||||
>({ y4:y4 = 5, y5:y5 = { x: 1 } } = {}) : { y4?: number; y5?: { x: number; }; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{ y4:y4 = 5, y5:y5 = { x: 1 } } = {} : { y4?: number; y5?: { x: number; }; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>({ y4:y4 = 5, y5:y5 = { x: 1 } } = {}) : {}
|
||||
> : ^^
|
||||
>{ y4:y4 = 5, y5:y5 = { x: 1 } } = {} : {}
|
||||
> : ^^
|
||||
>{ y4:y4 = 5, y5:y5 = { x: 1 } } : { y4?: number; y5?: { x: number; }; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>y4 : number
|
||||
@@ -579,8 +579,8 @@
|
||||
> : ^^^^^^
|
||||
>1 : 1
|
||||
> : ^
|
||||
>{} : { y4?: number; y5?: { x: number; }; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>{} : {}
|
||||
> : ^^
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -2,16 +2,16 @@
|
||||
|
||||
=== useBeforeDeclaration_destructuring.ts ===
|
||||
a;
|
||||
>a : any
|
||||
> : ^^^
|
||||
>a : string
|
||||
> : ^^^^^^
|
||||
|
||||
let {a, b = a} = {a: '', b: 1};
|
||||
>a : any
|
||||
> : ^^^
|
||||
>b : any
|
||||
> : ^^^
|
||||
>a : any
|
||||
> : ^^^
|
||||
>a : string
|
||||
> : ^^^^^^
|
||||
>b : string | number
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
>a : string
|
||||
> : ^^^^^^
|
||||
>{a: '', b: 1} : { a: string; b?: number; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>a : string
|
||||
@@ -24,8 +24,8 @@ let {a, b = a} = {a: '', b: 1};
|
||||
> : ^
|
||||
|
||||
b;
|
||||
>b : any
|
||||
> : ^^^
|
||||
>b : string | number
|
||||
> : ^^^^^^^^^^^^^^^
|
||||
|
||||
function test({c, d = c}: Record<string, number>) {}
|
||||
>test : ({ c, d }: Record<string, number>) => void
|
||||
|
||||
21
tests/cases/compiler/intraBindingPatternReferences.ts
Normal file
21
tests/cases/compiler/intraBindingPatternReferences.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
// @strict: true
|
||||
// @noEmit: true
|
||||
|
||||
// https://github.com/microsoft/TypeScript/issues/59177
|
||||
|
||||
function foo() { return a }
|
||||
|
||||
const [a, b = a + 1] = [42];
|
||||
|
||||
const [c1, c2 = c1] = [123];
|
||||
const [d1, d2 = d1, d3 = d2] = [123];
|
||||
|
||||
const { e1, e2 = e1 } = { e1: 1 };
|
||||
const { f1, f2 = f1, f3 = f2 } = { f1: 1 };
|
||||
|
||||
// Example that requires padding of object literal types at depth
|
||||
const mockCallback = ({ event: { params = {} } = {} }) => {};
|
||||
|
||||
// The contextual type for the second lambda in the object literal is 'any' because of the
|
||||
// intra-binding-pattern reference in the initializer for fn2
|
||||
const { fn1 = (x: number) => 0, fn2 = fn1 } = { fn1: x => x + 1, fn2: x => x + 2 };
|
||||
Reference in New Issue
Block a user