Merge branch 'master' into metadataDecoratorOption

# Conflicts:
#	src/compiler/diagnosticMessages.json
This commit is contained in:
Ron Buckton
2021-04-05 18:21:19 -07:00
188 changed files with 3307 additions and 1169 deletions
+12 -12
View File
@@ -288,9 +288,9 @@
}
},
"@octokit/core": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/@octokit/core/-/core-3.3.1.tgz",
"integrity": "sha512-Dc5NNQOYjgZU5S1goN6A/E500yXOfDUFRGQB8/2Tl16AcfvS3H9PudyOe3ZNE/MaVyHPIfC0htReHMJb1tMrvw==",
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/@octokit/core/-/core-3.4.0.tgz",
"integrity": "sha512-6/vlKPP8NF17cgYXqucdshWqmMZGXkuvtcrWCgU5NOI0Pl2GjlmZyWgBMrU8zJ3v2MJlM6++CiB45VKYmhiWWg==",
"dev": true,
"requires": {
"@octokit/auth-token": "^2.4.4",
@@ -422,9 +422,9 @@
}
},
"@types/chai": {
"version": "4.2.15",
"resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.2.15.tgz",
"integrity": "sha512-rYff6FI+ZTKAPkJUoyz7Udq3GaoDZnxYDEvdEdFZASiA7PoErltHezDishqQiSDWrGxvxmplH304jyzQmjp0AQ==",
"version": "4.2.16",
"resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.2.16.tgz",
"integrity": "sha512-vI5iOAsez9+roLS3M3+Xx7w+WRuDtSmF8bQkrbcIJ2sC1PcDgVoA0WGpa+bIrJ+y8zqY2oi//fUctkxtIcXJCw==",
"dev": true
},
"@types/convert-source-map": {
@@ -1374,9 +1374,9 @@
"dev": true
},
"before-after-hook": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.0.tgz",
"integrity": "sha512-jH6rKQIfroBbhEXVmI7XmXe3ix5S/PgJqpzdDPnR8JGLHWNYLsYZ6tK5iWOF/Ra3oqEX0NobXGlzbiylIzVphQ==",
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.1.tgz",
"integrity": "sha512-/6FKxSTWoJdbsLDF8tdIjaRiFXiE6UHsEHE3OPI/cwPURCVi1ukP0gmLn7XWEiFk5TcwQjjY5PWsU+j+tgXgmw==",
"dev": true
},
"binary-extensions": {
@@ -5679,9 +5679,9 @@
}
},
"y18n": {
"version": "5.0.5",
"resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.5.tgz",
"integrity": "sha512-hsRUr4FFrvhhRH12wOdfs38Gy7k2FFzB9qgN9v3aLykRq0dRcdcpz5C9FxdS2NuhOrI/628b/KSTJ3rwHysYSg==",
"version": "5.0.6",
"resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.6.tgz",
"integrity": "sha512-PlVX4Y0lDTN6E2V4ES2tEdyvXkeKzxa8c/vo0pxPr/TqbztddTP0yn7zZylIyiAuxerqj0Q5GhpJ1YJCP8LaZQ==",
"dev": true
},
"yargs": {
+120 -72
View File
@@ -1778,8 +1778,8 @@ namespace ts {
/**
* Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and
* the `nameNotFoundMessage` argument is not `undefined`.
*
* ***NOTE**: You should not call this directly. This function is intended to be used only by `resolveName`,
*
* ***NOTE**: You should not call this directly. This function is intended to be used only by `resolveName`,
* `resolveEntityName`, and `getSuggestedSymbolForNonexistentSymbol`.
*
* @param location The location at which to begin name resolution.
@@ -2572,6 +2572,7 @@ namespace ts {
* module.exports = <EntityNameExpression>
* {<Identifier>}
* {name: <EntityNameExpression>}
* const { x } = require ...
*/
function isAliasSymbolDeclaration(node: Node): boolean {
return node.kind === SyntaxKind.ImportEqualsDeclaration
@@ -5276,9 +5277,26 @@ namespace ts {
return factory.createKeywordTypeNode(SyntaxKind.AnyKeyword);
}
function shouldUsePlaceholderForProperty(propertySymbol: Symbol, context: NodeBuilderContext) {
// Use placeholders for reverse mapped types we've either already descended into, or which
// are nested reverse mappings within a mapping over a non-anonymous type. The later is a restriction mostly just to
// reduce the blowup in printback size from doing, eg, a deep reverse mapping over `Window`.
// Since anonymous types usually come from expressions, this allows us to preserve the output
// for deep mappings which likely come from expressions, while truncating those parts which
// come from mappings over library functions.
return !!(getCheckFlags(propertySymbol) & CheckFlags.ReverseMapped)
&& (
contains(context.reverseMappedStack, propertySymbol as ReverseMappedSymbol)
|| (
context.reverseMappedStack?.[0]
&& !(getObjectFlags(last(context.reverseMappedStack).propertyType) & ObjectFlags.Anonymous)
)
);
}
function addPropertyToElementList(propertySymbol: Symbol, context: NodeBuilderContext, typeElements: TypeElement[]) {
const propertyIsReverseMapped = !!(getCheckFlags(propertySymbol) & CheckFlags.ReverseMapped);
const propertyType = propertyIsReverseMapped && context.flags & NodeBuilderFlags.InReverseMappedType ?
const propertyType = shouldUsePlaceholderForProperty(propertySymbol, context) ?
anyType : getTypeOfSymbol(propertySymbol);
const saveEnclosingDeclaration = context.enclosingDeclaration;
context.enclosingDeclaration = undefined;
@@ -5309,16 +5327,20 @@ namespace ts {
}
}
else {
const savedFlags = context.flags;
context.flags |= propertyIsReverseMapped ? NodeBuilderFlags.InReverseMappedType : 0;
let propertyTypeNode: TypeNode;
if (propertyIsReverseMapped && !!(savedFlags & NodeBuilderFlags.InReverseMappedType)) {
if (shouldUsePlaceholderForProperty(propertySymbol, context)) {
propertyTypeNode = createElidedInformationPlaceholder(context);
}
else {
if (propertyIsReverseMapped) {
context.reverseMappedStack ||= [];
context.reverseMappedStack.push(propertySymbol as ReverseMappedSymbol);
}
propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : factory.createKeywordTypeNode(SyntaxKind.AnyKeyword);
if (propertyIsReverseMapped) {
context.reverseMappedStack!.pop();
}
}
context.flags = savedFlags;
const modifiers = isReadonlySymbol(propertySymbol) ? [factory.createToken(SyntaxKind.ReadonlyKeyword)] : undefined;
if (modifiers) {
@@ -6139,10 +6161,14 @@ namespace ts {
function serializeReturnTypeForSignature(context: NodeBuilderContext, type: Type, signature: Signature, includePrivateSymbol?: (s: Symbol) => void, bundled?: boolean) {
if (type !== errorType && context.enclosingDeclaration) {
const annotation = signature.declaration && getEffectiveReturnTypeNode(signature.declaration);
if (!!findAncestor(annotation, n => n === context.enclosingDeclaration) && annotation && instantiateType(getTypeFromTypeNode(annotation), signature.mapper) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) {
const result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled);
if (result) {
return result;
if (!!findAncestor(annotation, n => n === context.enclosingDeclaration) && annotation) {
const annotated = getTypeFromTypeNode(annotation);
const thisInstantiated = annotated.flags & TypeFlags.TypeParameter && (annotated as TypeParameter).isThisType ? instantiateType(annotated, signature.mapper) : annotated;
if (thisInstantiated === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) {
const result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled);
if (result) {
return result;
}
}
}
}
@@ -7846,6 +7872,7 @@ namespace ts {
typeParameterNamesByText?: Set<string>;
usedSymbolNames?: Set<string>;
remappedSymbolNames?: ESMap<SymbolId, string>;
reverseMappedStack?: ReverseMappedSymbol[];
}
function isDefaultBindingContext(location: Node) {
@@ -11000,6 +11027,14 @@ namespace ts {
}
}
type ReplaceableIndexedAccessType = IndexedAccessType & { objectType: TypeParameter, indexType: TypeParameter };
function replaceIndexedAccess(instantiable: Type, type: ReplaceableIndexedAccessType, replacement: Type) {
// map type.indexType to 0
// map type.objectType to `[TReplacement]`
// thus making the indexed access `[TReplacement][0]` or `TReplacement`
return instantiateType(instantiable, createTypeMapper([type.indexType, type.objectType], [getLiteralType(0), createTupleType([replacement])]));
}
function getIndexInfoOfIndexSymbol(indexSymbol: Symbol, indexKind: IndexKind) {
const declaration = getIndexDeclarationOfIndexSymbol(indexSymbol, indexKind);
if (!declaration) return undefined;
@@ -11020,8 +11055,21 @@ namespace ts {
inferredProp.declarations = prop.declarations;
inferredProp.nameType = getSymbolLinks(prop).nameType;
inferredProp.propertyType = getTypeOfSymbol(prop);
inferredProp.mappedType = type.mappedType;
inferredProp.constraintType = type.constraintType;
if (type.constraintType.type.flags & TypeFlags.IndexedAccess
&& (type.constraintType.type as IndexedAccessType).objectType.flags & TypeFlags.TypeParameter
&& (type.constraintType.type as IndexedAccessType).indexType.flags & TypeFlags.TypeParameter) {
// A reverse mapping of `{[K in keyof T[K_1]]: T[K_1]}` is the same as that of `{[K in keyof T]: T}`, since all we care about is
// inferring to the "type parameter" (or indexed access) shared by the constraint and template. So, to reduce the number of
// type identities produced, we simplify such indexed access occurences
const newTypeParam = (type.constraintType.type as IndexedAccessType).objectType;
const newMappedType = replaceIndexedAccess(type.mappedType, type.constraintType.type as ReplaceableIndexedAccessType, newTypeParam);
inferredProp.mappedType = newMappedType as MappedType;
inferredProp.constraintType = getIndexType(newTypeParam) as IndexType;
}
else {
inferredProp.mappedType = type.mappedType;
inferredProp.constraintType = type.constraintType;
}
members.set(prop.escapedName, inferredProp);
}
setStructuredTypeMembers(type, members, emptyArray, emptyArray, stringIndexInfo, undefined);
@@ -12070,6 +12118,10 @@ namespace ts {
return false;
}
function isOptionalPropertyDeclaration(node: Declaration) {
return isPropertyDeclaration(node) && node.questionToken;
}
function isOptionalJSDocPropertyLikeTag(node: Node): node is JSDocPropertyLikeTag {
if (!isJSDocPropertyLikeTag(node)) {
return false;
@@ -12984,9 +13036,17 @@ namespace ts {
function getConditionalFlowTypeOfType(type: Type, node: Node) {
let constraints: Type[] | undefined;
let covariant = true;
while (node && !isStatement(node) && node.kind !== SyntaxKind.JSDocComment) {
const parent = node.parent;
if (parent.kind === SyntaxKind.ConditionalType && node === (<ConditionalTypeNode>parent).trueType) {
// only consider variance flipped by parameter locations - `keyof` types would usually be considered variance inverting, but
// often get used in indexed accesses where they behave sortof invariantly, but our checking is lax
if (parent.kind === SyntaxKind.Parameter) {
covariant = !covariant;
}
// Always substitute on type parameters, regardless of variance, since even
// in contravarrying positions, they may be reliant on subtuted constraints to be valid
if ((covariant || type.flags & TypeFlags.TypeParameter) && parent.kind === SyntaxKind.ConditionalType && node === (<ConditionalTypeNode>parent).trueType) {
const constraint = getImpliedConstraint(type, (<ConditionalTypeNode>parent).checkType, (<ConditionalTypeNode>parent).extendsType);
if (constraint) {
constraints = append(constraints, constraint);
@@ -13898,7 +13958,7 @@ namespace ts {
const typeKey = !origin ? getTypeListId(types) :
origin.flags & TypeFlags.Union ? `|${getTypeListId((<UnionType>origin).types)}` :
origin.flags & TypeFlags.Intersection ? `&${getTypeListId((<IntersectionType>origin).types)}` :
`#${(<IndexType>origin).type.id}`;
`#${(<IndexType>origin).type.id}|${getTypeListId(types)}`; // origin type id alone is insufficient, as `keyof x` may resolve to multiple WIP values while `x` is still resolving
const id = typeKey + getAliasId(aliasSymbol, aliasTypeArguments);
let type = unionTypes.get(id);
if (!type) {
@@ -18409,6 +18469,11 @@ namespace ts {
}
}
else if (target.flags & TypeFlags.TemplateLiteral) {
if (source.flags & TypeFlags.TemplateLiteral) {
// Report unreliable variance for type variables referenced in template literal type placeholders.
// For example, `foo-${number}` is related to `foo-${string}` even though number isn't related to string.
instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers));
}
const result = inferTypesFromTemplateLiteralType(source, target as TemplateLiteralType);
if (result && every(result, (r, i) => isValidTypeForTemplateLiteralPlaceholder(r, (target as TemplateLiteralType).types[i]))) {
return Ternary.True;
@@ -18453,20 +18518,6 @@ namespace ts {
return result;
}
}
else if (source.flags & TypeFlags.TemplateLiteral) {
if (target.flags & TypeFlags.TemplateLiteral &&
(source as TemplateLiteralType).texts.length === (target as TemplateLiteralType).texts.length &&
(source as TemplateLiteralType).types.length === (target as TemplateLiteralType).types.length &&
every((source as TemplateLiteralType).texts, (t, i) => t === (target as TemplateLiteralType).texts[i]) &&
every((instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)) as TemplateLiteralType).types, (t, i) => !!((target as TemplateLiteralType).types[i].flags & (TypeFlags.Any | TypeFlags.String)) || !!isRelatedTo(t, (target as TemplateLiteralType).types[i], /*reportErrors*/ false))) {
return Ternary.True;
}
const constraint = getBaseConstraintOfType(source);
if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, reportErrors))) {
resetErrorInfo(saveErrorInfo);
return result;
}
}
else if (source.flags & TypeFlags.StringMapping) {
if (target.flags & TypeFlags.StringMapping && (<StringMappingType>source).symbol === (<StringMappingType>target).symbol) {
if (result = isRelatedTo((<StringMappingType>source).type, (<StringMappingType>target).type, reportErrors)) {
@@ -19694,14 +19745,12 @@ namespace ts {
function isDeeplyNestedType(type: Type, stack: Type[], depth: number): boolean {
if (depth >= 5) {
const identity = getRecursionIdentity(type);
if (identity) {
let count = 0;
for (let i = 0; i < depth; i++) {
if (getRecursionIdentity(stack[i]) === identity) {
count++;
if (count >= 5) {
return true;
}
let count = 0;
for (let i = 0; i < depth; i++) {
if (getRecursionIdentity(stack[i]) === identity) {
count++;
if (count >= 5) {
return true;
}
}
}
@@ -19709,15 +19758,20 @@ namespace ts {
return false;
}
// Types with constituents that could circularly reference the type have a recursion identity. The recursion
// identity is some object that is common to instantiations of the type with the same origin.
function getRecursionIdentity(type: Type): object | undefined {
// The recursion identity of a type is an object identity that is shared among multiple instantiations of the type.
// We track recursion identities in order to identify deeply nested and possibly infinite type instantiations with
// the same origin. For example, when type parameters are in scope in an object type such as { x: T }, all
// instantiations of that type have the same recursion identity. The default recursion identity is the object
// identity of the type, meaning that every type is unique. Generally, types with constituents that could circularly
// reference the type have a recursion identity that differs from the object identity.
function getRecursionIdentity(type: Type): object {
// Object and array literals are known not to contain recursive references and don't need a recursion identity.
if (type.flags & TypeFlags.Object && !isObjectOrArrayLiteralType(type)) {
if (getObjectFlags(type) && ObjectFlags.Reference && (type as TypeReference).node) {
// Deferred type references are tracked through their associated AST node. This gives us finer
// granularity than using their associated target because each manifest type reference has a
// unique AST node.
return (type as TypeReference).node;
return (type as TypeReference).node!;
}
if (type.symbol && !(getObjectFlags(type) & ObjectFlags.Anonymous && type.symbol.flags & SymbolFlags.Class)) {
// We track all object types that have an associated symbol (representing the origin of the type), but
@@ -19729,6 +19783,9 @@ namespace ts {
return type.target;
}
}
if (type.flags & TypeFlags.TypeParameter) {
return type.symbol;
}
if (type.flags & TypeFlags.IndexedAccess) {
// Identity is the leftmost object type in a chain of indexed accesses, eg, in A[P][Q] it is A
do {
@@ -19740,7 +19797,7 @@ namespace ts {
// The root object represents the origin of the conditional type
return (type as ConditionalType).root;
}
return undefined;
return type;
}
function isPropertyIdenticalTo(sourceProp: Symbol, targetProp: Symbol): boolean {
@@ -20732,7 +20789,11 @@ namespace ts {
}
function getTypeOfReverseMappedSymbol(symbol: ReverseMappedSymbol) {
return inferReverseMappedType(symbol.propertyType, symbol.mappedType, symbol.constraintType);
const links = getSymbolLinks(symbol);
if (!links.type) {
links.type = inferReverseMappedType(symbol.propertyType, symbol.mappedType, symbol.constraintType);
}
return links.type;
}
function inferReverseMappedType(sourceType: Type, target: MappedType, constraint: IndexType): Type {
@@ -21157,16 +21218,16 @@ namespace ts {
// We stop inferring and report a circularity if we encounter duplicate recursion identities on both
// the source side and the target side.
const saveExpandingFlags = expandingFlags;
const sourceIdentity = getRecursionIdentity(source) || source;
const targetIdentity = getRecursionIdentity(target) || target;
if (sourceIdentity && contains(sourceStack, sourceIdentity)) expandingFlags |= ExpandingFlags.Source;
if (targetIdentity && contains(targetStack, targetIdentity)) expandingFlags |= ExpandingFlags.Target;
const sourceIdentity = getRecursionIdentity(source);
const targetIdentity = getRecursionIdentity(target);
if (contains(sourceStack, sourceIdentity)) expandingFlags |= ExpandingFlags.Source;
if (contains(targetStack, targetIdentity)) expandingFlags |= ExpandingFlags.Target;
if (expandingFlags !== ExpandingFlags.Both) {
if (sourceIdentity) (sourceStack || (sourceStack = [])).push(sourceIdentity);
if (targetIdentity) (targetStack || (targetStack = [])).push(targetIdentity);
(sourceStack || (sourceStack = [])).push(sourceIdentity);
(targetStack || (targetStack = [])).push(targetIdentity);
action(source, target);
if (targetIdentity) targetStack.pop();
if (sourceIdentity) sourceStack.pop();
targetStack.pop();
sourceStack.pop();
}
else {
inferencePriority = InferencePriority.Circularity;
@@ -23807,7 +23868,7 @@ namespace ts {
// an dotted name expression, and if the location is not an assignment target, obtain the type
// of the expression (which will reflect control flow analysis). If the expression indeed
// resolved to the given symbol, return the narrowed type.
if (location.kind === SyntaxKind.Identifier) {
if (location.kind === SyntaxKind.Identifier || location.kind === SyntaxKind.PrivateIdentifier) {
if (isRightSideOfQualifiedNameOrPropertyAccess(location)) {
location = location.parent;
}
@@ -24071,7 +24132,7 @@ namespace ts {
}
}
else if (isAlias) {
declaration = symbol.declarations?.find(isSomeImportDeclaration);
declaration = getDeclarationOfAliasSymbol(symbol);
}
else {
return type;
@@ -27256,9 +27317,10 @@ namespace ts {
let diagnosticMessage;
const declarationName = idText(right);
if (isInPropertyInitializer(node)
&& !isOptionalPropertyDeclaration(valueDeclaration)
&& !(isAccessExpression(node) && isAccessExpression(node.expression))
&& !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)
&& !isPropertyDeclaredInAncestorClass(prop)) {
&& (compilerOptions.useDefineForClassFields || !isPropertyDeclaredInAncestorClass(prop))) {
diagnosticMessage = error(right, Diagnostics.Property_0_is_used_before_its_initialization, declarationName);
}
else if (valueDeclaration.kind === SyntaxKind.ClassDeclaration &&
@@ -35514,8 +35576,8 @@ namespace ts {
errorAndMaybeSuggestAwait(
condExpr,
/*maybeMissingAwait*/ true,
Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap,
"true", getTypeNameForErrorDisplay(type), "false");
Diagnostics.This_condition_will_always_return_true_since_this_0_appears_to_always_be_defined,
getTypeNameForErrorDisplay(type));
return;
}
@@ -35548,7 +35610,7 @@ namespace ts {
const isUsed = isBinaryExpression(condExpr.parent) && isFunctionUsedInBinaryExpressionChain(condExpr.parent, testedSymbol)
|| body && isFunctionUsedInConditionBody(condExpr, body, testedNode, testedSymbol);
if (!isUsed) {
error(location, Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead);
error(location, Diagnostics.This_condition_will_always_return_true_since_this_function_appears_to_always_be_defined_Did_you_mean_to_call_it_instead);
}
}
@@ -36832,6 +36894,7 @@ namespace ts {
switch (name.escapedText) {
case "any":
case "unknown":
case "never":
case "number":
case "bigint":
case "boolean":
@@ -42219,21 +42282,6 @@ namespace ts {
}
}
function isSomeImportDeclaration(decl: Node): boolean {
switch (decl.kind) {
case SyntaxKind.ImportClause: // For default import
case SyntaxKind.ImportEqualsDeclaration:
case SyntaxKind.NamespaceImport:
case SyntaxKind.ImportSpecifier: // For rename import `x as y`
return true;
case SyntaxKind.Identifier:
// For regular import, `decl` is an Identifier under the ImportSpecifier.
return decl.parent.kind === SyntaxKind.ImportSpecifier;
default:
return false;
}
}
namespace JsxNames {
export const JSX = "JSX" as __String;
export const IntrinsicElements = "IntrinsicElements" as __String;
+1
View File
@@ -875,6 +875,7 @@ namespace ts {
{
name: "metadataDecorator",
type: "string",
affectsEmit: true,
category: Diagnostics.Advanced_Options,
description: Diagnostics.Specify_the_name_of_the_metadata_decorator_function_to_use_when_emitDecoratorMetadata_is_set
},
+10 -6
View File
@@ -15,7 +15,7 @@
"category": "Error",
"code": 1006
},
"The parser expected to find a '}' to match the '{' token here.": {
"The parser expected to find a '{1}' to match the '{0}' token here.": {
"category": "Error",
"code": 1007
},
@@ -3181,7 +3181,7 @@
"category": "Error",
"code": 2773
},
"This condition will always return true since the function is always defined. Did you mean to call it instead?": {
"This condition will always return true since this function appears to always be defined. Did you mean to call it instead?": {
"category": "Error",
"code": 2774
},
@@ -3289,7 +3289,7 @@
"category": "Error",
"code": 2800
},
"This condition will always return true since the Promise is always truthy.": {
"This condition will always return true since this '{0}' appears to always be defined.": {
"category": "Error",
"code": 2801
},
@@ -3321,18 +3321,22 @@
"category": "Error",
"code": 2808
},
"Namespace '{0}' from module '{1}' has no exported member '{2}'.": {
"Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses.": {
"category": "Error",
"code": 2809
},
"'{0}' from module '{1}' has no exported member named '{2}'. Did you mean '{3}'?": {
"Namespace '{0}' from module '{1}' has no exported member '{2}'.": {
"category": "Error",
"code": 2810
},
"Cannot find namespace '{0}'. Did you mean '{1}?": {
"'{0}' from module '{1}' has no exported member named '{2}'. Did you mean '{3}'?": {
"category": "Error",
"code": 2811
},
"Cannot find namespace '{0}'. Did you mean '{1}?": {
"category": "Error",
"code": 2812
},
"Import declaration '{0}' is using private name '{1}'.": {
"category": "Error",
+46 -38
View File
@@ -551,6 +551,7 @@ namespace ts {
case SyntaxKind.JSDocPrivateTag:
case SyntaxKind.JSDocProtectedTag:
case SyntaxKind.JSDocReadonlyTag:
case SyntaxKind.JSDocDeprecatedTag:
return visitNode(cbNode, (node as JSDocTag).tagName)
|| (typeof (node as JSDoc).comment === "string" ? undefined : visitNodes(cbNode, cbNodes, (node as JSDoc).comment as NodeArray<JSDocText | JSDocLink> | undefined));
case SyntaxKind.PartiallyEmittedExpression:
@@ -1335,24 +1336,27 @@ namespace ts {
return inContext(NodeFlags.AwaitContext);
}
function parseErrorAtCurrentToken(message: DiagnosticMessage, arg0?: any): void {
parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0);
function parseErrorAtCurrentToken(message: DiagnosticMessage, arg0?: any): DiagnosticWithDetachedLocation | undefined {
return parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0);
}
function parseErrorAtPosition(start: number, length: number, message: DiagnosticMessage, arg0?: any): void {
function parseErrorAtPosition(start: number, length: number, message: DiagnosticMessage, arg0?: any): DiagnosticWithDetachedLocation | undefined {
// Don't report another error if it would just be at the same position as the last error.
const lastError = lastOrUndefined(parseDiagnostics);
let result: DiagnosticWithDetachedLocation | undefined;
if (!lastError || start !== lastError.start) {
parseDiagnostics.push(createDetachedDiagnostic(fileName, start, length, message, arg0));
result = createDetachedDiagnostic(fileName, start, length, message, arg0);
parseDiagnostics.push(result);
}
// Mark that we've encountered an error. We'll set an appropriate bit on the next
// node we finish so that it can't be reused incrementally.
parseErrorBeforeNextFinishedNode = true;
return result;
}
function parseErrorAt(start: number, end: number, message: DiagnosticMessage, arg0?: any): void {
parseErrorAtPosition(start, end - start, message, arg0);
function parseErrorAt(start: number, end: number, message: DiagnosticMessage, arg0?: any): DiagnosticWithDetachedLocation | undefined {
return parseErrorAtPosition(start, end - start, message, arg0);
}
function parseErrorAtRange(range: TextRange, message: DiagnosticMessage, arg0?: any): void {
@@ -1542,6 +1546,20 @@ namespace ts {
return false;
}
function parseExpectedMatchingBrackets(openKind: SyntaxKind, closeKind: SyntaxKind, openPosition: number) {
if (token() === closeKind) {
nextToken();
return;
}
const lastError = parseErrorAtCurrentToken(Diagnostics._0_expected, tokenToString(closeKind));
if (lastError) {
addRelatedInfo(
lastError,
createDetachedDiagnostic(fileName, openPosition, 1, Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, tokenToString(openKind), tokenToString(closeKind))
);
}
}
function parseOptional(t: SyntaxKind): boolean {
if (token() === t) {
nextToken();
@@ -2092,8 +2110,7 @@ namespace ts {
while (!isListTerminator(kind)) {
if (isListElement(kind, /*inErrorRecovery*/ false)) {
const element = parseListElement(kind, parseElement);
list.push(element);
list.push(parseListElement(kind, parseElement));
continue;
}
@@ -5426,10 +5443,11 @@ namespace ts {
function parseArrayLiteralExpression(): ArrayLiteralExpression {
const pos = getNodePos();
const openBracketPosition = scanner.getTokenPos();
parseExpected(SyntaxKind.OpenBracketToken);
const multiLine = scanner.hasPrecedingLineBreak();
const elements = parseDelimitedList(ParsingContext.ArrayLiteralMembers, parseArgumentOrArrayLiteralElement);
parseExpected(SyntaxKind.CloseBracketToken);
parseExpectedMatchingBrackets(SyntaxKind.OpenBracketToken, SyntaxKind.CloseBracketToken, openBracketPosition);
return finishNode(factory.createArrayLiteralExpression(elements, multiLine), pos);
}
@@ -5498,15 +5516,7 @@ namespace ts {
parseExpected(SyntaxKind.OpenBraceToken);
const multiLine = scanner.hasPrecedingLineBreak();
const properties = parseDelimitedList(ParsingContext.ObjectLiteralMembers, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true);
if (!parseExpected(SyntaxKind.CloseBraceToken)) {
const lastError = lastOrUndefined(parseDiagnostics);
if (lastError && lastError.code === Diagnostics._0_expected.code) {
addRelatedInfo(
lastError,
createDetachedDiagnostic(fileName, openBracePosition, 1, Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here)
);
}
}
parseExpectedMatchingBrackets(SyntaxKind.OpenBraceToken, SyntaxKind.CloseBraceToken, openBracePosition);
return finishNode(factory.createObjectLiteralExpression(properties, multiLine), pos);
}
@@ -5591,16 +5601,14 @@ namespace ts {
if (parseExpected(SyntaxKind.OpenBraceToken, diagnosticMessage) || ignoreMissingOpenBrace) {
const multiLine = scanner.hasPrecedingLineBreak();
const statements = parseList(ParsingContext.BlockStatements, parseStatement);
if (!parseExpected(SyntaxKind.CloseBraceToken)) {
const lastError = lastOrUndefined(parseDiagnostics);
if (lastError && lastError.code === Diagnostics._0_expected.code) {
addRelatedInfo(
lastError,
createDetachedDiagnostic(fileName, openBracePosition, 1, Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here)
);
}
parseExpectedMatchingBrackets(SyntaxKind.OpenBraceToken, SyntaxKind.CloseBraceToken, openBracePosition);
const result = finishNode(factory.createBlock(statements, multiLine), pos);
if (token() === SyntaxKind.EqualsToken) {
parseErrorAtCurrentToken(Diagnostics.Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses);
nextToken();
}
return finishNode(factory.createBlock(statements, multiLine), pos);
return result;
}
else {
const statements = createMissingList<Statement>();
@@ -5647,9 +5655,10 @@ namespace ts {
function parseIfStatement(): IfStatement {
const pos = getNodePos();
parseExpected(SyntaxKind.IfKeyword);
const openParenPosition = scanner.getTokenPos();
parseExpected(SyntaxKind.OpenParenToken);
const expression = allowInAnd(parseExpression);
parseExpected(SyntaxKind.CloseParenToken);
parseExpectedMatchingBrackets(SyntaxKind.OpenParenToken, SyntaxKind.CloseParenToken, openParenPosition);
const thenStatement = parseStatement();
const elseStatement = parseOptional(SyntaxKind.ElseKeyword) ? parseStatement() : undefined;
return finishNode(factory.createIfStatement(expression, thenStatement, elseStatement), pos);
@@ -5660,9 +5669,10 @@ namespace ts {
parseExpected(SyntaxKind.DoKeyword);
const statement = parseStatement();
parseExpected(SyntaxKind.WhileKeyword);
const openParenPosition = scanner.getTokenPos();
parseExpected(SyntaxKind.OpenParenToken);
const expression = allowInAnd(parseExpression);
parseExpected(SyntaxKind.CloseParenToken);
parseExpectedMatchingBrackets(SyntaxKind.OpenParenToken, SyntaxKind.CloseParenToken, openParenPosition);
// From: https://mail.mozilla.org/pipermail/es-discuss/2011-August/016188.html
// 157 min --- All allen at wirfs-brock.com CONF --- "do{;}while(false)false" prohibited in
@@ -5675,9 +5685,10 @@ namespace ts {
function parseWhileStatement(): WhileStatement {
const pos = getNodePos();
parseExpected(SyntaxKind.WhileKeyword);
const openParenPosition = scanner.getTokenPos();
parseExpected(SyntaxKind.OpenParenToken);
const expression = allowInAnd(parseExpression);
parseExpected(SyntaxKind.CloseParenToken);
parseExpectedMatchingBrackets(SyntaxKind.OpenParenToken, SyntaxKind.CloseParenToken, openParenPosition);
const statement = parseStatement();
return finishNode(factory.createWhileStatement(expression, statement), pos);
}
@@ -5749,9 +5760,10 @@ namespace ts {
function parseWithStatement(): WithStatement {
const pos = getNodePos();
parseExpected(SyntaxKind.WithKeyword);
const openParenPosition = scanner.getTokenPos();
parseExpected(SyntaxKind.OpenParenToken);
const expression = allowInAnd(parseExpression);
parseExpected(SyntaxKind.CloseParenToken);
parseExpectedMatchingBrackets(SyntaxKind.OpenParenToken, SyntaxKind.CloseParenToken, openParenPosition);
const statement = doInsideOfContext(NodeFlags.InWithStatement, parseStatement);
return finishNode(factory.createWithStatement(expression, statement), pos);
}
@@ -7973,13 +7985,9 @@ namespace ts {
hasChildren = true;
if (child.kind === SyntaxKind.JSDocTypeTag) {
if (childTypeTag) {
parseErrorAtCurrentToken(Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags);
const lastError = lastOrUndefined(parseDiagnostics);
const lastError = parseErrorAtCurrentToken(Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags);
if (lastError) {
addRelatedInfo(
lastError,
createDetachedDiagnostic(fileName, 0, 0, Diagnostics.The_tag_was_first_specified_here)
);
addRelatedInfo(lastError, createDetachedDiagnostic(fileName, 0, 0, Diagnostics.The_tag_was_first_specified_here));
}
break;
}
@@ -8011,7 +8019,7 @@ namespace ts {
}
const typedefTag = factory.createJSDocTypedefTag(tagName, typeExpression, fullName, comment);
return finishNode(typedefTag, start);
return finishNode(typedefTag, start, end);
}
function parseJSDocTypeNameWithNamespace(nested?: boolean) {
+4
View File
@@ -1717,7 +1717,11 @@ namespace ts {
continue;
}
const outputs = getAllProjectOutputs(parsed, !host.useCaseSensitiveFileNames());
if (!outputs.length) continue;
const inputFileNames = new Set(parsed.fileNames.map(f => toPath(state, f)));
for (const output of outputs) {
// If output name is same as input file name, do not delete and ignore the error
if (inputFileNames.has(toPath(state, output))) continue;
if (host.fileExists(output)) {
if (filesToDelete) {
filesToDelete.push(output);
-1
View File
@@ -4353,7 +4353,6 @@ namespace ts {
InObjectTypeLiteral = 1 << 22,
InTypeAlias = 1 << 23, // Writing type in type alias declaration
InInitialEntityName = 1 << 24, // Set when writing the LHS of an entity name or entity name expression
InReverseMappedType = 1 << 25,
}
// Ensure the shared flags between this and `NodeBuilderFlags` stay in alignment
+2 -1
View File
@@ -306,7 +306,8 @@ namespace ts.server {
fileName: entry.file,
textSpan: this.decodeSpan(entry),
kind: ScriptElementKind.unknown,
name: ""
name: "",
unverified: entry.unverified,
})),
textSpan: this.decodeSpan(body.textSpan, request.arguments.file)
};
-2
View File
@@ -135,8 +135,6 @@ namespace compiler {
}
}
}
this.diagnostics = diagnostics;
}
public get vfs(): vfs.FileSystem {
+21 -10
View File
@@ -685,10 +685,10 @@ namespace FourSlash {
}
public verifyGoToDefinitionIs(endMarker: ArrayOrSingle<string>) {
this.verifyGoToXWorker(toArray(endMarker), () => this.getGoToDefinition());
this.verifyGoToXWorker(/*startMarker*/ undefined, toArray(endMarker), () => this.getGoToDefinition());
}
public verifyGoToDefinition(arg0: any, endMarkerNames?: ArrayOrSingle<string> | { file: string }) {
public verifyGoToDefinition(arg0: any, endMarkerNames?: ArrayOrSingle<string | { marker: string, unverified?: boolean }> | { file: string, unverified?: boolean }) {
this.verifyGoToX(arg0, endMarkerNames, () => this.getGoToDefinitionAndBoundSpan());
}
@@ -705,7 +705,7 @@ namespace FourSlash {
this.languageService.getTypeDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition));
}
private verifyGoToX(arg0: any, endMarkerNames: ArrayOrSingle<string> | { file: string } | undefined, getDefs: () => readonly ts.DefinitionInfo[] | ts.DefinitionInfoAndBoundSpan | undefined) {
private verifyGoToX(arg0: any, endMarkerNames: ArrayOrSingle<string | { marker: string, unverified?: boolean }> | { file: string, unverified?: boolean } | undefined, getDefs: () => readonly ts.DefinitionInfo[] | ts.DefinitionInfoAndBoundSpan | undefined) {
if (endMarkerNames) {
this.verifyGoToXPlain(arg0, endMarkerNames, getDefs);
}
@@ -725,7 +725,7 @@ namespace FourSlash {
}
}
private verifyGoToXPlain(startMarkerNames: ArrayOrSingle<string>, endMarkerNames: ArrayOrSingle<string> | { file: string }, getDefs: () => readonly ts.DefinitionInfo[] | ts.DefinitionInfoAndBoundSpan | undefined) {
private verifyGoToXPlain(startMarkerNames: ArrayOrSingle<string>, endMarkerNames: ArrayOrSingle<string | { marker: string, unverified?: boolean }> | { file: string, unverified?: boolean }, getDefs: () => readonly ts.DefinitionInfo[] | ts.DefinitionInfoAndBoundSpan | undefined) {
for (const start of toArray(startMarkerNames)) {
this.verifyGoToXSingle(start, endMarkerNames, getDefs);
}
@@ -737,12 +737,12 @@ namespace FourSlash {
}
}
private verifyGoToXSingle(startMarkerName: string, endMarkerNames: ArrayOrSingle<string> | { file: string }, getDefs: () => readonly ts.DefinitionInfo[] | ts.DefinitionInfoAndBoundSpan | undefined) {
private verifyGoToXSingle(startMarkerName: string, endMarkerNames: ArrayOrSingle<string | { marker: string, unverified?: boolean }> | { file: string, unverified?: boolean }, getDefs: () => readonly ts.DefinitionInfo[] | ts.DefinitionInfoAndBoundSpan | undefined) {
this.goToMarker(startMarkerName);
this.verifyGoToXWorker(toArray(endMarkerNames), getDefs, startMarkerName);
this.verifyGoToXWorker(startMarkerName, toArray(endMarkerNames), getDefs, startMarkerName);
}
private verifyGoToXWorker(endMarkers: readonly (string | { file: string })[], getDefs: () => readonly ts.DefinitionInfo[] | ts.DefinitionInfoAndBoundSpan | undefined, startMarkerName?: string) {
private verifyGoToXWorker(startMarker: string | undefined, endMarkers: readonly (string | { marker?: string, file?: string, unverified?: boolean })[], getDefs: () => readonly ts.DefinitionInfo[] | ts.DefinitionInfoAndBoundSpan | undefined, startMarkerName?: string) {
const defs = getDefs();
let definitions: readonly ts.DefinitionInfo[];
let testName: string;
@@ -763,8 +763,11 @@ namespace FourSlash {
}
ts.zipWith(endMarkers, definitions, (endMarkerOrFileResult, definition, i) => {
const expectedFileName = typeof endMarkerOrFileResult === "string" ? this.getMarkerByName(endMarkerOrFileResult).fileName : endMarkerOrFileResult.file;
const expectedPosition = typeof endMarkerOrFileResult === "string" ? this.getMarkerByName(endMarkerOrFileResult).position : 0;
const markerName = typeof endMarkerOrFileResult === "string" ? endMarkerOrFileResult : endMarkerOrFileResult.marker;
const marker = markerName !== undefined ? this.getMarkerByName(markerName) : undefined;
const expectedFileName = marker?.fileName || typeof endMarkerOrFileResult !== "string" && endMarkerOrFileResult.file;
ts.Debug.assert(typeof expectedFileName === "string");
const expectedPosition = marker?.position || 0;
if (ts.comparePaths(expectedFileName, definition.fileName, /*ignoreCase*/ true) !== ts.Comparison.EqualTo || expectedPosition !== definition.textSpan.start) {
const filesToDisplay = ts.deduplicate([expectedFileName, definition.fileName], ts.equateValues);
const markers = [{ text: "EXPECTED", fileName: expectedFileName, position: expectedPosition }, { text: "ACTUAL", fileName: definition.fileName, position: definition.textSpan.start }];
@@ -777,7 +780,15 @@ namespace FourSlash {
return `// @Filename: ${fileName}\n${fileContent}`;
}).join("\n\n");
this.raiseError(`${testName} failed for definition ${endMarkerOrFileResult} (${i}): expected ${expectedFileName} at ${expectedPosition}, got ${definition.fileName} at ${definition.textSpan.start}\n\n${text}\n`);
this.raiseError(`${testName} failed for definition ${markerName || expectedFileName} (${i}): expected ${expectedFileName} at ${expectedPosition}, got ${definition.fileName} at ${definition.textSpan.start}\n\n${text}\n`);
}
if (definition.unverified && (typeof endMarkerOrFileResult === "string" || !endMarkerOrFileResult.unverified)) {
const isFileResult = typeof endMarkerOrFileResult !== "string" && !!endMarkerOrFileResult.file;
this.raiseError(
`${testName} failed for definition ${markerName || expectedFileName} (${i}): The actual definition was an \`unverified\` result. Use:\n\n` +
` verify.goToDefinition(${startMarker === undefined ? "startMarker" : `"${startMarker}"`}, { ${isFileResult ? `file: "${expectedFileName}"` : `marker: "${markerName}"`}, unverified: true })\n\n` +
`if this is expected.`
);
}
});
}
+1 -1
View File
@@ -1013,7 +1013,7 @@ namespace ts.server.protocol {
* Definition response message. Gives text range for definition.
*/
export interface DefinitionResponse extends Response {
body?: FileSpanWithContext[];
body?: DefinitionInfo[];
}
export interface DefinitionInfoAndBoundSpanResponse extends Response {
+3 -2
View File
@@ -1224,6 +1224,7 @@ namespace ts.server {
containerName: info.containerName,
kind: info.kind,
name: info.name,
...info.unverified && { unverified: info.unverified },
};
});
}
@@ -1300,8 +1301,8 @@ namespace ts.server {
}));
}
private mapDefinitionInfo(definitions: readonly DefinitionInfo[], project: Project): readonly protocol.FileSpanWithContext[] {
return definitions.map(def => this.toFileSpanWithContext(def.fileName, def.textSpan, def.contextSpan, project));
private mapDefinitionInfo(definitions: readonly DefinitionInfo[], project: Project): readonly protocol.DefinitionInfo[] {
return definitions.map(def => ({ ...this.toFileSpanWithContext(def.fileName, def.textSpan, def.contextSpan, project), ...def.unverified && { unverified: def.unverified } }));
}
/*
@@ -14,6 +14,7 @@ namespace ts.codefix {
Diagnostics.Operator_0_cannot_be_applied_to_type_1.code,
Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2.code,
Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap.code,
Diagnostics.This_condition_will_always_return_true_since_this_0_appears_to_always_be_defined.code,
Diagnostics.Type_0_is_not_an_array_type.code,
Diagnostics.Type_0_is_not_an_array_type_or_a_string_type.code,
Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators.code,
@@ -65,6 +65,10 @@ namespace ts.codefix {
const isInJavascript = isInJSFile(functionToConvert);
const setOfExpressionsToReturn = getAllPromiseExpressionsToReturn(functionToConvert, checker);
const functionToConvertRenamed = renameCollidingVarNames(functionToConvert, checker, synthNamesMap);
if (!returnsPromise(functionToConvertRenamed, checker)) {
return;
}
const returnStatements = functionToConvertRenamed.body && isBlock(functionToConvertRenamed.body) ? getReturnStatementsWithPromiseHandlers(functionToConvertRenamed.body, checker) : emptyArray;
const transformer: Transformer = { checker, synthNamesMap, setOfExpressionsToReturn, isInJSFile: isInJavascript };
if (!returnStatements.length) {
+19 -9
View File
@@ -436,7 +436,9 @@ namespace ts.codefix {
/**
* Convert `import x = require("x").`
* Also converts uses like `x.y()` to `y()` and uses a named import.
* Also:
* - Convert `x.default()` to `x()` to handle ES6 default export
* - Converts uses like `x.y()` to `y()` and uses a named import.
*/
function convertSingleIdentifierImport(name: Identifier, moduleSpecifier: StringLiteralLike, checker: TypeChecker, identifiers: Identifiers, quotePreference: QuotePreference): ConvertedImports {
const nameSymbol = checker.getSymbolAtLocation(name);
@@ -454,15 +456,23 @@ namespace ts.codefix {
const { parent } = use;
if (isPropertyAccessExpression(parent)) {
const { expression, name: { text: propertyName } } = parent;
Debug.assert(expression === use, "Didn't expect expression === use"); // Else shouldn't have been in `collectIdentifiers`
let idName = namedBindingsNames.get(propertyName);
if (idName === undefined) {
idName = makeUniqueName(propertyName, identifiers);
namedBindingsNames.set(propertyName, idName);
}
const { name: { text: propertyName } } = parent;
if (propertyName === "default") {
needDefaultImport = true;
(useSitesToUnqualify ??= new Map()).set(parent, factory.createIdentifier(idName));
const importDefaultName = use.getText();
(useSitesToUnqualify ??= new Map()).set(parent, factory.createIdentifier(importDefaultName));
}
else {
Debug.assert(parent.expression === use, "Didn't expect expression === use"); // Else shouldn't have been in `collectIdentifiers`
let idName = namedBindingsNames.get(propertyName);
if (idName === undefined) {
idName = makeUniqueName(propertyName, identifiers);
namedBindingsNames.set(propertyName, idName);
}
(useSitesToUnqualify ??= new Map()).set(parent, factory.createIdentifier(idName));
}
}
else {
needDefaultImport = true;
@@ -2,7 +2,7 @@
namespace ts.codefix {
const fixId = "fixMissingCallParentheses";
const errorCodes = [
Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead.code,
Diagnostics.This_condition_will_always_return_true_since_this_function_appears_to_always_be_defined_Did_you_mean_to_call_it_instead.code,
];
registerCodeFix({
+3 -2
View File
@@ -1659,8 +1659,9 @@ namespace ts.Completions {
function isContextTokenValueLocation(contextToken: Node) {
return contextToken &&
contextToken.kind === SyntaxKind.TypeOfKeyword &&
(contextToken.parent.kind === SyntaxKind.TypeQuery || isTypeOfExpression(contextToken.parent));
((contextToken.kind === SyntaxKind.TypeOfKeyword &&
(contextToken.parent.kind === SyntaxKind.TypeQuery || isTypeOfExpression(contextToken.parent))) ||
(contextToken.kind === SyntaxKind.AssertsKeyword && contextToken.parent.kind === SyntaxKind.TypePredicate));
}
function isContextTokenTypeLocation(contextToken: Node): boolean {
+77 -20
View File
@@ -83,12 +83,26 @@ namespace ts {
* @param fileName The name of the file to be released
* @param compilationSettings The compilation settings used to acquire the file
*/
/**@deprecated pass scriptKind for correctness */
releaseDocument(fileName: string, compilationSettings: CompilerOptions): void;
/**
* Informs the DocumentRegistry that a file is not needed any longer.
*
* Note: It is not allowed to call release on a SourceFile that was not acquired from
* this registry originally.
*
* @param fileName The name of the file to be released
* @param compilationSettings The compilation settings used to acquire the file
* @param scriptKind The script kind of the file to be released
*/
releaseDocument(fileName: string, compilationSettings: CompilerOptions, scriptKind: ScriptKind): void; // eslint-disable-line @typescript-eslint/unified-signatures
/**
* @deprecated pass scriptKind for correctness */
releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey): void;
releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey, scriptKind: ScriptKind): void; // eslint-disable-line @typescript-eslint/unified-signatures
/*@internal*/
getLanguageServiceRefCounts(path: Path): [string, number | undefined][];
getLanguageServiceRefCounts(path: Path, scriptKind: ScriptKind): [string, number | undefined][];
reportStats(): string;
}
@@ -110,6 +124,11 @@ namespace ts {
languageServiceRefCount: number;
}
type BucketEntry = DocumentRegistryEntry | ESMap<ScriptKind, DocumentRegistryEntry>;
function isDocumentRegistryEntry(entry: BucketEntry): entry is DocumentRegistryEntry {
return !!(entry as DocumentRegistryEntry).sourceFile;
}
export function createDocumentRegistry(useCaseSensitiveFileNames?: boolean, currentDirectory?: string): DocumentRegistry {
return createDocumentRegistryInternal(useCaseSensitiveFileNames, currentDirectory);
}
@@ -118,18 +137,24 @@ namespace ts {
export function createDocumentRegistryInternal(useCaseSensitiveFileNames?: boolean, currentDirectory = "", externalCache?: ExternalDocumentCache): DocumentRegistry {
// Maps from compiler setting target (ES3, ES5, etc.) to all the cached documents we have
// for those settings.
const buckets = new Map<string, ESMap<Path, DocumentRegistryEntry>>();
const buckets = new Map<DocumentRegistryBucketKey, ESMap<Path, BucketEntry>>();
const getCanonicalFileName = createGetCanonicalFileName(!!useCaseSensitiveFileNames);
function reportStats() {
const bucketInfoArray = arrayFrom(buckets.keys()).filter(name => name && name.charAt(0) === "_").map(name => {
const entries = buckets.get(name)!;
const sourceFiles: { name: string; refCount: number; }[] = [];
const sourceFiles: { name: string; scriptKind: ScriptKind, refCount: number; }[] = [];
entries.forEach((entry, name) => {
sourceFiles.push({
name,
refCount: entry.languageServiceRefCount
});
if (isDocumentRegistryEntry(entry)) {
sourceFiles.push({
name,
scriptKind: entry.sourceFile.scriptKind,
refCount: entry.languageServiceRefCount
});
}
else {
entry.forEach((value, scriptKind) => sourceFiles.push({ name, scriptKind, refCount: value.languageServiceRefCount }));
}
});
sourceFiles.sort((x, y) => y.refCount - x.refCount);
return {
@@ -160,6 +185,12 @@ namespace ts {
return acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, /*acquiring*/ false, scriptKind);
}
function getDocumentRegistryEntry(bucketEntry: BucketEntry, scriptKind: ScriptKind | undefined) {
const entry = isDocumentRegistryEntry(bucketEntry) ? bucketEntry : bucketEntry.get(Debug.checkDefined(scriptKind, "If there are more than one scriptKind's for same document the scriptKind should be provided"));
Debug.assert(scriptKind === undefined || !entry || entry.sourceFile.scriptKind === scriptKind, `Script kind should match provided ScriptKind:${scriptKind} and sourceFile.scriptKind: ${entry?.sourceFile.scriptKind}, !entry: ${!entry}`);
return entry;
}
function acquireOrUpdateDocument(
fileName: string,
path: Path,
@@ -169,10 +200,11 @@ namespace ts {
version: string,
acquiring: boolean,
scriptKind?: ScriptKind): SourceFile {
const bucket = getOrUpdate(buckets, key, () => new Map<Path, DocumentRegistryEntry>());
let entry = bucket.get(path);
scriptKind = ensureScriptKind(fileName, scriptKind);
const scriptTarget = scriptKind === ScriptKind.JSON ? ScriptTarget.JSON : compilationSettings.target || ScriptTarget.ES5;
const bucket = getOrUpdate(buckets, key, () => new Map());
const bucketEntry = bucket.get(path);
let entry = bucketEntry && getDocumentRegistryEntry(bucketEntry, scriptKind);
if (!entry && externalCache) {
const sourceFile = externalCache.getDocument(key, path);
if (sourceFile) {
@@ -181,7 +213,7 @@ namespace ts {
sourceFile,
languageServiceRefCount: 0
};
bucket.set(path, entry);
setBucketEntry();
}
}
@@ -195,7 +227,7 @@ namespace ts {
sourceFile,
languageServiceRefCount: 1,
};
bucket.set(path, entry);
setBucketEntry();
}
else {
// We have an entry for this file. However, it may be for a different version of
@@ -221,28 +253,53 @@ namespace ts {
Debug.assert(entry.languageServiceRefCount !== 0);
return entry.sourceFile;
function setBucketEntry() {
if (!bucketEntry) {
bucket.set(path, entry!);
}
else if (isDocumentRegistryEntry(bucketEntry)) {
const scriptKindMap = new Map<ScriptKind, DocumentRegistryEntry>();
scriptKindMap.set(bucketEntry.sourceFile.scriptKind, bucketEntry);
scriptKindMap.set(scriptKind!, entry!);
bucket.set(path, scriptKindMap);
}
else {
bucketEntry.set(scriptKind!, entry!);
}
}
}
function releaseDocument(fileName: string, compilationSettings: CompilerOptions): void {
function releaseDocument(fileName: string, compilationSettings: CompilerOptions, scriptKind?: ScriptKind): void {
const path = toPath(fileName, currentDirectory, getCanonicalFileName);
const key = getKeyForCompilationSettings(compilationSettings);
return releaseDocumentWithKey(path, key);
return releaseDocumentWithKey(path, key, scriptKind);
}
function releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey): void {
function releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey, scriptKind?: ScriptKind): void {
const bucket = Debug.checkDefined(buckets.get(key));
const entry = bucket.get(path)!;
const bucketEntry = bucket.get(path)!;
const entry = getDocumentRegistryEntry(bucketEntry, scriptKind)!;
entry.languageServiceRefCount--;
Debug.assert(entry.languageServiceRefCount >= 0);
if (entry.languageServiceRefCount === 0) {
bucket.delete(path);
if (isDocumentRegistryEntry(bucketEntry)) {
bucket.delete(path);
}
else {
bucketEntry.delete(scriptKind!);
if (bucketEntry.size === 1) {
bucket.set(path, firstDefinedIterator(bucketEntry.values(), identity)!);
}
}
}
}
function getLanguageServiceRefCounts(path: Path) {
function getLanguageServiceRefCounts(path: Path, scriptKind: ScriptKind) {
return arrayFrom(buckets.entries(), ([key, bucket]): [string, number | undefined] => {
const entry = bucket.get(path);
const bucketEntry = bucket.get(path);
const entry = bucketEntry && getDocumentRegistryEntry(bucketEntry, scriptKind);
return [key, entry && entry.languageServiceRefCount];
});
}
+3 -1
View File
@@ -1180,7 +1180,9 @@ namespace ts.FindAllReferences {
for (const indirectUser of indirectUsers) {
for (const node of getPossibleSymbolReferenceNodes(indirectUser, isDefaultExport ? "default" : exportName)) {
// Import specifiers should be handled by importSearches
if (isIdentifier(node) && !isImportOrExportSpecifier(node.parent) && checker.getSymbolAtLocation(node) === exportSymbol) {
const symbol = checker.getSymbolAtLocation(node);
const hasExportAssignmentDeclaration = some(symbol?.declarations, d => tryCast(d, isExportAssignment) ? true : false);
if (isIdentifier(node) && !isImportOrExportSpecifier(node.parent) && (symbol === exportSymbol || hasExportAssignmentDeclaration)) {
cb(node);
}
}
+1 -1
View File
@@ -146,7 +146,7 @@ namespace ts.GoToDefinition {
end: node.getEnd(),
fileName: node.text
},
unverified: !!verifiedFileName,
unverified: !verifiedFileName,
};
}
}
+1
View File
@@ -44,6 +44,7 @@ namespace ts.JsDoc {
"kind",
"lends",
"license",
"link",
"listens",
"member",
"memberof",
+17 -4
View File
@@ -48,7 +48,7 @@ namespace ts.refactor {
});
// If a VariableStatement, will have exactly one VariableDeclaration, with an Identifier for a name.
type ExportToConvert = FunctionDeclaration | ClassDeclaration | InterfaceDeclaration | EnumDeclaration | NamespaceDeclaration | TypeAliasDeclaration | VariableStatement;
type ExportToConvert = FunctionDeclaration | ClassDeclaration | InterfaceDeclaration | EnumDeclaration | NamespaceDeclaration | TypeAliasDeclaration | VariableStatement | ExportAssignment;
interface ExportInfo {
readonly exportNode: ExportToConvert;
readonly exportName: Identifier; // This is exportNode.name except for VariableStatement_s.
@@ -67,7 +67,8 @@ namespace ts.refactor {
const exportingModuleSymbol = isSourceFile(exportNode.parent) ? exportNode.parent.symbol : exportNode.parent.parent.symbol;
const flags = getSyntacticModifierFlags(exportNode);
const flags = getSyntacticModifierFlags(exportNode) || ((isExportAssignment(exportNode) && !exportNode.isExportEquals) ? ModifierFlags.ExportDefault : ModifierFlags.None);
const wasDefault = !!(flags & ModifierFlags.Default);
// If source file already has a default export, don't offer refactor.
if (!(flags & ModifierFlags.Export) || !wasDefault && exportingModuleSymbol.exports!.has(InternalSymbolName.Default)) {
@@ -95,6 +96,11 @@ namespace ts.refactor {
Debug.assert(!wasDefault, "Can't have a default flag here");
return isIdentifier(decl.name) ? { exportNode: vs, exportName: decl.name, wasDefault, exportingModuleSymbol } : undefined;
}
case SyntaxKind.ExportAssignment: {
const node = exportNode as ExportAssignment;
const exp = node.expression as Identifier;
return node.isExportEquals ? undefined : { exportNode: node, exportName: exp, wasDefault, exportingModuleSymbol };
}
default:
return undefined;
}
@@ -107,7 +113,14 @@ namespace ts.refactor {
function changeExport(exportingSourceFile: SourceFile, { wasDefault, exportNode, exportName }: ExportInfo, changes: textChanges.ChangeTracker, checker: TypeChecker): void {
if (wasDefault) {
changes.delete(exportingSourceFile, Debug.checkDefined(findModifier(exportNode, SyntaxKind.DefaultKeyword), "Should find a default keyword in modifier list"));
if (isExportAssignment(exportNode) && !exportNode.isExportEquals) {
const exp = exportNode.expression as Identifier;
const spec = makeExportSpecifier(exp.text, exp.text);
changes.replaceNode(exportingSourceFile, exportNode, factory.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, factory.createNamedExports([spec])));
}
else {
changes.delete(exportingSourceFile, Debug.checkDefined(findModifier(exportNode, SyntaxKind.DefaultKeyword), "Should find a default keyword in modifier list"));
}
}
else {
const exportKeyword = Debug.checkDefined(findModifier(exportNode, SyntaxKind.ExportKeyword), "Should find an export keyword in modifier list");
@@ -134,7 +147,7 @@ namespace ts.refactor {
changes.insertNodeAfter(exportingSourceFile, exportNode, factory.createExportDefault(factory.createIdentifier(exportName.text)));
break;
default:
Debug.assertNever(exportNode, `Unexpected exportNode kind ${(exportNode as ExportToConvert).kind}`);
Debug.fail(`Unexpected exportNode kind ${(exportNode as ExportToConvert).kind}`);
}
}
}
+9 -5
View File
@@ -1444,7 +1444,7 @@ namespace ts {
// not part of the new program.
function onReleaseOldSourceFile(oldSourceFile: SourceFile, oldOptions: CompilerOptions) {
const oldSettingsKey = documentRegistry.getKeyForCompilationSettings(oldOptions);
documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, oldSettingsKey);
documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, oldSettingsKey, oldSourceFile.scriptKind);
}
function getOrCreateSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean): SourceFile | undefined {
@@ -1493,9 +1493,13 @@ namespace ts {
// We do not support the scenario where a host can modify a registered
// file's script kind, i.e. in one project some file is treated as ".ts"
// and in another as ".js"
Debug.assertEqual(hostFileInformation.scriptKind, oldSourceFile.scriptKind, "Registered script kind should match new script kind.");
return documentRegistry.updateDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind);
if (hostFileInformation.scriptKind === oldSourceFile.scriptKind) {
return documentRegistry.updateDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind);
}
else {
// Release old source file and fall through to aquire new file with new script kind
documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions()), oldSourceFile.scriptKind);
}
}
// We didn't already have the file. Fall through and acquire it from the registry.
@@ -1531,7 +1535,7 @@ namespace ts {
// Use paths to ensure we are using correct key and paths as document registry could be created with different current directory than host
const key = documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions());
forEach(program.getSourceFiles(), f =>
documentRegistry.releaseDocumentWithKey(f.resolvedPath, key));
documentRegistry.releaseDocumentWithKey(f.resolvedPath, key, f.scriptKind));
program = undefined!; // TODO: GH#18217
}
host = undefined!;
+3 -4
View File
@@ -118,10 +118,9 @@ namespace ts {
returnsPromise(node, checker);
}
function returnsPromise(node: FunctionLikeDeclaration, checker: TypeChecker): boolean {
const functionType = checker.getTypeAtLocation(node);
const callSignatures = checker.getSignaturesOfType(functionType, SignatureKind.Call);
const returnType = callSignatures.length ? checker.getReturnTypeOfSignature(callSignatures[0]) : undefined;
export function returnsPromise(node: FunctionLikeDeclaration, checker: TypeChecker): boolean {
const signature = checker.getSignatureFromDeclaration(node);
const returnType = signature ? checker.getReturnTypeOfSignature(signature) : undefined;
return !!returnType && !!checker.getPromisedTypeOfPromise(returnType);
}
+4 -2
View File
@@ -2516,8 +2516,10 @@ namespace ts {
}
/* @internal */
export function needsParentheses(expression: Expression) {
return isBinaryExpression(expression) && expression.operatorToken.kind === SyntaxKind.CommaToken || isObjectLiteralExpression(expression);
export function needsParentheses(expression: Expression): boolean {
return isBinaryExpression(expression) && expression.operatorToken.kind === SyntaxKind.CommaToken
|| isObjectLiteralExpression(expression)
|| isAsExpression(expression) && isObjectLiteralExpression(expression.expression);
}
export function getContextualTypeFromParent(node: Expression, checker: TypeChecker): Type | undefined {
+1
View File
@@ -113,6 +113,7 @@
"unittests/services/textChanges.ts",
"unittests/services/transpile.ts",
"unittests/tsbuild/amdModulesWithOut.ts",
"unittests/tsbuild/clean.ts",
"unittests/tsbuild/configFileErrors.ts",
"unittests/tsbuild/configFileExtends.ts",
"unittests/tsbuild/containerOnlyReferenced.ts",
@@ -1680,6 +1680,24 @@ import { fn } from "./module";
function [#|f|]() {
return Promise.resolve(0).then(fn);
}
`);
_testConvertToAsyncFunctionFailed("convertToAsyncFunction__NoSuggestionInFunctionsWithNonFixableReturnStatements1", `
function f(x: number): Promise<void>;
function f(): void;
function [#|f|](x?: number): Promise<void> | void {
if (!x) return;
return fetch('').then(() => {});
}
`);
_testConvertToAsyncFunctionFailed("convertToAsyncFunction__NoSuggestionInFunctionsWithNonFixableReturnStatements2", `
function f(x: number): Promise<void>;
function f(): number;
function [#|f|](x?: number): Promise<void> | number {
if (x) return x;
return fetch('').then(() => {});
}
`);
});
+16
View File
@@ -0,0 +1,16 @@
namespace ts {
describe("unittests:: tsbuild - clean", () => {
verifyTsc({
scenario: "clean",
subScenario: `file name and output name clashing`,
commandLineArgs: ["--b", "/src/tsconfig.json", "-clean"],
fs: () => loadProjectFromFiles({
"/src/index.js": "",
"/src/bar.ts": "",
"/src/tsconfig.json": JSON.stringify({
compilerOptions: { allowJs: true },
}),
}),
});
});
}
@@ -27,7 +27,7 @@ namespace ts.projectSystem {
assert.isDefined(moduleInfo);
assert.equal(moduleInfo.isOrphan(), moduleIsOrphan);
const key = service.documentRegistry.getKeyForCompilationSettings(project.getCompilationSettings());
assert.deepEqual(service.documentRegistry.getLanguageServiceRefCounts(moduleInfo.path), [[key, moduleIsOrphan ? undefined : 1]]);
assert.deepEqual(service.documentRegistry.getLanguageServiceRefCounts(moduleInfo.path, moduleInfo.scriptKind), [[key, moduleIsOrphan ? undefined : 1]]);
}
function createServiceAndHost() {
@@ -121,6 +121,28 @@ var x = 10;`
service.openClientFile(file.path);
checkNumberOfProjects(service, { configuredProjects: 1 });
});
it("when changing scriptKind of the untitled files", () => {
const host = createServerHost([libFile], { useCaseSensitiveFileNames: true });
const service = createProjectService(host, { useInferredProjectPerProjectRoot: true });
service.openClientFile(untitledFile, "const x = 10;", ScriptKind.TS, tscWatch.projectRoot);
checkNumberOfProjects(service, { inferredProjects: 1 });
checkProjectActualFiles(service.inferredProjects[0], [untitledFile, libFile.path]);
const program = service.inferredProjects[0].getCurrentProgram()!;
const sourceFile = program.getSourceFile(untitledFile)!;
// Close untitled file
service.closeClientFile(untitledFile);
// Open untitled file with different mode
service.openClientFile(untitledFile, "const x = 10;", ScriptKind.TSX, tscWatch.projectRoot);
checkNumberOfProjects(service, { inferredProjects: 1 });
checkProjectActualFiles(service.inferredProjects[0], [untitledFile, libFile.path]);
const newProgram = service.inferredProjects[0].getCurrentProgram()!;
const newSourceFile = newProgram.getSourceFile(untitledFile)!;
assert.notStrictEqual(newProgram, program);
assert.notStrictEqual(newSourceFile, sourceFile);
});
});
describe("unittests:: tsserver:: dynamicFiles:: ", () => {
@@ -218,7 +218,7 @@ function fooB() { }`
assert.deepEqual(response.definitions, [{
file: file2.path,
start: { line: 1, offset: 1 },
end: { line: 1, offset: 1 }
end: { line: 1, offset: 1 },
}]);
});
});
@@ -4436,4 +4436,4 @@ ${dependencyTs.content}`);
});
});
});
}
}
+17 -3
View File
@@ -2299,8 +2299,7 @@ declare namespace ts {
IgnoreErrors = 70221824,
InObjectTypeLiteral = 4194304,
InTypeAlias = 8388608,
InInitialEntityName = 16777216,
InReverseMappedType = 33554432
InInitialEntityName = 16777216
}
export enum TypeFormatFlags {
None = 0,
@@ -6528,8 +6527,23 @@ declare namespace ts {
* @param fileName The name of the file to be released
* @param compilationSettings The compilation settings used to acquire the file
*/
/**@deprecated pass scriptKind for correctness */
releaseDocument(fileName: string, compilationSettings: CompilerOptions): void;
/**
* Informs the DocumentRegistry that a file is not needed any longer.
*
* Note: It is not allowed to call release on a SourceFile that was not acquired from
* this registry originally.
*
* @param fileName The name of the file to be released
* @param compilationSettings The compilation settings used to acquire the file
* @param scriptKind The script kind of the file to be released
*/
releaseDocument(fileName: string, compilationSettings: CompilerOptions, scriptKind: ScriptKind): void;
/**
* @deprecated pass scriptKind for correctness */
releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey): void;
releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey, scriptKind: ScriptKind): void;
reportStats(): string;
}
type DocumentRegistryBucketKey = string & {
@@ -7400,7 +7414,7 @@ declare namespace ts.server.protocol {
* Definition response message. Gives text range for definition.
*/
interface DefinitionResponse extends Response {
body?: FileSpanWithContext[];
body?: DefinitionInfo[];
}
interface DefinitionInfoAndBoundSpanResponse extends Response {
body?: DefinitionInfoAndBoundSpan;
+16 -2
View File
@@ -2299,8 +2299,7 @@ declare namespace ts {
IgnoreErrors = 70221824,
InObjectTypeLiteral = 4194304,
InTypeAlias = 8388608,
InInitialEntityName = 16777216,
InReverseMappedType = 33554432
InInitialEntityName = 16777216
}
export enum TypeFormatFlags {
None = 0,
@@ -6528,8 +6527,23 @@ declare namespace ts {
* @param fileName The name of the file to be released
* @param compilationSettings The compilation settings used to acquire the file
*/
/**@deprecated pass scriptKind for correctness */
releaseDocument(fileName: string, compilationSettings: CompilerOptions): void;
/**
* Informs the DocumentRegistry that a file is not needed any longer.
*
* Note: It is not allowed to call release on a SourceFile that was not acquired from
* this registry originally.
*
* @param fileName The name of the file to be released
* @param compilationSettings The compilation settings used to acquire the file
* @param scriptKind The script kind of the file to be released
*/
releaseDocument(fileName: string, compilationSettings: CompilerOptions, scriptKind: ScriptKind): void;
/**
* @deprecated pass scriptKind for correctness */
releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey): void;
releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey, scriptKind: ScriptKind): void;
reportStats(): string;
}
type DocumentRegistryBucketKey = string & {
@@ -13,14 +13,15 @@ tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(2
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(30,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(31,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(32,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(35,9): error TS1128: Declaration or statement expected.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(35,9): error TS2809: Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(38,2): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(38,6): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(42,36): error TS1034: 'super' must be followed by an argument list or member access.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(44,19): error TS1034: 'super' must be followed by an argument list or member access.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(46,27): error TS1034: 'super' must be followed by an argument list or member access.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(50,20): error TS1128: Declaration or statement expected.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(51,11): error TS1005: ';' expected.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(50,20): error TS2809: Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(51,11): error TS2809: Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(51,13): error TS1005: ';' expected.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(54,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(57,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(58,2): error TS2631: Cannot assign to 'M' because it is a namespace.
@@ -38,7 +39,7 @@ tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(6
tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(70,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
==== tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts (38 errors) ====
==== tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts (39 errors) ====
// expected error for all the LHS of assignments
var value: any;
@@ -105,7 +106,7 @@ tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(7
// object literals
{ a: 0} = value;
~
!!! error TS1128: Declaration or statement expected.
!!! error TS2809: Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses.
// array literals
['', ''] = value;
@@ -132,9 +133,11 @@ tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts(7
// function expression
function bar() { } = value;
~
!!! error TS1128: Declaration or statement expected.
!!! error TS2809: Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses.
() => { } = value;
~
!!! error TS2809: Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses.
~~~~~
!!! error TS1005: ';' expected.
// function calls
@@ -146,7 +146,7 @@ function bar() { } = value;
>value : any
() => { } = value;
>() => { } : () => void
>() => { } = : () => void
>value : any
// function calls
@@ -1,10 +1,10 @@
tests/cases/compiler/bluebirdStaticThis.ts(5,22): error TS2420: Class 'Promise<R>' incorrectly implements interface 'Thenable<R>'.
Property 'then' is missing in type 'Promise<R>' but required in type 'Thenable<R>'.
tests/cases/compiler/bluebirdStaticThis.ts(22,51): error TS2809: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Resolver'.
tests/cases/compiler/bluebirdStaticThis.ts(57,109): error TS2809: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Inspection'.
tests/cases/compiler/bluebirdStaticThis.ts(58,91): error TS2809: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Inspection'.
tests/cases/compiler/bluebirdStaticThis.ts(59,91): error TS2809: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Inspection'.
tests/cases/compiler/bluebirdStaticThis.ts(60,73): error TS2809: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Inspection'.
tests/cases/compiler/bluebirdStaticThis.ts(22,51): error TS2810: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Resolver'.
tests/cases/compiler/bluebirdStaticThis.ts(57,109): error TS2810: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Inspection'.
tests/cases/compiler/bluebirdStaticThis.ts(58,91): error TS2810: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Inspection'.
tests/cases/compiler/bluebirdStaticThis.ts(59,91): error TS2810: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Inspection'.
tests/cases/compiler/bluebirdStaticThis.ts(60,73): error TS2810: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Inspection'.
==== tests/cases/compiler/bluebirdStaticThis.ts (6 errors) ====
@@ -35,7 +35,7 @@ tests/cases/compiler/bluebirdStaticThis.ts(60,73): error TS2809: Namespace 'Prom
static defer<R>(dit: typeof Promise): Promise.Resolver<R>;
~~~~~~~~
!!! error TS2809: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Resolver'.
!!! error TS2810: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Resolver'.
static cast<R>(dit: typeof Promise, value: Promise.Thenable<R>): Promise<R>;
static cast<R>(dit: typeof Promise, value: R): Promise<R>;
@@ -72,16 +72,16 @@ tests/cases/compiler/bluebirdStaticThis.ts(60,73): error TS2809: Namespace 'Prom
static settle<R>(dit: typeof Promise, values: Promise.Thenable<Promise.Thenable<R>[]>): Promise<Promise.Inspection<R>[]>;
~~~~~~~~~~
!!! error TS2809: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Inspection'.
!!! error TS2810: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Inspection'.
static settle<R>(dit: typeof Promise, values: Promise.Thenable<R[]>): Promise<Promise.Inspection<R>[]>;
~~~~~~~~~~
!!! error TS2809: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Inspection'.
!!! error TS2810: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Inspection'.
static settle<R>(dit: typeof Promise, values: Promise.Thenable<R>[]): Promise<Promise.Inspection<R>[]>;
~~~~~~~~~~
!!! error TS2809: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Inspection'.
!!! error TS2810: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Inspection'.
static settle<R>(dit: typeof Promise, values: R[]): Promise<Promise.Inspection<R>[]>;
~~~~~~~~~~
!!! error TS2809: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Inspection'.
!!! error TS2810: Namespace 'Promise' from module 'tests/cases/compiler/bluebirdStaticThis' has no exported member 'Inspection'.
static any<R>(dit: typeof Promise, values: Promise.Thenable<Promise.Thenable<R>[]>): Promise<R>;
static any<R>(dit: typeof Promise, values: Promise.Thenable<R[]>): Promise<R>;
@@ -0,0 +1,53 @@
//// [callOfConditionalTypeWithConcreteBranches.ts]
type Q<T> = number extends T ? (n: number) => void : never;
function fn<T>(arg: Q<T>) {
// Expected: OK
// Actual: Cannot convert 10 to number & T
arg(10);
}
// Legal invocations are not problematic
fn<string | number>(m => m.toFixed());
fn<number>(m => m.toFixed());
// Ensure the following real-world example that relies on substitution still works
type ExtractParameters<T> = "parameters" extends keyof T
// The above allows "parameters" to index `T` since all later
// instances are actually implicitly `"parameters" & keyof T`
? {
[K in keyof T["parameters"]]: T["parameters"][K];
}[keyof T["parameters"]]
: {};
// Original example, but with inverted variance
type Q2<T> = number extends T ? (cb: (n: number) => void) => void : never;
function fn2<T>(arg: Q2<T>) {
function useT(_arg: T): void {}
// Expected: OK
arg(arg => useT(arg));
}
// Legal invocations are not problematic
fn2<string | number>(m => m(42));
fn2<number>(m => m(42));
// webidl-conversions example where substituion must occur, despite contravariance of the position
// due to the invariant usage in `Parameters`
type X<V> = V extends (...args: any[]) => any ? (...args: Parameters<V>) => void : Function;
//// [callOfConditionalTypeWithConcreteBranches.js]
function fn(arg) {
// Expected: OK
// Actual: Cannot convert 10 to number & T
arg(10);
}
// Legal invocations are not problematic
fn(function (m) { return m.toFixed(); });
fn(function (m) { return m.toFixed(); });
function fn2(arg) {
function useT(_arg) { }
// Expected: OK
arg(function (arg) { return useT(arg); });
}
// Legal invocations are not problematic
fn2(function (m) { return m(42); });
fn2(function (m) { return m(42); });
@@ -0,0 +1,105 @@
=== tests/cases/compiler/callOfConditionalTypeWithConcreteBranches.ts ===
type Q<T> = number extends T ? (n: number) => void : never;
>Q : Symbol(Q, Decl(callOfConditionalTypeWithConcreteBranches.ts, 0, 0))
>T : Symbol(T, Decl(callOfConditionalTypeWithConcreteBranches.ts, 0, 7))
>T : Symbol(T, Decl(callOfConditionalTypeWithConcreteBranches.ts, 0, 7))
>n : Symbol(n, Decl(callOfConditionalTypeWithConcreteBranches.ts, 0, 32))
function fn<T>(arg: Q<T>) {
>fn : Symbol(fn, Decl(callOfConditionalTypeWithConcreteBranches.ts, 0, 59))
>T : Symbol(T, Decl(callOfConditionalTypeWithConcreteBranches.ts, 1, 12))
>arg : Symbol(arg, Decl(callOfConditionalTypeWithConcreteBranches.ts, 1, 15))
>Q : Symbol(Q, Decl(callOfConditionalTypeWithConcreteBranches.ts, 0, 0))
>T : Symbol(T, Decl(callOfConditionalTypeWithConcreteBranches.ts, 1, 12))
// Expected: OK
// Actual: Cannot convert 10 to number & T
arg(10);
>arg : Symbol(arg, Decl(callOfConditionalTypeWithConcreteBranches.ts, 1, 15))
}
// Legal invocations are not problematic
fn<string | number>(m => m.toFixed());
>fn : Symbol(fn, Decl(callOfConditionalTypeWithConcreteBranches.ts, 0, 59))
>m : Symbol(m, Decl(callOfConditionalTypeWithConcreteBranches.ts, 7, 20))
>m.toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --))
>m : Symbol(m, Decl(callOfConditionalTypeWithConcreteBranches.ts, 7, 20))
>toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --))
fn<number>(m => m.toFixed());
>fn : Symbol(fn, Decl(callOfConditionalTypeWithConcreteBranches.ts, 0, 59))
>m : Symbol(m, Decl(callOfConditionalTypeWithConcreteBranches.ts, 8, 11))
>m.toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --))
>m : Symbol(m, Decl(callOfConditionalTypeWithConcreteBranches.ts, 8, 11))
>toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --))
// Ensure the following real-world example that relies on substitution still works
type ExtractParameters<T> = "parameters" extends keyof T
>ExtractParameters : Symbol(ExtractParameters, Decl(callOfConditionalTypeWithConcreteBranches.ts, 8, 29))
>T : Symbol(T, Decl(callOfConditionalTypeWithConcreteBranches.ts, 11, 23))
>T : Symbol(T, Decl(callOfConditionalTypeWithConcreteBranches.ts, 11, 23))
// The above allows "parameters" to index `T` since all later
// instances are actually implicitly `"parameters" & keyof T`
? {
[K in keyof T["parameters"]]: T["parameters"][K];
>K : Symbol(K, Decl(callOfConditionalTypeWithConcreteBranches.ts, 15, 9))
>T : Symbol(T, Decl(callOfConditionalTypeWithConcreteBranches.ts, 11, 23))
>T : Symbol(T, Decl(callOfConditionalTypeWithConcreteBranches.ts, 11, 23))
>K : Symbol(K, Decl(callOfConditionalTypeWithConcreteBranches.ts, 15, 9))
}[keyof T["parameters"]]
>T : Symbol(T, Decl(callOfConditionalTypeWithConcreteBranches.ts, 11, 23))
: {};
// Original example, but with inverted variance
type Q2<T> = number extends T ? (cb: (n: number) => void) => void : never;
>Q2 : Symbol(Q2, Decl(callOfConditionalTypeWithConcreteBranches.ts, 17, 7))
>T : Symbol(T, Decl(callOfConditionalTypeWithConcreteBranches.ts, 20, 8))
>T : Symbol(T, Decl(callOfConditionalTypeWithConcreteBranches.ts, 20, 8))
>cb : Symbol(cb, Decl(callOfConditionalTypeWithConcreteBranches.ts, 20, 33))
>n : Symbol(n, Decl(callOfConditionalTypeWithConcreteBranches.ts, 20, 38))
function fn2<T>(arg: Q2<T>) {
>fn2 : Symbol(fn2, Decl(callOfConditionalTypeWithConcreteBranches.ts, 20, 74))
>T : Symbol(T, Decl(callOfConditionalTypeWithConcreteBranches.ts, 21, 13))
>arg : Symbol(arg, Decl(callOfConditionalTypeWithConcreteBranches.ts, 21, 16))
>Q2 : Symbol(Q2, Decl(callOfConditionalTypeWithConcreteBranches.ts, 17, 7))
>T : Symbol(T, Decl(callOfConditionalTypeWithConcreteBranches.ts, 21, 13))
function useT(_arg: T): void {}
>useT : Symbol(useT, Decl(callOfConditionalTypeWithConcreteBranches.ts, 21, 29))
>_arg : Symbol(_arg, Decl(callOfConditionalTypeWithConcreteBranches.ts, 22, 16))
>T : Symbol(T, Decl(callOfConditionalTypeWithConcreteBranches.ts, 21, 13))
// Expected: OK
arg(arg => useT(arg));
>arg : Symbol(arg, Decl(callOfConditionalTypeWithConcreteBranches.ts, 21, 16))
>arg : Symbol(arg, Decl(callOfConditionalTypeWithConcreteBranches.ts, 24, 6))
>useT : Symbol(useT, Decl(callOfConditionalTypeWithConcreteBranches.ts, 21, 29))
>arg : Symbol(arg, Decl(callOfConditionalTypeWithConcreteBranches.ts, 24, 6))
}
// Legal invocations are not problematic
fn2<string | number>(m => m(42));
>fn2 : Symbol(fn2, Decl(callOfConditionalTypeWithConcreteBranches.ts, 20, 74))
>m : Symbol(m, Decl(callOfConditionalTypeWithConcreteBranches.ts, 27, 21))
>m : Symbol(m, Decl(callOfConditionalTypeWithConcreteBranches.ts, 27, 21))
fn2<number>(m => m(42));
>fn2 : Symbol(fn2, Decl(callOfConditionalTypeWithConcreteBranches.ts, 20, 74))
>m : Symbol(m, Decl(callOfConditionalTypeWithConcreteBranches.ts, 28, 12))
>m : Symbol(m, Decl(callOfConditionalTypeWithConcreteBranches.ts, 28, 12))
// webidl-conversions example where substituion must occur, despite contravariance of the position
// due to the invariant usage in `Parameters`
type X<V> = V extends (...args: any[]) => any ? (...args: Parameters<V>) => void : Function;
>X : Symbol(X, Decl(callOfConditionalTypeWithConcreteBranches.ts, 28, 24))
>V : Symbol(V, Decl(callOfConditionalTypeWithConcreteBranches.ts, 33, 7))
>V : Symbol(V, Decl(callOfConditionalTypeWithConcreteBranches.ts, 33, 7))
>args : Symbol(args, Decl(callOfConditionalTypeWithConcreteBranches.ts, 33, 23))
>args : Symbol(args, Decl(callOfConditionalTypeWithConcreteBranches.ts, 33, 49))
>Parameters : Symbol(Parameters, Decl(lib.es5.d.ts, --, --))
>V : Symbol(V, Decl(callOfConditionalTypeWithConcreteBranches.ts, 33, 7))
>Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
@@ -0,0 +1,99 @@
=== tests/cases/compiler/callOfConditionalTypeWithConcreteBranches.ts ===
type Q<T> = number extends T ? (n: number) => void : never;
>Q : Q<T>
>n : number
function fn<T>(arg: Q<T>) {
>fn : <T>(arg: Q<T>) => void
>arg : Q<T>
// Expected: OK
// Actual: Cannot convert 10 to number & T
arg(10);
>arg(10) : void
>arg : Q<T>
>10 : 10
}
// Legal invocations are not problematic
fn<string | number>(m => m.toFixed());
>fn<string | number>(m => m.toFixed()) : void
>fn : <T>(arg: Q<T>) => void
>m => m.toFixed() : (m: number) => string
>m : number
>m.toFixed() : string
>m.toFixed : (fractionDigits?: number) => string
>m : number
>toFixed : (fractionDigits?: number) => string
fn<number>(m => m.toFixed());
>fn<number>(m => m.toFixed()) : void
>fn : <T>(arg: Q<T>) => void
>m => m.toFixed() : (m: number) => string
>m : number
>m.toFixed() : string
>m.toFixed : (fractionDigits?: number) => string
>m : number
>toFixed : (fractionDigits?: number) => string
// Ensure the following real-world example that relies on substitution still works
type ExtractParameters<T> = "parameters" extends keyof T
>ExtractParameters : ExtractParameters<T>
// The above allows "parameters" to index `T` since all later
// instances are actually implicitly `"parameters" & keyof T`
? {
[K in keyof T["parameters"]]: T["parameters"][K];
}[keyof T["parameters"]]
: {};
// Original example, but with inverted variance
type Q2<T> = number extends T ? (cb: (n: number) => void) => void : never;
>Q2 : Q2<T>
>cb : (n: number) => void
>n : number
function fn2<T>(arg: Q2<T>) {
>fn2 : <T>(arg: Q2<T>) => void
>arg : Q2<T>
function useT(_arg: T): void {}
>useT : (_arg: T) => void
>_arg : T
// Expected: OK
arg(arg => useT(arg));
>arg(arg => useT(arg)) : void
>arg : Q2<T>
>arg => useT(arg) : (arg: T & number) => void
>arg : T & number
>useT(arg) : void
>useT : (_arg: T) => void
>arg : T & number
}
// Legal invocations are not problematic
fn2<string | number>(m => m(42));
>fn2<string | number>(m => m(42)) : void
>fn2 : <T>(arg: Q2<T>) => void
>m => m(42) : (m: (n: number) => void) => void
>m : (n: number) => void
>m(42) : void
>m : (n: number) => void
>42 : 42
fn2<number>(m => m(42));
>fn2<number>(m => m(42)) : void
>fn2 : <T>(arg: Q2<T>) => void
>m => m(42) : (m: (n: number) => void) => void
>m : (n: number) => void
>m(42) : void
>m : (n: number) => void
>42 : 42
// webidl-conversions example where substituion must occur, despite contravariance of the position
// due to the invariant usage in `Parameters`
type X<V> = V extends (...args: any[]) => any ? (...args: Parameters<V>) => void : Function;
>X : X<V>
>args : any[]
>args : Parameters<V>
@@ -1,196 +0,0 @@
tests/cases/compiler/circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts(63,84): error TS2344: Type 'GetProps<C>' does not satisfy the constraint 'Shared<TInjectedProps, GetProps<C>>'.
Type 'unknown' is not assignable to type 'Shared<TInjectedProps, GetProps<C>>'.
Type 'Matching<TInjectedProps, GetProps<C>>' is not assignable to type 'Shared<TInjectedProps, GetProps<C>>'.
Type 'P extends keyof TInjectedProps ? TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : TInjectedProps[P] : GetProps<C>[P]' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
Type 'GetProps<C>[P] | (TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : TInjectedProps[P])' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
Type 'GetProps<C>[P]' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
Type 'GetProps<C>[Extract<keyof TInjectedProps, keyof GetProps<C>>]' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
Type 'GetProps<C>[Extract<keyof TInjectedProps, keyof GetProps<C>>]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
Type 'GetProps<C>[P]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
Type 'Extract<keyof TInjectedProps, keyof GetProps<C>> extends keyof TInjectedProps ? TInjectedProps[Extract<keyof TInjectedProps, keyof GetProps<C>>] extends GetProps<C>[Extract<keyof TInjectedProps, keyof GetProps<C>>] ? GetProps<C>[Extract<keyof TInjectedProps, keyof GetProps<C>>] : TInjectedProps[Extract<keyof TInjectedProps, keyof GetProps<C>>] : GetProps<C>[Extract<keyof TInjectedProps, keyof GetProps<C>>]' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
Type 'GetProps<C>[Extract<keyof TInjectedProps, keyof GetProps<C>>] | (TInjectedProps[Extract<keyof TInjectedProps, keyof GetProps<C>>] extends GetProps<C>[Extract<keyof TInjectedProps, keyof GetProps<C>>] ? GetProps<C>[Extract<keyof TInjectedProps, keyof GetProps<C>>] : TInjectedProps[Extract<keyof TInjectedProps, keyof GetProps<C>>])' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
Type 'GetProps<C>[Extract<keyof TInjectedProps, keyof GetProps<C>>]' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
Type 'GetProps<C>[Extract<string, keyof GetProps<C>>] | GetProps<C>[Extract<number, keyof GetProps<C>>] | GetProps<C>[Extract<symbol, keyof GetProps<C>>]' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
Type 'GetProps<C>[Extract<string, keyof GetProps<C>>]' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
Type 'GetProps<C>[keyof GetProps<C> & string]' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
Type 'GetProps<C>[string]' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
Type 'GetProps<C>[string]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
Type 'GetProps<C>[keyof GetProps<C> & string]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
Type 'GetProps<C>[Extract<string, keyof GetProps<C>>]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
Type 'GetProps<C>[Extract<keyof TInjectedProps, keyof GetProps<C>>]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
Type '(Extract<string, keyof GetProps<C>> extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] extends GetProps<C>[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] ? GetProps<C>[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] : TInjectedProps[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] : GetProps<C>[Extract<string, keyof GetProps<C>>]) | (Extract<number, keyof GetProps<C>> extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & Extract<number, keyof GetProps<C>>] extends GetProps<C>[keyof TInjectedProps & Extract<number, keyof GetProps<C>>] ? GetProps<C>[keyof TInjectedProps & Extract<number, keyof GetProps<C>>] : TInjectedProps[keyof TInjectedProps & Extract<number, keyof GetProps<C>>] : GetProps<C>[Extract<number, keyof GetProps<C>>]) | (Extract<symbol, keyof GetProps<C>> extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & Extract<symbol, keyof GetProps<C>>] extends GetProps<C>[keyof TInjectedProps & Extract<symbol, keyof GetProps<C>>] ? GetProps<C>[keyof TInjectedProps & Extract<symbol, keyof GetProps<C>>] : TInjectedProps[keyof TInjectedProps & Extract<symbol, keyof GetProps<C>>] : GetProps<C>[Extract<symbol, keyof GetProps<C>>])' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
Type 'Extract<string, keyof GetProps<C>> extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] extends GetProps<C>[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] ? GetProps<C>[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] : TInjectedProps[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] : GetProps<C>[Extract<string, keyof GetProps<C>>]' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
Type '(TInjectedProps[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] extends GetProps<C>[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] ? GetProps<C>[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] : TInjectedProps[keyof TInjectedProps & Extract<string, keyof GetProps<C>>]) | GetProps<C>[Extract<string, keyof GetProps<C>>]' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
Type 'TInjectedProps[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] extends GetProps<C>[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] ? GetProps<C>[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] : TInjectedProps[keyof TInjectedProps & Extract<string, keyof GetProps<C>>]' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
Type 'TInjectedProps[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] | GetProps<C>[keyof TInjectedProps & Extract<string, keyof GetProps<C>>]' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
Type 'TInjectedProps[keyof TInjectedProps & Extract<string, keyof GetProps<C>>]' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
Type 'TInjectedProps[string]' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
Type 'TInjectedProps[string]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
Type 'TInjectedProps[keyof TInjectedProps & Extract<string, keyof GetProps<C>>]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
Type 'TInjectedProps[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] extends GetProps<C>[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] ? GetProps<C>[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] : TInjectedProps[keyof TInjectedProps & Extract<string, keyof GetProps<C>>]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
Type 'keyof GetProps<C> & string extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & keyof GetProps<C> & string] extends GetProps<C>[keyof TInjectedProps & keyof GetProps<C> & string] ? GetProps<C>[keyof TInjectedProps & keyof GetProps<C> & string] : TInjectedProps[keyof TInjectedProps & keyof GetProps<C> & string] : GetProps<C>[keyof GetProps<C> & string]' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
Type '(TInjectedProps[keyof TInjectedProps & keyof GetProps<C> & string] extends GetProps<C>[keyof TInjectedProps & keyof GetProps<C> & string] ? GetProps<C>[keyof TInjectedProps & keyof GetProps<C> & string] : TInjectedProps[keyof TInjectedProps & keyof GetProps<C> & string]) | GetProps<C>[keyof GetProps<C> & string]' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps<C> & string] extends GetProps<C>[keyof TInjectedProps & keyof GetProps<C> & string] ? GetProps<C>[keyof TInjectedProps & keyof GetProps<C> & string] : TInjectedProps[keyof TInjectedProps & keyof GetProps<C> & string]' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps<C> & string] | GetProps<C>[keyof TInjectedProps & keyof GetProps<C> & string]' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps<C> & string]' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
Type 'TInjectedProps[string]' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
Type 'TInjectedProps[string]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps<C> & string]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps<C> & string] extends GetProps<C>[keyof TInjectedProps & keyof GetProps<C> & string] ? GetProps<C>[keyof TInjectedProps & keyof GetProps<C> & string] : TInjectedProps[keyof TInjectedProps & keyof GetProps<C> & string]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
Type 'string extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & string] extends GetProps<C>[keyof TInjectedProps & string] ? GetProps<C>[keyof TInjectedProps & string] : TInjectedProps[keyof TInjectedProps & string] : GetProps<C>[string]' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
Type 'string extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & string] extends GetProps<C>[keyof TInjectedProps & string] ? GetProps<C>[keyof TInjectedProps & string] : TInjectedProps[keyof TInjectedProps & string] : GetProps<C>[string]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
Type 'keyof GetProps<C> & string extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & keyof GetProps<C> & string] extends GetProps<C>[keyof TInjectedProps & keyof GetProps<C> & string] ? GetProps<C>[keyof TInjectedProps & keyof GetProps<C> & string] : TInjectedProps[keyof TInjectedProps & keyof GetProps<C> & string] : GetProps<C>[keyof GetProps<C> & string]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
Type '(TInjectedProps[keyof TInjectedProps & keyof GetProps<C> & string] extends GetProps<C>[keyof TInjectedProps & keyof GetProps<C> & string] ? GetProps<C>[keyof TInjectedProps & keyof GetProps<C> & string] : TInjectedProps[keyof TInjectedProps & keyof GetProps<C> & string]) | GetProps<C>[keyof GetProps<C> & string]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps<C> & string] extends GetProps<C>[keyof TInjectedProps & keyof GetProps<C> & string] ? GetProps<C>[keyof TInjectedProps & keyof GetProps<C> & string] : TInjectedProps[keyof TInjectedProps & keyof GetProps<C> & string]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps<C> & string] | GetProps<C>[keyof TInjectedProps & keyof GetProps<C> & string]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps<C> & string]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
Type 'TInjectedProps[string]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
Type 'Extract<string, keyof GetProps<C>> extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] extends GetProps<C>[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] ? GetProps<C>[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] : TInjectedProps[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] : GetProps<C>[Extract<string, keyof GetProps<C>>]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
Type '(TInjectedProps[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] extends GetProps<C>[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] ? GetProps<C>[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] : TInjectedProps[keyof TInjectedProps & Extract<string, keyof GetProps<C>>]) | GetProps<C>[Extract<string, keyof GetProps<C>>]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
Type 'TInjectedProps[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] extends GetProps<C>[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] ? GetProps<C>[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] : TInjectedProps[keyof TInjectedProps & Extract<string, keyof GetProps<C>>]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
Type 'TInjectedProps[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] | GetProps<C>[keyof TInjectedProps & Extract<string, keyof GetProps<C>>]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
Type 'TInjectedProps[keyof TInjectedProps & Extract<string, keyof GetProps<C>>]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
Type 'TInjectedProps[string]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
Type 'Extract<keyof TInjectedProps, keyof GetProps<C>> extends keyof TInjectedProps ? TInjectedProps[Extract<keyof TInjectedProps, keyof GetProps<C>>] extends GetProps<C>[Extract<keyof TInjectedProps, keyof GetProps<C>>] ? GetProps<C>[Extract<keyof TInjectedProps, keyof GetProps<C>>] : TInjectedProps[Extract<keyof TInjectedProps, keyof GetProps<C>>] : GetProps<C>[Extract<keyof TInjectedProps, keyof GetProps<C>>]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
Type 'GetProps<C>[Extract<keyof TInjectedProps, keyof GetProps<C>>] | (TInjectedProps[Extract<keyof TInjectedProps, keyof GetProps<C>>] extends GetProps<C>[Extract<keyof TInjectedProps, keyof GetProps<C>>] ? GetProps<C>[Extract<keyof TInjectedProps, keyof GetProps<C>>] : TInjectedProps[Extract<keyof TInjectedProps, keyof GetProps<C>>])' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
Type 'GetProps<C>[Extract<keyof TInjectedProps, keyof GetProps<C>>]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
Type 'P extends keyof TInjectedProps ? TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : TInjectedProps[P] : GetProps<C>[P]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
Type 'GetProps<C>[P] | (TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : TInjectedProps[P])' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
Type 'GetProps<C>[P]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
Type 'GetProps<C>[Extract<keyof TInjectedProps, keyof GetProps<C>>]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
Type 'GetProps<C>[Extract<string, keyof GetProps<C>>] | GetProps<C>[Extract<number, keyof GetProps<C>>] | GetProps<C>[Extract<symbol, keyof GetProps<C>>]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
Type 'GetProps<C>[Extract<string, keyof GetProps<C>>]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
Type 'GetProps<C>[keyof GetProps<C> & string]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
Type 'GetProps<C>[string]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
==== tests/cases/compiler/circularlyConstrainedMappedTypeContainingConditionalNoInfiniteInstantiationDepth.ts (1 errors) ====
declare class Component<P> {
constructor(props: Readonly<P>);
constructor(props: P, context?: any);
readonly props: Readonly<P> & Readonly<{ children?: {} }>;
}
interface ComponentClass<P = {}> {
new (props: P, context?: any): Component<P>;
propTypes?: WeakValidationMap<P>;
defaultProps?: Partial<P>;
displayName?: string;
}
interface FunctionComponent<P = {}> {
(props: P & { children?: {} }, context?: any): {} | null;
propTypes?: WeakValidationMap<P>;
defaultProps?: Partial<P>;
displayName?: string;
}
export declare const nominalTypeHack: unique symbol;
export interface Validator<T> {
(props: object, propName: string, componentName: string, location: string, propFullName: string): Error | null;
[nominalTypeHack]?: T;
}
type WeakValidationMap<T> = {
[K in keyof T]?: null extends T[K]
? Validator<T[K] | null | undefined>
: undefined extends T[K]
? Validator<T[K] | null | undefined>
: Validator<T[K]>
};
type ComponentType<P = {}> = ComponentClass<P> | FunctionComponent<P>;
export type Shared<
InjectedProps,
DecorationTargetProps extends Shared<InjectedProps, DecorationTargetProps>
> = {
[P in Extract<keyof InjectedProps, keyof DecorationTargetProps>]?: InjectedProps[P] extends DecorationTargetProps[P] ? DecorationTargetProps[P] : never;
};
// Infers prop type from component C
export type GetProps<C> = C extends ComponentType<infer P> ? P : never;
export type ConnectedComponentClass<
C extends ComponentType<any>,
P
> = ComponentClass<P> & {
WrappedComponent: C;
};
export type Matching<InjectedProps, DecorationTargetProps> = {
[P in keyof DecorationTargetProps]: P extends keyof InjectedProps
? InjectedProps[P] extends DecorationTargetProps[P]
? DecorationTargetProps[P]
: InjectedProps[P]
: DecorationTargetProps[P];
};
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
export type InferableComponentEnhancerWithProps<TInjectedProps, TNeedsProps> =
<C extends ComponentType<Matching<TInjectedProps, GetProps<C>>>>(
component: C
) => ConnectedComponentClass<C, Omit<GetProps<C>, keyof Shared<TInjectedProps, GetProps<C>>> & TNeedsProps>;
~~~~~~~~~~~
!!! error TS2344: Type 'GetProps<C>' does not satisfy the constraint 'Shared<TInjectedProps, GetProps<C>>'.
!!! error TS2344: Type 'unknown' is not assignable to type 'Shared<TInjectedProps, GetProps<C>>'.
!!! error TS2344: Type 'Matching<TInjectedProps, GetProps<C>>' is not assignable to type 'Shared<TInjectedProps, GetProps<C>>'.
!!! error TS2344: Type 'P extends keyof TInjectedProps ? TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : TInjectedProps[P] : GetProps<C>[P]' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
!!! error TS2344: Type 'GetProps<C>[P] | (TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : TInjectedProps[P])' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
!!! error TS2344: Type 'GetProps<C>[P]' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
!!! error TS2344: Type 'GetProps<C>[Extract<keyof TInjectedProps, keyof GetProps<C>>]' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
!!! error TS2344: Type 'GetProps<C>[Extract<keyof TInjectedProps, keyof GetProps<C>>]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
!!! error TS2344: Type 'GetProps<C>[P]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
!!! error TS2344: Type 'Extract<keyof TInjectedProps, keyof GetProps<C>> extends keyof TInjectedProps ? TInjectedProps[Extract<keyof TInjectedProps, keyof GetProps<C>>] extends GetProps<C>[Extract<keyof TInjectedProps, keyof GetProps<C>>] ? GetProps<C>[Extract<keyof TInjectedProps, keyof GetProps<C>>] : TInjectedProps[Extract<keyof TInjectedProps, keyof GetProps<C>>] : GetProps<C>[Extract<keyof TInjectedProps, keyof GetProps<C>>]' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
!!! error TS2344: Type 'GetProps<C>[Extract<keyof TInjectedProps, keyof GetProps<C>>] | (TInjectedProps[Extract<keyof TInjectedProps, keyof GetProps<C>>] extends GetProps<C>[Extract<keyof TInjectedProps, keyof GetProps<C>>] ? GetProps<C>[Extract<keyof TInjectedProps, keyof GetProps<C>>] : TInjectedProps[Extract<keyof TInjectedProps, keyof GetProps<C>>])' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
!!! error TS2344: Type 'GetProps<C>[Extract<keyof TInjectedProps, keyof GetProps<C>>]' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
!!! error TS2344: Type 'GetProps<C>[Extract<string, keyof GetProps<C>>] | GetProps<C>[Extract<number, keyof GetProps<C>>] | GetProps<C>[Extract<symbol, keyof GetProps<C>>]' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
!!! error TS2344: Type 'GetProps<C>[Extract<string, keyof GetProps<C>>]' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
!!! error TS2344: Type 'GetProps<C>[keyof GetProps<C> & string]' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
!!! error TS2344: Type 'GetProps<C>[string]' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
!!! error TS2344: Type 'GetProps<C>[string]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
!!! error TS2344: Type 'GetProps<C>[keyof GetProps<C> & string]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
!!! error TS2344: Type 'GetProps<C>[Extract<string, keyof GetProps<C>>]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
!!! error TS2344: Type 'GetProps<C>[Extract<keyof TInjectedProps, keyof GetProps<C>>]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
!!! error TS2344: Type '(Extract<string, keyof GetProps<C>> extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] extends GetProps<C>[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] ? GetProps<C>[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] : TInjectedProps[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] : GetProps<C>[Extract<string, keyof GetProps<C>>]) | (Extract<number, keyof GetProps<C>> extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & Extract<number, keyof GetProps<C>>] extends GetProps<C>[keyof TInjectedProps & Extract<number, keyof GetProps<C>>] ? GetProps<C>[keyof TInjectedProps & Extract<number, keyof GetProps<C>>] : TInjectedProps[keyof TInjectedProps & Extract<number, keyof GetProps<C>>] : GetProps<C>[Extract<number, keyof GetProps<C>>]) | (Extract<symbol, keyof GetProps<C>> extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & Extract<symbol, keyof GetProps<C>>] extends GetProps<C>[keyof TInjectedProps & Extract<symbol, keyof GetProps<C>>] ? GetProps<C>[keyof TInjectedProps & Extract<symbol, keyof GetProps<C>>] : TInjectedProps[keyof TInjectedProps & Extract<symbol, keyof GetProps<C>>] : GetProps<C>[Extract<symbol, keyof GetProps<C>>])' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
!!! error TS2344: Type 'Extract<string, keyof GetProps<C>> extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] extends GetProps<C>[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] ? GetProps<C>[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] : TInjectedProps[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] : GetProps<C>[Extract<string, keyof GetProps<C>>]' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
!!! error TS2344: Type '(TInjectedProps[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] extends GetProps<C>[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] ? GetProps<C>[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] : TInjectedProps[keyof TInjectedProps & Extract<string, keyof GetProps<C>>]) | GetProps<C>[Extract<string, keyof GetProps<C>>]' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] extends GetProps<C>[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] ? GetProps<C>[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] : TInjectedProps[keyof TInjectedProps & Extract<string, keyof GetProps<C>>]' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] | GetProps<C>[keyof TInjectedProps & Extract<string, keyof GetProps<C>>]' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & Extract<string, keyof GetProps<C>>]' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
!!! error TS2344: Type 'TInjectedProps[string]' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
!!! error TS2344: Type 'TInjectedProps[string]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & Extract<string, keyof GetProps<C>>]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] extends GetProps<C>[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] ? GetProps<C>[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] : TInjectedProps[keyof TInjectedProps & Extract<string, keyof GetProps<C>>]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
!!! error TS2344: Type 'keyof GetProps<C> & string extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & keyof GetProps<C> & string] extends GetProps<C>[keyof TInjectedProps & keyof GetProps<C> & string] ? GetProps<C>[keyof TInjectedProps & keyof GetProps<C> & string] : TInjectedProps[keyof TInjectedProps & keyof GetProps<C> & string] : GetProps<C>[keyof GetProps<C> & string]' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
!!! error TS2344: Type '(TInjectedProps[keyof TInjectedProps & keyof GetProps<C> & string] extends GetProps<C>[keyof TInjectedProps & keyof GetProps<C> & string] ? GetProps<C>[keyof TInjectedProps & keyof GetProps<C> & string] : TInjectedProps[keyof TInjectedProps & keyof GetProps<C> & string]) | GetProps<C>[keyof GetProps<C> & string]' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps<C> & string] extends GetProps<C>[keyof TInjectedProps & keyof GetProps<C> & string] ? GetProps<C>[keyof TInjectedProps & keyof GetProps<C> & string] : TInjectedProps[keyof TInjectedProps & keyof GetProps<C> & string]' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps<C> & string] | GetProps<C>[keyof TInjectedProps & keyof GetProps<C> & string]' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps<C> & string]' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
!!! error TS2344: Type 'TInjectedProps[string]' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
!!! error TS2344: Type 'TInjectedProps[string]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps<C> & string]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps<C> & string] extends GetProps<C>[keyof TInjectedProps & keyof GetProps<C> & string] ? GetProps<C>[keyof TInjectedProps & keyof GetProps<C> & string] : TInjectedProps[keyof TInjectedProps & keyof GetProps<C> & string]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
!!! error TS2344: Type 'string extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & string] extends GetProps<C>[keyof TInjectedProps & string] ? GetProps<C>[keyof TInjectedProps & string] : TInjectedProps[keyof TInjectedProps & string] : GetProps<C>[string]' is not assignable to type '(TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never) | undefined'.
!!! error TS2344: Type 'string extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & string] extends GetProps<C>[keyof TInjectedProps & string] ? GetProps<C>[keyof TInjectedProps & string] : TInjectedProps[keyof TInjectedProps & string] : GetProps<C>[string]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
!!! error TS2344: Type 'keyof GetProps<C> & string extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & keyof GetProps<C> & string] extends GetProps<C>[keyof TInjectedProps & keyof GetProps<C> & string] ? GetProps<C>[keyof TInjectedProps & keyof GetProps<C> & string] : TInjectedProps[keyof TInjectedProps & keyof GetProps<C> & string] : GetProps<C>[keyof GetProps<C> & string]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
!!! error TS2344: Type '(TInjectedProps[keyof TInjectedProps & keyof GetProps<C> & string] extends GetProps<C>[keyof TInjectedProps & keyof GetProps<C> & string] ? GetProps<C>[keyof TInjectedProps & keyof GetProps<C> & string] : TInjectedProps[keyof TInjectedProps & keyof GetProps<C> & string]) | GetProps<C>[keyof GetProps<C> & string]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps<C> & string] extends GetProps<C>[keyof TInjectedProps & keyof GetProps<C> & string] ? GetProps<C>[keyof TInjectedProps & keyof GetProps<C> & string] : TInjectedProps[keyof TInjectedProps & keyof GetProps<C> & string]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps<C> & string] | GetProps<C>[keyof TInjectedProps & keyof GetProps<C> & string]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & keyof GetProps<C> & string]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
!!! error TS2344: Type 'TInjectedProps[string]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
!!! error TS2344: Type 'Extract<string, keyof GetProps<C>> extends keyof TInjectedProps ? TInjectedProps[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] extends GetProps<C>[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] ? GetProps<C>[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] : TInjectedProps[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] : GetProps<C>[Extract<string, keyof GetProps<C>>]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
!!! error TS2344: Type '(TInjectedProps[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] extends GetProps<C>[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] ? GetProps<C>[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] : TInjectedProps[keyof TInjectedProps & Extract<string, keyof GetProps<C>>]) | GetProps<C>[Extract<string, keyof GetProps<C>>]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] extends GetProps<C>[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] ? GetProps<C>[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] : TInjectedProps[keyof TInjectedProps & Extract<string, keyof GetProps<C>>]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & Extract<string, keyof GetProps<C>>] | GetProps<C>[keyof TInjectedProps & Extract<string, keyof GetProps<C>>]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
!!! error TS2344: Type 'TInjectedProps[keyof TInjectedProps & Extract<string, keyof GetProps<C>>]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
!!! error TS2344: Type 'TInjectedProps[string]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
!!! error TS2344: Type 'Extract<keyof TInjectedProps, keyof GetProps<C>> extends keyof TInjectedProps ? TInjectedProps[Extract<keyof TInjectedProps, keyof GetProps<C>>] extends GetProps<C>[Extract<keyof TInjectedProps, keyof GetProps<C>>] ? GetProps<C>[Extract<keyof TInjectedProps, keyof GetProps<C>>] : TInjectedProps[Extract<keyof TInjectedProps, keyof GetProps<C>>] : GetProps<C>[Extract<keyof TInjectedProps, keyof GetProps<C>>]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
!!! error TS2344: Type 'GetProps<C>[Extract<keyof TInjectedProps, keyof GetProps<C>>] | (TInjectedProps[Extract<keyof TInjectedProps, keyof GetProps<C>>] extends GetProps<C>[Extract<keyof TInjectedProps, keyof GetProps<C>>] ? GetProps<C>[Extract<keyof TInjectedProps, keyof GetProps<C>>] : TInjectedProps[Extract<keyof TInjectedProps, keyof GetProps<C>>])' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
!!! error TS2344: Type 'GetProps<C>[Extract<keyof TInjectedProps, keyof GetProps<C>>]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
!!! error TS2344: Type 'P extends keyof TInjectedProps ? TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : TInjectedProps[P] : GetProps<C>[P]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
!!! error TS2344: Type 'GetProps<C>[P] | (TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : TInjectedProps[P])' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
!!! error TS2344: Type 'GetProps<C>[P]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
!!! error TS2344: Type 'GetProps<C>[Extract<keyof TInjectedProps, keyof GetProps<C>>]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
!!! error TS2344: Type 'GetProps<C>[Extract<string, keyof GetProps<C>>] | GetProps<C>[Extract<number, keyof GetProps<C>>] | GetProps<C>[Extract<symbol, keyof GetProps<C>>]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
!!! error TS2344: Type 'GetProps<C>[Extract<string, keyof GetProps<C>>]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
!!! error TS2344: Type 'GetProps<C>[keyof GetProps<C> & string]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
!!! error TS2344: Type 'GetProps<C>[string]' is not assignable to type 'TInjectedProps[P] extends GetProps<C>[P] ? GetProps<C>[P] : never'.
@@ -1,9 +1,9 @@
tests/cases/compiler/classUsedBeforeInitializedVariables.ts(4,15): error TS2729: Property 'p4' is used before its initialization.
tests/cases/compiler/classUsedBeforeInitializedVariables.ts(7,34): error TS2729: Property 'directlyAssigned' is used before its initialization.
tests/cases/compiler/classUsedBeforeInitializedVariables.ts(16,15): error TS2729: Property 'withinObjectLiteral' is used before its initialization.
tests/cases/compiler/classUsedBeforeInitializedVariables.ts(20,19): error TS2729: Property 'withinObjectLiteralGetterName' is used before its initialization.
tests/cases/compiler/classUsedBeforeInitializedVariables.ts(26,19): error TS2729: Property 'withinObjectLiteralSetterName' is used before its initialization.
tests/cases/compiler/classUsedBeforeInitializedVariables.ts(29,64): error TS2729: Property 'withinClassDeclarationExtension' is used before its initialization.
tests/cases/compiler/classUsedBeforeInitializedVariables.ts(13,34): error TS2729: Property 'directlyAssigned' is used before its initialization.
tests/cases/compiler/classUsedBeforeInitializedVariables.ts(22,15): error TS2729: Property 'withinObjectLiteral' is used before its initialization.
tests/cases/compiler/classUsedBeforeInitializedVariables.ts(26,19): error TS2729: Property 'withinObjectLiteralGetterName' is used before its initialization.
tests/cases/compiler/classUsedBeforeInitializedVariables.ts(32,19): error TS2729: Property 'withinObjectLiteralSetterName' is used before its initialization.
tests/cases/compiler/classUsedBeforeInitializedVariables.ts(35,64): error TS2729: Property 'withinClassDeclarationExtension' is used before its initialization.
==== tests/cases/compiler/classUsedBeforeInitializedVariables.ts (6 errors) ====
@@ -15,11 +15,17 @@ tests/cases/compiler/classUsedBeforeInitializedVariables.ts(29,64): error TS2729
!!! error TS2729: Property 'p4' is used before its initialization.
!!! related TS2728 tests/cases/compiler/classUsedBeforeInitializedVariables.ts:5:5: 'p4' is declared here.
p4 = 0;
p5?: number;
p6?: string;
p7 = {
hello: (this.p6 = "string"),
};
directlyAssigned: any = this.directlyAssigned;
~~~~~~~~~~~~~~~~
!!! error TS2729: Property 'directlyAssigned' is used before its initialization.
!!! related TS2728 tests/cases/compiler/classUsedBeforeInitializedVariables.ts:7:5: 'directlyAssigned' is declared here.
!!! related TS2728 tests/cases/compiler/classUsedBeforeInitializedVariables.ts:13:5: 'directlyAssigned' is declared here.
withinArrowFunction: any = () => this.withinArrowFunction;
@@ -31,14 +37,14 @@ tests/cases/compiler/classUsedBeforeInitializedVariables.ts(29,64): error TS2729
[this.withinObjectLiteral]: true,
~~~~~~~~~~~~~~~~~~~
!!! error TS2729: Property 'withinObjectLiteral' is used before its initialization.
!!! related TS2728 tests/cases/compiler/classUsedBeforeInitializedVariables.ts:15:5: 'withinObjectLiteral' is declared here.
!!! related TS2728 tests/cases/compiler/classUsedBeforeInitializedVariables.ts:21:5: 'withinObjectLiteral' is declared here.
};
withinObjectLiteralGetterName: any = {
get [this.withinObjectLiteralGetterName]() {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2729: Property 'withinObjectLiteralGetterName' is used before its initialization.
!!! related TS2728 tests/cases/compiler/classUsedBeforeInitializedVariables.ts:19:5: 'withinObjectLiteralGetterName' is declared here.
!!! related TS2728 tests/cases/compiler/classUsedBeforeInitializedVariables.ts:25:5: 'withinObjectLiteralGetterName' is declared here.
return true;
}
};
@@ -47,13 +53,15 @@ tests/cases/compiler/classUsedBeforeInitializedVariables.ts(29,64): error TS2729
set [this.withinObjectLiteralSetterName](_: any) {}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2729: Property 'withinObjectLiteralSetterName' is used before its initialization.
!!! related TS2728 tests/cases/compiler/classUsedBeforeInitializedVariables.ts:25:5: 'withinObjectLiteralSetterName' is declared here.
!!! related TS2728 tests/cases/compiler/classUsedBeforeInitializedVariables.ts:31:5: 'withinObjectLiteralSetterName' is declared here.
};
withinClassDeclarationExtension: any = (class extends this.withinClassDeclarationExtension { });
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2729: Property 'withinClassDeclarationExtension' is used before its initialization.
!!! related TS2728 tests/cases/compiler/classUsedBeforeInitializedVariables.ts:29:5: 'withinClassDeclarationExtension' is declared here.
!!! related TS2728 tests/cases/compiler/classUsedBeforeInitializedVariables.ts:35:5: 'withinClassDeclarationExtension' is declared here.
fromOptional = this.p5;
// These error cases are ignored (not checked by control flow analysis)
@@ -4,6 +4,12 @@ class Test {
p2 = this.p1;
p3 = this.p4;
p4 = 0;
p5?: number;
p6?: string;
p7 = {
hello: (this.p6 = "string"),
};
directlyAssigned: any = this.directlyAssigned;
@@ -29,6 +35,8 @@ class Test {
withinClassDeclarationExtension: any = (class extends this.withinClassDeclarationExtension { });
fromOptional = this.p5;
// These error cases are ignored (not checked by control flow analysis)
assignedByArrowFunction: any = (() => this.assignedByFunction)();
@@ -63,6 +71,9 @@ var Test = /** @class */ (function () {
this.p2 = this.p1;
this.p3 = this.p4;
this.p4 = 0;
this.p7 = {
hello: (this.p6 = "string"),
};
this.directlyAssigned = this.directlyAssigned;
this.withinArrowFunction = function () { return _this.withinArrowFunction; };
this.withinFunction = function () {
@@ -94,6 +105,7 @@ var Test = /** @class */ (function () {
}
return class_1;
}(this.withinClassDeclarationExtension)));
this.fromOptional = this.p5;
// These error cases are ignored (not checked by control flow analysis)
this.assignedByArrowFunction = (function () { return _this.assignedByFunction; })();
this.assignedByFunction = (function () {
@@ -20,76 +20,99 @@ class Test {
p4 = 0;
>p4 : Symbol(Test.p4, Decl(classUsedBeforeInitializedVariables.ts, 3, 17))
directlyAssigned: any = this.directlyAssigned;
>directlyAssigned : Symbol(Test.directlyAssigned, Decl(classUsedBeforeInitializedVariables.ts, 4, 11))
>this.directlyAssigned : Symbol(Test.directlyAssigned, Decl(classUsedBeforeInitializedVariables.ts, 4, 11))
p5?: number;
>p5 : Symbol(Test.p5, Decl(classUsedBeforeInitializedVariables.ts, 4, 11))
p6?: string;
>p6 : Symbol(Test.p6, Decl(classUsedBeforeInitializedVariables.ts, 5, 16))
p7 = {
>p7 : Symbol(Test.p7, Decl(classUsedBeforeInitializedVariables.ts, 7, 16))
hello: (this.p6 = "string"),
>hello : Symbol(hello, Decl(classUsedBeforeInitializedVariables.ts, 8, 10))
>this.p6 : Symbol(Test.p6, Decl(classUsedBeforeInitializedVariables.ts, 5, 16))
>this : Symbol(Test, Decl(classUsedBeforeInitializedVariables.ts, 0, 0))
>directlyAssigned : Symbol(Test.directlyAssigned, Decl(classUsedBeforeInitializedVariables.ts, 4, 11))
>p6 : Symbol(Test.p6, Decl(classUsedBeforeInitializedVariables.ts, 5, 16))
};
directlyAssigned: any = this.directlyAssigned;
>directlyAssigned : Symbol(Test.directlyAssigned, Decl(classUsedBeforeInitializedVariables.ts, 10, 6))
>this.directlyAssigned : Symbol(Test.directlyAssigned, Decl(classUsedBeforeInitializedVariables.ts, 10, 6))
>this : Symbol(Test, Decl(classUsedBeforeInitializedVariables.ts, 0, 0))
>directlyAssigned : Symbol(Test.directlyAssigned, Decl(classUsedBeforeInitializedVariables.ts, 10, 6))
withinArrowFunction: any = () => this.withinArrowFunction;
>withinArrowFunction : Symbol(Test.withinArrowFunction, Decl(classUsedBeforeInitializedVariables.ts, 6, 50))
>this.withinArrowFunction : Symbol(Test.withinArrowFunction, Decl(classUsedBeforeInitializedVariables.ts, 6, 50))
>withinArrowFunction : Symbol(Test.withinArrowFunction, Decl(classUsedBeforeInitializedVariables.ts, 12, 50))
>this.withinArrowFunction : Symbol(Test.withinArrowFunction, Decl(classUsedBeforeInitializedVariables.ts, 12, 50))
>this : Symbol(Test, Decl(classUsedBeforeInitializedVariables.ts, 0, 0))
>withinArrowFunction : Symbol(Test.withinArrowFunction, Decl(classUsedBeforeInitializedVariables.ts, 6, 50))
>withinArrowFunction : Symbol(Test.withinArrowFunction, Decl(classUsedBeforeInitializedVariables.ts, 12, 50))
withinFunction: any = function () {
>withinFunction : Symbol(Test.withinFunction, Decl(classUsedBeforeInitializedVariables.ts, 8, 62))
>withinFunction : Symbol(Test.withinFunction, Decl(classUsedBeforeInitializedVariables.ts, 14, 62))
return this.withinFunction;
};
withinObjectLiteral: any = {
>withinObjectLiteral : Symbol(Test.withinObjectLiteral, Decl(classUsedBeforeInitializedVariables.ts, 12, 6))
>withinObjectLiteral : Symbol(Test.withinObjectLiteral, Decl(classUsedBeforeInitializedVariables.ts, 18, 6))
[this.withinObjectLiteral]: true,
>[this.withinObjectLiteral] : Symbol([this.withinObjectLiteral], Decl(classUsedBeforeInitializedVariables.ts, 14, 32))
>this.withinObjectLiteral : Symbol(Test.withinObjectLiteral, Decl(classUsedBeforeInitializedVariables.ts, 12, 6))
>[this.withinObjectLiteral] : Symbol([this.withinObjectLiteral], Decl(classUsedBeforeInitializedVariables.ts, 20, 32))
>this.withinObjectLiteral : Symbol(Test.withinObjectLiteral, Decl(classUsedBeforeInitializedVariables.ts, 18, 6))
>this : Symbol(Test, Decl(classUsedBeforeInitializedVariables.ts, 0, 0))
>withinObjectLiteral : Symbol(Test.withinObjectLiteral, Decl(classUsedBeforeInitializedVariables.ts, 12, 6))
>withinObjectLiteral : Symbol(Test.withinObjectLiteral, Decl(classUsedBeforeInitializedVariables.ts, 18, 6))
};
withinObjectLiteralGetterName: any = {
>withinObjectLiteralGetterName : Symbol(Test.withinObjectLiteralGetterName, Decl(classUsedBeforeInitializedVariables.ts, 16, 6))
>withinObjectLiteralGetterName : Symbol(Test.withinObjectLiteralGetterName, Decl(classUsedBeforeInitializedVariables.ts, 22, 6))
get [this.withinObjectLiteralGetterName]() {
>[this.withinObjectLiteralGetterName] : Symbol([this.withinObjectLiteralGetterName], Decl(classUsedBeforeInitializedVariables.ts, 18, 42))
>this.withinObjectLiteralGetterName : Symbol(Test.withinObjectLiteralGetterName, Decl(classUsedBeforeInitializedVariables.ts, 16, 6))
>[this.withinObjectLiteralGetterName] : Symbol([this.withinObjectLiteralGetterName], Decl(classUsedBeforeInitializedVariables.ts, 24, 42))
>this.withinObjectLiteralGetterName : Symbol(Test.withinObjectLiteralGetterName, Decl(classUsedBeforeInitializedVariables.ts, 22, 6))
>this : Symbol(Test, Decl(classUsedBeforeInitializedVariables.ts, 0, 0))
>withinObjectLiteralGetterName : Symbol(Test.withinObjectLiteralGetterName, Decl(classUsedBeforeInitializedVariables.ts, 16, 6))
>withinObjectLiteralGetterName : Symbol(Test.withinObjectLiteralGetterName, Decl(classUsedBeforeInitializedVariables.ts, 22, 6))
return true;
}
};
withinObjectLiteralSetterName: any = {
>withinObjectLiteralSetterName : Symbol(Test.withinObjectLiteralSetterName, Decl(classUsedBeforeInitializedVariables.ts, 22, 6))
>withinObjectLiteralSetterName : Symbol(Test.withinObjectLiteralSetterName, Decl(classUsedBeforeInitializedVariables.ts, 28, 6))
set [this.withinObjectLiteralSetterName](_: any) {}
>[this.withinObjectLiteralSetterName] : Symbol([this.withinObjectLiteralSetterName], Decl(classUsedBeforeInitializedVariables.ts, 24, 42))
>this.withinObjectLiteralSetterName : Symbol(Test.withinObjectLiteralSetterName, Decl(classUsedBeforeInitializedVariables.ts, 22, 6))
>[this.withinObjectLiteralSetterName] : Symbol([this.withinObjectLiteralSetterName], Decl(classUsedBeforeInitializedVariables.ts, 30, 42))
>this.withinObjectLiteralSetterName : Symbol(Test.withinObjectLiteralSetterName, Decl(classUsedBeforeInitializedVariables.ts, 28, 6))
>this : Symbol(Test, Decl(classUsedBeforeInitializedVariables.ts, 0, 0))
>withinObjectLiteralSetterName : Symbol(Test.withinObjectLiteralSetterName, Decl(classUsedBeforeInitializedVariables.ts, 22, 6))
>_ : Symbol(_, Decl(classUsedBeforeInitializedVariables.ts, 25, 49))
>withinObjectLiteralSetterName : Symbol(Test.withinObjectLiteralSetterName, Decl(classUsedBeforeInitializedVariables.ts, 28, 6))
>_ : Symbol(_, Decl(classUsedBeforeInitializedVariables.ts, 31, 49))
};
withinClassDeclarationExtension: any = (class extends this.withinClassDeclarationExtension { });
>withinClassDeclarationExtension : Symbol(Test.withinClassDeclarationExtension, Decl(classUsedBeforeInitializedVariables.ts, 26, 6))
>this.withinClassDeclarationExtension : Symbol(Test.withinClassDeclarationExtension, Decl(classUsedBeforeInitializedVariables.ts, 26, 6))
>withinClassDeclarationExtension : Symbol(Test.withinClassDeclarationExtension, Decl(classUsedBeforeInitializedVariables.ts, 32, 6))
>this.withinClassDeclarationExtension : Symbol(Test.withinClassDeclarationExtension, Decl(classUsedBeforeInitializedVariables.ts, 32, 6))
>this : Symbol(Test, Decl(classUsedBeforeInitializedVariables.ts, 0, 0))
>withinClassDeclarationExtension : Symbol(Test.withinClassDeclarationExtension, Decl(classUsedBeforeInitializedVariables.ts, 26, 6))
>withinClassDeclarationExtension : Symbol(Test.withinClassDeclarationExtension, Decl(classUsedBeforeInitializedVariables.ts, 32, 6))
fromOptional = this.p5;
>fromOptional : Symbol(Test.fromOptional, Decl(classUsedBeforeInitializedVariables.ts, 34, 100))
>this.p5 : Symbol(Test.p5, Decl(classUsedBeforeInitializedVariables.ts, 4, 11))
>this : Symbol(Test, Decl(classUsedBeforeInitializedVariables.ts, 0, 0))
>p5 : Symbol(Test.p5, Decl(classUsedBeforeInitializedVariables.ts, 4, 11))
// These error cases are ignored (not checked by control flow analysis)
assignedByArrowFunction: any = (() => this.assignedByFunction)();
>assignedByArrowFunction : Symbol(Test.assignedByArrowFunction, Decl(classUsedBeforeInitializedVariables.ts, 28, 100))
>this.assignedByFunction : Symbol(Test.assignedByFunction, Decl(classUsedBeforeInitializedVariables.ts, 32, 69))
>assignedByArrowFunction : Symbol(Test.assignedByArrowFunction, Decl(classUsedBeforeInitializedVariables.ts, 36, 27))
>this.assignedByFunction : Symbol(Test.assignedByFunction, Decl(classUsedBeforeInitializedVariables.ts, 40, 69))
>this : Symbol(Test, Decl(classUsedBeforeInitializedVariables.ts, 0, 0))
>assignedByFunction : Symbol(Test.assignedByFunction, Decl(classUsedBeforeInitializedVariables.ts, 32, 69))
>assignedByFunction : Symbol(Test.assignedByFunction, Decl(classUsedBeforeInitializedVariables.ts, 40, 69))
assignedByFunction: any = (function () {
>assignedByFunction : Symbol(Test.assignedByFunction, Decl(classUsedBeforeInitializedVariables.ts, 32, 69))
>assignedByFunction : Symbol(Test.assignedByFunction, Decl(classUsedBeforeInitializedVariables.ts, 40, 69))
return this.assignedByFunction;
})();
@@ -22,6 +22,27 @@ class Test {
>p4 : number
>0 : 0
p5?: number;
>p5 : number
p6?: string;
>p6 : string
p7 = {
>p7 : { hello: string; }
>{ hello: (this.p6 = "string"), } : { hello: string; }
hello: (this.p6 = "string"),
>hello : string
>(this.p6 = "string") : "string"
>this.p6 = "string" : "string"
>this.p6 : string
>this : this
>p6 : string
>"string" : "string"
};
directlyAssigned: any = this.directlyAssigned;
>directlyAssigned : any
>this.directlyAssigned : any
@@ -95,6 +116,12 @@ class Test {
>this : this
>withinClassDeclarationExtension : any
fromOptional = this.p5;
>fromOptional : number
>this.p5 : number
>this : this
>p5 : number
// These error cases are ignored (not checked by control flow analysis)
assignedByArrowFunction: any = (() => this.assignedByFunction)();
@@ -0,0 +1,20 @@
=== /bar.js ===
const { a } = require("./foo");
>a : Symbol(a, Decl(bar.js, 0, 7))
>require : Symbol(require)
>"./foo" : Symbol("/foo", Decl(foo.d.ts, 0, 0))
if (a) {
>a : Symbol(a, Decl(bar.js, 0, 7))
var x = a + 1;
>x : Symbol(x, Decl(bar.js, 2, 5))
>a : Symbol(a, Decl(bar.js, 0, 7))
}
=== /foo.d.ts ===
// Regresion test for GH#41957
export const a: number | null;
>a : Symbol(a, Decl(foo.d.ts, 3, 12))
@@ -0,0 +1,24 @@
=== /bar.js ===
const { a } = require("./foo");
>a : number | null
>require("./foo") : typeof import("/foo")
>require : any
>"./foo" : "./foo"
if (a) {
>a : number | null
var x = a + 1;
>x : number
>a + 1 : number
>a : number
>1 : 1
}
=== /foo.d.ts ===
// Regresion test for GH#41957
export const a: number | null;
>a : number | null
>null : null
@@ -121,6 +121,7 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS
if (retValue != 0 ^= {
~~
!!! error TS1005: ')' expected.
!!! related TS1007 tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts:22:20: The parser expected to find a ')' to match the '(' token here.
~
@@ -0,0 +1,56 @@
//// [declarationEmitOverloadedPrivateInference.ts]
function noArgs(): string {
return null as any;
}
function oneArg(input: string): string {
return null as any;
}
export class Wrapper {
private proxy<T, U>(fn: (options: T) => U): (options: T) => U;
private proxy<T, U>(fn: (options?: T) => U, noArgs: true): (options?: T) => U;
private proxy<T, U>(fn: (options: T) => U) {
return null as any;
}
public Proxies = {
Failure: this.proxy(noArgs, true),
Success: this.proxy(oneArg),
};
}
//// [declarationEmitOverloadedPrivateInference.js]
"use strict";
exports.__esModule = true;
exports.Wrapper = void 0;
function noArgs() {
return null;
}
function oneArg(input) {
return null;
}
var Wrapper = /** @class */ (function () {
function Wrapper() {
this.Proxies = {
Failure: this.proxy(noArgs, true),
Success: this.proxy(oneArg)
};
}
Wrapper.prototype.proxy = function (fn) {
return null;
};
return Wrapper;
}());
exports.Wrapper = Wrapper;
//// [declarationEmitOverloadedPrivateInference.d.ts]
export declare class Wrapper {
private proxy;
Proxies: {
Failure: (options?: unknown) => string;
Success: (options: string) => string;
};
}
@@ -0,0 +1,73 @@
=== tests/cases/compiler/declarationEmitOverloadedPrivateInference.ts ===
function noArgs(): string {
>noArgs : Symbol(noArgs, Decl(declarationEmitOverloadedPrivateInference.ts, 0, 0))
return null as any;
}
function oneArg(input: string): string {
>oneArg : Symbol(oneArg, Decl(declarationEmitOverloadedPrivateInference.ts, 2, 1))
>input : Symbol(input, Decl(declarationEmitOverloadedPrivateInference.ts, 4, 16))
return null as any;
}
export class Wrapper {
>Wrapper : Symbol(Wrapper, Decl(declarationEmitOverloadedPrivateInference.ts, 6, 1))
private proxy<T, U>(fn: (options: T) => U): (options: T) => U;
>proxy : Symbol(Wrapper.proxy, Decl(declarationEmitOverloadedPrivateInference.ts, 8, 22), Decl(declarationEmitOverloadedPrivateInference.ts, 9, 66), Decl(declarationEmitOverloadedPrivateInference.ts, 10, 82))
>T : Symbol(T, Decl(declarationEmitOverloadedPrivateInference.ts, 9, 18))
>U : Symbol(U, Decl(declarationEmitOverloadedPrivateInference.ts, 9, 20))
>fn : Symbol(fn, Decl(declarationEmitOverloadedPrivateInference.ts, 9, 24))
>options : Symbol(options, Decl(declarationEmitOverloadedPrivateInference.ts, 9, 29))
>T : Symbol(T, Decl(declarationEmitOverloadedPrivateInference.ts, 9, 18))
>U : Symbol(U, Decl(declarationEmitOverloadedPrivateInference.ts, 9, 20))
>options : Symbol(options, Decl(declarationEmitOverloadedPrivateInference.ts, 9, 49))
>T : Symbol(T, Decl(declarationEmitOverloadedPrivateInference.ts, 9, 18))
>U : Symbol(U, Decl(declarationEmitOverloadedPrivateInference.ts, 9, 20))
private proxy<T, U>(fn: (options?: T) => U, noArgs: true): (options?: T) => U;
>proxy : Symbol(Wrapper.proxy, Decl(declarationEmitOverloadedPrivateInference.ts, 8, 22), Decl(declarationEmitOverloadedPrivateInference.ts, 9, 66), Decl(declarationEmitOverloadedPrivateInference.ts, 10, 82))
>T : Symbol(T, Decl(declarationEmitOverloadedPrivateInference.ts, 10, 18))
>U : Symbol(U, Decl(declarationEmitOverloadedPrivateInference.ts, 10, 20))
>fn : Symbol(fn, Decl(declarationEmitOverloadedPrivateInference.ts, 10, 24))
>options : Symbol(options, Decl(declarationEmitOverloadedPrivateInference.ts, 10, 29))
>T : Symbol(T, Decl(declarationEmitOverloadedPrivateInference.ts, 10, 18))
>U : Symbol(U, Decl(declarationEmitOverloadedPrivateInference.ts, 10, 20))
>noArgs : Symbol(noArgs, Decl(declarationEmitOverloadedPrivateInference.ts, 10, 47))
>options : Symbol(options, Decl(declarationEmitOverloadedPrivateInference.ts, 10, 64))
>T : Symbol(T, Decl(declarationEmitOverloadedPrivateInference.ts, 10, 18))
>U : Symbol(U, Decl(declarationEmitOverloadedPrivateInference.ts, 10, 20))
private proxy<T, U>(fn: (options: T) => U) {
>proxy : Symbol(Wrapper.proxy, Decl(declarationEmitOverloadedPrivateInference.ts, 8, 22), Decl(declarationEmitOverloadedPrivateInference.ts, 9, 66), Decl(declarationEmitOverloadedPrivateInference.ts, 10, 82))
>T : Symbol(T, Decl(declarationEmitOverloadedPrivateInference.ts, 12, 18))
>U : Symbol(U, Decl(declarationEmitOverloadedPrivateInference.ts, 12, 20))
>fn : Symbol(fn, Decl(declarationEmitOverloadedPrivateInference.ts, 12, 24))
>options : Symbol(options, Decl(declarationEmitOverloadedPrivateInference.ts, 12, 29))
>T : Symbol(T, Decl(declarationEmitOverloadedPrivateInference.ts, 12, 18))
>U : Symbol(U, Decl(declarationEmitOverloadedPrivateInference.ts, 12, 20))
return null as any;
}
public Proxies = {
>Proxies : Symbol(Wrapper.Proxies, Decl(declarationEmitOverloadedPrivateInference.ts, 14, 5))
Failure: this.proxy(noArgs, true),
>Failure : Symbol(Failure, Decl(declarationEmitOverloadedPrivateInference.ts, 16, 22))
>this.proxy : Symbol(Wrapper.proxy, Decl(declarationEmitOverloadedPrivateInference.ts, 8, 22), Decl(declarationEmitOverloadedPrivateInference.ts, 9, 66), Decl(declarationEmitOverloadedPrivateInference.ts, 10, 82))
>this : Symbol(Wrapper, Decl(declarationEmitOverloadedPrivateInference.ts, 6, 1))
>proxy : Symbol(Wrapper.proxy, Decl(declarationEmitOverloadedPrivateInference.ts, 8, 22), Decl(declarationEmitOverloadedPrivateInference.ts, 9, 66), Decl(declarationEmitOverloadedPrivateInference.ts, 10, 82))
>noArgs : Symbol(noArgs, Decl(declarationEmitOverloadedPrivateInference.ts, 0, 0))
Success: this.proxy(oneArg),
>Success : Symbol(Success, Decl(declarationEmitOverloadedPrivateInference.ts, 17, 42))
>this.proxy : Symbol(Wrapper.proxy, Decl(declarationEmitOverloadedPrivateInference.ts, 8, 22), Decl(declarationEmitOverloadedPrivateInference.ts, 9, 66), Decl(declarationEmitOverloadedPrivateInference.ts, 10, 82))
>this : Symbol(Wrapper, Decl(declarationEmitOverloadedPrivateInference.ts, 6, 1))
>proxy : Symbol(Wrapper.proxy, Decl(declarationEmitOverloadedPrivateInference.ts, 8, 22), Decl(declarationEmitOverloadedPrivateInference.ts, 9, 66), Decl(declarationEmitOverloadedPrivateInference.ts, 10, 82))
>oneArg : Symbol(oneArg, Decl(declarationEmitOverloadedPrivateInference.ts, 2, 1))
};
}
@@ -0,0 +1,68 @@
=== tests/cases/compiler/declarationEmitOverloadedPrivateInference.ts ===
function noArgs(): string {
>noArgs : () => string
return null as any;
>null as any : any
>null : null
}
function oneArg(input: string): string {
>oneArg : (input: string) => string
>input : string
return null as any;
>null as any : any
>null : null
}
export class Wrapper {
>Wrapper : Wrapper
private proxy<T, U>(fn: (options: T) => U): (options: T) => U;
>proxy : { <T, U>(fn: (options: T) => U): (options: T) => U; <T, U>(fn: (options?: T) => U, noArgs: true): (options?: T) => U; }
>fn : (options: T) => U
>options : T
>options : T
private proxy<T, U>(fn: (options?: T) => U, noArgs: true): (options?: T) => U;
>proxy : { <T, U>(fn: (options: T) => U): (options: T) => U; <T, U>(fn: (options?: T) => U, noArgs: true): (options?: T) => U; }
>fn : (options?: T) => U
>options : T
>noArgs : true
>true : true
>options : T
private proxy<T, U>(fn: (options: T) => U) {
>proxy : { <T, U>(fn: (options: T) => U): (options: T) => U; <T, U>(fn: (options?: T) => U, noArgs: true): (options?: T) => U; }
>fn : (options: T) => U
>options : T
return null as any;
>null as any : any
>null : null
}
public Proxies = {
>Proxies : { Failure: (options?: unknown) => string; Success: (options: string) => string; }
>{ Failure: this.proxy(noArgs, true), Success: this.proxy(oneArg), } : { Failure: (options?: unknown) => string; Success: (options: string) => string; }
Failure: this.proxy(noArgs, true),
>Failure : (options?: unknown) => string
>this.proxy(noArgs, true) : (options?: unknown) => string
>this.proxy : { <T, U>(fn: (options: T) => U): (options: T) => U; <T, U>(fn: (options?: T) => U, noArgs: true): (options?: T) => U; }
>this : this
>proxy : { <T, U>(fn: (options: T) => U): (options: T) => U; <T, U>(fn: (options?: T) => U, noArgs: true): (options?: T) => U; }
>noArgs : () => string
>true : true
Success: this.proxy(oneArg),
>Success : (options: string) => string
>this.proxy(oneArg) : (options: string) => string
>this.proxy : { <T, U>(fn: (options: T) => U): (options: T) => U; <T, U>(fn: (options?: T) => U, noArgs: true): (options?: T) => U; }
>this : this
>proxy : { <T, U>(fn: (options: T) => U): (options: T) => U; <T, U>(fn: (options?: T) => U, noArgs: true): (options?: T) => U; }
>oneArg : (input: string) => string
};
}
@@ -38,13 +38,13 @@ export const updateIfChanged = <T>(t: T) => {
>newU : U
return Object.assign(
>Object.assign( <K extends Key<U>>(key: K) => reduce<Value<K, U>>(u[key as keyof U] as Value<K, U>, (v: Value<K, U>) => { return update(Object.assign(Array.isArray(u) ? [] : {}, u, { [key]: v })); }), { map: (updater: (u: U) => U) => set(updater(u)), set }) : (<K extends keyof U>(key: K) => (<K extends keyof Value<K, U>>(key: K) => (<K extends keyof Value<K, Value<K, U>>>(key: K) => (<K extends keyof Value<K, Value<K, Value<K, U>>>>(key: K) => (<K extends keyof Value<K, Value<K, Value<K, Value<K, U>>>>>(key: K) => (<K extends keyof Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>(key: K) => (<K extends keyof Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>(key: K) => (<K extends keyof Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>(key: K) => (<K extends keyof Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>>(key: K) => (<K extends keyof Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>>>(key: K) => (<K extends keyof Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>>>>(key: K) => any & { map: (updater: (u: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>>>>) => U) => T; set: (newU: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>>>>) => T; }) & { map: (updater: (u: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>>>) => U) => T; set: (newU: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>>>) => T; }) & { map: (updater: (u: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>>) => U) => T; set: (newU: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>>) => T; }) & { map: (updater: (u: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>) => U) => T; set: (newU: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>) => T; }) & { map: (updater: (u: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>) => U) => T; set: (newU: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>) => T; }) & { map: (updater: (u: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>) => U) => T; set: (newU: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>) => T; }) & { map: (updater: (u: Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>) => U) => T; set: (newU: Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>) => T; }) & { map: (updater: (u: Value<K, Value<K, Value<K, Value<K, U>>>>) => U) => T; set: (newU: Value<K, Value<K, Value<K, Value<K, U>>>>) => T; }) & { map: (updater: (u: Value<K, Value<K, Value<K, U>>>) => U) => T; set: (newU: Value<K, Value<K, Value<K, U>>>) => T; }) & { map: (updater: (u: Value<K, Value<K, U>>) => U) => T; set: (newU: Value<K, Value<K, U>>) => T; }) & { map: (updater: (u: Value<K, U>) => U) => T; set: (newU: Value<K, U>) => T; }) & { map: (updater: (u: U) => U) => T; set: (newU: U) => T; }
>Object.assign( <K extends Key<U>>(key: K) => reduce<Value<K, U>>(u[key as keyof U] as Value<K, U>, (v: Value<K, U>) => { return update(Object.assign(Array.isArray(u) ? [] : {}, u, { [key]: v })); }), { map: (updater: (u: U) => U) => set(updater(u)), set }) : (<K extends keyof U>(key: K) => (<K extends keyof Value<K, U>>(key: K) => (<K extends keyof Value<K, Value<K, U>>>(key: K) => (<K extends keyof Value<K, Value<K, Value<K, U>>>>(key: K) => (<K extends keyof Value<K, Value<K, Value<K, Value<K, U>>>>>(key: K) => (<K extends keyof Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>(key: K) => (<K extends keyof Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>(key: K) => (<K extends keyof Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>(key: K) => (<K extends keyof Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>>(key: K) => (<K extends keyof Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>>>(key: K) => (<K extends keyof Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>>>>(key: K) => any & { map: (updater: (u: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>>>>) => Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>>>>) => T; set: (newU: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>>>>) => T; }) & { map: (updater: (u: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>>>) => Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>>>) => T; set: (newU: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>>>) => T; }) & { map: (updater: (u: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>>) => Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>>) => T; set: (newU: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>>) => T; }) & { map: (updater: (u: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>) => Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>) => T; set: (newU: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>) => T; }) & { map: (updater: (u: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>) => Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>) => T; set: (newU: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>) => T; }) & { map: (updater: (u: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>) => Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>) => T; set: (newU: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>) => T; }) & { map: (updater: (u: Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>) => Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>) => T; set: (newU: Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>) => T; }) & { map: (updater: (u: Value<K, Value<K, Value<K, Value<K, U>>>>) => Value<K, Value<K, Value<K, Value<K, U>>>>) => T; set: (newU: Value<K, Value<K, Value<K, Value<K, U>>>>) => T; }) & { map: (updater: (u: Value<K, Value<K, Value<K, U>>>) => Value<K, Value<K, Value<K, U>>>) => T; set: (newU: Value<K, Value<K, Value<K, U>>>) => T; }) & { map: (updater: (u: Value<K, Value<K, U>>) => Value<K, Value<K, U>>) => T; set: (newU: Value<K, Value<K, U>>) => T; }) & { map: (updater: (u: Value<K, U>) => Value<K, U>) => T; set: (newU: Value<K, U>) => T; }) & { map: (updater: (u: U) => U) => T; set: (newU: U) => T; }
>Object.assign : { <T, U>(target: T, source: U): T & U; <T, U, V>(target: T, source1: U, source2: V): T & U & V; <T, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W; (target: object, ...sources: any[]): any; }
>Object : ObjectConstructor
>assign : { <T, U>(target: T, source: U): T & U; <T, U, V>(target: T, source1: U, source2: V): T & U & V; <T, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W; (target: object, ...sources: any[]): any; }
<K extends Key<U>>(key: K) =>
><K extends Key<U>>(key: K) => reduce<Value<K, U>>(u[key as keyof U] as Value<K, U>, (v: Value<K, U>) => { return update(Object.assign(Array.isArray(u) ? [] : {}, u, { [key]: v })); }) : <K extends keyof U>(key: K) => (<K extends keyof Value<K, U>>(key: K) => (<K extends keyof Value<K, Value<K, U>>>(key: K) => (<K extends keyof Value<K, Value<K, Value<K, U>>>>(key: K) => (<K extends keyof Value<K, Value<K, Value<K, Value<K, U>>>>>(key: K) => (<K extends keyof Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>(key: K) => (<K extends keyof Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>(key: K) => (<K extends keyof Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>(key: K) => (<K extends keyof Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>>(key: K) => (<K extends keyof Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>>>(key: K) => (<K extends keyof Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>>>>(key: K) => any & { map: (updater: (u: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>>>>) => U) => T; set: (newU: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>>>>) => T; }) & { map: (updater: (u: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>>>) => U) => T; set: (newU: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>>>) => T; }) & { map: (updater: (u: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>>) => U) => T; set: (newU: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>>) => T; }) & { map: (updater: (u: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>) => U) => T; set: (newU: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>) => T; }) & { map: (updater: (u: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>) => U) => T; set: (newU: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>) => T; }) & { map: (updater: (u: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>) => U) => T; set: (newU: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>) => T; }) & { map: (updater: (u: Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>) => U) => T; set: (newU: Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>) => T; }) & { map: (updater: (u: Value<K, Value<K, Value<K, Value<K, U>>>>) => U) => T; set: (newU: Value<K, Value<K, Value<K, Value<K, U>>>>) => T; }) & { map: (updater: (u: Value<K, Value<K, Value<K, U>>>) => U) => T; set: (newU: Value<K, Value<K, Value<K, U>>>) => T; }) & { map: (updater: (u: Value<K, Value<K, U>>) => U) => T; set: (newU: Value<K, Value<K, U>>) => T; }) & { map: (updater: (u: Value<K, U>) => U) => T; set: (newU: Value<K, U>) => T; }
><K extends Key<U>>(key: K) => reduce<Value<K, U>>(u[key as keyof U] as Value<K, U>, (v: Value<K, U>) => { return update(Object.assign(Array.isArray(u) ? [] : {}, u, { [key]: v })); }) : <K extends keyof U>(key: K) => (<K extends keyof Value<K, U>>(key: K) => (<K extends keyof Value<K, Value<K, U>>>(key: K) => (<K extends keyof Value<K, Value<K, Value<K, U>>>>(key: K) => (<K extends keyof Value<K, Value<K, Value<K, Value<K, U>>>>>(key: K) => (<K extends keyof Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>(key: K) => (<K extends keyof Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>(key: K) => (<K extends keyof Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>(key: K) => (<K extends keyof Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>>(key: K) => (<K extends keyof Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>>>(key: K) => (<K extends keyof Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>>>>(key: K) => any & { map: (updater: (u: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>>>>) => Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>>>>) => T; set: (newU: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>>>>) => T; }) & { map: (updater: (u: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>>>) => Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>>>) => T; set: (newU: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>>>) => T; }) & { map: (updater: (u: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>>) => Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>>) => T; set: (newU: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>>) => T; }) & { map: (updater: (u: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>) => Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>) => T; set: (newU: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>>) => T; }) & { map: (updater: (u: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>) => Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>) => T; set: (newU: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>>) => T; }) & { map: (updater: (u: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>) => Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>) => T; set: (newU: Value<K, Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>>) => T; }) & { map: (updater: (u: Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>) => Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>) => T; set: (newU: Value<K, Value<K, Value<K, Value<K, Value<K, U>>>>>) => T; }) & { map: (updater: (u: Value<K, Value<K, Value<K, Value<K, U>>>>) => Value<K, Value<K, Value<K, Value<K, U>>>>) => T; set: (newU: Value<K, Value<K, Value<K, Value<K, U>>>>) => T; }) & { map: (updater: (u: Value<K, Value<K, Value<K, U>>>) => Value<K, Value<K, Value<K, U>>>) => T; set: (newU: Value<K, Value<K, Value<K, U>>>) => T; }) & { map: (updater: (u: Value<K, Value<K, U>>) => Value<K, Value<K, U>>) => T; set: (newU: Value<K, Value<K, U>>) => T; }) & { map: (updater: (u: Value<K, U>) => Value<K, U>) => T; set: (newU: Value<K, U>) => T; }
>key : K
reduce<Value<K, U>>(u[key as keyof U] as Value<K, U>, (v: Value<K, U>) => {
@@ -0,0 +1,27 @@
tests/cases/compiler/destructionAssignmentError.ts(6,3): error TS2695: Left side of comma operator is unused and has no side effects.
tests/cases/compiler/destructionAssignmentError.ts(6,10): error TS2809: Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses.
tests/cases/compiler/destructionAssignmentError.ts(11,3): error TS2695: Left side of comma operator is unused and has no side effects.
tests/cases/compiler/destructionAssignmentError.ts(12,1): error TS2809: Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses.
==== tests/cases/compiler/destructionAssignmentError.ts (4 errors) ====
declare function fn(): { a: 1, b: 2 }
let a: number;
let b: number;
({ a, b } = fn());
{ a, b } = fn();
~
!!! error TS2695: Left side of comma operator is unused and has no side effects.
~
!!! error TS2809: Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses.
({ a, b } =
fn());
{ a, b }
~
!!! error TS2695: Left side of comma operator is unused and has no side effects.
= fn();
~
!!! error TS2809: Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses.
@@ -0,0 +1,28 @@
//// [destructionAssignmentError.ts]
declare function fn(): { a: 1, b: 2 }
let a: number;
let b: number;
({ a, b } = fn());
{ a, b } = fn();
({ a, b } =
fn());
{ a, b }
= fn();
//// [destructionAssignmentError.js]
var _a, _b;
var a;
var b;
(_a = fn(), a = _a.a, b = _a.b);
{
a, b;
}
fn();
(_b = fn(), a = _b.a, b = _b.b);
{
a, b;
}
fn();
@@ -0,0 +1,36 @@
=== tests/cases/compiler/destructionAssignmentError.ts ===
declare function fn(): { a: 1, b: 2 }
>fn : Symbol(fn, Decl(destructionAssignmentError.ts, 0, 0))
>a : Symbol(a, Decl(destructionAssignmentError.ts, 0, 24))
>b : Symbol(b, Decl(destructionAssignmentError.ts, 0, 30))
let a: number;
>a : Symbol(a, Decl(destructionAssignmentError.ts, 1, 3))
let b: number;
>b : Symbol(b, Decl(destructionAssignmentError.ts, 2, 3))
({ a, b } = fn());
>a : Symbol(a, Decl(destructionAssignmentError.ts, 4, 2))
>b : Symbol(b, Decl(destructionAssignmentError.ts, 4, 5))
>fn : Symbol(fn, Decl(destructionAssignmentError.ts, 0, 0))
{ a, b } = fn();
>a : Symbol(a, Decl(destructionAssignmentError.ts, 1, 3))
>b : Symbol(b, Decl(destructionAssignmentError.ts, 2, 3))
>fn : Symbol(fn, Decl(destructionAssignmentError.ts, 0, 0))
({ a, b } =
>a : Symbol(a, Decl(destructionAssignmentError.ts, 7, 2))
>b : Symbol(b, Decl(destructionAssignmentError.ts, 7, 5))
fn());
>fn : Symbol(fn, Decl(destructionAssignmentError.ts, 0, 0))
{ a, b }
>a : Symbol(a, Decl(destructionAssignmentError.ts, 1, 3))
>b : Symbol(b, Decl(destructionAssignmentError.ts, 2, 3))
= fn();
>fn : Symbol(fn, Decl(destructionAssignmentError.ts, 0, 0))
@@ -0,0 +1,48 @@
=== tests/cases/compiler/destructionAssignmentError.ts ===
declare function fn(): { a: 1, b: 2 }
>fn : () => { a: 1; b: 2;}
>a : 1
>b : 2
let a: number;
>a : number
let b: number;
>b : number
({ a, b } = fn());
>({ a, b } = fn()) : { a: 1; b: 2; }
>{ a, b } = fn() : { a: 1; b: 2; }
>{ a, b } : { a: number; b: number; }
>a : number
>b : number
>fn() : { a: 1; b: 2; }
>fn : () => { a: 1; b: 2; }
{ a, b } = fn();
>a, b : number
>a : number
>b : number
>fn() : { a: 1; b: 2; }
>fn : () => { a: 1; b: 2; }
({ a, b } =
>({ a, b } =fn()) : { a: 1; b: 2; }
>{ a, b } =fn() : { a: 1; b: 2; }
>{ a, b } : { a: number; b: number; }
>a : number
>b : number
fn());
>fn() : { a: 1; b: 2; }
>fn : () => { a: 1; b: 2; }
{ a, b }
>a, b : number
>a : number
>b : number
= fn();
>fn() : { a: 1; b: 2; }
>fn : () => { a: 1; b: 2; }
@@ -16,5 +16,4 @@ tests/cases/compiler/errorRecoveryWithDotFollowedByNamespaceKeyword.ts(9,2): err
}
!!! error TS1005: '}' expected.
!!! related TS1007 tests/cases/compiler/errorRecoveryWithDotFollowedByNamespaceKeyword.ts:3:19: The parser expected to find a '}' to match the '{' token here.
!!! related TS1007 tests/cases/compiler/errorRecoveryWithDotFollowedByNamespaceKeyword.ts:2:20: The parser expected to find a '}' to match the '{' token here.
!!! related TS1007 tests/cases/compiler/errorRecoveryWithDotFollowedByNamespaceKeyword.ts:3:19: The parser expected to find a '}' to match the '{' token here.
@@ -0,0 +1,48 @@
tests/cases/compiler/index.tsx(35,13): error TS2322: Type '{ key: string; }' is not assignable to type 'HTMLAttributes<HTMLLIElement>'.
Property 'key' does not exist on type 'HTMLAttributes<HTMLLIElement>'.
==== tests/cases/compiler/index.tsx (1 errors) ====
interface MiddlewareArray<T> extends Array<T> {}
declare function configureStore(options: { middleware: MiddlewareArray<any> }): void;
declare const defaultMiddleware: MiddlewareArray<any>;
configureStore({
middleware: [...defaultMiddleware], // Should not error
});
declare namespace React {
type DetailedHTMLProps<E extends HTMLAttributes<T>, T> = E;
interface HTMLAttributes<T> {
children?: ReactNode;
}
type ReactNode = ReactChild | ReactFragment | boolean | null | undefined;
type ReactText = string | number;
type ReactChild = ReactText;
type ReactFragment = {} | ReactNodeArray;
interface ReactNodeArray extends Array<ReactNode> {}
}
declare namespace JSX {
interface IntrinsicElements {
ul: React.DetailedHTMLProps<React.HTMLAttributes<HTMLUListElement>, HTMLUListElement>;
li: React.DetailedHTMLProps<React.HTMLAttributes<HTMLLIElement>, HTMLLIElement>;
}
}
declare var React: any;
const Component = () => {
const categories = ['Fruit', 'Vegetables'];
return (
<ul>
<li>All</li>
{categories.map((category) => (
<li key={category}>{category}</li> // Error about 'key' only
~~~
!!! error TS2322: Type '{ key: string; }' is not assignable to type 'HTMLAttributes<HTMLLIElement>'.
!!! error TS2322: Property 'key' does not exist on type 'HTMLAttributes<HTMLLIElement>'.
))}
</ul>
);
};
@@ -0,0 +1,58 @@
//// [index.tsx]
interface MiddlewareArray<T> extends Array<T> {}
declare function configureStore(options: { middleware: MiddlewareArray<any> }): void;
declare const defaultMiddleware: MiddlewareArray<any>;
configureStore({
middleware: [...defaultMiddleware], // Should not error
});
declare namespace React {
type DetailedHTMLProps<E extends HTMLAttributes<T>, T> = E;
interface HTMLAttributes<T> {
children?: ReactNode;
}
type ReactNode = ReactChild | ReactFragment | boolean | null | undefined;
type ReactText = string | number;
type ReactChild = ReactText;
type ReactFragment = {} | ReactNodeArray;
interface ReactNodeArray extends Array<ReactNode> {}
}
declare namespace JSX {
interface IntrinsicElements {
ul: React.DetailedHTMLProps<React.HTMLAttributes<HTMLUListElement>, HTMLUListElement>;
li: React.DetailedHTMLProps<React.HTMLAttributes<HTMLLIElement>, HTMLLIElement>;
}
}
declare var React: any;
const Component = () => {
const categories = ['Fruit', 'Vegetables'];
return (
<ul>
<li>All</li>
{categories.map((category) => (
<li key={category}>{category}</li> // Error about 'key' only
))}
</ul>
);
};
//// [index.js]
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
to[j] = from[i];
return to;
};
configureStore({
middleware: __spreadArray([], defaultMiddleware)
});
var Component = function () {
var categories = ['Fruit', 'Vegetables'];
return (React.createElement("ul", null,
React.createElement("li", null, "All"),
categories.map(function (category) { return (React.createElement("li", { key: category }, category) // Error about 'key' only
); })));
};
@@ -0,0 +1,128 @@
=== tests/cases/compiler/index.tsx ===
interface MiddlewareArray<T> extends Array<T> {}
>MiddlewareArray : Symbol(MiddlewareArray, Decl(index.tsx, 0, 0))
>T : Symbol(T, Decl(index.tsx, 0, 26))
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 2 more)
>T : Symbol(T, Decl(index.tsx, 0, 26))
declare function configureStore(options: { middleware: MiddlewareArray<any> }): void;
>configureStore : Symbol(configureStore, Decl(index.tsx, 0, 48))
>options : Symbol(options, Decl(index.tsx, 1, 32))
>middleware : Symbol(middleware, Decl(index.tsx, 1, 42))
>MiddlewareArray : Symbol(MiddlewareArray, Decl(index.tsx, 0, 0))
declare const defaultMiddleware: MiddlewareArray<any>;
>defaultMiddleware : Symbol(defaultMiddleware, Decl(index.tsx, 3, 13))
>MiddlewareArray : Symbol(MiddlewareArray, Decl(index.tsx, 0, 0))
configureStore({
>configureStore : Symbol(configureStore, Decl(index.tsx, 0, 48))
middleware: [...defaultMiddleware], // Should not error
>middleware : Symbol(middleware, Decl(index.tsx, 4, 16))
>defaultMiddleware : Symbol(defaultMiddleware, Decl(index.tsx, 3, 13))
});
declare namespace React {
>React : Symbol(React, Decl(index.tsx, 6, 3), Decl(index.tsx, 25, 11))
type DetailedHTMLProps<E extends HTMLAttributes<T>, T> = E;
>DetailedHTMLProps : Symbol(DetailedHTMLProps, Decl(index.tsx, 8, 25))
>E : Symbol(E, Decl(index.tsx, 9, 25))
>HTMLAttributes : Symbol(HTMLAttributes, Decl(index.tsx, 9, 61))
>T : Symbol(T, Decl(index.tsx, 9, 53))
>T : Symbol(T, Decl(index.tsx, 9, 53))
>E : Symbol(E, Decl(index.tsx, 9, 25))
interface HTMLAttributes<T> {
>HTMLAttributes : Symbol(HTMLAttributes, Decl(index.tsx, 9, 61))
>T : Symbol(T, Decl(index.tsx, 10, 27))
children?: ReactNode;
>children : Symbol(HTMLAttributes.children, Decl(index.tsx, 10, 31))
>ReactNode : Symbol(ReactNode, Decl(index.tsx, 12, 3))
}
type ReactNode = ReactChild | ReactFragment | boolean | null | undefined;
>ReactNode : Symbol(ReactNode, Decl(index.tsx, 12, 3))
>ReactChild : Symbol(ReactChild, Decl(index.tsx, 14, 35))
>ReactFragment : Symbol(ReactFragment, Decl(index.tsx, 15, 30))
type ReactText = string | number;
>ReactText : Symbol(ReactText, Decl(index.tsx, 13, 75))
type ReactChild = ReactText;
>ReactChild : Symbol(ReactChild, Decl(index.tsx, 14, 35))
>ReactText : Symbol(ReactText, Decl(index.tsx, 13, 75))
type ReactFragment = {} | ReactNodeArray;
>ReactFragment : Symbol(ReactFragment, Decl(index.tsx, 15, 30))
>ReactNodeArray : Symbol(ReactNodeArray, Decl(index.tsx, 16, 43))
interface ReactNodeArray extends Array<ReactNode> {}
>ReactNodeArray : Symbol(ReactNodeArray, Decl(index.tsx, 16, 43))
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 2 more)
>ReactNode : Symbol(ReactNode, Decl(index.tsx, 12, 3))
}
declare namespace JSX {
>JSX : Symbol(JSX, Decl(index.tsx, 18, 1))
interface IntrinsicElements {
>IntrinsicElements : Symbol(IntrinsicElements, Decl(index.tsx, 19, 23))
ul: React.DetailedHTMLProps<React.HTMLAttributes<HTMLUListElement>, HTMLUListElement>;
>ul : Symbol(IntrinsicElements.ul, Decl(index.tsx, 20, 31))
>React : Symbol(React, Decl(index.tsx, 6, 3), Decl(index.tsx, 25, 11))
>DetailedHTMLProps : Symbol(React.DetailedHTMLProps, Decl(index.tsx, 8, 25))
>React : Symbol(React, Decl(index.tsx, 6, 3), Decl(index.tsx, 25, 11))
>HTMLAttributes : Symbol(React.HTMLAttributes, Decl(index.tsx, 9, 61))
>HTMLUListElement : Symbol(HTMLUListElement, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --))
>HTMLUListElement : Symbol(HTMLUListElement, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --))
li: React.DetailedHTMLProps<React.HTMLAttributes<HTMLLIElement>, HTMLLIElement>;
>li : Symbol(IntrinsicElements.li, Decl(index.tsx, 21, 90))
>React : Symbol(React, Decl(index.tsx, 6, 3), Decl(index.tsx, 25, 11))
>DetailedHTMLProps : Symbol(React.DetailedHTMLProps, Decl(index.tsx, 8, 25))
>React : Symbol(React, Decl(index.tsx, 6, 3), Decl(index.tsx, 25, 11))
>HTMLAttributes : Symbol(React.HTMLAttributes, Decl(index.tsx, 9, 61))
>HTMLLIElement : Symbol(HTMLLIElement, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --))
>HTMLLIElement : Symbol(HTMLLIElement, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --))
}
}
declare var React: any;
>React : Symbol(React, Decl(index.tsx, 6, 3), Decl(index.tsx, 25, 11))
const Component = () => {
>Component : Symbol(Component, Decl(index.tsx, 27, 5))
const categories = ['Fruit', 'Vegetables'];
>categories : Symbol(categories, Decl(index.tsx, 28, 7))
return (
<ul>
>ul : Symbol(JSX.IntrinsicElements.ul, Decl(index.tsx, 20, 31))
<li>All</li>
>li : Symbol(JSX.IntrinsicElements.li, Decl(index.tsx, 21, 90))
>li : Symbol(JSX.IntrinsicElements.li, Decl(index.tsx, 21, 90))
{categories.map((category) => (
>categories.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --))
>categories : Symbol(categories, Decl(index.tsx, 28, 7))
>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --))
>category : Symbol(category, Decl(index.tsx, 33, 23))
<li key={category}>{category}</li> // Error about 'key' only
>li : Symbol(JSX.IntrinsicElements.li, Decl(index.tsx, 21, 90))
>key : Symbol(key, Decl(index.tsx, 34, 11))
>category : Symbol(category, Decl(index.tsx, 33, 23))
>category : Symbol(category, Decl(index.tsx, 33, 23))
>li : Symbol(JSX.IntrinsicElements.li, Decl(index.tsx, 21, 90))
))}
</ul>
>ul : Symbol(JSX.IntrinsicElements.ul, Decl(index.tsx, 20, 31))
);
};
@@ -0,0 +1,108 @@
=== tests/cases/compiler/index.tsx ===
interface MiddlewareArray<T> extends Array<T> {}
declare function configureStore(options: { middleware: MiddlewareArray<any> }): void;
>configureStore : (options: { middleware: MiddlewareArray<any>;}) => void
>options : { middleware: MiddlewareArray<any>; }
>middleware : MiddlewareArray<any>
declare const defaultMiddleware: MiddlewareArray<any>;
>defaultMiddleware : MiddlewareArray<any>
configureStore({
>configureStore({ middleware: [...defaultMiddleware], // Should not error}) : void
>configureStore : (options: { middleware: MiddlewareArray<any>; }) => void
>{ middleware: [...defaultMiddleware], // Should not error} : { middleware: any[]; }
middleware: [...defaultMiddleware], // Should not error
>middleware : any[]
>[...defaultMiddleware] : any[]
>...defaultMiddleware : any
>defaultMiddleware : MiddlewareArray<any>
});
declare namespace React {
type DetailedHTMLProps<E extends HTMLAttributes<T>, T> = E;
>DetailedHTMLProps : E
interface HTMLAttributes<T> {
children?: ReactNode;
>children : ReactNode
}
type ReactNode = ReactChild | ReactFragment | boolean | null | undefined;
>ReactNode : ReactNode
>null : null
type ReactText = string | number;
>ReactText : ReactText
type ReactChild = ReactText;
>ReactChild : ReactText
type ReactFragment = {} | ReactNodeArray;
>ReactFragment : ReactFragment
interface ReactNodeArray extends Array<ReactNode> {}
}
declare namespace JSX {
interface IntrinsicElements {
ul: React.DetailedHTMLProps<React.HTMLAttributes<HTMLUListElement>, HTMLUListElement>;
>ul : React.HTMLAttributes<HTMLUListElement>
>React : any
>React : any
li: React.DetailedHTMLProps<React.HTMLAttributes<HTMLLIElement>, HTMLLIElement>;
>li : React.HTMLAttributes<HTMLLIElement>
>React : any
>React : any
}
}
declare var React: any;
>React : any
const Component = () => {
>Component : () => any
>() => { const categories = ['Fruit', 'Vegetables']; return ( <ul> <li>All</li> {categories.map((category) => ( <li key={category}>{category}</li> // Error about 'key' only ))} </ul> );} : () => any
const categories = ['Fruit', 'Vegetables'];
>categories : string[]
>['Fruit', 'Vegetables'] : string[]
>'Fruit' : "Fruit"
>'Vegetables' : "Vegetables"
return (
>( <ul> <li>All</li> {categories.map((category) => ( <li key={category}>{category}</li> // Error about 'key' only ))} </ul> ) : any
<ul>
><ul> <li>All</li> {categories.map((category) => ( <li key={category}>{category}</li> // Error about 'key' only ))} </ul> : any
>ul : any
<li>All</li>
><li>All</li> : any
>li : any
>li : any
{categories.map((category) => (
>categories.map((category) => ( <li key={category}>{category}</li> // Error about 'key' only )) : any[]
>categories.map : <U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[]
>categories : string[]
>map : <U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[]
>(category) => ( <li key={category}>{category}</li> // Error about 'key' only ) : (category: string) => any
>category : string
>( <li key={category}>{category}</li> // Error about 'key' only ) : any
<li key={category}>{category}</li> // Error about 'key' only
><li key={category}>{category}</li> : any
>li : any
>key : string
>category : string
>category : string
>li : any
))}
</ul>
>ul : any
);
};
@@ -0,0 +1,44 @@
tests/cases/compiler/flatArrayNoExcessiveStackDepth.ts(20,5): error TS2322: Type 'Arr extends readonly (infer InnerArr)[] ? FlatArray<InnerArr, 0 | 2 | 1 | -1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20> : Arr' is not assignable to type 'FlatArray<Arr, D>'.
Type 'unknown' is not assignable to type 'FlatArray<Arr, D>'.
Type 'unknown' is not assignable to type 'Arr extends readonly (infer InnerArr)[] ? FlatArray<InnerArr, [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20][D]> : Arr'.
Type 'Arr extends readonly (infer InnerArr)[] ? FlatArray<InnerArr, 0 | 2 | 1 | -1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20> : Arr' is not assignable to type 'Arr extends readonly (infer InnerArr)[] ? FlatArray<InnerArr, [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20][D]> : Arr'.
Type 'unknown' is not assignable to type 'Arr extends readonly (infer InnerArr)[] ? FlatArray<InnerArr, [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20][D]> : Arr'.
Type 'FlatArray<InnerArr, 0 | 2 | 1 | -1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20>' is not assignable to type 'FlatArray<InnerArr, [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20][D]>'.
Type 'InnerArr' is not assignable to type 'FlatArray<InnerArr, [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20][D]>'.
Type 'InnerArr' is not assignable to type '(InnerArr extends readonly (infer InnerArr)[] ? FlatArray<InnerArr, [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20][[-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20][D]]> : InnerArr) & InnerArr'.
Type 'InnerArr' is not assignable to type 'InnerArr extends readonly (infer InnerArr)[] ? FlatArray<InnerArr, [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20][[-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20][D]]> : InnerArr'.
==== tests/cases/compiler/flatArrayNoExcessiveStackDepth.ts (1 errors) ====
// Repro from #43493
declare const foo: unknown[];
const bar = foo.flatMap(bar => bar as Foo);
interface Foo extends Array<string> {}
// Repros from comments in #43249
const repro_43249 = (value: unknown) => {
if (typeof value !== "string") {
throw new Error("No");
}
const match = value.match(/anything/) || [];
const [, extracted] = match;
};
function f<Arr, D extends number>(x: FlatArray<Arr, any>, y: FlatArray<Arr, D>) {
x = y;
y = x; // Error
~
!!! error TS2322: Type 'Arr extends readonly (infer InnerArr)[] ? FlatArray<InnerArr, 0 | 2 | 1 | -1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20> : Arr' is not assignable to type 'FlatArray<Arr, D>'.
!!! error TS2322: Type 'unknown' is not assignable to type 'FlatArray<Arr, D>'.
!!! error TS2322: Type 'unknown' is not assignable to type 'Arr extends readonly (infer InnerArr)[] ? FlatArray<InnerArr, [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20][D]> : Arr'.
!!! error TS2322: Type 'Arr extends readonly (infer InnerArr)[] ? FlatArray<InnerArr, 0 | 2 | 1 | -1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20> : Arr' is not assignable to type 'Arr extends readonly (infer InnerArr)[] ? FlatArray<InnerArr, [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20][D]> : Arr'.
!!! error TS2322: Type 'unknown' is not assignable to type 'Arr extends readonly (infer InnerArr)[] ? FlatArray<InnerArr, [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20][D]> : Arr'.
!!! error TS2322: Type 'FlatArray<InnerArr, 0 | 2 | 1 | -1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20>' is not assignable to type 'FlatArray<InnerArr, [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20][D]>'.
!!! error TS2322: Type 'InnerArr' is not assignable to type 'FlatArray<InnerArr, [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20][D]>'.
!!! error TS2322: Type 'InnerArr' is not assignable to type '(InnerArr extends readonly (infer InnerArr)[] ? FlatArray<InnerArr, [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20][[-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20][D]]> : InnerArr) & InnerArr'.
!!! error TS2322: Type 'InnerArr' is not assignable to type 'InnerArr extends readonly (infer InnerArr)[] ? FlatArray<InnerArr, [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20][[-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20][D]]> : InnerArr'.
}
@@ -0,0 +1,49 @@
//// [flatArrayNoExcessiveStackDepth.ts]
// Repro from #43493
declare const foo: unknown[];
const bar = foo.flatMap(bar => bar as Foo);
interface Foo extends Array<string> {}
// Repros from comments in #43249
const repro_43249 = (value: unknown) => {
if (typeof value !== "string") {
throw new Error("No");
}
const match = value.match(/anything/) || [];
const [, extracted] = match;
};
function f<Arr, D extends number>(x: FlatArray<Arr, any>, y: FlatArray<Arr, D>) {
x = y;
y = x; // Error
}
//// [flatArrayNoExcessiveStackDepth.js]
"use strict";
// Repro from #43493
const bar = foo.flatMap(bar => bar);
// Repros from comments in #43249
const repro_43249 = (value) => {
if (typeof value !== "string") {
throw new Error("No");
}
const match = value.match(/anything/) || [];
const [, extracted] = match;
};
function f(x, y) {
x = y;
y = x; // Error
}
//// [flatArrayNoExcessiveStackDepth.d.ts]
declare const foo: unknown[];
declare const bar: string[];
interface Foo extends Array<string> {
}
declare const repro_43249: (value: unknown) => void;
declare function f<Arr, D extends number>(x: FlatArray<Arr, any>, y: FlatArray<Arr, D>): void;
@@ -0,0 +1,64 @@
=== tests/cases/compiler/flatArrayNoExcessiveStackDepth.ts ===
// Repro from #43493
declare const foo: unknown[];
>foo : Symbol(foo, Decl(flatArrayNoExcessiveStackDepth.ts, 2, 13))
const bar = foo.flatMap(bar => bar as Foo);
>bar : Symbol(bar, Decl(flatArrayNoExcessiveStackDepth.ts, 3, 5))
>foo.flatMap : Symbol(Array.flatMap, Decl(lib.es2019.array.d.ts, --, --))
>foo : Symbol(foo, Decl(flatArrayNoExcessiveStackDepth.ts, 2, 13))
>flatMap : Symbol(Array.flatMap, Decl(lib.es2019.array.d.ts, --, --))
>bar : Symbol(bar, Decl(flatArrayNoExcessiveStackDepth.ts, 3, 24))
>bar : Symbol(bar, Decl(flatArrayNoExcessiveStackDepth.ts, 3, 24))
>Foo : Symbol(Foo, Decl(flatArrayNoExcessiveStackDepth.ts, 3, 43))
interface Foo extends Array<string> {}
>Foo : Symbol(Foo, Decl(flatArrayNoExcessiveStackDepth.ts, 3, 43))
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 2 more)
// Repros from comments in #43249
const repro_43249 = (value: unknown) => {
>repro_43249 : Symbol(repro_43249, Decl(flatArrayNoExcessiveStackDepth.ts, 9, 5))
>value : Symbol(value, Decl(flatArrayNoExcessiveStackDepth.ts, 9, 21))
if (typeof value !== "string") {
>value : Symbol(value, Decl(flatArrayNoExcessiveStackDepth.ts, 9, 21))
throw new Error("No");
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
}
const match = value.match(/anything/) || [];
>match : Symbol(match, Decl(flatArrayNoExcessiveStackDepth.ts, 13, 9))
>value.match : Symbol(String.match, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
>value : Symbol(value, Decl(flatArrayNoExcessiveStackDepth.ts, 9, 21))
>match : Symbol(String.match, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
const [, extracted] = match;
>extracted : Symbol(extracted, Decl(flatArrayNoExcessiveStackDepth.ts, 14, 12))
>match : Symbol(match, Decl(flatArrayNoExcessiveStackDepth.ts, 13, 9))
};
function f<Arr, D extends number>(x: FlatArray<Arr, any>, y: FlatArray<Arr, D>) {
>f : Symbol(f, Decl(flatArrayNoExcessiveStackDepth.ts, 15, 2))
>Arr : Symbol(Arr, Decl(flatArrayNoExcessiveStackDepth.ts, 17, 11))
>D : Symbol(D, Decl(flatArrayNoExcessiveStackDepth.ts, 17, 15))
>x : Symbol(x, Decl(flatArrayNoExcessiveStackDepth.ts, 17, 34))
>FlatArray : Symbol(FlatArray, Decl(lib.es2019.array.d.ts, --, --))
>Arr : Symbol(Arr, Decl(flatArrayNoExcessiveStackDepth.ts, 17, 11))
>y : Symbol(y, Decl(flatArrayNoExcessiveStackDepth.ts, 17, 57))
>FlatArray : Symbol(FlatArray, Decl(lib.es2019.array.d.ts, --, --))
>Arr : Symbol(Arr, Decl(flatArrayNoExcessiveStackDepth.ts, 17, 11))
>D : Symbol(D, Decl(flatArrayNoExcessiveStackDepth.ts, 17, 15))
x = y;
>x : Symbol(x, Decl(flatArrayNoExcessiveStackDepth.ts, 17, 34))
>y : Symbol(y, Decl(flatArrayNoExcessiveStackDepth.ts, 17, 57))
y = x; // Error
>y : Symbol(y, Decl(flatArrayNoExcessiveStackDepth.ts, 17, 57))
>x : Symbol(x, Decl(flatArrayNoExcessiveStackDepth.ts, 17, 34))
}
@@ -0,0 +1,70 @@
=== tests/cases/compiler/flatArrayNoExcessiveStackDepth.ts ===
// Repro from #43493
declare const foo: unknown[];
>foo : unknown[]
const bar = foo.flatMap(bar => bar as Foo);
>bar : string[]
>foo.flatMap(bar => bar as Foo) : string[]
>foo.flatMap : <U, This = undefined>(callback: (this: This, value: unknown, index: number, array: unknown[]) => U | readonly U[], thisArg?: This | undefined) => U[]
>foo : unknown[]
>flatMap : <U, This = undefined>(callback: (this: This, value: unknown, index: number, array: unknown[]) => U | readonly U[], thisArg?: This | undefined) => U[]
>bar => bar as Foo : (this: undefined, bar: unknown) => Foo
>bar : unknown
>bar as Foo : Foo
>bar : unknown
interface Foo extends Array<string> {}
// Repros from comments in #43249
const repro_43249 = (value: unknown) => {
>repro_43249 : (value: unknown) => void
>(value: unknown) => { if (typeof value !== "string") { throw new Error("No"); } const match = value.match(/anything/) || []; const [, extracted] = match;} : (value: unknown) => void
>value : unknown
if (typeof value !== "string") {
>typeof value !== "string" : boolean
>typeof value : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>value : unknown
>"string" : "string"
throw new Error("No");
>new Error("No") : Error
>Error : ErrorConstructor
>"No" : "No"
}
const match = value.match(/anything/) || [];
>match : RegExpMatchArray
>value.match(/anything/) || [] : RegExpMatchArray
>value.match(/anything/) : RegExpMatchArray | null
>value.match : { (regexp: string | RegExp): RegExpMatchArray | null; (matcher: { [Symbol.match](string: string): RegExpMatchArray | null; }): RegExpMatchArray | null; }
>value : string
>match : { (regexp: string | RegExp): RegExpMatchArray | null; (matcher: { [Symbol.match](string: string): RegExpMatchArray | null; }): RegExpMatchArray | null; }
>/anything/ : RegExp
>[] : never[]
const [, extracted] = match;
> : undefined
>extracted : string
>match : RegExpMatchArray
};
function f<Arr, D extends number>(x: FlatArray<Arr, any>, y: FlatArray<Arr, D>) {
>f : <Arr, D extends number>(x: FlatArray<Arr, any>, y: FlatArray<Arr, D>) => void
>x : FlatArray<Arr, any>
>y : FlatArray<Arr, D>
x = y;
>x = y : FlatArray<Arr, D>
>x : FlatArray<Arr, any>
>y : FlatArray<Arr, D>
y = x; // Error
>y = x : Arr extends readonly (infer InnerArr)[] ? FlatArray<InnerArr, 0 | 2 | 1 | -1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20> : Arr
>y : FlatArray<Arr, D>
>x : Arr extends readonly (infer InnerArr)[] ? FlatArray<InnerArr, 0 | 2 | 1 | -1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20> : Arr
}
@@ -19,7 +19,7 @@ declare const foo: Reducer<MyState['combined']['foo']>;
const myReducer1: Reducer<MyState> = combineReducers({
>myReducer1 : Reducer<MyState>
>combineReducers({ combined: combineReducers({ foo }),}) : Reducer<{ combined: { foo: any; }; }>
>combineReducers({ combined: combineReducers({ foo }),}) : Reducer<{ combined: { foo: number; }; }>
>combineReducers : <S>(reducers: { [K in keyof S]: Reducer<S[K]>; }) => Reducer<S>
>{ combined: combineReducers({ foo }),} : { combined: Reducer<{ foo: number; }>; }
@@ -33,8 +33,8 @@ const myReducer1: Reducer<MyState> = combineReducers({
});
const myReducer2 = combineReducers({
>myReducer2 : Reducer<{ combined: { foo: any; }; }>
>combineReducers({ combined: combineReducers({ foo }),}) : Reducer<{ combined: { foo: any; }; }>
>myReducer2 : Reducer<{ combined: { foo: number; }; }>
>combineReducers({ combined: combineReducers({ foo }),}) : Reducer<{ combined: { foo: number; }; }>
>combineReducers : <S>(reducers: { [K in keyof S]: Reducer<S[K]>; }) => Reducer<S>
>{ combined: combineReducers({ foo }),} : { combined: Reducer<{ foo: number; }>; }
@@ -1,4 +1,4 @@
tests/cases/compiler/importedModuleAddToGlobal.ts(15,23): error TS2811: Cannot find namespace 'b'. Did you mean 'B?
tests/cases/compiler/importedModuleAddToGlobal.ts(15,23): error TS2812: Cannot find namespace 'b'. Did you mean 'B?
==== tests/cases/compiler/importedModuleAddToGlobal.ts (1 errors) ====
@@ -18,6 +18,6 @@ tests/cases/compiler/importedModuleAddToGlobal.ts(15,23): error TS2811: Cannot f
import a = A;
function hello(): b.B { return null; }
~
!!! error TS2811: Cannot find namespace 'b'. Did you mean 'B?
!!! error TS2812: Cannot find namespace 'b'. Did you mean 'B?
!!! related TS2728 tests/cases/compiler/importedModuleAddToGlobal.ts:8:8: 'B' is declared here.
}
@@ -4,9 +4,11 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfacesWithPredefine
tests/cases/conformance/interfaces/interfaceDeclarations/interfacesWithPredefinedTypesAsNames.ts(4,11): error TS2427: Interface name cannot be 'boolean'.
tests/cases/conformance/interfaces/interfaceDeclarations/interfacesWithPredefinedTypesAsNames.ts(5,1): error TS2304: Cannot find name 'interface'.
tests/cases/conformance/interfaces/interfaceDeclarations/interfacesWithPredefinedTypesAsNames.ts(5,11): error TS1005: ';' expected.
tests/cases/conformance/interfaces/interfaceDeclarations/interfacesWithPredefinedTypesAsNames.ts(6,11): error TS2427: Interface name cannot be 'unknown'.
tests/cases/conformance/interfaces/interfaceDeclarations/interfacesWithPredefinedTypesAsNames.ts(7,11): error TS2427: Interface name cannot be 'never'.
==== tests/cases/conformance/interfaces/interfaceDeclarations/interfacesWithPredefinedTypesAsNames.ts (6 errors) ====
==== tests/cases/conformance/interfaces/interfaceDeclarations/interfacesWithPredefinedTypesAsNames.ts (8 errors) ====
interface any { }
~~~
!!! error TS2427: Interface name cannot be 'any'.
@@ -23,4 +25,10 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfacesWithPredefine
~~~~~~~~~
!!! error TS2304: Cannot find name 'interface'.
~~~~
!!! error TS1005: ';' expected.
!!! error TS1005: ';' expected.
interface unknown {}
~~~~~~~
!!! error TS2427: Interface name cannot be 'unknown'.
interface never {}
~~~~~
!!! error TS2427: Interface name cannot be 'never'.
@@ -3,7 +3,9 @@ interface any { }
interface number { }
interface string { }
interface boolean { }
interface void {}
interface void {}
interface unknown {}
interface never {}
//// [interfacesWithPredefinedTypesAsNames.js]
interface;
@@ -12,3 +12,9 @@ interface boolean { }
>boolean : Symbol(boolean, Decl(interfacesWithPredefinedTypesAsNames.ts, 2, 20))
interface void {}
interface unknown {}
>unknown : Symbol(unknown, Decl(interfacesWithPredefinedTypesAsNames.ts, 4, 17))
interface never {}
>never : Symbol(never, Decl(interfacesWithPredefinedTypesAsNames.ts, 5, 20))
@@ -8,3 +8,5 @@ interface void {}
>void {} : undefined
>{} : {}
interface unknown {}
interface never {}
@@ -1,4 +1,4 @@
tests/cases/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.ts(11,10): error TS2809: Namespace 'c' from module 'tests/cases/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError' has no exported member 'b'.
tests/cases/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.ts(11,10): error TS2810: Namespace 'c' from module 'tests/cases/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError' has no exported member 'b'.
==== tests/cases/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.ts (1 errors) ====
@@ -14,4 +14,4 @@ tests/cases/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessE
var x: c.b;
~
!!! error TS2809: Namespace 'c' from module 'tests/cases/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError' has no exported member 'b'.
!!! error TS2810: Namespace 'c' from module 'tests/cases/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError' has no exported member 'b'.
@@ -1,4 +1,4 @@
tests/cases/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.ts(16,17): error TS2809: Namespace 'c' from module 'tests/cases/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError' has no exported member 'b'.
tests/cases/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.ts(16,17): error TS2810: Namespace 'c' from module 'tests/cases/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError' has no exported member 'b'.
==== tests/cases/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.ts (1 errors) ====
@@ -19,4 +19,4 @@ tests/cases/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExp
export var z: c.b.I;
~
!!! error TS2809: Namespace 'c' from module 'tests/cases/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError' has no exported member 'b'.
!!! error TS2810: Namespace 'c' from module 'tests/cases/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError' has no exported member 'b'.
@@ -1,6 +1,6 @@
tests/cases/conformance/internalModules/moduleDeclarations/invalidInstantiatedModule.ts(2,18): error TS2300: Duplicate identifier 'Point'.
tests/cases/conformance/internalModules/moduleDeclarations/invalidInstantiatedModule.ts(3,16): error TS2300: Duplicate identifier 'Point'.
tests/cases/conformance/internalModules/moduleDeclarations/invalidInstantiatedModule.ts(12,8): error TS2811: Cannot find namespace 'm'. Did you mean 'M?
tests/cases/conformance/internalModules/moduleDeclarations/invalidInstantiatedModule.ts(12,8): error TS2812: Cannot find namespace 'm'. Did you mean 'M?
==== tests/cases/conformance/internalModules/moduleDeclarations/invalidInstantiatedModule.ts (3 errors) ====
@@ -21,7 +21,7 @@ tests/cases/conformance/internalModules/moduleDeclarations/invalidInstantiatedMo
var m = M2;
var p: m.Point; // Error
~
!!! error TS2811: Cannot find namespace 'm'. Did you mean 'M?
!!! error TS2812: Cannot find namespace 'm'. Did you mean 'M?
!!! related TS2728 tests/cases/conformance/internalModules/moduleDeclarations/invalidInstantiatedModule.ts:1:8: 'M' is declared here.
@@ -350,12 +350,14 @@ declare function applySpec<T>(obj: Spec<T>): (...args: any[]) => T;
declare var g1: (...args: any[]) => {
sum: number;
nested: {
mul: any;
mul: string;
};
};
declare var g2: (...args: any[]) => {
foo: {
bar: any;
bar: {
baz: boolean;
};
};
};
declare const foo: <T>(object: T, partial: Partial<T>) => T;
@@ -434,8 +434,8 @@ declare function applySpec<T>(obj: Spec<T>): (...args: any[]) => T;
// Infers g1: (...args: any[]) => { sum: number, nested: { mul: string } }
var g1 = applySpec({
>g1 : (...args: any[]) => { sum: number; nested: { mul: any; }; }
>applySpec({ sum: (a: any) => 3, nested: { mul: (b: any) => "n" }}) : (...args: any[]) => { sum: number; nested: { mul: any; }; }
>g1 : (...args: any[]) => { sum: number; nested: { mul: string; }; }
>applySpec({ sum: (a: any) => 3, nested: { mul: (b: any) => "n" }}) : (...args: any[]) => { sum: number; nested: { mul: string; }; }
>applySpec : <T>(obj: Spec<T>) => (...args: any[]) => T
>{ sum: (a: any) => 3, nested: { mul: (b: any) => "n" }} : { sum: (a: any) => number; nested: { mul: (b: any) => string; }; }
@@ -459,8 +459,8 @@ var g1 = applySpec({
// Infers g2: (...args: any[]) => { foo: { bar: { baz: boolean } } }
var g2 = applySpec({ foo: { bar: { baz: (x: any) => true } } });
>g2 : (...args: any[]) => { foo: { bar: any; }; }
>applySpec({ foo: { bar: { baz: (x: any) => true } } }) : (...args: any[]) => { foo: { bar: any; }; }
>g2 : (...args: any[]) => { foo: { bar: { baz: boolean; }; }; }
>applySpec({ foo: { bar: { baz: (x: any) => true } } }) : (...args: any[]) => { foo: { bar: { baz: boolean; }; }; }
>applySpec : <T>(obj: Spec<T>) => (...args: any[]) => T
>{ foo: { bar: { baz: (x: any) => true } } } : { foo: { bar: { baz: (x: any) => boolean; }; }; }
>foo : { bar: { baz: (x: any) => boolean; }; }
@@ -135,10 +135,10 @@ export interface B {
export interface C<T_1, U_1> {
new (): string;
new (x: T_1): U_1;
new <Q_6>(x: Q_6): T_1 & Q_6;
new <Q_4>(x: Q_4): T_1 & Q_4;
(): number;
(x: T_1): U_1;
<Q_4>(x: Q_4): T_1 & Q_4;
<Q_3>(x: Q_3): T_1 & Q_3;
field: T_1 & U_1;
optionalField?: T_1;
readonly readonlyField: T_1 & U_1;
@@ -18,7 +18,7 @@ tests/cases/conformance/jsdoc/declarations/file.js(6,5): error TS4084: Exported
==== tests/cases/conformance/jsdoc/declarations/file.js (3 errors) ====
/** @typedef {import('./base')} BaseFactory */
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS4084: Exported type alias 'BaseFactory' has or is using private name 'Base' from module "tests/cases/conformance/jsdoc/declarations/base".
/**
* @callback BaseFactoryFactory
@@ -0,0 +1,9 @@
[
{
"marker": {
"fileName": "/tests/cases/fourslash/jsDocSignature-43394.ts",
"position": 58,
"name": ""
}
}
]
@@ -0,0 +1,56 @@
//// [keyofGenericExtendingClassDoubleLayer.ts]
class Model<Attributes = any> {
public createdAt: Date;
}
type ModelAttributes<T> = Omit<T, keyof Model>;
class AutoModel<T> extends Model<ModelAttributes<T>> {}
class PersonModel extends AutoModel<PersonModel> {
public age: number;
toJson() {
let x: keyof this = 'createdAt';
}
}
//// [keyofGenericExtendingClassDoubleLayer.js]
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var Model = /** @class */ (function () {
function Model() {
}
return Model;
}());
var AutoModel = /** @class */ (function (_super) {
__extends(AutoModel, _super);
function AutoModel() {
return _super !== null && _super.apply(this, arguments) || this;
}
return AutoModel;
}(Model));
var PersonModel = /** @class */ (function (_super) {
__extends(PersonModel, _super);
function PersonModel() {
return _super !== null && _super.apply(this, arguments) || this;
}
PersonModel.prototype.toJson = function () {
var x = 'createdAt';
};
return PersonModel;
}(AutoModel));
@@ -0,0 +1,40 @@
=== tests/cases/compiler/keyofGenericExtendingClassDoubleLayer.ts ===
class Model<Attributes = any> {
>Model : Symbol(Model, Decl(keyofGenericExtendingClassDoubleLayer.ts, 0, 0))
>Attributes : Symbol(Attributes, Decl(keyofGenericExtendingClassDoubleLayer.ts, 0, 12))
public createdAt: Date;
>createdAt : Symbol(Model.createdAt, Decl(keyofGenericExtendingClassDoubleLayer.ts, 0, 31))
>Date : Symbol(Date, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.scripthost.d.ts, --, --))
}
type ModelAttributes<T> = Omit<T, keyof Model>;
>ModelAttributes : Symbol(ModelAttributes, Decl(keyofGenericExtendingClassDoubleLayer.ts, 2, 1))
>T : Symbol(T, Decl(keyofGenericExtendingClassDoubleLayer.ts, 4, 21))
>Omit : Symbol(Omit, Decl(lib.es5.d.ts, --, --))
>T : Symbol(T, Decl(keyofGenericExtendingClassDoubleLayer.ts, 4, 21))
>Model : Symbol(Model, Decl(keyofGenericExtendingClassDoubleLayer.ts, 0, 0))
class AutoModel<T> extends Model<ModelAttributes<T>> {}
>AutoModel : Symbol(AutoModel, Decl(keyofGenericExtendingClassDoubleLayer.ts, 4, 47))
>T : Symbol(T, Decl(keyofGenericExtendingClassDoubleLayer.ts, 6, 16))
>Model : Symbol(Model, Decl(keyofGenericExtendingClassDoubleLayer.ts, 0, 0))
>ModelAttributes : Symbol(ModelAttributes, Decl(keyofGenericExtendingClassDoubleLayer.ts, 2, 1))
>T : Symbol(T, Decl(keyofGenericExtendingClassDoubleLayer.ts, 6, 16))
class PersonModel extends AutoModel<PersonModel> {
>PersonModel : Symbol(PersonModel, Decl(keyofGenericExtendingClassDoubleLayer.ts, 6, 55))
>AutoModel : Symbol(AutoModel, Decl(keyofGenericExtendingClassDoubleLayer.ts, 4, 47))
>PersonModel : Symbol(PersonModel, Decl(keyofGenericExtendingClassDoubleLayer.ts, 6, 55))
public age: number;
>age : Symbol(PersonModel.age, Decl(keyofGenericExtendingClassDoubleLayer.ts, 8, 50))
toJson() {
>toJson : Symbol(PersonModel.toJson, Decl(keyofGenericExtendingClassDoubleLayer.ts, 9, 23))
let x: keyof this = 'createdAt';
>x : Symbol(x, Decl(keyofGenericExtendingClassDoubleLayer.ts, 12, 11))
}
}
@@ -0,0 +1,31 @@
=== tests/cases/compiler/keyofGenericExtendingClassDoubleLayer.ts ===
class Model<Attributes = any> {
>Model : Model<Attributes>
public createdAt: Date;
>createdAt : Date
}
type ModelAttributes<T> = Omit<T, keyof Model>;
>ModelAttributes : ModelAttributes<T>
class AutoModel<T> extends Model<ModelAttributes<T>> {}
>AutoModel : AutoModel<T>
>Model : Model<ModelAttributes<T>>
class PersonModel extends AutoModel<PersonModel> {
>PersonModel : PersonModel
>AutoModel : AutoModel<PersonModel>
public age: number;
>age : number
toJson() {
>toJson : () => void
let x: keyof this = 'createdAt';
>x : keyof this
>'createdAt' : "createdAt"
}
}
File diff suppressed because one or more lines are too long
@@ -0,0 +1,8 @@
tests/cases/compiler/missingCloseBracketInArray.ts(1,48): error TS1005: ']' expected.
==== tests/cases/compiler/missingCloseBracketInArray.ts (1 errors) ====
var alphas:string[] = alphas = ["1","2","3","4"
!!! error TS1005: ']' expected.
!!! related TS1007 tests/cases/compiler/missingCloseBracketInArray.ts:1:32: The parser expected to find a ']' to match the '[' token here.
@@ -0,0 +1,5 @@
//// [missingCloseBracketInArray.ts]
var alphas:string[] = alphas = ["1","2","3","4"
//// [missingCloseBracketInArray.js]
var alphas = alphas = ["1", "2", "3", "4"];
@@ -0,0 +1,5 @@
=== tests/cases/compiler/missingCloseBracketInArray.ts ===
var alphas:string[] = alphas = ["1","2","3","4"
>alphas : Symbol(alphas, Decl(missingCloseBracketInArray.ts, 0, 3))
>alphas : Symbol(alphas, Decl(missingCloseBracketInArray.ts, 0, 3))
@@ -0,0 +1,11 @@
=== tests/cases/compiler/missingCloseBracketInArray.ts ===
var alphas:string[] = alphas = ["1","2","3","4"
>alphas : string[]
>alphas = ["1","2","3","4" : string[]
>alphas : string[]
>["1","2","3","4" : string[]
>"1" : "1"
>"2" : "2"
>"3" : "3"
>"4" : "4"
@@ -0,0 +1,32 @@
tests/cases/compiler/missingCloseParenStatements.ts(2,26): error TS1005: ')' expected.
tests/cases/compiler/missingCloseParenStatements.ts(4,5): error TS1005: ')' expected.
tests/cases/compiler/missingCloseParenStatements.ts(8,39): error TS1005: ')' expected.
tests/cases/compiler/missingCloseParenStatements.ts(11,35): error TS1005: ')' expected.
==== tests/cases/compiler/missingCloseParenStatements.ts (4 errors) ====
var a1, a2, a3 = 0;
if ( a1 && (a2 + a3 > 0) {
~
!!! error TS1005: ')' expected.
!!! related TS1007 tests/cases/compiler/missingCloseParenStatements.ts:2:4: The parser expected to find a ')' to match the '(' token here.
while( (a2 > 0) && a1
{
~
!!! error TS1005: ')' expected.
!!! related TS1007 tests/cases/compiler/missingCloseParenStatements.ts:3:10: The parser expected to find a ')' to match the '(' token here.
do {
var i = i + 1;
a1 = a1 + i;
with ((a2 + a3 > 0) && a1 {
~
!!! error TS1005: ')' expected.
!!! related TS1007 tests/cases/compiler/missingCloseParenStatements.ts:8:18: The parser expected to find a ')' to match the '(' token here.
console.log(x);
}
} while (i < 5 && (a1 > 5);
~
!!! error TS1005: ')' expected.
!!! related TS1007 tests/cases/compiler/missingCloseParenStatements.ts:11:17: The parser expected to find a ')' to match the '(' token here.
}
}
@@ -0,0 +1,28 @@
//// [missingCloseParenStatements.ts]
var a1, a2, a3 = 0;
if ( a1 && (a2 + a3 > 0) {
while( (a2 > 0) && a1
{
do {
var i = i + 1;
a1 = a1 + i;
with ((a2 + a3 > 0) && a1 {
console.log(x);
}
} while (i < 5 && (a1 > 5);
}
}
//// [missingCloseParenStatements.js]
var a1, a2, a3 = 0;
if (a1 && (a2 + a3 > 0)) {
while ((a2 > 0) && a1) {
do {
var i = i + 1;
a1 = a1 + i;
with ((a2 + a3 > 0) && a1) {
console.log(x);
}
} while (i < 5 && (a1 > 5));
}
}
@@ -0,0 +1,37 @@
=== tests/cases/compiler/missingCloseParenStatements.ts ===
var a1, a2, a3 = 0;
>a1 : Symbol(a1, Decl(missingCloseParenStatements.ts, 0, 3))
>a2 : Symbol(a2, Decl(missingCloseParenStatements.ts, 0, 7))
>a3 : Symbol(a3, Decl(missingCloseParenStatements.ts, 0, 11))
if ( a1 && (a2 + a3 > 0) {
>a1 : Symbol(a1, Decl(missingCloseParenStatements.ts, 0, 3))
>a2 : Symbol(a2, Decl(missingCloseParenStatements.ts, 0, 7))
>a3 : Symbol(a3, Decl(missingCloseParenStatements.ts, 0, 11))
while( (a2 > 0) && a1
>a2 : Symbol(a2, Decl(missingCloseParenStatements.ts, 0, 7))
>a1 : Symbol(a1, Decl(missingCloseParenStatements.ts, 0, 3))
{
do {
var i = i + 1;
>i : Symbol(i, Decl(missingCloseParenStatements.ts, 5, 15))
>i : Symbol(i, Decl(missingCloseParenStatements.ts, 5, 15))
a1 = a1 + i;
>a1 : Symbol(a1, Decl(missingCloseParenStatements.ts, 0, 3))
>a1 : Symbol(a1, Decl(missingCloseParenStatements.ts, 0, 3))
>i : Symbol(i, Decl(missingCloseParenStatements.ts, 5, 15))
with ((a2 + a3 > 0) && a1 {
>a2 : Symbol(a2, Decl(missingCloseParenStatements.ts, 0, 7))
>a3 : Symbol(a3, Decl(missingCloseParenStatements.ts, 0, 11))
>a1 : Symbol(a1, Decl(missingCloseParenStatements.ts, 0, 3))
console.log(x);
}
} while (i < 5 && (a1 > 5);
>i : Symbol(i, Decl(missingCloseParenStatements.ts, 5, 15))
>a1 : Symbol(a1, Decl(missingCloseParenStatements.ts, 0, 3))
}
}
@@ -0,0 +1,67 @@
=== tests/cases/compiler/missingCloseParenStatements.ts ===
var a1, a2, a3 = 0;
>a1 : any
>a2 : any
>a3 : number
>0 : 0
if ( a1 && (a2 + a3 > 0) {
>a1 && (a2 + a3 > 0) : boolean
>a1 : any
>(a2 + a3 > 0) : boolean
>a2 + a3 > 0 : boolean
>a2 + a3 : any
>a2 : any
>a3 : number
>0 : 0
while( (a2 > 0) && a1
>(a2 > 0) && a1 : any
>(a2 > 0) : boolean
>a2 > 0 : boolean
>a2 : any
>0 : 0
>a1 : any
{
do {
var i = i + 1;
>i : any
>i + 1 : any
>i : any
>1 : 1
a1 = a1 + i;
>a1 = a1 + i : any
>a1 : any
>a1 + i : any
>a1 : any
>i : any
with ((a2 + a3 > 0) && a1 {
>(a2 + a3 > 0) && a1 : any
>(a2 + a3 > 0) : boolean
>a2 + a3 > 0 : boolean
>a2 + a3 : any
>a2 : any
>a3 : number
>0 : 0
>a1 : any
console.log(x);
>console.log(x) : any
>console.log : any
>console : any
>log : any
>x : any
}
} while (i < 5 && (a1 > 5);
>i < 5 && (a1 > 5) : boolean
>i < 5 : boolean
>i : any
>5 : 5
>(a1 > 5) : boolean
>a1 > 5 : boolean
>a1 : any
>5 : 5
}
}
@@ -32,7 +32,6 @@ tests/cases/conformance/classes/nestedClassDeclaration.ts(17,1): error TS1128: D
!!! error TS2304: Cannot find name 'C4'.
~
!!! error TS1005: ',' expected.
!!! related TS1007 tests/cases/conformance/classes/nestedClassDeclaration.ts:14:9: The parser expected to find a '}' to match the '{' token here.
}
}
~
@@ -9,5 +9,4 @@ tests/cases/compiler/objectLiteralWithSemicolons4.ts(3,1): error TS1005: ',' exp
!!! error TS18004: No value exists in scope for the shorthand property 'a'. Either declare one or provide an initializer.
;
~
!!! error TS1005: ',' expected.
!!! related TS1007 tests/cases/compiler/objectLiteralWithSemicolons4.ts:1:9: The parser expected to find a '}' to match the '{' token here.
!!! error TS1005: ',' expected.
@@ -28,7 +28,6 @@ tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts(4,20): error T
!!! error TS2304: Cannot find name 'matchMedia'.
~
!!! error TS1005: ',' expected.
!!! related TS1007 tests/cases/conformance/types/spread/objectSpreadNegativeParse.ts:3:10: The parser expected to find a '}' to match the '{' token here.
~
!!! error TS1128: Declaration or statement expected.
let o10 = { ...get x() { return 12; }};
@@ -25,7 +25,6 @@ tests/cases/compiler/parseErrorIncorrectReturnToken.ts(12,1): error TS1128: Decl
m(n: number) => string {
~~
!!! error TS1005: '{' expected.
!!! related TS1007 tests/cases/compiler/parseErrorIncorrectReturnToken.ts:8:9: The parser expected to find a '}' to match the '{' token here.
~~~~~~
!!! error TS2693: 'string' only refers to a type, but is being used as a value here.
~
@@ -11,6 +11,7 @@ tests/cases/conformance/parser/ecmascript5/ErrorRecovery/IfStatements/parserErro
}
~
!!! error TS1005: ')' expected.
!!! related TS1007 tests/cases/conformance/parser/ecmascript5/ErrorRecovery/IfStatements/parserErrorRecoveryIfStatement2.ts:3:8: The parser expected to find a ')' to match the '(' token here.
f2() {
}
f3() {
@@ -11,6 +11,7 @@ tests/cases/conformance/parser/ecmascript5/ErrorRecovery/IfStatements/parserErro
}
~
!!! error TS1005: ')' expected.
!!! related TS1007 tests/cases/conformance/parser/ecmascript5/ErrorRecovery/IfStatements/parserErrorRecoveryIfStatement3.ts:3:8: The parser expected to find a ')' to match the '(' token here.
f2() {
}
f3() {
@@ -20,5 +20,4 @@ tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserFuzz1.ts(2,15): e
~~~~~~
!!! error TS1005: ';' expected.
!!! error TS1005: '{' expected.
!!! related TS1007 tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserFuzz1.ts:1:9: The parser expected to find a '}' to match the '{' token here.
!!! error TS1005: '{' expected.
@@ -1,11 +1,11 @@
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnfinishedTypeNameBeforeKeyword1.ts(1,8): error TS2811: Cannot find namespace 'TypeModule1'. Did you mean 'TypeModule2?
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnfinishedTypeNameBeforeKeyword1.ts(1,8): error TS2812: Cannot find namespace 'TypeModule1'. Did you mean 'TypeModule2?
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnfinishedTypeNameBeforeKeyword1.ts(1,20): error TS1003: Identifier expected.
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnfinishedTypeNameBeforeKeyword1.ts (2 errors) ====
var x: TypeModule1.
~~~~~~~~~~~
!!! error TS2811: Cannot find namespace 'TypeModule1'. Did you mean 'TypeModule2?
!!! error TS2812: Cannot find namespace 'TypeModule1'. Did you mean 'TypeModule2?
!!! error TS1003: Identifier expected.
module TypeModule2 {
@@ -1,5 +1,5 @@
tests/cases/compiler/primaryExpressionMods.ts(7,8): error TS2709: Cannot use namespace 'M' as a type.
tests/cases/compiler/primaryExpressionMods.ts(11,8): error TS2811: Cannot find namespace 'm'. Did you mean 'M?
tests/cases/compiler/primaryExpressionMods.ts(11,8): error TS2812: Cannot find namespace 'm'. Did you mean 'M?
==== tests/cases/compiler/primaryExpressionMods.ts (2 errors) ====
@@ -17,6 +17,6 @@ tests/cases/compiler/primaryExpressionMods.ts(11,8): error TS2811: Cannot find n
var x2 = m.a; // Same as M.a
var q: m.P; // Error
~
!!! error TS2811: Cannot find namespace 'm'. Did you mean 'M?
!!! error TS2812: Cannot find namespace 'm'. Did you mean 'M?
!!! related TS2728 tests/cases/compiler/primaryExpressionMods.ts:1:8: 'M' is declared here.

Some files were not shown because too many files have changed in this diff Show More