diff --git a/Jakefile.js b/Jakefile.js index b986d81dacc..9e8c51a306e 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -1308,7 +1308,7 @@ task("lint", ["build-rules"], () => { : `Gulpfile.ts scripts/generateLocalizedDiagnosticMessages.ts "scripts/tslint/**/*.ts" "src/**/*.ts" --exclude "src/lib/*.d.ts"`; const cmd = `node node_modules/tslint/bin/tslint ${files} --formatters-dir ./built/local/tslint/formatters --format autolinkableStylish`; console.log("Linting: " + cmd); - jake.exec([cmd], { interactive: true }, () => { + jake.exec([cmd], { interactive: true, windowsVerbatimArguments: true }, () => { if (fold.isTravis()) console.log(fold.end("lint")); complete(); }); diff --git a/lib/lib.es5.d.ts b/lib/lib.es5.d.ts index 3f495ed40a9..07ffe74c05f 100644 --- a/lib/lib.es5.d.ts +++ b/lib/lib.es5.d.ts @@ -792,8 +792,7 @@ interface Date { interface DateConstructor { new(): Date; - new(value: number): Date; - new(value: string): Date; + new(value: string | number): Date; new(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; (): string; readonly prototype: Date; diff --git a/pull_request_template.md b/pull_request_template.md index 2c49c84641b..9c74ff2d6e8 100644 --- a/pull_request_template.md +++ b/pull_request_template.md @@ -2,7 +2,7 @@ Thank you for submitting a pull request! Here's a checklist you might find useful. -[ ] There is an associated issue that is labelled +[ ] There is an associated issue that is labeled 'Bug' or 'help wanted' or is in the Community milestone [ ] Code is up-to-date with the `master` branch [ ] You've successfully run `jake runtests` locally diff --git a/scripts/configurePrerelease.ts b/scripts/configurePrerelease.ts index a63490ca051..d17ddb963b1 100644 --- a/scripts/configurePrerelease.ts +++ b/scripts/configurePrerelease.ts @@ -55,7 +55,7 @@ function updateTsFile(tsFilePath: string, tsFileContents: string, majorMinor: st const parsedMajorMinor = majorMinorMatch[1]; ts.Debug.assert(parsedMajorMinor === majorMinor, "versionMajorMinor does not match.", () => `${tsFilePath}: '${parsedMajorMinor}'; package.json: '${majorMinor}'`); - const versionRgx = /export const version = `\$\{versionMajorMinor\}\.(\d)`;/; + const versionRgx = /export const version = `\$\{versionMajorMinor\}\.(\d)(-dev)?`;/; const patchMatch = versionRgx.exec(tsFileContents); ts.Debug.assert(patchMatch !== null, "The file seems to no longer have a string matching", () => versionRgx.toString()); const parsedPatch = patchMatch[1]; @@ -85,4 +85,4 @@ function getPrereleasePatch(tag: string, plainPatch: string): string { return `${plainPatch}-${tag}.${timeStr}`; } -main(); \ No newline at end of file +main(); diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 243b442407b..640bd37994f 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -393,6 +393,10 @@ namespace ts { ? Diagnostics.Cannot_redeclare_block_scoped_variable_0 : Diagnostics.Duplicate_identifier_0; + if (symbol.flags & SymbolFlags.Enum || includes & SymbolFlags.Enum) { + message = Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations; + } + if (symbol.declarations && symbol.declarations.length) { // If the current node is a default export of some sort, then check if // there are any other default exports that we need to error on. @@ -756,11 +760,11 @@ namespace ts { } function isNarrowingTypeofOperands(expr1: Expression, expr2: Expression) { - return expr1.kind === SyntaxKind.TypeOfExpression && isNarrowableOperand((expr1).expression) && (expr2.kind === SyntaxKind.StringLiteral || expr2.kind === SyntaxKind.NoSubstitutionTemplateLiteral); + return isTypeOfExpression(expr1) && isNarrowableOperand(expr1.expression) && isStringLiteralLike(expr2); } function isNarrowableInOperands(left: Expression, right: Expression) { - return (left.kind === SyntaxKind.StringLiteral || left.kind === SyntaxKind.NoSubstitutionTemplateLiteral) && isNarrowingExpression(right); + return isStringLiteralLike(left) && isNarrowingExpression(right); } function isNarrowingBinaryExpression(expr: BinaryExpression) { diff --git a/src/compiler/builder.ts b/src/compiler/builder.ts index 886a2194bd9..121609db104 100644 --- a/src/compiler/builder.ts +++ b/src/compiler/builder.ts @@ -41,15 +41,9 @@ namespace ts { program: Program; } - function hasSameKeys(map1: ReadonlyMap | undefined, map2: ReadonlyMap | undefined) { - if (map1 === undefined) { - return map2 === undefined; - } - if (map2 === undefined) { - return map1 === undefined; - } + function hasSameKeys(map1: ReadonlyMap | undefined, map2: ReadonlyMap | undefined): boolean { // Has same size and every key is present in both maps - return map1.size === map2.size && !forEachKey(map1, key => !map2.has(key)); + return map1 as ReadonlyMap === map2 || map1 && map2 && map1.size === map2.size && !forEachKey(map1, key => !map2.has(key)); } /** diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 2604bec3dbd..110d941b8b7 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -299,6 +299,10 @@ namespace ts { node = getParseTreeNode(node); return node && tryGetThisTypeAt(node); }, + getTypeArgumentConstraint: node => { + node = getParseTreeNode(node, isTypeNode); + return node && getTypeArgumentConstraint(node); + }, }; const tupleTypes: GenericType[] = []; @@ -572,8 +576,10 @@ namespace ts { } const enum MappedTypeModifiers { - Readonly = 1 << 0, - Optional = 1 << 1, + IncludeReadonly = 1 << 0, + ExcludeReadonly = 1 << 1, + IncludeOptional = 1 << 2, + ExcludeOptional = 1 << 3, } const enum ExpandingFlags { @@ -870,8 +876,11 @@ namespace ts { error(getNameOfDeclaration(source.declarations[0]), Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); } else { - const message = target.flags & SymbolFlags.BlockScopedVariable || source.flags & SymbolFlags.BlockScopedVariable - ? Diagnostics.Cannot_redeclare_block_scoped_variable_0 : Diagnostics.Duplicate_identifier_0; + const message = target.flags & SymbolFlags.Enum || source.flags & SymbolFlags.Enum + ? Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations + : target.flags & SymbolFlags.BlockScopedVariable || source.flags & SymbolFlags.BlockScopedVariable + ? Diagnostics.Cannot_redeclare_block_scoped_variable_0 + : Diagnostics.Duplicate_identifier_0; forEach(source.declarations, node => { error(getNameOfDeclaration(node) || node, message, symbolToString(source)); }); @@ -1157,7 +1166,7 @@ namespace ts { const originalLocation = location; // needed for did-you-mean error reporting, which gathers candidates starting from the original location let result: Symbol; let lastLocation: Node; - let lastNonBlockLocation: Node; + let lastSelfReferenceLocation: Node; let propertyWithInvalidInitializer: Node; const errorLocation = location; let grandparent: Node; @@ -1381,17 +1390,17 @@ namespace ts { } break; } - if (isNonBlockLocation(location)) { - lastNonBlockLocation = location; + if (isSelfReferenceLocation(location)) { + lastSelfReferenceLocation = location; } lastLocation = location; location = location.parent; } // We just climbed up parents looking for the name, meaning that we started in a descendant node of `lastLocation`. - // If `result === lastNonBlockLocation.symbol`, that means that we are somewhere inside `lastNonBlockLocation` looking up a name, and resolving to `lastLocation` itself. + // If `result === lastSelfReferenceLocation.symbol`, that means that we are somewhere inside `lastSelfReferenceLocation` looking up a name, and resolving to `lastLocation` itself. // That means that this is a self-reference of `lastLocation`, and shouldn't count this when considering whether `lastLocation` is used. - if (isUse && result && nameNotFoundMessage && noUnusedIdentifiers && result !== lastNonBlockLocation.symbol) { + if (isUse && result && nameNotFoundMessage && noUnusedIdentifiers && (!lastSelfReferenceLocation || result !== lastSelfReferenceLocation.symbol)) { result.isReferenced = true; } @@ -1474,17 +1483,17 @@ namespace ts { return result; } - function isNonBlockLocation({ kind }: Node): boolean { - switch (kind) { - case SyntaxKind.Block: - case SyntaxKind.ModuleBlock: - case SyntaxKind.SwitchStatement: - case SyntaxKind.CaseBlock: - case SyntaxKind.CaseClause: - case SyntaxKind.DefaultClause: - return false; - default: + function isSelfReferenceLocation(node: Node): boolean { + switch (node.kind) { + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.ClassDeclaration: + case SyntaxKind.InterfaceDeclaration: + case SyntaxKind.EnumDeclaration: + case SyntaxKind.TypeAliasDeclaration: + case SyntaxKind.ModuleDeclaration: // For `namespace N { N; }` return true; + default: + return false; } } @@ -1503,7 +1512,7 @@ namespace ts { } function checkAndReportErrorForMissingPrefix(errorLocation: Node, name: __String, nameArg: __String | Identifier): boolean { - if ((errorLocation.kind === SyntaxKind.Identifier && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { + if (!isIdentifier(errorLocation) || errorLocation.escapedText !== name || isTypeReferenceIdentifier(errorLocation) || isInTypeQuery(errorLocation)) { return false; } @@ -2031,12 +2040,9 @@ namespace ts { } function resolveExternalModuleNameWorker(location: Node, moduleReferenceExpression: Expression, moduleNotFoundError: DiagnosticMessage, isForAugmentation = false): Symbol { - if (moduleReferenceExpression.kind !== SyntaxKind.StringLiteral && moduleReferenceExpression.kind !== SyntaxKind.NoSubstitutionTemplateLiteral) { - return; - } - - const moduleReferenceLiteral = moduleReferenceExpression; - return resolveExternalModule(location, moduleReferenceLiteral.text, moduleNotFoundError, moduleReferenceLiteral, isForAugmentation); + return isStringLiteralLike(moduleReferenceExpression) + ? resolveExternalModule(location, moduleReferenceExpression.text, moduleNotFoundError, moduleReferenceExpression, isForAugmentation) + : undefined; } function resolveExternalModule(location: Node, moduleReference: string, moduleNotFoundError: DiagnosticMessage, errorNode: Node, isForAugmentation = false): Symbol { @@ -2471,10 +2477,6 @@ namespace ts { (ignoreQualification || canQualifySymbol(symbolFromSymbolTable, meaning)); } - function isUMDExportSymbol(symbol: Symbol) { - return symbol && symbol.declarations && symbol.declarations[0] && isNamespaceExportDeclaration(symbol.declarations[0]); - } - function trySymbolTable(symbols: SymbolTable, ignoreQualification: boolean | undefined) { // If symbol is directly available by its name in the symbol table if (isAccessible(symbols.get(symbol.escapedName), /*resolvedAliasSymbol*/ undefined, ignoreQualification)) { @@ -2975,11 +2977,10 @@ namespace ts { function createMappedTypeNodeFromType(type: MappedType) { Debug.assert(!!(type.flags & TypeFlags.Object)); - const readonlyToken = type.declaration && type.declaration.readonlyToken ? createToken(SyntaxKind.ReadonlyKeyword) : undefined; - const questionToken = type.declaration && type.declaration.questionToken ? createToken(SyntaxKind.QuestionToken) : undefined; + const readonlyToken = type.declaration.readonlyToken ? createToken(type.declaration.readonlyToken.kind) : undefined; + const questionToken = type.declaration.questionToken ? createToken(type.declaration.questionToken.kind) : undefined; const typeParameterNode = typeParameterToDeclaration(getTypeParameterFromMappedType(type), context, getConstraintTypeFromMappedType(type)); const templateTypeNode = typeToTypeNodeHelper(getTemplateTypeFromMappedType(type), context); - const mappedTypeNode = createMappedTypeNode(readonlyToken, typeParameterNode, questionToken, templateTypeNode); return setEmitFlags(mappedTypeNode, EmitFlags.SingleLine); } @@ -3226,7 +3227,8 @@ namespace ts { context.tracker.reportPrivateInBaseOfClassExpression(unescapeLeadingUnderscores(propertySymbol.escapedName)); } } - const propertyType = getCheckFlags(propertySymbol) & CheckFlags.ReverseMapped ? anyType : getTypeOfSymbol(propertySymbol); + const propertyType = getCheckFlags(propertySymbol) & CheckFlags.ReverseMapped && context.flags & NodeBuilderFlags.InReverseMappedType ? + anyType : getTypeOfSymbol(propertySymbol); const saveEnclosingDeclaration = context.enclosingDeclaration; context.enclosingDeclaration = undefined; if (getCheckFlags(propertySymbol) & CheckFlags.Late) { @@ -3249,7 +3251,10 @@ namespace ts { } } else { + const savedFlags = context.flags; + context.flags |= !!(getCheckFlags(propertySymbol) & CheckFlags.ReverseMapped) ? NodeBuilderFlags.InReverseMappedType : 0; const propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType, context) : createKeywordTypeNode(SyntaxKind.AnyKeyword); + context.flags = savedFlags; const modifiers = isReadonlySymbol(propertySymbol) ? [createToken(SyntaxKind.ReadonlyKeyword)] : undefined; const propertySignature = createPropertySignature( @@ -4418,7 +4423,7 @@ namespace ts { type = getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true); } else { - Debug.fail("Unhandled declaration kind! " + (ts as any).SyntaxKind[declaration.kind]); + Debug.fail("Unhandled declaration kind! " + Debug.showSyntaxKind(declaration)); } if (!popTypeResolution()) { @@ -5828,8 +5833,9 @@ namespace ts { function resolveReverseMappedTypeMembers(type: ReverseMappedType) { const indexInfo = getIndexInfoOfType(type.source, IndexKind.String); - const readonlyMask = type.mappedType.declaration.readonlyToken ? false : true; - const optionalMask = type.mappedType.declaration.questionToken ? 0 : SymbolFlags.Optional; + const modifiers = getMappedTypeModifiers(type.mappedType); + const readonlyMask = modifiers & MappedTypeModifiers.IncludeReadonly ? false : true; + const optionalMask = modifiers & MappedTypeModifiers.IncludeOptional ? 0 : SymbolFlags.Optional; const stringIndexInfo = indexInfo && createIndexInfo(inferReverseMappedType(indexInfo.type, type.mappedType), readonlyMask && indexInfo.isReadonly); const members = createSymbolTable(); for (const prop of getPropertiesOfType(type.source)) { @@ -5855,8 +5861,7 @@ namespace ts { const constraintType = getConstraintTypeFromMappedType(type); const templateType = getTemplateTypeFromMappedType(type.target || type); const modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); // The 'T' in 'keyof T' - const templateReadonly = !!type.declaration.readonlyToken; - const templateOptional = !!type.declaration.questionToken; + const templateModifiers = getMappedTypeModifiers(type); const constraintDeclaration = type.declaration.typeParameter.constraint; if (constraintDeclaration.kind === SyntaxKind.TypeOperator && (constraintDeclaration).operator === SyntaxKind.KeyOfKeyword) { @@ -5897,10 +5902,17 @@ namespace ts { if (t.flags & TypeFlags.StringLiteral) { const propName = escapeLeadingUnderscores((t).value); const modifiersProp = getPropertyOfType(modifiersType, propName); - const isOptional = templateOptional || !!(modifiersProp && modifiersProp.flags & SymbolFlags.Optional); - const checkFlags = templateReadonly || modifiersProp && isReadonlySymbol(modifiersProp) ? CheckFlags.Readonly : 0; - const prop = createSymbol(SymbolFlags.Property | (isOptional ? SymbolFlags.Optional : 0), propName, checkFlags); - prop.type = propType; + const isOptional = !!(templateModifiers & MappedTypeModifiers.IncludeOptional || + !(templateModifiers & MappedTypeModifiers.ExcludeOptional) && modifiersProp && modifiersProp.flags & SymbolFlags.Optional); + const isReadonly = !!(templateModifiers & MappedTypeModifiers.IncludeReadonly || + !(templateModifiers & MappedTypeModifiers.ExcludeReadonly) && modifiersProp && isReadonlySymbol(modifiersProp)); + const prop = createSymbol(SymbolFlags.Property | (isOptional ? SymbolFlags.Optional : 0), propName, isReadonly ? CheckFlags.Readonly : 0); + // When creating an optional property in strictNullChecks mode, if 'undefined' isn't assignable to the + // type, we include 'undefined' in the type. Similarly, when creating a non-optional property in strictNullChecks + // mode, if the underlying property is optional we remove 'undefined' from the type. + prop.type = strictNullChecks && isOptional && !isTypeAssignableTo(undefinedType, propType) ? getOptionalType(propType) : + strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & SymbolFlags.Optional ? getTypeWithFacts(propType, TypeFacts.NEUndefined) : + propType; if (propertySymbol) { prop.syntheticOrigin = propertySymbol; prop.declarations = propertySymbol.declarations; @@ -5909,7 +5921,7 @@ namespace ts { members.set(propName, prop); } else if (t.flags & (TypeFlags.Any | TypeFlags.String)) { - stringIndexInfo = createIndexInfo(propType, templateReadonly); + stringIndexInfo = createIndexInfo(propType, !!(templateModifiers & MappedTypeModifiers.IncludeReadonly)); } } } @@ -5927,7 +5939,7 @@ namespace ts { function getTemplateTypeFromMappedType(type: MappedType) { return type.templateType || (type.templateType = type.declaration.type ? - instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), !!type.declaration.questionToken), type.mapper || identityMapper) : + instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), !!(getMappedTypeModifiers(type) & MappedTypeModifiers.IncludeOptional)), type.mapper || identityMapper) : unknownType); } @@ -5955,18 +5967,24 @@ namespace ts { } function getMappedTypeModifiers(type: MappedType): MappedTypeModifiers { - return (type.declaration.readonlyToken ? MappedTypeModifiers.Readonly : 0) | - (type.declaration.questionToken ? MappedTypeModifiers.Optional : 0); + const declaration = type.declaration; + return (declaration.readonlyToken ? declaration.readonlyToken.kind === SyntaxKind.MinusToken ? MappedTypeModifiers.ExcludeReadonly : MappedTypeModifiers.IncludeReadonly : 0) | + (declaration.questionToken ? declaration.questionToken.kind === SyntaxKind.MinusToken ? MappedTypeModifiers.ExcludeOptional : MappedTypeModifiers.IncludeOptional : 0); } - function getCombinedMappedTypeModifiers(type: MappedType): MappedTypeModifiers { + function getMappedTypeOptionality(type: MappedType): number { + const modifiers = getMappedTypeModifiers(type); + return modifiers & MappedTypeModifiers.ExcludeOptional ? -1 : modifiers & MappedTypeModifiers.IncludeOptional ? 1 : 0; + } + + function getCombinedMappedTypeOptionality(type: MappedType): number { + const optionality = getMappedTypeOptionality(type); const modifiersType = getModifiersTypeFromMappedType(type); - return getMappedTypeModifiers(type) | - (isGenericMappedType(modifiersType) ? getMappedTypeModifiers(modifiersType) : 0); + return optionality || (isGenericMappedType(modifiersType) ? getMappedTypeOptionality(modifiersType) : 0); } function isPartialMappedType(type: Type) { - return getObjectFlags(type) & ObjectFlags.Mapped && !!(type).declaration.questionToken; + return !!(getObjectFlags(type) & ObjectFlags.Mapped && getMappedTypeModifiers(type) & MappedTypeModifiers.IncludeOptional); } function isGenericMappedType(type: Type): type is MappedType { @@ -6108,11 +6126,13 @@ namespace ts { // with its constraint. We do this because if the constraint is a union type it will be distributed // over the conditional type and possibly reduced. For example, 'T extends undefined ? never : T' // removes 'undefined' from T. - const checkType = type.checkType; - if (checkType.flags & TypeFlags.TypeParameter) { - const constraint = getConstraintOfTypeParameter(checkType); + if (isDistributiveConditionalType(type)) { + const constraint = getConstraintOfType(type.checkType); if (constraint) { - return instantiateType(type, createTypeMapper([checkType], [constraint])); + const target = type.target || type; + const mapper = createTypeMapper([target.checkType], [constraint]); + const combinedMapper = type.mapper ? combineTypeMappers(mapper, type.mapper) : mapper; + return instantiateType(target, combinedMapper); } } return undefined; @@ -6975,6 +6995,42 @@ namespace ts { return type.symbol && getDeclarationOfKind(type.symbol, SyntaxKind.TypeParameter).constraint; } + function getInferredTypeParameterConstraint(typeParameter: TypeParameter) { + let inferences: Type[]; + if (typeParameter.symbol) { + for (const declaration of typeParameter.symbol.declarations) { + // When an 'infer T' declaration is immediately contained in a type reference node + // (such as 'Foo'), T's constraint is inferred from the constraint of the + // corresponding type parameter in 'Foo'. When multiple 'infer T' declarations are + // present, we form an intersection of the inferred constraint types. + if (declaration.parent.kind === SyntaxKind.InferType && declaration.parent.parent.kind === SyntaxKind.TypeReference) { + const typeReference = declaration.parent.parent; + const typeParameters = getTypeParametersForTypeReference(typeReference); + if (typeParameters) { + const index = typeReference.typeArguments.indexOf(declaration.parent); + if (index < typeParameters.length) { + const declaredConstraint = getConstraintOfTypeParameter(typeParameters[index]); + if (declaredConstraint) { + // Type parameter constraints can reference other type parameters so + // constraints need to be instantiated. If instantiation produces the + // type parameter itself, we discard that inference. For example, in + // type Foo = [T, U]; + // type Bar = T extends Foo ? Foo : T; + // the instantiated constraint for U is X, so we discard that inference. + const mapper = createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReference, typeParameters)); + const constraint = instantiateType(declaredConstraint, mapper); + if (constraint !== typeParameter) { + inferences = append(inferences, constraint); + } + } + } + } + } + } + } + return inferences && getIntersectionType(inferences); + } + function getConstraintFromTypeParameter(typeParameter: TypeParameter): Type { if (!typeParameter.constraint) { if (typeParameter.target) { @@ -6983,7 +7039,8 @@ namespace ts { } else { const constraintDeclaration = getConstraintDeclaration(typeParameter); - typeParameter.constraint = constraintDeclaration ? getTypeFromTypeNode(constraintDeclaration) : noConstraintType; + typeParameter.constraint = constraintDeclaration ? getTypeFromTypeNode(constraintDeclaration) : + getInferredTypeParameterConstraint(typeParameter) || noConstraintType; } } return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; @@ -7090,12 +7147,8 @@ namespace ts { const typeArguments = concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgs, typeParameters, minTypeArgumentCount, isJs)); return createTypeReference(type, typeArguments); } - if (node.typeArguments) { - error(node, Diagnostics.Type_0_is_not_generic, typeToString(type)); - return unknownType; + return checkNoTypeArguments(node, symbol) ? type : unknownType; } - return type; - } function getTypeAliasInstantiation(symbol: Symbol, typeArguments: Type[]): Type { const type = getDeclaredTypeOfSymbol(symbol); @@ -7132,12 +7185,8 @@ namespace ts { } return getTypeAliasInstantiation(symbol, typeArguments); } - if (node.typeArguments) { - error(node, Diagnostics.Type_0_is_not_generic, symbolToString(symbol)); - return unknownType; + return checkNoTypeArguments(node, symbol) ? type : unknownType; } - return type; - } function getTypeReferenceName(node: TypeReferenceType): EntityNameOrEntityNameExpression | undefined { switch (node.kind) { @@ -7177,12 +7226,10 @@ namespace ts { // Get type from reference to named type that cannot be generic (enum or type parameter) const res = tryGetDeclaredTypeOfSymbol(symbol); - if (res !== undefined) { - if (typeArguments) { - error(node, Diagnostics.Type_0_is_not_generic, symbolToString(symbol)); - return unknownType; - } - return res.flags & TypeFlags.TypeParameter ? getConstrainedTypeParameter(res, node) : res; + if (res) { + return checkNoTypeArguments(node, symbol) ? + res.flags & TypeFlags.TypeParameter ? getConstrainedTypeParameter(res, node) : res : + unknownType; } if (!(symbol.flags & SymbolFlags.Value && isJSDocTypeReference(node))) { @@ -7230,7 +7277,7 @@ namespace ts { function getConstrainedTypeParameter(typeParameter: TypeParameter, node: Node) { let constraints: Type[]; - while (isTypeNode(node)) { + while (isPartOfTypeNode(node)) { const parent = node.parent; if (parent.kind === SyntaxKind.ConditionalType && node === (parent).trueType) { if (getTypeFromTypeNode((parent).checkType) === typeParameter) { @@ -7246,39 +7293,58 @@ namespace ts { return node.flags & NodeFlags.JSDoc && node.kind === SyntaxKind.TypeReference; } + function checkNoTypeArguments(node: TypeReferenceType, symbol?: Symbol) { + if (node.typeArguments) { + error(node, Diagnostics.Type_0_is_not_generic, symbol ? symbolToString(symbol) : declarationNameToString((node).typeName)); + return false; + } + return true; + } + function getIntendedTypeFromJSDocTypeReference(node: TypeReferenceNode): Type { if (isIdentifier(node.typeName)) { - if (node.typeName.escapedText === "Object") { - if (isJSDocIndexSignature(node)) { - const indexed = getTypeFromTypeNode(node.typeArguments[0]); - const target = getTypeFromTypeNode(node.typeArguments[1]); - const index = createIndexInfo(target, /*isReadonly*/ false); - return createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, indexed === stringType && index, indexed === numberType && index); - } - return anyType; - } + const typeArgs = node.typeArguments; switch (node.typeName.escapedText) { case "String": + checkNoTypeArguments(node); return stringType; case "Number": + checkNoTypeArguments(node); return numberType; case "Boolean": + checkNoTypeArguments(node); return booleanType; case "Void": + checkNoTypeArguments(node); return voidType; case "Undefined": + checkNoTypeArguments(node); return undefinedType; case "Null": + checkNoTypeArguments(node); return nullType; case "Function": case "function": + checkNoTypeArguments(node); return globalFunctionType; case "Array": case "array": - return !node.typeArguments || !node.typeArguments.length ? anyArrayType : undefined; + return !typeArgs || !typeArgs.length ? anyArrayType : undefined; case "Promise": case "promise": - return !node.typeArguments || !node.typeArguments.length ? createPromiseType(anyType) : undefined; + return !typeArgs || !typeArgs.length ? createPromiseType(anyType) : undefined; + case "Object": + if (typeArgs && typeArgs.length === 2) { + if (isJSDocIndexSignature(node)) { + const indexed = getTypeFromTypeNode(typeArgs[0]); + const target = getTypeFromTypeNode(typeArgs[1]); + const index = createIndexInfo(target, /*isReadonly*/ false); + return createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, indexed === stringType && index, indexed === numberType && index); + } + return anyType; + } + checkNoTypeArguments(node); + return anyType; } } } @@ -7303,7 +7369,7 @@ namespace ts { type = getTypeReferenceType(node, symbol); } // Cache both the resolved symbol and the resolved type. The resolved symbol is needed in when we check the - // type reference in checkTypeReferenceOrExpressionWithTypeArguments. + // type reference in checkTypeReferenceNode. links.resolvedSymbol = symbol; links.resolvedType = type; } @@ -7952,7 +8018,7 @@ namespace ts { } if (!(indexType.flags & TypeFlags.Nullable) && isTypeAssignableToKind(indexType, TypeFlags.StringLike | TypeFlags.NumberLike | TypeFlags.ESSymbolLike)) { if (isTypeAny(objectType)) { - return anyType; + return objectType; } const indexInfo = isTypeAssignableToKind(indexType, TypeFlags.NumberLike) && getIndexInfoOfType(objectType, IndexKind.Number) || getIndexInfoOfType(objectType, IndexKind.String) || @@ -8156,7 +8222,7 @@ namespace ts { // types with type parameters mapped to the wildcard type, the most permissive instantiations // possible (the wildcard type is assignable to and from all types). If those are not related, // then no instatiations will be and we can just return the false branch type. - if (!isTypeAssignableTo(getWildcardInstantiation(checkType), getWildcardInstantiation(extendsType))) { + if (!typeMaybeAssignableTo(getWildcardInstantiation(checkType), getWildcardInstantiation(extendsType))) { return instantiateType(baseFalseType, mapper); } // The check could be true for some instantiation @@ -8189,19 +8255,24 @@ namespace ts { const erasedCheckType = getActualTypeParameter(checkType); const trueType = instantiateType(baseTrueType, mapper); const falseType = instantiateType(baseFalseType, mapper); - const id = target && (target.id + "," + erasedCheckType.id + "," + extendsType.id + "," + trueType.id + "," + falseType.id); - const cached = id && conditionalTypes.get(id); + // We compute the cache key from the ids of the four constituent types, plus an indicator of whether the + // type is distributive (i.e. whether the original declaration has a type parameter as the check type). + const isDistributive = (target ? target.checkType : erasedCheckType).flags & TypeFlags.TypeParameter ? 1 : 0; + const id = erasedCheckType.id + "," + extendsType.id + "," + trueType.id + "," + falseType.id + "," + isDistributive; + const cached = conditionalTypes.get(id); if (cached) { return cached; } const result = createConditionalType(erasedCheckType, extendsType, trueType, falseType, inferTypeParameters, target, mapper, aliasSymbol, instantiateTypes(baseAliasTypeArguments, mapper)); - if (id) { - conditionalTypes.set(id, result); - } + conditionalTypes.set(id, result); return result; } + function isDistributiveConditionalType(type: ConditionalType) { + return !!((type.target || type).checkType.flags & TypeFlags.TypeParameter); + } + function getInferTypeParameters(node: ConditionalTypeNode): TypeParameter[] { let result: TypeParameter[]; if (node.locals) { @@ -8814,9 +8885,9 @@ namespace ts { // Check if we have a conditional type where the check type is a naked type parameter. If so, // the conditional type is distributive over union types and when T is instantiated to a union // type A | B, we produce (A extends U ? X : Y) | (B extends U ? X : Y). - const checkType = target.checkType; - if (checkType.flags & TypeFlags.TypeParameter) { - const instantiatedType = combinedMapper(checkType); + if (isDistributiveConditionalType(target)) { + const checkType = target.checkType; + const instantiatedType = combinedMapper(checkType); if (checkType !== instantiatedType && instantiatedType.flags & TypeFlags.Union) { return mapType(instantiatedType, t => instantiateConditionalType(target, createReplacementMapper(checkType, t, combinedMapper))); } @@ -9593,17 +9664,43 @@ namespace ts { function isIdenticalTo(source: Type, target: Type): Ternary { let result: Ternary; - if (source.flags & TypeFlags.Object && target.flags & TypeFlags.Object) { + const flags = source.flags & target.flags; + if (flags & TypeFlags.Object) { return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false); } - if (source.flags & TypeFlags.Union && target.flags & TypeFlags.Union || - source.flags & TypeFlags.Intersection && target.flags & TypeFlags.Intersection) { + if (flags & (TypeFlags.Union | TypeFlags.Intersection)) { if (result = eachTypeRelatedToSomeType(source, target)) { if (result &= eachTypeRelatedToSomeType(target, source)) { return result; } } } + if (flags & TypeFlags.Index) { + return isRelatedTo((source).type, (target).type, /*reportErrors*/ false); + } + if (flags & TypeFlags.IndexedAccess) { + if (result = isRelatedTo((source).objectType, (target).objectType, /*reportErrors*/ false)) { + if (result &= isRelatedTo((source).indexType, (target).indexType, /*reportErrors*/ false)) { + return result; + } + } + } + if (flags & TypeFlags.Conditional) { + if (result = isRelatedTo((source).checkType, (target).checkType, /*reportErrors*/ false)) { + if (result &= isRelatedTo((source).extendsType, (target).extendsType, /*reportErrors*/ false)) { + if (result &= isRelatedTo((source).trueType, (target).trueType, /*reportErrors*/ false)) { + if (result &= isRelatedTo((source).falseType, (target).falseType, /*reportErrors*/ false)) { + if (isDistributiveConditionalType(source) === isDistributiveConditionalType(target)) { + return result; + } + } + } + } + } + } + if (flags & TypeFlags.Substitution) { + return isRelatedTo((source).substitute, (target).substitute, /*reportErrors*/ false); + } return Ternary.False; } @@ -9890,7 +9987,7 @@ namespace ts { if (target.flags & TypeFlags.TypeParameter) { // A source type { [P in keyof T]: X } is related to a target type T if X is related to T[P]. if (getObjectFlags(source) & ObjectFlags.Mapped && getConstraintTypeFromMappedType(source) === getIndexType(target)) { - if (!(source).declaration.questionToken) { + if (!(getMappedTypeModifiers(source) & MappedTypeModifiers.IncludeOptional)) { const templateType = getTemplateTypeFromMappedType(source); const indexedAccessType = getIndexedAccessType(target, getTypeParameterFromMappedType(source)); if (result = isRelatedTo(templateType, indexedAccessType, reportErrors)) { @@ -9929,6 +10026,8 @@ namespace ts { else if (isGenericMappedType(target)) { // A source type T is related to a target type { [P in X]: T[P] } const template = getTemplateTypeFromMappedType(target); + const modifiers = getMappedTypeModifiers(target); + if (!(modifiers & MappedTypeModifiers.ExcludeOptional)) { if (template.flags & TypeFlags.IndexedAccess && (template).objectType === source && (template).indexType === getTypeParameterFromMappedType(target)) { return Ternary.True; @@ -9943,6 +10042,7 @@ namespace ts { } } } + } if (source.flags & TypeFlags.TypeParameter) { let constraint = getConstraintForRelation(source); @@ -9989,7 +10089,19 @@ namespace ts { } } } - if (result = isRelatedTo(getDefaultConstraintOfConditionalType(source), target, reportErrors)) { + if (target.flags & TypeFlags.Conditional) { + if (isTypeIdenticalTo((source).checkType, (target).checkType) && + isTypeIdenticalTo((source).extendsType, (target).extendsType)) { + if (result = isRelatedTo((source).trueType, (target).trueType, reportErrors)) { + result &= isRelatedTo((source).falseType, (target).falseType, reportErrors); + } + if (result) { + errorInfo = saveErrorInfo; + return result; + } + } + } + else if (result = isRelatedTo(getDefaultConstraintOfConditionalType(source), target, reportErrors)) { errorInfo = saveErrorInfo; return result; } @@ -10080,8 +10192,7 @@ namespace ts { function mappedTypeRelatedTo(source: MappedType, target: MappedType, reportErrors: boolean): Ternary { const modifiersRelated = relation === comparableRelation || ( relation === identityRelation ? getMappedTypeModifiers(source) === getMappedTypeModifiers(target) : - !(getCombinedMappedTypeModifiers(source) & MappedTypeModifiers.Optional) || - getCombinedMappedTypeModifiers(target) & MappedTypeModifiers.Optional); + getCombinedMappedTypeOptionality(source) <= getCombinedMappedTypeOptionality(target)); if (modifiersRelated) { let result: Ternary; if (result = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) { @@ -11124,7 +11235,7 @@ namespace ts { const t = getTypeOfSymbol(p); if (t.flags & TypeFlags.ContainsWideningType) { if (!reportWideningErrorsInType(t)) { - error(p.valueDeclaration, Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, symbolName(p), typeToString(getWidenedType(t))); + error(p.valueDeclaration, Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, symbolToString(p), typeToString(getWidenedType(t))); } errorReported = true; } @@ -12844,11 +12955,11 @@ namespace ts { const operator = expr.operatorToken.kind; const left = getReferenceCandidate(expr.left); const right = getReferenceCandidate(expr.right); - if (left.kind === SyntaxKind.TypeOfExpression && (right.kind === SyntaxKind.StringLiteral || right.kind === SyntaxKind.NoSubstitutionTemplateLiteral)) { - return narrowTypeByTypeof(type, left, operator, right, assumeTrue); + if (left.kind === SyntaxKind.TypeOfExpression && isStringLiteralLike(right)) { + return narrowTypeByTypeof(type, left, operator, right, assumeTrue); } - if (right.kind === SyntaxKind.TypeOfExpression && (left.kind === SyntaxKind.StringLiteral || left.kind === SyntaxKind.NoSubstitutionTemplateLiteral)) { - return narrowTypeByTypeof(type, right, operator, left, assumeTrue); + if (right.kind === SyntaxKind.TypeOfExpression && isStringLiteralLike(left)) { + return narrowTypeByTypeof(type, right, operator, left, assumeTrue); } if (isMatchingReference(reference, left)) { return narrowTypeByEquality(type, operator, right, assumeTrue); @@ -12870,8 +12981,8 @@ namespace ts { return narrowTypeByInstanceof(type, expr, assumeTrue); case SyntaxKind.InKeyword: const target = getReferenceCandidate(expr.right); - if ((expr.left.kind === SyntaxKind.StringLiteral || expr.left.kind === SyntaxKind.NoSubstitutionTemplateLiteral) && isMatchingReference(reference, target)) { - return narrowByInKeyword(type, expr.left, assumeTrue); + if (isStringLiteralLike(expr.left) && isMatchingReference(reference, target)) { + return narrowByInKeyword(type, expr.left, assumeTrue); } break; case SyntaxKind.CommaToken: @@ -16212,24 +16323,13 @@ namespace ts { propertyName: __String, type: Type): boolean { - if (type !== unknownType && !isTypeAny(type)) { - const prop = getPropertyOfType(type, propertyName); - if (prop) { - return checkPropertyAccessibility(node, left, type, prop); - } - - // In js files properties of unions are allowed in completion - if (isInJavaScriptFile(left) && (type.flags & TypeFlags.Union)) { - for (const elementType of (type).types) { - if (isValidPropertyAccessWithType(node, left, propertyName, elementType)) { - return true; - } - } - } - - return false; + if (type === unknownType || isTypeAny(type)) { + return true; } - return true; + const prop = getPropertyOfType(type, propertyName); + return prop ? checkPropertyAccessibility(node, left, type, prop) + // In js files properties of unions are allowed in completion + : isInJavaScriptFile(node) && (type.flags & TypeFlags.Union) && (type).types.some(elementType => isValidPropertyAccessWithType(node, left, propertyName, elementType)); } /** @@ -18348,7 +18448,7 @@ namespace ts { * * @param returnType - return type of the function, can be undefined if return type is not explicitly specified */ - function checkAllCodePathsInNonVoidFunctionReturnOrThrow(func: FunctionLikeDeclaration, returnType: Type): void { + function checkAllCodePathsInNonVoidFunctionReturnOrThrow(func: FunctionLikeDeclaration | MethodSignature, returnType: Type): void { if (!produceDiagnostics) { return; } @@ -18360,7 +18460,7 @@ namespace ts { // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (nodeIsMissing(func.body) || func.body.kind !== SyntaxKind.Block || !functionHasImplicitReturn(func)) { + if (func.kind === SyntaxKind.MethodSignature || nodeIsMissing(func.body) || func.body.kind !== SyntaxKind.Block || !functionHasImplicitReturn(func)) { return; } @@ -19524,7 +19624,7 @@ namespace ts { return nullWideningType; case SyntaxKind.NoSubstitutionTemplateLiteral: case SyntaxKind.StringLiteral: - return getFreshTypeOfLiteralType(getLiteralType((node as LiteralExpression).text)); + return getFreshTypeOfLiteralType(getLiteralType((node as StringLiteralLike).text)); case SyntaxKind.NumericLiteral: checkGrammarNumericLiteral(node as NumericLiteral); return getFreshTypeOfLiteralType(getLiteralType(+(node as NumericLiteral).text)); @@ -20031,7 +20131,7 @@ namespace ts { checkVariableLikeDeclaration(node); } - function checkMethodDeclaration(node: MethodDeclaration) { + function checkMethodDeclaration(node: MethodDeclaration | MethodSignature) { // Grammar checking if (!checkGrammarMethod(node)) checkGrammarComputedPropertyName(node.name); @@ -20040,7 +20140,7 @@ namespace ts { // Abstract methods cannot have an implementation. // Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node. - if (hasModifier(node, ModifierFlags.Abstract) && node.body) { + if (hasModifier(node, ModifierFlags.Abstract) && node.kind === SyntaxKind.MethodDeclaration && node.body) { error(node, Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, declarationNameToString(node.name)); } } @@ -20187,8 +20287,12 @@ namespace ts { checkDecorators(node); } - function checkTypeArgumentConstraints(typeParameters: TypeParameter[], typeArgumentNodes: ReadonlyArray): boolean { - const minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); + function getEffectiveTypeArguments(node: TypeReferenceNode | ExpressionWithTypeArguments, typeParameters: TypeParameter[]) { + return fillMissingTypeArguments(map(node.typeArguments, getTypeFromTypeNode), typeParameters, + getMinTypeArgumentCount(typeParameters), isInJavaScriptFile(node)); + } + + function checkTypeArgumentConstraints(node: TypeReferenceNode | ExpressionWithTypeArguments, typeParameters: TypeParameter[]): boolean { let typeArguments: Type[]; let mapper: TypeMapper; let result = true; @@ -20196,25 +20300,35 @@ namespace ts { const constraint = getConstraintOfTypeParameter(typeParameters[i]); if (constraint) { if (!typeArguments) { - typeArguments = fillMissingTypeArguments(map(typeArgumentNodes, getTypeFromTypeNode), typeParameters, minTypeArgumentCount, isInJavaScriptFile(typeArgumentNodes[i])); + typeArguments = getEffectiveTypeArguments(node, typeParameters); mapper = createTypeMapper(typeParameters, typeArguments); } - const typeArgument = typeArguments[i]; result = result && checkTypeAssignableTo( - typeArgument, + typeArguments[i], instantiateType(constraint, mapper), - typeArgumentNodes[i], + node.typeArguments[i], Diagnostics.Type_0_does_not_satisfy_the_constraint_1); } } return result; } + function getTypeParametersForTypeReference(node: TypeReferenceNode | ExpressionWithTypeArguments) { + const type = getTypeFromTypeReference(node); + if (type !== unknownType) { + const symbol = getNodeLinks(node).resolvedSymbol; + if (symbol) { + return symbol.flags & SymbolFlags.TypeAlias && getSymbolLinks(symbol).typeParameters || + (getObjectFlags(type) & ObjectFlags.Reference ? (type).target.localTypeParameters : undefined); + } + } + return undefined; + } + function checkTypeReferenceNode(node: TypeReferenceNode | ExpressionWithTypeArguments) { checkGrammarTypeArguments(node, node.typeArguments); if (node.kind === SyntaxKind.TypeReference && node.typeName.jsdocDotPos !== undefined && !isInJavaScriptFile(node) && !isInJSDoc(node)) { grammarErrorAtPos(node, node.typeName.jsdocDotPos, 1, Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments); - } const type = getTypeFromTypeReference(node); if (type !== unknownType) { @@ -20222,22 +20336,10 @@ namespace ts { // Do type argument local checks only if referenced type is successfully resolved forEach(node.typeArguments, checkSourceElement); if (produceDiagnostics) { - const symbol = getNodeLinks(node).resolvedSymbol; - if (!symbol) { - // There is no resolved symbol cached if the type resolved to a builtin - // via JSDoc type reference resolution (eg, Boolean became boolean), none - // of which are generic when they have no associated symbol - // (additionally, JSDoc's index signature syntax, Object actually uses generic syntax without being generic) - if (!isJSDocIndexSignature(node)) { - error(node, Diagnostics.Type_0_is_not_generic, typeToString(type)); - } - return; + const typeParameters = getTypeParametersForTypeReference(node); + if (typeParameters) { + checkTypeArgumentConstraints(node, typeParameters); } - let typeParameters = symbol.flags & SymbolFlags.TypeAlias && getSymbolLinks(symbol).typeParameters; - if (!typeParameters && getObjectFlags(type) & ObjectFlags.Reference) { - typeParameters = (type).target.localTypeParameters; - } - checkTypeArgumentConstraints(typeParameters, node.typeArguments); } } if (type.flags & TypeFlags.Enum && getNodeLinks(node).resolvedSymbol.flags & SymbolFlags.EnumMember) { @@ -20246,6 +20348,14 @@ namespace ts { } } + function getTypeArgumentConstraint(node: TypeNode): Type | undefined { + const typeReferenceNode = tryCast(node.parent, isTypeReferenceType); + if (!typeReferenceNode) return undefined; + const typeParameters = getTypeParametersForTypeReference(typeReferenceNode); + const constraint = getConstraintOfTypeParameter(typeParameters[typeReferenceNode.typeArguments.indexOf(node)!]); + return constraint && instantiateType(constraint, createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReferenceNode, typeParameters))); + } + function checkTypeQuery(node: TypeQueryNode) { getTypeFromTypeQueryNode(node); } @@ -20287,7 +20397,7 @@ namespace ts { const indexType = (type).indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType))) { if (accessNode.kind === SyntaxKind.ElementAccessExpression && isAssignmentTarget(accessNode) && - getObjectFlags(objectType) & ObjectFlags.Mapped && (objectType).declaration.readonlyToken) { + getObjectFlags(objectType) & ObjectFlags.Mapped && getMappedTypeModifiers(objectType) & MappedTypeModifiers.IncludeReadonly) { error(accessNode, Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); } return type; @@ -20671,7 +20781,7 @@ namespace ts { case SyntaxKind.ImportSpecifier: // https://github.com/Microsoft/TypeScript/pull/7591 return DeclarationSpaces.ExportValue; default: - Debug.fail((ts as any).SyntaxKind[d.kind]); + Debug.fail(Debug.showSyntaxKind(d)); } } } @@ -20867,7 +20977,7 @@ namespace ts { * * @param node The signature to check */ - function checkAsyncFunctionReturnType(node: FunctionLikeDeclaration): Type { + function checkAsyncFunctionReturnType(node: FunctionLikeDeclaration | MethodSignature): Type { // As part of our emit for an async function, we will need to emit the entity name of // the return type annotation as an expression. To meet the necessary runtime semantics // for __awaiter, we must also check that the type of the declaration (e.g. the static @@ -21229,7 +21339,7 @@ namespace ts { } } - function checkFunctionOrMethodDeclaration(node: FunctionDeclaration | MethodDeclaration): void { + function checkFunctionOrMethodDeclaration(node: FunctionDeclaration | MethodDeclaration | MethodSignature): void { checkDecorators(node); checkSignatureDeclaration(node); const functionFlags = getFunctionFlags(node); @@ -21271,7 +21381,8 @@ namespace ts { } } - checkSourceElement(node.body); + const body = node.kind === SyntaxKind.MethodSignature ? undefined : node.body; + checkSourceElement(body); const returnTypeNode = getEffectiveReturnTypeNode(node); if ((functionFlags & FunctionFlags.Generator) === 0) { // Async function or normal function @@ -21284,11 +21395,11 @@ namespace ts { if (produceDiagnostics && !returnTypeNode) { // Report an implicit any error if there is no body, no explicit return type, and node is not a private method // in an ambient context - if (noImplicitAny && nodeIsMissing(node.body) && !isPrivateWithinAmbient(node)) { + if (noImplicitAny && nodeIsMissing(body) && !isPrivateWithinAmbient(node)) { reportImplicitAnyError(node, anyType); } - if (functionFlags & FunctionFlags.Generator && nodeIsPresent(node.body)) { + if (functionFlags & FunctionFlags.Generator && nodeIsPresent(body)) { // A generator with a body and no type annotation can still cause errors. It can error if the // yielded values have no common supertype, or it can give an implicit any error if it has no // yielded values. The only way to trigger these errors is to try checking its return type. @@ -21954,20 +22065,6 @@ namespace ts { forEach(node.declarationList.declarations, checkSourceElement); } - function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node: MethodDeclaration) { - // We only disallow modifier on a method declaration if it is a property of object-literal-expression - if (node.modifiers && node.parent.kind === SyntaxKind.ObjectLiteralExpression) { - if (getFunctionFlags(node) & FunctionFlags.Async) { - if (node.modifiers.length > 1) { - return grammarErrorOnFirstToken(node, Diagnostics.Modifiers_cannot_appear_here); - } - } - else { - return grammarErrorOnFirstToken(node, Diagnostics.Modifiers_cannot_appear_here); - } - } - } - function checkExpressionStatement(node: ExpressionStatement) { // Grammar checking checkGrammarStatementInAmbientContext(node); @@ -22935,7 +23032,7 @@ namespace ts { if (some(baseTypeNode.typeArguments)) { forEach(baseTypeNode.typeArguments, checkSourceElement); for (const constructor of getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode)) { - if (!checkTypeArgumentConstraints(constructor.typeParameters, baseTypeNode.typeArguments)) { + if (!checkTypeArgumentConstraints(baseTypeNode, constructor.typeParameters)) { break; } } @@ -24021,7 +24118,7 @@ namespace ts { return checkSignatureDeclaration(node); case SyntaxKind.MethodDeclaration: case SyntaxKind.MethodSignature: - return checkMethodDeclaration(node); + return checkMethodDeclaration(node); case SyntaxKind.Constructor: return checkConstructorDeclaration(node); case SyntaxKind.GetAccessor: @@ -24619,7 +24716,8 @@ namespace ts { if (entityName.kind === SyntaxKind.Identifier) { if (isJSXTagName(entityName) && isJsxIntrinsicIdentifier(entityName)) { - return getIntrinsicTagSymbol(entityName.parent); + const symbol = getIntrinsicTagSymbol(entityName.parent); + return symbol === unknownSymbol ? undefined : symbol; } return resolveEntityName(entityName, SymbolFlags.Value, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); @@ -24829,8 +24927,10 @@ namespace ts { if (isInRightSideOfImportOrExportAssignment(node)) { const symbol = getSymbolAtLocation(node); - const declaredType = symbol && getDeclaredTypeOfSymbol(symbol); - return declaredType !== unknownType ? declaredType : getTypeOfSymbol(symbol); + if (symbol) { + const declaredType = getDeclaredTypeOfSymbol(symbol); + return declaredType !== unknownType ? declaredType : getTypeOfSymbol(symbol); + } } return unknownType; @@ -25010,7 +25110,7 @@ namespace ts { // we prefix depends on the kind of entity. SymbolFlags.ExportHasLocal encompasses all the // kinds that we do NOT prefix. const exportSymbol = getMergedSymbol(symbol.exportSymbol); - if (!prefixLocals && exportSymbol.flags & SymbolFlags.ExportHasLocal) { + if (!prefixLocals && exportSymbol.flags & SymbolFlags.ExportHasLocal && !(exportSymbol.flags & SymbolFlags.Variable)) { return undefined; } symbol = exportSymbol; @@ -26049,7 +26149,7 @@ namespace ts { } } - function checkGrammarFunctionLikeDeclaration(node: FunctionLikeDeclaration): boolean { + function checkGrammarFunctionLikeDeclaration(node: FunctionLikeDeclaration | MethodSignature): boolean { // Prevent cascading error by short-circuit const file = getSourceFileOfNode(node); return checkGrammarDecoratorsAndModifiers(node) || checkGrammarTypeParameterList(node.typeParameters, file) || @@ -26061,16 +26161,15 @@ namespace ts { return checkGrammarClassDeclarationHeritageClauses(node) || checkGrammarTypeParameterList(node.typeParameters, file); } - function checkGrammarArrowFunction(node: FunctionLikeDeclaration, file: SourceFile): boolean { - if (node.kind === SyntaxKind.ArrowFunction) { - const arrowFunction = node; - const startLine = getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; - const endLine = getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; - if (startLine !== endLine) { - return grammarErrorOnNode(arrowFunction.equalsGreaterThanToken, Diagnostics.Line_terminator_not_permitted_before_arrow); - } + function checkGrammarArrowFunction(node: Node, file: SourceFile): boolean { + if (!isArrowFunction(node)) { + return false; } - return false; + + const { equalsGreaterThanToken } = node; + const startLine = getLineAndCharacterOfPosition(file, equalsGreaterThanToken.pos).line; + const endLine = getLineAndCharacterOfPosition(file, equalsGreaterThanToken.end).line; + return startLine !== endLine && grammarErrorOnNode(equalsGreaterThanToken, Diagnostics.Line_terminator_not_permitted_before_arrow); } function checkGrammarIndexSignatureParameters(node: SignatureDeclaration): boolean { @@ -26535,19 +26634,26 @@ namespace ts { } } - function checkGrammarMethod(node: MethodDeclaration) { - if (checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) || - checkGrammarFunctionLikeDeclaration(node) || - checkGrammarForGenerator(node)) { + function checkGrammarMethod(node: MethodDeclaration | MethodSignature) { + if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.parent.kind === SyntaxKind.ObjectLiteralExpression) { - if (checkGrammarForInvalidQuestionMark(node.questionToken, Diagnostics.An_object_member_cannot_be_declared_optional)) { - return true; + if (node.kind === SyntaxKind.MethodDeclaration) { + if (node.parent.kind === SyntaxKind.ObjectLiteralExpression) { + // We only disallow modifier on a method declaration if it is a property of object-literal-expression + if (node.modifiers && !(node.modifiers.length === 1 && first(node.modifiers).kind === SyntaxKind.AsyncKeyword)) { + return grammarErrorOnFirstToken(node, Diagnostics.Modifiers_cannot_appear_here); + } + else if (checkGrammarForInvalidQuestionMark(node.questionToken, Diagnostics.An_object_member_cannot_be_declared_optional)) { + return true; + } + else if (node.body === undefined) { + return grammarErrorAtPos(node, node.end - 1, ";".length, Diagnostics._0_expected, "{"); + } } - else if (node.body === undefined) { - return grammarErrorAtPos(node, node.end - 1, ";".length, Diagnostics._0_expected, "{"); + if (checkGrammarForGenerator(node)) { + return true; } } @@ -26560,7 +26666,7 @@ namespace ts { if (node.flags & NodeFlags.Ambient) { return checkGrammarForInvalidDynamicName(node.name, Diagnostics.A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } - else if (!node.body) { + else if (node.kind === SyntaxKind.MethodDeclaration && !node.body) { return checkGrammarForInvalidDynamicName(node.name, Diagnostics.A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } } diff --git a/src/compiler/core.ts b/src/compiler/core.ts index f6f2667c276..424380892c7 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -6,7 +6,7 @@ namespace ts { // If changing the text in this section, be sure to test `configureNightly` too. export const versionMajorMinor = "2.8"; /** The version of the TypeScript compiler release */ - export const version = `${versionMajorMinor}.0`; + export const version = `${versionMajorMinor}.0-dev`; } namespace ts { @@ -794,6 +794,18 @@ namespace ts { return deduplicated; } + export function insertSorted(array: SortedArray, insert: T, compare: Comparer): void { + if (array.length === 0) { + array.push(insert); + return; + } + + const insertIndex = binarySearch(array, insert, identity, compare); + if (insertIndex < 0) { + array.splice(~insertIndex, 0, insert); + } + } + export function sortAndDeduplicate(array: ReadonlyArray, comparer: Comparer, equalityComparer?: EqualityComparer) { return deduplicateSorted(sort(array, comparer), equalityComparer || comparer); } @@ -1454,7 +1466,7 @@ namespace ts { if (value !== undefined && test(value)) return value; if (value && typeof (value as any).kind === "number") { - Debug.fail(`Invalid cast. The supplied ${(ts as any).SyntaxKind[(value as any).kind]} did not pass the test '${Debug.getFunctionName(test)}'.`); + Debug.fail(`Invalid cast. The supplied ${Debug.showSyntaxKind(value as any as Node)} did not pass the test '${Debug.getFunctionName(test)}'.`); } else { Debug.fail(`Invalid cast. The supplied value did not pass the test '${Debug.getFunctionName(test)}'.`); @@ -2889,6 +2901,13 @@ namespace ts { return value; } + export function assertEachDefined>(value: A, message: string): A { + for (const v of value) { + assertDefined(v, message); + } + return value; + } + export function assertNever(member: never, message?: string, stackCrawlMark?: AnyFunction): never { return fail(message || `Illegal value: ${member}`, stackCrawlMark || assertNever); } @@ -2906,6 +2925,27 @@ namespace ts { return match ? match[1] : ""; } } + + export function showSymbol(symbol: Symbol): string { + const symbolFlags = (ts as any).SymbolFlags; + return `{ flags: ${symbolFlags ? showFlags(symbol.flags, symbolFlags) : symbol.flags}; declarations: ${map(symbol.declarations, showSyntaxKind)} }`; + } + + function showFlags(flags: number, flagsEnum: { [flag: number]: string }): string { + const out = []; + for (let pow = 0; pow <= 30; pow++) { + const n = 1 << pow; + if (flags & n) { + out.push(flagsEnum[n]); + } + } + return out.join("|"); + } + + export function showSyntaxKind(node: Node): string { + const syntaxKind = (ts as any).SyntaxKind; + return syntaxKind ? syntaxKind[node.kind] : node.kind.toString(); + } } /** Remove an item from an array, moving everything to its right one space left. */ @@ -2985,7 +3025,7 @@ namespace ts { */ export function matchedText(pattern: Pattern, candidate: string): string { Debug.assert(isPatternMatch(pattern, candidate)); - return candidate.substr(pattern.prefix.length, candidate.length - pattern.suffix.length); + return candidate.substring(pattern.prefix.length, candidate.length - pattern.suffix.length); } /** Return the object corresponding to the best pattern to match `candidate`. */ diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index 24646ff31eb..f18a32889aa 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -593,7 +593,9 @@ namespace ts { writeLine(); increaseIndent(); if (node.readonlyToken) { - write("readonly "); + write(node.readonlyToken.kind === SyntaxKind.PlusToken ? "+readonly " : + node.readonlyToken.kind === SyntaxKind.MinusToken ? "-readonly " : + "readonly "); } write("["); writeEntityName(node.typeParameter.name); @@ -601,7 +603,9 @@ namespace ts { emitType(node.typeParameter.constraint); write("]"); if (node.questionToken) { - write("?"); + write(node.questionToken.kind === SyntaxKind.PlusToken ? "+?" : + node.questionToken.kind === SyntaxKind.MinusToken ? "-?" : + "?"); } write(": "); emitType(node.type); diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 77614dd7573..f120e81283a 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1984,6 +1984,11 @@ "category": "Error", "code": 2566 }, + "Enum declarations can only merge with namespace or other enum declarations.": { + "category": "Error", + "code": 2567 + }, + "JSX element attributes type '{0}' may not be a union type.": { "category": "Error", "code": 2600 diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 3c9866b3536..735e0d67f47 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1251,14 +1251,20 @@ namespace ts { } if (node.readonlyToken) { emit(node.readonlyToken); + if (node.readonlyToken.kind !== SyntaxKind.ReadonlyKeyword) { + writeKeyword("readonly"); + } writeSpace(); } - writePunctuation("["); pipelineEmitWithNotification(EmitHint.MappedTypeParameter, node.typeParameter); writePunctuation("]"); - - emitIfPresent(node.questionToken); + if (node.questionToken) { + emit(node.questionToken); + if (node.questionToken.kind !== SyntaxKind.QuestionToken) { + writePunctuation("?"); + } + } writePunctuation(":"); writeSpace(); emit(node.type); diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 165c70b37e6..8166196e469 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -804,7 +804,7 @@ namespace ts { : node; } - export function createMappedTypeNode(readonlyToken: ReadonlyToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | undefined, type: TypeNode | undefined): MappedTypeNode { + export function createMappedTypeNode(readonlyToken: ReadonlyToken | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined): MappedTypeNode { const node = createSynthesizedNode(SyntaxKind.MappedType) as MappedTypeNode; node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; @@ -813,7 +813,7 @@ namespace ts { return node; } - export function updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | undefined, type: TypeNode | undefined): MappedTypeNode { + export function updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyToken | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined): MappedTypeNode { return node.readonlyToken !== readonlyToken || node.typeParameter !== typeParameter || node.questionToken !== questionToken diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 3209f234f85..b71983b9783 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -695,7 +695,7 @@ namespace ts { else if (token() === SyntaxKind.OpenBraceToken || lookAhead(() => token() === SyntaxKind.StringLiteral)) { result.jsonObject = parseObjectLiteralExpression(); - sourceFile.endOfFileToken = parseExpectedToken(SyntaxKind.EndOfFileToken, /*reportAtCurrentPosition*/ false, Diagnostics.Unexpected_token); + sourceFile.endOfFileToken = parseExpectedToken(SyntaxKind.EndOfFileToken, Diagnostics.Unexpected_token); } else { parseExpected(SyntaxKind.OpenBraceToken); @@ -1135,10 +1135,10 @@ namespace ts { return undefined; } - function parseExpectedToken(t: TKind, reportAtCurrentPosition: boolean, diagnosticMessage: DiagnosticMessage, arg0?: any): Token; - function parseExpectedToken(t: SyntaxKind, reportAtCurrentPosition: boolean, diagnosticMessage: DiagnosticMessage, arg0?: any): Node { + function parseExpectedToken(t: TKind, diagnosticMessage?: DiagnosticMessage, arg0?: any): Token; + function parseExpectedToken(t: SyntaxKind, diagnosticMessage?: DiagnosticMessage, arg0?: any): Node { return parseOptionalToken(t) || - createMissingNode(t, reportAtCurrentPosition, diagnosticMessage, arg0); + createMissingNode(t, /*reportAtCurrentPosition*/ false, diagnosticMessage || Diagnostics._0_expected, arg0 || tokenToString(t)); } function parseTokenNode(): T { @@ -2113,7 +2113,7 @@ namespace ts { literal = parseTemplateMiddleOrTemplateTail(); } else { - literal = parseExpectedToken(SyntaxKind.TemplateTail, /*reportAtCurrentPosition*/ false, Diagnostics._0_expected, tokenToString(SyntaxKind.CloseBraceToken)); + literal = parseExpectedToken(SyntaxKind.TemplateTail, Diagnostics._0_expected, tokenToString(SyntaxKind.CloseBraceToken)); } span.literal = literal; @@ -2607,6 +2607,9 @@ namespace ts { function isStartOfMappedType() { nextToken(); + if (token() === SyntaxKind.PlusToken || token() === SyntaxKind.MinusToken) { + return nextToken() === SyntaxKind.ReadonlyKeyword; + } if (token() === SyntaxKind.ReadonlyKeyword) { nextToken(); } @@ -2624,11 +2627,21 @@ namespace ts { function parseMappedType() { const node = createNode(SyntaxKind.MappedType); parseExpected(SyntaxKind.OpenBraceToken); - node.readonlyToken = parseOptionalToken(SyntaxKind.ReadonlyKeyword); + if (token() === SyntaxKind.ReadonlyKeyword || token() === SyntaxKind.PlusToken || token() === SyntaxKind.MinusToken) { + node.readonlyToken = parseTokenNode(); + if (node.readonlyToken.kind !== SyntaxKind.ReadonlyKeyword) { + parseExpectedToken(SyntaxKind.ReadonlyKeyword); + } + } parseExpected(SyntaxKind.OpenBracketToken); node.typeParameter = parseMappedTypeParameter(); parseExpected(SyntaxKind.CloseBracketToken); - node.questionToken = parseOptionalToken(SyntaxKind.QuestionToken); + if (token() === SyntaxKind.QuestionToken || token() === SyntaxKind.PlusToken || token() === SyntaxKind.MinusToken) { + node.questionToken = parseTokenNode(); + if (node.questionToken.kind !== SyntaxKind.QuestionToken) { + parseExpectedToken(SyntaxKind.QuestionToken); + } + } node.type = parseTypeAnnotation(); parseSemicolon(); parseExpected(SyntaxKind.CloseBraceToken); @@ -3242,7 +3255,7 @@ namespace ts { node.parameters = createNodeArray([parameter], parameter.pos, parameter.end); - node.equalsGreaterThanToken = parseExpectedToken(SyntaxKind.EqualsGreaterThanToken, /*reportAtCurrentPosition*/ false, Diagnostics._0_expected, "=>"); + node.equalsGreaterThanToken = parseExpectedToken(SyntaxKind.EqualsGreaterThanToken); node.body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier); return addJSDocComment(finishNode(node)); @@ -3273,7 +3286,7 @@ namespace ts { // If we have an arrow, then try to parse the body. Even if not, try to parse if we // have an opening brace, just in case we're in an error state. const lastToken = token(); - arrowFunction.equalsGreaterThanToken = parseExpectedToken(SyntaxKind.EqualsGreaterThanToken, /*reportAtCurrentPosition*/ false, Diagnostics._0_expected, "=>"); + arrowFunction.equalsGreaterThanToken = parseExpectedToken(SyntaxKind.EqualsGreaterThanToken); arrowFunction.body = (lastToken === SyntaxKind.EqualsGreaterThanToken || lastToken === SyntaxKind.OpenBraceToken) ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); @@ -3539,8 +3552,7 @@ namespace ts { node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(SyntaxKind.ColonToken, /*reportAtCurrentPosition*/ false, - Diagnostics._0_expected, tokenToString(SyntaxKind.ColonToken)); + node.colonToken = parseExpectedToken(SyntaxKind.ColonToken); node.whenFalse = nodeIsPresent(node.colonToken) ? parseAssignmentExpressionOrHigher() : createMissingNode(SyntaxKind.Identifier, /*reportAtCurrentPosition*/ false, Diagnostics._0_expected, tokenToString(SyntaxKind.ColonToken)); @@ -4014,7 +4026,7 @@ namespace ts { // If it wasn't then just try to parse out a '.' and report an error. const node = createNode(SyntaxKind.PropertyAccessExpression, expression.pos); node.expression = expression; - parseExpectedToken(SyntaxKind.DotToken, /*reportAtCurrentPosition*/ false, Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + parseExpectedToken(SyntaxKind.DotToken, Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); return finishNode(node); } diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index ef1a3f8fd49..8cafd8c0138 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -120,7 +120,10 @@ namespace ts { }; export let sys: System = (() => { - const utf8ByteOrderMark = "\u00EF\u00BB\u00BF"; + // NodeJS detects "\uFEFF" at the start of the string and *replaces* it with the actual + // byte order mark from the specified encoding. Using any other byte order mark does + // not actually work. + const byteOrderMarkIndicator = "\uFEFF"; function getNodeSystem(): System { const _fs = require("fs"); @@ -367,7 +370,7 @@ namespace ts { function writeFile(fileName: string, data: string, writeByteOrderMark?: boolean): void { // If a BOM is required, emit one if (writeByteOrderMark) { - data = utf8ByteOrderMark + data; + data = byteOrderMarkIndicator + data; } let fd: number; @@ -572,7 +575,7 @@ namespace ts { writeFile(path: string, data: string, writeByteOrderMark?: boolean) { // If a BOM is required, emit one if (writeByteOrderMark) { - data = utf8ByteOrderMark + data; + data = byteOrderMarkIndicator + data; } ChakraHost.writeFile(path, data); diff --git a/src/compiler/transformers/esnext.ts b/src/compiler/transformers/esnext.ts index 424371ad311..82ff52ead90 100644 --- a/src/compiler/transformers/esnext.ts +++ b/src/compiler/transformers/esnext.ts @@ -153,7 +153,7 @@ namespace ts { if (statement.kind === SyntaxKind.ForOfStatement && (statement).awaitModifier) { return visitForOfStatement(statement, node); } - return restoreEnclosingLabel(visitEachChild(node, visitor, context), node); + return restoreEnclosingLabel(visitEachChild(statement, visitor, context), node); } return visitEachChild(node, visitor, context); } diff --git a/src/compiler/transformers/utilities.ts b/src/compiler/transformers/utilities.ts index 9267a239bb4..f7d28d6b4fc 100644 --- a/src/compiler/transformers/utilities.ts +++ b/src/compiler/transformers/utilities.ts @@ -214,9 +214,8 @@ namespace ts { * - this is mostly subjective beyond the requirement that the expression not be sideeffecting */ export function isSimpleCopiableExpression(expression: Expression) { - return expression.kind === SyntaxKind.StringLiteral || + return isStringLiteralLike(expression) || expression.kind === SyntaxKind.NumericLiteral || - expression.kind === SyntaxKind.NoSubstitutionTemplateLiteral || isKeyword(expression.kind) || isIdentifier(expression); } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 3a3f41ef138..0e3f83f6e09 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -661,6 +661,8 @@ namespace ts { export type AtToken = Token; export type ReadonlyToken = Token; export type AwaitKeywordToken = Token; + export type PlusToken = Token; + export type MinusToken = Token; export type Modifier = Token @@ -983,6 +985,7 @@ namespace ts { export interface MethodSignature extends SignatureDeclarationBase, TypeElement { kind: SyntaxKind.MethodSignature; + parent?: ClassLikeDeclaration | InterfaceDeclaration | TypeLiteralNode; name: PropertyName; } @@ -997,6 +1000,7 @@ namespace ts { // of the method, or use helpers like isObjectLiteralMethodDeclaration export interface MethodDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.MethodDeclaration; + parent?: ClassLikeDeclaration | ObjectLiteralExpression; name: PropertyName; body?: FunctionBody; } @@ -1156,9 +1160,9 @@ namespace ts { export interface MappedTypeNode extends TypeNode, Declaration { kind: SyntaxKind.MappedType; - readonlyToken?: ReadonlyToken; + readonlyToken?: ReadonlyToken | PlusToken | MinusToken; typeParameter: TypeParameterDeclaration; - questionToken?: QuestionToken; + questionToken?: QuestionToken | PlusToken | MinusToken; type?: TypeNode; } @@ -1174,7 +1178,7 @@ namespace ts { /* @internal */ singleQuote?: boolean; } - /* @internal */ export type StringLiteralLike = StringLiteral | NoSubstitutionTemplateLiteral; + export type StringLiteralLike = StringLiteral | NoSubstitutionTemplateLiteral; // Note: 'brands' in our syntax nodes serve to give us a small amount of nominal typing. // Consider 'Expression'. Without the brand, 'Expression' is actually no different @@ -2940,6 +2944,7 @@ namespace ts { /* @internal */ resolveExternalModuleSymbol(symbol: Symbol): Symbol; /** @param node A location where we might consider accessing `this`. Not necessarily a ThisExpression. */ /* @internal */ tryGetThisTypeAt(node: Node): Type | undefined; + /* @internal */ getTypeArgumentConstraint(node: TypeNode): Type | undefined; } /* @internal */ @@ -2983,6 +2988,7 @@ 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 @@ -4117,16 +4123,6 @@ namespace ts { [option: string]: string[] | boolean | undefined; } - export interface DiscoverTypingsInfo { - fileNames: string[]; // The file names that belong to the same project. - projectRootPath: string; // The path to the project root directory - safeListPath: string; // The path used to retrieve the safe list - packageNameToTypingLocation: Map; // The map of package names to their cached typing locations - typeAcquisition: TypeAcquisition; // Used to customize the type acquisition process - compilerOptions: CompilerOptions; // Used as a source for typing inference - unresolvedImports: ReadonlyArray; // List of unresolved module ids from imports - } - export enum ModuleKind { None = 0, CommonJS = 1, @@ -5009,6 +5005,10 @@ namespace ts { newLength: number; } + export interface SortedArray extends Array { + " __sortedArrayBrand": any; + } + /* @internal */ export interface DiagnosticCollection { // Adds a diagnostic to this diagnostic collection. diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 9d36656fb2d..06f457b41f9 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -771,6 +771,8 @@ namespace ts { return node.parent.kind !== SyntaxKind.VoidExpression; case SyntaxKind.ExpressionWithTypeArguments: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); + case SyntaxKind.TypeParameter: + return node.parent.kind === SyntaxKind.MappedType || node.parent.kind === SyntaxKind.InferType; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container @@ -1694,17 +1696,19 @@ namespace ts { node.expression.right.right; } - function getSingleInitializerOfVariableStatement(node: Node, child?: Node): Node { - return isVariableStatement(node) && - node.declarationList.declarations.length > 0 && - (!child || node.declarationList.declarations[0].initializer === child) && - node.declarationList.declarations[0].initializer; + function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node: Node): Expression | undefined { + switch (node.kind) { + case ts.SyntaxKind.VariableStatement: + const v = getSingleVariableOfVariableStatement(node); + return v && v.initializer; + case ts.SyntaxKind.PropertyDeclaration: + return (node as PropertyDeclaration).initializer; + } } - function getSingleVariableOfVariableStatement(node: Node, child?: Node): Node { + function getSingleVariableOfVariableStatement(node: Node): VariableDeclaration | undefined { return isVariableStatement(node) && node.declarationList.declarations.length > 0 && - (!child || node.declarationList.declarations[0] === child) && node.declarationList.declarations[0]; } @@ -1722,7 +1726,7 @@ namespace ts { function getJSDocCommentsAndTagsWorker(node: Node): void { const parent = node.parent; - if (parent && (parent.kind === SyntaxKind.PropertyAssignment || getNestedModuleDeclaration(parent))) { + if (parent && (parent.kind === SyntaxKind.PropertyAssignment || parent.kind === SyntaxKind.PropertyDeclaration || getNestedModuleDeclaration(parent))) { getJSDocCommentsAndTagsWorker(parent); } // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. @@ -1732,11 +1736,11 @@ namespace ts { // */ // var x = function(name) { return name.length; } if (parent && parent.parent && - (getSingleVariableOfVariableStatement(parent.parent, node) || getSourceOfAssignment(parent.parent))) { + (getSingleVariableOfVariableStatement(parent.parent) === node || getSourceOfAssignment(parent.parent))) { getJSDocCommentsAndTagsWorker(parent.parent); } if (parent && parent.parent && parent.parent.parent && - (getSingleInitializerOfVariableStatement(parent.parent.parent, node) || getSourceOfDefaultedAssignment(parent.parent.parent))) { + (getSingleInitializerOfVariableStatementOrPropertyDeclaration(parent.parent.parent) === node || getSourceOfDefaultedAssignment(parent.parent.parent))) { getJSDocCommentsAndTagsWorker(parent.parent.parent); } if (isBinaryExpression(node) && getSpecialPropertyAssignmentKind(node) !== SpecialPropertyAssignmentKind.None || @@ -1780,7 +1784,7 @@ namespace ts { const host = getJSDocHost(node); const decl = getSourceOfDefaultedAssignment(host) || getSourceOfAssignment(host) || - getSingleInitializerOfVariableStatement(host) || + getSingleInitializerOfVariableStatementOrPropertyDeclaration(host) || getSingleVariableOfVariableStatement(host) || getNestedModuleDeclaration(host) || host; @@ -1830,6 +1834,7 @@ namespace ts { case SyntaxKind.ParenthesizedExpression: case SyntaxKind.ArrayLiteralExpression: case SyntaxKind.SpreadElement: + case SyntaxKind.NonNullExpression: node = parent; break; case SyntaxKind.ShorthandPropertyAssignment: @@ -2519,11 +2524,10 @@ namespace ts { } export function createDiagnosticCollection(): DiagnosticCollection { - let nonFileDiagnostics: Diagnostic[] = []; - const fileDiagnostics = createMap(); - + let nonFileDiagnostics = [] as SortedArray; + const filesWithDiagnostics = [] as SortedArray; + const fileDiagnostics = createMap>(); let hasReadNonFileDiagnostics = false; - let diagnosticsModified = false; let modificationCount = 0; return { @@ -2543,66 +2547,45 @@ namespace ts { } function add(diagnostic: Diagnostic): void { - let diagnostics: Diagnostic[]; + let diagnostics: SortedArray; if (diagnostic.file) { diagnostics = fileDiagnostics.get(diagnostic.file.fileName); if (!diagnostics) { - diagnostics = []; + diagnostics = [] as SortedArray; fileDiagnostics.set(diagnostic.file.fileName, diagnostics); + insertSorted(filesWithDiagnostics, diagnostic.file.fileName, compareStringsCaseSensitive); } } else { // If we've already read the non-file diagnostics, do not modify the existing array. if (hasReadNonFileDiagnostics) { hasReadNonFileDiagnostics = false; - nonFileDiagnostics = nonFileDiagnostics.slice(); + nonFileDiagnostics = nonFileDiagnostics.slice() as SortedArray; } diagnostics = nonFileDiagnostics; } - diagnostics.push(diagnostic); - diagnosticsModified = true; + insertSorted(diagnostics, diagnostic, compareDiagnostics); modificationCount++; } function getGlobalDiagnostics(): Diagnostic[] { - sortAndDeduplicate(); hasReadNonFileDiagnostics = true; return nonFileDiagnostics; } function getDiagnostics(fileName?: string): Diagnostic[] { - sortAndDeduplicate(); if (fileName) { return fileDiagnostics.get(fileName) || []; } - const allDiagnostics: Diagnostic[] = []; - function pushDiagnostic(d: Diagnostic) { - allDiagnostics.push(d); + const fileDiags = flatMap(filesWithDiagnostics, f => fileDiagnostics.get(f)); + if (!nonFileDiagnostics.length) { + return fileDiags; } - - forEach(nonFileDiagnostics, pushDiagnostic); - - fileDiagnostics.forEach(diagnostics => { - forEach(diagnostics, pushDiagnostic); - }); - - return sortAndDeduplicateDiagnostics(allDiagnostics); - } - - function sortAndDeduplicate() { - if (!diagnosticsModified) { - return; - } - - diagnosticsModified = false; - nonFileDiagnostics = sortAndDeduplicateDiagnostics(nonFileDiagnostics); - - fileDiagnostics.forEach((diagnostics, key) => { - fileDiagnostics.set(key, sortAndDeduplicateDiagnostics(diagnostics)); - }); + fileDiags.unshift(...nonFileDiagnostics); + return fileDiags; } } @@ -3868,6 +3851,10 @@ namespace ts { export function forSomeAncestorDirectory(directory: string, callback: (directory: string) => boolean): boolean { return !!forEachAncestorDirectory(directory, d => callback(d) ? true : undefined); } + + export function isUMDExportSymbol(symbol: Symbol) { + return symbol && symbol.declarations && symbol.declarations[0] && isNamespaceExportDeclaration(symbol.declarations[0]); + } } namespace ts { @@ -5246,6 +5233,7 @@ namespace ts { /** * True if node is of some token syntax kind. * For example, this is true for an IfKeyword but not for an IfStatement. + * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. */ export function isToken(n: Node): boolean { return n.kind >= SyntaxKind.FirstToken && n.kind <= SyntaxKind.LastToken; @@ -6032,4 +6020,13 @@ namespace ts { return false; } } + + /* @internal */ + export function isTypeReferenceType(node: Node): node is TypeReferenceType { + return node.kind === SyntaxKind.TypeReference || node.kind === SyntaxKind.ExpressionWithTypeArguments; + } + + export function isStringLiteralLike(node: Node): node is StringLiteralLike { + return node.kind === SyntaxKind.StringLiteral || node.kind === SyntaxKind.NoSubstitutionTemplateLiteral; + } } diff --git a/src/compiler/watch.ts b/src/compiler/watch.ts index 08a30810568..7a98c43dd04 100644 --- a/src/compiler/watch.ts +++ b/src/compiler/watch.ts @@ -420,6 +420,8 @@ namespace ts { } } + const initialVersion = 1; + /** * Creates the watch from the host for root files and compiler options */ @@ -429,11 +431,17 @@ namespace ts { */ export function createWatchProgram(host: WatchCompilerHostOfConfigFile): WatchOfConfigFile; export function createWatchProgram(host: WatchCompilerHostOfFilesAndCompilerOptions & WatchCompilerHostOfConfigFile): WatchOfFilesAndCompilerOptions | WatchOfConfigFile { - interface HostFileInfo { + interface FilePresentOnHost { version: number; sourceFile: SourceFile; fileWatcher: FileWatcher; } + type FileMissingOnHost = number; + interface FilePresenceUnknownOnHost { + version: number; + } + type FileMayBePresentOnHost = FilePresentOnHost | FilePresenceUnknownOnHost; + type HostFileInfo = FilePresentOnHost | FileMissingOnHost | FilePresenceUnknownOnHost; let builderProgram: T; let reloadLevel: ConfigFileProgramReloadLevel; // level to indicate if the program needs to be reloaded from config file/just filenames etc @@ -441,7 +449,7 @@ namespace ts { let watchedWildcardDirectories: Map; // map of watchers for the wild card directories in the config file let timerToUpdateProgram: any; // timer callback to recompile the program - const sourceFilesCache = createMap(); // Cache that stores the source file and version info + const sourceFilesCache = createMap(); // Cache that stores the source file and version info let missingFilePathsRequestedForRelease: Path[]; // These paths are held temparirly so that we can remove the entry from source file cache if the file is not tracked by missing files let hasChangedCompilerOptions = false; // True if the compiler options have changed between compilations let hasChangedAutomaticTypeDirectiveNames = false; // True if the automatic type directives have changed @@ -480,14 +488,14 @@ namespace ts { const watchFilePath = compilerOptions.extendedDiagnostics ? ts.addFilePathWatcherWithLogging : ts.addFilePathWatcher; const watchDirectoryWorker = compilerOptions.extendedDiagnostics ? ts.addDirectoryWatcherWithLogging : ts.addDirectoryWatcher; + const getCanonicalFileName = createGetCanonicalFileName(useCaseSensitiveFileNames); + let newLine = updateNewLine(); + writeLog(`Current directory: ${currentDirectory} CaseSensitiveFileNames: ${useCaseSensitiveFileNames}`); if (configFileName) { watchFile(host, configFileName, scheduleProgramReload, writeLog); } - const getCanonicalFileName = createGetCanonicalFileName(useCaseSensitiveFileNames); - let newLine = updateNewLine(); - const compilerHost: CompilerHost & ResolutionCacheHost = { // Members for CompilerHost getSourceFile: (fileName, languageVersion, onError?, shouldCreateNewSourceFile?) => getVersionedSourceFileByPath(fileName, toPath(fileName), languageVersion, onError, shouldCreateNewSourceFile), @@ -575,7 +583,9 @@ namespace ts { // Compile the program if (loggingEnabled) { - writeLog(`CreatingProgramWith::\n roots: ${JSON.stringify(rootFileNames)}\n options: ${JSON.stringify(compilerOptions)}`); + writeLog(`CreatingProgramWith::`); + writeLog(` roots: ${JSON.stringify(rootFileNames)}`); + writeLog(` options: ${JSON.stringify(compilerOptions)}`); } const needsUpdateInTypeRootWatch = hasChangedCompilerOptions || !program; @@ -627,11 +637,20 @@ namespace ts { return ts.toPath(fileName, currentDirectory, getCanonicalFileName); } + function isFileMissingOnHost(hostSourceFile: HostFileInfo): hostSourceFile is FileMissingOnHost { + return typeof hostSourceFile === "number"; + } + + function isFilePresentOnHost(hostSourceFile: FileMayBePresentOnHost): hostSourceFile is FilePresentOnHost { + return !!(hostSourceFile as FilePresentOnHost).sourceFile; + } + function fileExists(fileName: string) { const path = toPath(fileName); - const hostSourceFileInfo = sourceFilesCache.get(path); - if (hostSourceFileInfo !== undefined) { - return !isString(hostSourceFileInfo); + // If file is missing on host from cache, we can definitely say file doesnt exist + // otherwise we need to ensure from the disk + if (isFileMissingOnHost(sourceFilesCache.get(path))) { + return true; } return directoryStructureHost.fileExists(fileName); @@ -640,39 +659,42 @@ namespace ts { function getVersionedSourceFileByPath(fileName: string, path: Path, languageVersion: ScriptTarget, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean): SourceFile { const hostSourceFile = sourceFilesCache.get(path); // No source file on the host - if (isString(hostSourceFile)) { + if (isFileMissingOnHost(hostSourceFile)) { return undefined; } // Create new source file if requested or the versions dont match - if (!hostSourceFile || shouldCreateNewSourceFile || hostSourceFile.version.toString() !== hostSourceFile.sourceFile.version) { + if (!hostSourceFile || shouldCreateNewSourceFile || !isFilePresentOnHost(hostSourceFile) || hostSourceFile.version.toString() !== hostSourceFile.sourceFile.version) { const sourceFile = getNewSourceFile(); if (hostSourceFile) { if (shouldCreateNewSourceFile) { hostSourceFile.version++; } + if (sourceFile) { - hostSourceFile.sourceFile = sourceFile; + // Set the source file and create file watcher now that file was present on the disk + (hostSourceFile as FilePresentOnHost).sourceFile = sourceFile; sourceFile.version = hostSourceFile.version.toString(); - if (!hostSourceFile.fileWatcher) { - hostSourceFile.fileWatcher = watchFilePath(host, fileName, onSourceFileChange, path, writeLog); + if (!(hostSourceFile as FilePresentOnHost).fileWatcher) { + (hostSourceFile as FilePresentOnHost).fileWatcher = watchFilePath(host, fileName, onSourceFileChange, path, writeLog); } } else { // There is no source file on host any more, close the watch, missing file paths will track it - hostSourceFile.fileWatcher.close(); - sourceFilesCache.set(path, hostSourceFile.version.toString()); + if (isFilePresentOnHost(hostSourceFile)) { + hostSourceFile.fileWatcher.close(); + } + sourceFilesCache.set(path, hostSourceFile.version); } } else { - let fileWatcher: FileWatcher; if (sourceFile) { - sourceFile.version = "1"; - fileWatcher = watchFilePath(host, fileName, onSourceFileChange, path, writeLog); - sourceFilesCache.set(path, { sourceFile, version: 1, fileWatcher }); + sourceFile.version = initialVersion.toString(); + const fileWatcher = watchFilePath(host, fileName, onSourceFileChange, path, writeLog); + sourceFilesCache.set(path, { sourceFile, version: initialVersion, fileWatcher }); } else { - sourceFilesCache.set(path, "0"); + sourceFilesCache.set(path, initialVersion); } } return sourceFile; @@ -697,20 +719,22 @@ namespace ts { } } - function removeSourceFile(path: Path) { + function nextSourceFileVersion(path: Path) { const hostSourceFile = sourceFilesCache.get(path); if (hostSourceFile !== undefined) { - if (!isString(hostSourceFile)) { - hostSourceFile.fileWatcher.close(); - resolutionCache.invalidateResolutionOfFile(path); + if (isFileMissingOnHost(hostSourceFile)) { + // The next version, lets set it as presence unknown file + sourceFilesCache.set(path, { version: Number(hostSourceFile) + 1 }); + } + else { + hostSourceFile.version++; } - sourceFilesCache.delete(path); } } function getSourceVersion(path: Path): string { const hostSourceFile = sourceFilesCache.get(path); - return !hostSourceFile || isString(hostSourceFile) ? undefined : hostSourceFile.version.toString(); + return !hostSourceFile || isFileMissingOnHost(hostSourceFile) ? undefined : hostSourceFile.version.toString(); } function onReleaseOldSourceFile(oldSourceFile: SourceFile, _oldOptions: CompilerOptions) { @@ -721,10 +745,10 @@ namespace ts { // there was version update and new source file was created. if (hostSourceFileInfo) { // record the missing file paths so they can be removed later if watchers arent tracking them - if (isString(hostSourceFileInfo)) { + if (isFileMissingOnHost(hostSourceFileInfo)) { (missingFilePathsRequestedForRelease || (missingFilePathsRequestedForRelease = [])).push(oldSourceFile.path); } - else if (hostSourceFileInfo.sourceFile === oldSourceFile) { + else if ((hostSourceFileInfo as FilePresentOnHost).sourceFile === oldSourceFile) { sourceFilesCache.delete(oldSourceFile.path); resolutionCache.removeResolutionsOfFile(oldSourceFile.path); } @@ -808,27 +832,12 @@ namespace ts { function onSourceFileChange(fileName: string, eventKind: FileWatcherEventKind, path: Path) { updateCachedSystemWithFile(fileName, path, eventKind); - const hostSourceFile = sourceFilesCache.get(path); - if (hostSourceFile) { - // Update the cache - if (eventKind === FileWatcherEventKind.Deleted) { - resolutionCache.invalidateResolutionOfFile(path); - if (!isString(hostSourceFile)) { - hostSourceFile.fileWatcher.close(); - sourceFilesCache.set(path, (++hostSourceFile.version).toString()); - } - } - else { - // Deleted file created - if (isString(hostSourceFile)) { - sourceFilesCache.delete(path); - } - else { - // file changed - just update the version - hostSourceFile.version++; - } - } + + // Update the source file cache + if (eventKind === FileWatcherEventKind.Deleted && sourceFilesCache.get(path)) { + resolutionCache.invalidateResolutionOfFile(path); } + nextSourceFileVersion(path); // Update the program scheduleProgramUpdate(); @@ -856,7 +865,7 @@ namespace ts { missingFilesMap.delete(missingFilePath); // Delete the entry in the source files cache so that new source file is created - removeSourceFile(missingFilePath); + nextSourceFileVersion(missingFilePath); // When a missing file is created, we should update the graph. scheduleProgramUpdate(); @@ -885,17 +894,10 @@ namespace ts { const fileOrDirectoryPath = toPath(fileOrDirectory); // Since the file existance changed, update the sourceFiles cache - const result = cachedDirectoryStructureHost && cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); - - // Instead of deleting the file, mark it as changed instead - // Many times node calls add/remove/file when watching directories recursively - const hostSourceFile = sourceFilesCache.get(fileOrDirectoryPath); - if (hostSourceFile && !isString(hostSourceFile) && (result ? result.fileExists : directoryStructureHost.fileExists(fileOrDirectory))) { - hostSourceFile.version++; - } - else { - removeSourceFile(fileOrDirectoryPath); + if (cachedDirectoryStructureHost) { + cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); } + nextSourceFileVersion(fileOrDirectoryPath); // If the the added or created file or directory is not supported file name, ignore the file // But when watched directory is added/removed, we need to reload the file list diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 5758d30a08a..1cbb5b7b017 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -64,7 +64,7 @@ namespace FourSlash { export interface Range { fileName: string; - start: number; + pos: number; end: number; marker?: Marker; } @@ -710,9 +710,9 @@ namespace FourSlash { if (!range) { this.raiseError(`goToDefinitionsAndBoundSpan failed - found a TextSpan ${JSON.stringify(defs.textSpan)} when it wasn't expected.`); } - else if (defs.textSpan.start !== range.start || defs.textSpan.length !== range.end - range.start) { + else if (defs.textSpan.start !== range.pos || defs.textSpan.length !== range.end - range.pos) { const expected: ts.TextSpan = { - start: range.start, length: range.end - range.start + start: range.pos, length: range.end - range.pos }; this.raiseError(`goToDefinitionsAndBoundSpan failed - expected to find TextSpan ${JSON.stringify(expected)} but got ${JSON.stringify(defs.textSpan)}`); } @@ -855,7 +855,7 @@ namespace FourSlash { if (completion.insertText !== insertText) { this.raiseError(`Expected completion insert text at index ${index} to be ${insertText}, got ${completion.insertText}`); } - const convertedReplacementSpan = replacementSpan && textSpanFromRange(replacementSpan); + const convertedReplacementSpan = replacementSpan && ts.createTextSpanFromRange(replacementSpan); try { assert.deepEqual(completion.replacementSpan, convertedReplacementSpan); } @@ -1002,8 +1002,8 @@ namespace FourSlash { private verifyRange(desc: string, expected: Range, actual: ts.Node) { const actualStart = actual.getStart(); const actualEnd = actual.getEnd(); - if (actualStart !== expected.start || actualEnd !== expected.end) { - this.raiseError(`${desc} should be ${expected.start}-${expected.end}, got ${actualStart}-${actualEnd}`); + if (actualStart !== expected.pos || actualEnd !== expected.end) { + this.raiseError(`${desc} should be ${expected.pos}-${expected.end}, got ${actualStart}-${actualEnd}`); } } @@ -1053,7 +1053,7 @@ namespace FourSlash { if (actualReferences.length > expectedReferences.length) { // Find the unaccounted-for reference. for (const actual of actualReferences) { - if (!ts.forEach(expectedReferences, r => r.start === actual.textSpan.start)) { + if (!ts.forEach(expectedReferences, r => r.pos === actual.textSpan.start)) { this.raiseError(`A reference ${stringify(actual)} is unaccounted for.`); } } @@ -1062,13 +1062,13 @@ namespace FourSlash { } for (const reference of expectedReferences) { - const { fileName, start, end } = reference; + const { fileName, pos, end } = reference; if (reference.marker && reference.marker.data) { const { isWriteAccess, isDefinition } = reference.marker.data as { isWriteAccess?: boolean, isDefinition?: boolean }; - this.verifyReferencesWorker(actualReferences, fileName, start, end, isWriteAccess, isDefinition); + this.verifyReferencesWorker(actualReferences, fileName, pos, end, isWriteAccess, isDefinition); } else { - this.verifyReferencesWorker(actualReferences, fileName, start, end); + this.verifyReferencesWorker(actualReferences, fileName, pos, end); } } } @@ -1092,14 +1092,14 @@ namespace FourSlash { references: ts.ReferenceEntry[]; } const fullExpected = ts.map(parts, ({ definition, ranges }) => ({ - definition: typeof definition === "string" ? definition : { ...definition, range: textSpanFromRange(definition.range) }, + definition: typeof definition === "string" ? definition : { ...definition, range: ts.createTextSpanFromRange(definition.range) }, references: ranges.map(r => { const { isWriteAccess = false, isDefinition = false, isInString } = (r.marker && r.marker.data || {}) as { isWriteAccess?: boolean, isDefinition?: boolean, isInString?: true }; return { isWriteAccess, isDefinition, fileName: r.fileName, - textSpan: textSpanFromRange(r), + textSpan: ts.createTextSpanFromRange(r), ...(isInString ? { isInString: true } : undefined), }; }), @@ -1280,7 +1280,7 @@ Actual: ${stringify(fullActual)}`); assert.equal(actualQuickInfoDocumentation, expectedDocumentation || "", this.assertionMessageAtLastKnownMarker("quick info doc")); } - public verifyQuickInfoDisplayParts(kind: string, kindModifiers: string, textSpan: { start: number; length: number; }, + public verifyQuickInfoDisplayParts(kind: string, kindModifiers: string, textSpan: TextSpan, displayParts: ts.SymbolDisplayPart[], documentation: ts.SymbolDisplayPart[], tags: ts.JSDocTagInfo[] @@ -1346,11 +1346,11 @@ Actual: ${stringify(fullActual)}`); this.raiseError("Rename location count does not match result.\n\nExpected: " + stringify(ranges) + "\n\nActual:" + stringify(references)); } - ranges = ranges.sort((r1, r2) => r1.start - r2.start); + ranges = ranges.sort((r1, r2) => r1.pos - r2.pos); references = references.sort((r1, r2) => r1.textSpan.start - r2.textSpan.start); ts.zipWith(references, ranges, (reference, range) => { - if (reference.textSpan.start !== range.start || ts.textSpanEnd(reference.textSpan) !== range.end) { + if (reference.textSpan.start !== range.pos || ts.textSpanEnd(reference.textSpan) !== range.end) { this.raiseError("Rename location results do not match.\n\nExpected: " + stringify(ranges) + "\n\nActual:" + stringify(references)); } }); @@ -1473,9 +1473,9 @@ Actual: ${stringify(fullActual)}`); } const expectedRange = this.getRanges()[0]; - if (renameInfo.triggerSpan.start !== expectedRange.start || + if (renameInfo.triggerSpan.start !== expectedRange.pos || ts.textSpanEnd(renameInfo.triggerSpan) !== expectedRange.end) { - this.raiseError("Expected triggerSpan [" + expectedRange.start + "," + expectedRange.end + "). Got [" + + this.raiseError("Expected triggerSpan [" + expectedRange.pos + "," + expectedRange.end + "). Got [" + renameInfo.triggerSpan.start + "," + ts.textSpanEnd(renameInfo.triggerSpan) + ") instead."); } } @@ -1964,7 +1964,7 @@ Actual: ${stringify(fullActual)}`); for (const range of this.testData.ranges) { if (range.fileName === fileName) { - range.start = updatePosition(range.start); + range.pos = updatePosition(range.pos); range.end = updatePosition(range.end); } } @@ -1999,9 +1999,9 @@ Actual: ${stringify(fullActual)}`); this.goToPosition(len); } - public goToRangeStart({ fileName, start }: Range) { + public goToRangeStart({ fileName, pos }: Range) { this.openFile(fileName); - this.goToPosition(start); + this.goToPosition(pos); } public goToTypeDefinition(definitionIndex: number) { @@ -2088,9 +2088,9 @@ Actual: ${stringify(fullActual)}`); const delayedErrors: string[] = []; for (const range of ranges) { - const length = range.end - range.start; + const length = range.end - range.pos; const matchingImpl = ts.find(implementations, impl => - range.fileName === impl.fileName && range.start === impl.textSpan.start && length === impl.textSpan.length); + range.fileName === impl.fileName && range.pos === impl.textSpan.start && length === impl.textSpan.length); if (matchingImpl) { if (range.marker && range.marker.data) { const expected = <{ displayParts?: ts.SymbolDisplayPart[], parts: string[], kind?: string }>range.marker.data; @@ -2128,7 +2128,7 @@ Actual: ${stringify(fullActual)}`); if (unsatisfiedRanges.length) { error += "\nUnsatisfied ranges:"; for (const range of unsatisfiedRanges) { - error += `\n (${range.start}, ${range.end}) in ${range.fileName}: ${this.rangeText(range)}`; + error += `\n (${range.pos}, ${range.end}) in ${range.fileName}: ${this.rangeText(range)}`; } } @@ -2173,8 +2173,8 @@ Actual: ${stringify(fullActual)}`); return result; } - private rangeText({ fileName, start, end }: Range): string { - return this.getFileContent(fileName).slice(start, end); + private rangeText({ fileName, pos, end }: Range): string { + return this.getFileContent(fileName).slice(pos, end); } public verifyCaretAtMarker(markerName = "") { @@ -2345,7 +2345,7 @@ Actual: ${stringify(fullActual)}`); this.verifyClassifications(expected, actual, this.activeFile.content); } - public verifyOutliningSpans(spans: TextSpan[]) { + public verifyOutliningSpans(spans: FourSlash.Range[]) { const actual = this.languageService.getOutliningSpans(this.activeFile.fileName); if (actual.length !== spans.length) { @@ -2353,13 +2353,13 @@ Actual: ${stringify(fullActual)}`); } ts.zipWith(spans, actual, (expectedSpan, actualSpan, i) => { - if (expectedSpan.start !== actualSpan.textSpan.start || expectedSpan.end !== ts.textSpanEnd(actualSpan.textSpan)) { - this.raiseError(`verifyOutliningSpans failed - span ${(i + 1)} expected: (${expectedSpan.start},${expectedSpan.end}), actual: (${actualSpan.textSpan.start},${ts.textSpanEnd(actualSpan.textSpan)})`); + if (expectedSpan.pos !== actualSpan.textSpan.start || expectedSpan.end !== ts.textSpanEnd(actualSpan.textSpan)) { + this.raiseError(`verifyOutliningSpans failed - span ${(i + 1)} expected: (${expectedSpan.pos},${expectedSpan.end}), actual: (${actualSpan.textSpan.start},${ts.textSpanEnd(actualSpan.textSpan)})`); } }); } - public verifyTodoComments(descriptors: string[], spans: TextSpan[]) { + public verifyTodoComments(descriptors: string[], spans: Range[]) { const actual = this.languageService.getTodoComments(this.activeFile.fileName, descriptors.map(d => { return { text: d, priority: 0 }; })); @@ -2370,8 +2370,8 @@ Actual: ${stringify(fullActual)}`); ts.zipWith(spans, actual, (expectedSpan, actualComment, i) => { const actualCommentSpan = ts.createTextSpan(actualComment.position, actualComment.message.length); - if (expectedSpan.start !== actualCommentSpan.start || expectedSpan.end !== ts.textSpanEnd(actualCommentSpan)) { - this.raiseError(`verifyOutliningSpans failed - span ${(i + 1)} expected: (${expectedSpan.start},${expectedSpan.end}), actual: (${actualCommentSpan.start},${ts.textSpanEnd(actualCommentSpan)})`); + if (expectedSpan.pos !== actualCommentSpan.start || expectedSpan.end !== ts.textSpanEnd(actualCommentSpan)) { + this.raiseError(`verifyOutliningSpans failed - span ${(i + 1)} expected: (${expectedSpan.pos},${expectedSpan.end}), actual: (${actualCommentSpan.start},${ts.textSpanEnd(actualCommentSpan)})`); } }); } @@ -2549,12 +2549,14 @@ Actual: ${stringify(fullActual)}`); } public verifyImportFixAtPosition(expectedTextArray: string[], errorCode?: number) { - const ranges = this.getRanges().filter(r => r.fileName === this.activeFile.fileName); + const { fileName } = this.activeFile; + const ranges = this.getRanges().filter(r => r.fileName === fileName); if (ranges.length !== 1) { this.raiseError("Exactly one range should be specified in the testfile."); } + const range = ts.first(ranges); - const codeFixes = this.getCodeFixes(this.activeFile.fileName, errorCode); + const codeFixes = this.getCodeFixes(fileName, errorCode); if (codeFixes.length === 0) { if (expectedTextArray.length !== 0) { @@ -2564,11 +2566,14 @@ Actual: ${stringify(fullActual)}`); } const actualTextArray: string[] = []; - const scriptInfo = this.languageServiceAdapterHost.getScriptInfo(codeFixes[0].changes[0].fileName); + const scriptInfo = this.languageServiceAdapterHost.getScriptInfo(fileName); const originalContent = scriptInfo.content; for (const codeFix of codeFixes) { - this.applyEdits(codeFix.changes[0].fileName, codeFix.changes[0].textChanges, /*isFormattingEdit*/ false); - const text = this.rangeText(ranges[0]); + ts.Debug.assert(codeFix.changes.length === 1); + const change = ts.first(codeFix.changes); + ts.Debug.assert(change.fileName === fileName); + this.applyEdits(change.fileName, change.textChanges, /*isFormattingEdit*/ false); + const text = this.rangeText(range); actualTextArray.push(text); scriptInfo.updateContent(originalContent); } @@ -2830,7 +2835,7 @@ Actual: ${stringify(fullActual)}`); this.goToRangeStart(r); this.verifyOccurrencesAtPositionListCount(ranges.length); for (const range of ranges) { - this.verifyOccurrencesAtPositionListContains(range.fileName, range.start, range.end, isWriteAccess); + this.verifyOccurrencesAtPositionListContains(range.fileName, range.pos, range.end, isWriteAccess); } } } @@ -2886,8 +2891,8 @@ Actual: ${stringify(fullActual)}`); } ts.zipWith(expectedRangesInFile, spansInFile, (expectedRange, span) => { - if (span.textSpan.start !== expectedRange.start || ts.textSpanEnd(span.textSpan) !== expectedRange.end) { - this.raiseError(`verifyDocumentHighlights failed - span does not match, actual: ${stringify(span.textSpan)}, expected: ${expectedRange.start}--${expectedRange.end}`); + if (span.textSpan.start !== expectedRange.pos || ts.textSpanEnd(span.textSpan) !== expectedRange.end) { + this.raiseError(`verifyDocumentHighlights failed - span does not match, actual: ${stringify(span.textSpan)}, expected: ${expectedRange.pos}--${expectedRange.end}`); } }); } @@ -2970,7 +2975,7 @@ Actual: ${stringify(fullActual)}`); throw new Error("Exactly one refactor range is allowed per test."); } - const applicableRefactors = this.languageService.getApplicableRefactors(this.activeFile.fileName, { pos: ranges[0].start, end: ranges[0].end }); + const applicableRefactors = this.languageService.getApplicableRefactors(this.activeFile.fileName, { pos: ranges[0].pos, end: ranges[0].end }); const isAvailable = applicableRefactors && applicableRefactors.length > 0; if (negative && isAvailable) { this.raiseError(`verifyApplicableRefactorAvailableForRange failed - expected no refactor but found some.`); @@ -3104,6 +3109,9 @@ Actual: ${stringify(fullActual)}`); hasAction: boolean | undefined, options: FourSlashInterface.VerifyCompletionListContainsOptions | undefined, ) { + const eq = (a: T, b: T, msg: string) => { + assert.deepEqual(a, b, this.assertionMessageAtLastKnownMarker(msg + " for " + stringify(entryId))); + }; const matchingItems = items.filter(item => item.name === entryId.name && item.source === entryId.source); if (matchingItems.length === 0) { const itemsString = items.map(item => stringify({ name: item.name, source: item.source, kind: item.kind })).join(",\n"); @@ -3118,30 +3126,30 @@ Actual: ${stringify(fullActual)}`); const details = this.getCompletionEntryDetails(item.name, item.source); if (documentation !== undefined) { - assert.equal(ts.displayPartsToString(details.documentation), documentation, this.assertionMessageAtLastKnownMarker("completion item documentation for " + entryId)); + eq(ts.displayPartsToString(details.documentation), documentation, "completion item documentation"); } if (text !== undefined) { - assert.equal(ts.displayPartsToString(details.displayParts), text, this.assertionMessageAtLastKnownMarker("completion item detail text for " + entryId)); + eq(ts.displayPartsToString(details.displayParts), text, "completion item detail text"); } if (entryId.source === undefined) { - assert.equal(options && options.sourceDisplay, undefined); + eq(options && options.sourceDisplay, /*b*/ undefined, "source display"); } else { - assert.deepEqual(details.source, [ts.textPart(options!.sourceDisplay)]); + eq(details.source, [ts.textPart(options!.sourceDisplay)], "source display"); } } if (kind !== undefined) { if (typeof kind === "string") { - assert.equal(item.kind, kind, this.assertionMessageAtLastKnownMarker("completion item kind for " + entryId)); + eq(item.kind, kind, "completion item kind"); } else { if (kind.kind) { - assert.equal(item.kind, kind.kind, this.assertionMessageAtLastKnownMarker("completion item kind for " + entryId)); + eq(item.kind, kind.kind, "completion item kind"); } if (kind.kindModifiers !== undefined) { - assert.equal(item.kindModifiers, kind.kindModifiers, this.assertionMessageAtLastKnownMarker("completion item kindModifiers for " + entryId)); + eq(item.kindModifiers, kind.kindModifiers, "completion item kindModifiers"); } } } @@ -3150,14 +3158,14 @@ Actual: ${stringify(fullActual)}`); if (spanIndex !== undefined) { const span = this.getTextSpanForRangeAtIndex(spanIndex); - assert.isTrue(TestState.textSpansEqual(span, item.replacementSpan), this.assertionMessageAtLastKnownMarker(stringify(span) + " does not equal " + stringify(item.replacementSpan) + " replacement span for " + entryId)); + assert.isTrue(TestState.textSpansEqual(span, item.replacementSpan), this.assertionMessageAtLastKnownMarker(stringify(span) + " does not equal " + stringify(item.replacementSpan) + " replacement span for " + stringify(entryId))); } - assert.equal(item.hasAction, hasAction, "hasAction"); - assert.equal(item.isRecommended, options && options.isRecommended, "isRecommended"); - assert.equal(item.insertText, options && options.insertText, "insertText"); + eq(item.hasAction, hasAction, "hasAction"); + eq(item.isRecommended, options && options.isRecommended, "isRecommended"); + eq(item.insertText, options && options.insertText, "insertText"); if (options && options.replacementSpan) { // TODO: GH#21679 - assert.deepEqual(item.replacementSpan, options && options.replacementSpan && textSpanFromRange(options.replacementSpan), "replacementSpan"); + eq(item.replacementSpan, options && options.replacementSpan && ts.createTextSpanFromRange(options.replacementSpan), "replacementSpan"); } } @@ -3208,7 +3216,7 @@ Actual: ${stringify(fullActual)}`); private getTextSpanForRangeAtIndex(index: number): ts.TextSpan { const ranges = this.getRanges(); if (ranges && ranges.length > index) { - return textSpanFromRange(ranges[index]); + return ts.createTextSpanFromRange(ranges[index]); } else { this.raiseError("Supplied span index: " + index + " does not exist in range list of size: " + (ranges ? 0 : ranges.length)); @@ -3238,10 +3246,6 @@ Actual: ${stringify(fullActual)}`); } } - function textSpanFromRange(range: FourSlash.Range): ts.TextSpan { - return ts.createTextSpanFromBounds(range.start, range.end); - } - export function runFourSlashTest(basePath: string, testType: FourSlashTestType, fileName: string) { const content = Harness.IO.readFile(fileName); runFourSlashTestContent(basePath, testType, content, fileName); @@ -3562,7 +3566,7 @@ ${code} const range: Range = { fileName, - start: rangeStart.position, + pos: rangeStart.position, end: (i - 1) - difference, marker: rangeStart.marker }; @@ -3682,7 +3686,7 @@ ${code} } // put ranges in the correct order - localRanges = localRanges.sort((a, b) => a.start < b.start ? -1 : 1); + localRanges = localRanges.sort((a, b) => a.pos < b.pos ? -1 : 1); localRanges.forEach((r) => { ranges.push(r); }); return { @@ -3755,7 +3759,7 @@ namespace FourSlashInterface { } public spans(): ts.TextSpan[] { - return this.ranges().map(r => ts.createTextSpan(r.start, r.end - r.start)); + return this.ranges().map(r => ts.createTextSpan(r.pos, r.end - r.pos)); } public rangesByText(): ts.Map { @@ -4161,7 +4165,7 @@ namespace FourSlashInterface { this.state.verifyCurrentNameOrDottedNameSpanText(text); } - public outliningSpansInCurrentFile(spans: FourSlash.TextSpan[]) { + public outliningSpansInCurrentFile(spans: FourSlash.Range[]) { this.state.verifyOutliningSpans(spans); } @@ -4244,7 +4248,7 @@ namespace FourSlashInterface { } public occurrencesAtPositionContains(range: FourSlash.Range, isWriteAccess?: boolean) { - this.state.verifyOccurrencesAtPositionListContains(range.fileName, range.start, range.end, isWriteAccess); + this.state.verifyOccurrencesAtPositionListContains(range.fileName, range.pos, range.end, isWriteAccess); } public occurrencesAtPositionCount(expectedCount: number) { @@ -4309,7 +4313,7 @@ namespace FourSlashInterface { this.state.verifyRenameLocations(startRanges, options); } - public verifyQuickInfoDisplayParts(kind: string, kindModifiers: string, textSpan: { start: number; length: number; }, + public verifyQuickInfoDisplayParts(kind: string, kindModifiers: string, textSpan: FourSlash.TextSpan, displayParts: ts.SymbolDisplayPart[], documentation: ts.SymbolDisplayPart[], tags: ts.JSDocTagInfo[]) { this.state.verifyQuickInfoDisplayParts(kind, kindModifiers, textSpan, displayParts, documentation, tags); } diff --git a/src/harness/rwcRunner.ts b/src/harness/rwcRunner.ts index ef7a371b0c4..3631186bb48 100644 --- a/src/harness/rwcRunner.ts +++ b/src/harness/rwcRunner.ts @@ -170,7 +170,8 @@ namespace RWC { }); - it("has the expected emitted code", () => { + it("has the expected emitted code", function(this: Mocha.ITestCallbackContext) { + this.timeout(10000); // Allow long timeouts for RWC js verification Harness.Baseline.runMultifileBaseline(baseName, "", () => { return Harness.Compiler.iterateOutputs(compilerResult.files); }, baselineOpts, [".js", ".jsx"]); diff --git a/src/harness/typeWriter.ts b/src/harness/typeWriter.ts index 17eda776bda..bc25bfd12d6 100644 --- a/src/harness/typeWriter.ts +++ b/src/harness/typeWriter.ts @@ -52,7 +52,7 @@ class TypeWriterWalker { } private *visitNode(node: ts.Node, isSymbolWalk: boolean): IterableIterator { - if (ts.isExpressionNode(node) || node.kind === ts.SyntaxKind.Identifier) { + if (ts.isExpressionNode(node) || node.kind === ts.SyntaxKind.Identifier || ts.isDeclarationName(node)) { const result = this.writeTypeOrSymbol(node, isSymbolWalk); if (result) { yield result; @@ -122,4 +122,4 @@ class TypeWriterWalker { symbol: symbolString }; } -} \ No newline at end of file +} diff --git a/src/harness/unittests/extractFunctions.ts b/src/harness/unittests/extractFunctions.ts index 56b3c35a292..5e9214fb35e 100644 --- a/src/harness/unittests/extractFunctions.ts +++ b/src/harness/unittests/extractFunctions.ts @@ -546,6 +546,18 @@ var q = /*b*/ //c /*g*/ + /*h*/ //i /*j*/ 2|] /*k*/ //l /*m*/; /*n*/ //o`); + + testExtractFunction("extractFunction_NamelessClass", ` +export default class { + M() { + [#|1 + 1|]; + } +}`); + + testExtractFunction("extractFunction_NoDeclarations", ` +function F() { +[#|arguments.length|]; // arguments has no declaration +}`); }); function testExtractFunction(caption: string, text: string, includeLib?: boolean) { diff --git a/src/harness/unittests/extractRanges.ts b/src/harness/unittests/extractRanges.ts index 00fbf334b38..ce9d18815bf 100644 --- a/src/harness/unittests/extractRanges.ts +++ b/src/harness/unittests/extractRanges.ts @@ -9,7 +9,7 @@ namespace ts { if (!selectionRange) { throw new Error(`Test ${s} does not specify selection range`); } - const result = refactor.extractSymbol.getRangeToExtract(file, createTextSpanFromBounds(selectionRange.start, selectionRange.end)); + const result = refactor.extractSymbol.getRangeToExtract(file, createTextSpanFromRange(selectionRange)); assert(result.targetRange === undefined, "failure expected"); const sortedErrors = result.errors.map(e => e.messageText).sort(); assert.deepEqual(sortedErrors, expectedErrors.sort(), "unexpected errors"); @@ -23,19 +23,19 @@ namespace ts { if (!selectionRange) { throw new Error(`Test ${s} does not specify selection range`); } - const result = refactor.extractSymbol.getRangeToExtract(f, createTextSpanFromBounds(selectionRange.start, selectionRange.end)); + const result = refactor.extractSymbol.getRangeToExtract(f, createTextSpanFromRange(selectionRange)); const expectedRange = t.ranges.get("extracted"); if (expectedRange) { - let start: number, end: number; + let pos: number, end: number; if (ts.isArray(result.targetRange.range)) { - start = result.targetRange.range[0].getStart(f); + pos = result.targetRange.range[0].getStart(f); end = ts.lastOrUndefined(result.targetRange.range).getEnd(); } else { - start = result.targetRange.range.getStart(f); + pos = result.targetRange.range.getStart(f); end = result.targetRange.range.getEnd(); } - assert.equal(start, expectedRange.start, "incorrect start of range"); + assert.equal(pos, expectedRange.pos, "incorrect pos of range"); assert.equal(end, expectedRange.end, "incorrect end of range"); } else { diff --git a/src/harness/unittests/extractTestHelpers.ts b/src/harness/unittests/extractTestHelpers.ts index f519555bd26..8970990326c 100644 --- a/src/harness/unittests/extractTestHelpers.ts +++ b/src/harness/unittests/extractTestHelpers.ts @@ -2,13 +2,13 @@ /// namespace ts { - export interface Range { - start: number; + interface Range { + pos: number; end: number; name: string; } - export interface Test { + interface Test { source: string; ranges: Map; } @@ -34,7 +34,7 @@ namespace ts { const name = s === e ? source.charCodeAt(saved + 1) === CharacterCodes.hash ? "selection" : "extracted" : source.substring(s, e); - activeRanges.push({ name, start: text.length, end: undefined }); + activeRanges.push({ name, pos: text.length, end: undefined }); lastPos = pos; continue; } @@ -123,12 +123,12 @@ namespace ts { cancellationToken: { throwIfCancellationRequested: noop, isCancellationRequested: returnFalse }, program, file: sourceFile, - startPosition: selectionRange.start, + startPosition: selectionRange.pos, endPosition: selectionRange.end, host: notImplementedHost, formatContext: formatting.getFormatContext(testFormatOptions), }; - const rangeToExtract = refactor.extractSymbol.getRangeToExtract(sourceFile, createTextSpanFromBounds(selectionRange.start, selectionRange.end)); + const rangeToExtract = refactor.extractSymbol.getRangeToExtract(sourceFile, createTextSpanFromRange(selectionRange)); assert.equal(rangeToExtract.errors, undefined, rangeToExtract.errors && "Range error: " + rangeToExtract.errors[0].messageText); const infos = refactor.extractSymbol.getAvailableActions(context); const actions = find(infos, info => info.description === description.message).actions; @@ -186,12 +186,12 @@ namespace ts { cancellationToken: { throwIfCancellationRequested: noop, isCancellationRequested: returnFalse }, program, file: sourceFile, - startPosition: selectionRange.start, + startPosition: selectionRange.pos, endPosition: selectionRange.end, host: notImplementedHost, formatContext: formatting.getFormatContext(testFormatOptions), }; - const rangeToExtract = refactor.extractSymbol.getRangeToExtract(sourceFile, createTextSpanFromBounds(selectionRange.start, selectionRange.end)); + const rangeToExtract = refactor.extractSymbol.getRangeToExtract(sourceFile, createTextSpanFromRange(selectionRange)); assert.isUndefined(rangeToExtract.errors, rangeToExtract.errors && "Range error: " + rangeToExtract.errors[0].messageText); const infos = refactor.extractSymbol.getAvailableActions(context); assert.isUndefined(find(infos, info => info.description === description.message)); diff --git a/src/harness/unittests/tscWatchMode.ts b/src/harness/unittests/tscWatchMode.ts index b6d3099dc77..b7a477b04bf 100644 --- a/src/harness/unittests/tscWatchMode.ts +++ b/src/harness/unittests/tscWatchMode.ts @@ -1719,6 +1719,38 @@ namespace ts.tscWatch { return [files[0]]; } }); + + it("file is deleted and created as part of change", () => { + const projectLocation = "/home/username/project"; + const file: FileOrFolder = { + path: `${projectLocation}/app/file.ts`, + content: "var a = 10;" + }; + const fileJs = `${projectLocation}/app/file.js`; + const configFile: FileOrFolder = { + path: `${projectLocation}/tsconfig.json`, + content: JSON.stringify({ + include: [ + "app/**/*.ts" + ] + }) + }; + const files = [file, configFile, libFile]; + const host = createWatchedSystem(files, { currentDirectory: projectLocation, useCaseSensitiveFileNames: true }); + createWatchOfConfigFile("tsconfig.json", host); + verifyProgram(); + + file.content += "\nvar b = 10;"; + + host.reloadFS(files, { invokeFileDeleteCreateAsPartInsteadOfChange: true }); + host.runQueuedTimeoutCallbacks(); + verifyProgram(); + + function verifyProgram() { + assert.isTrue(host.fileExists(fileJs)); + assert.equal(host.readFile(fileJs), file.content + "\n"); + } + }); }); describe("tsc-watch module resolution caching", () => { diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index 42199c895b1..8d84732f3aa 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -63,7 +63,7 @@ namespace ts.projectSystem { readonly globalTypingsCacheLocation: string, throttleLimit: number, installTypingHost: server.ServerHost, - readonly typesRegistry = createMap(), + readonly typesRegistry = createMap>(), log?: TI.Log) { super(installTypingHost, globalTypingsCacheLocation, safeList.path, customTypesMap.path, throttleLimit, log); } @@ -126,6 +126,25 @@ namespace ts.projectSystem { return JSON.stringify({ dependencies }); } + export function createTypesRegistry(...list: string[]): Map> { + const versionMap = { + "latest": "1.3.0", + "ts2.0": "1.0.0", + "ts2.1": "1.0.0", + "ts2.2": "1.2.0", + "ts2.3": "1.3.0", + "ts2.4": "1.3.0", + "ts2.5": "1.3.0", + "ts2.6": "1.3.0", + "ts2.7": "1.3.0" + }; + const map = createMap>(); + for (const l of list) { + map.set(l, versionMap); + } + return map; + } + export function toExternalFile(fileName: string): protocol.ExternalFile { return { fileName }; } @@ -2092,9 +2111,6 @@ namespace ts.projectSystem { /*closedFiles*/ undefined); checkNumberOfProjects(projectService, { inferredProjects: 1 }); - const changedFiles = projectService.getChangedFiles_TestOnly(); - assert(changedFiles && changedFiles.length === 1, `expected 1 changed file, got ${JSON.stringify(changedFiles && changedFiles.length || 0)}`); - projectService.ensureInferredProjectsUpToDate_TestOnly(); checkNumberOfProjects(projectService, { inferredProjects: 2 }); }); @@ -2885,9 +2901,109 @@ namespace ts.projectSystem { tags: [] }); }); + + it("files opened, closed affecting multiple projects", () => { + const file: FileOrFolder = { + path: "/a/b/projects/config/file.ts", + content: `import {a} from "../files/file1"; export let b = a;` + }; + const config: FileOrFolder = { + path: "/a/b/projects/config/tsconfig.json", + content: "" + }; + const filesFile1: FileOrFolder = { + path: "/a/b/projects/files/file1.ts", + content: "export let a = 10;" + }; + const filesFile2: FileOrFolder = { + path: "/a/b/projects/files/file2.ts", + content: "export let aa = 10;" + }; + + const files = [config, file, filesFile1, filesFile2, libFile]; + const host = createServerHost(files); + const session = createSession(host); + // Create configured project + session.executeCommandSeq({ + command: protocol.CommandTypes.Open, + arguments: { + file: file.path + } + }); + + const projectService = session.getProjectService(); + const configuredProject = projectService.configuredProjects.get(config.path); + verifyConfiguredProject(); + + // open files/file1 = should not create another project + session.executeCommandSeq({ + command: protocol.CommandTypes.Open, + arguments: { + file: filesFile1.path + } + }); + verifyConfiguredProject(); + + // Close the file = should still have project + session.executeCommandSeq({ + command: protocol.CommandTypes.Close, + arguments: { + file: file.path + } + }); + verifyConfiguredProject(); + + // Open files/file2 - should create inferred project and close configured project + session.executeCommandSeq({ + command: protocol.CommandTypes.Open, + arguments: { + file: filesFile2.path + } + }); + checkNumberOfProjects(projectService, { inferredProjects: 1 }); + checkProjectActualFiles(projectService.inferredProjects[0], [libFile.path, filesFile2.path]); + + // Actions on file1 would result in assert + session.executeCommandSeq({ + command: protocol.CommandTypes.Occurrences, + arguments: { + file: filesFile1.path, + line: 1, + offset: filesFile1.content.indexOf("a") + } + }); + + function verifyConfiguredProject() { + checkNumberOfProjects(projectService, { configuredProjects: 1 }); + checkProjectActualFiles(configuredProject, [file.path, filesFile1.path, libFile.path, config.path]); + } + }); }); describe("tsserverProjectSystem Proper errors", () => { + function createErrorLogger() { + let hasError = false; + const errorLogger: server.Logger = { + close: noop, + hasLevel: () => true, + loggingEnabled: () => true, + perftrc: noop, + info: noop, + msg: (_s, type) => { + if (type === server.Msg.Err) { + hasError = true; + } + }, + startGroup: noop, + endGroup: noop, + getLogFileName: (): string => undefined + }; + return { + errorLogger, + hasError: () => hasError + }; + } + it("document is not contained in project", () => { const file1 = { path: "/a/b/app.ts", @@ -2910,23 +3026,8 @@ namespace ts.projectSystem { describe("when opening new file that doesnt exist on disk yet", () => { function verifyNonExistentFile(useProjectRoot: boolean) { const host = createServerHost([libFile]); - let hasError = false; - const errLogger: server.Logger = { - close: noop, - hasLevel: () => true, - loggingEnabled: () => true, - perftrc: noop, - info: noop, - msg: (_s, type) => { - if (type === server.Msg.Err) { - hasError = true; - } - }, - startGroup: noop, - endGroup: noop, - getLogFileName: (): string => undefined - }; - const session = createSession(host, { canUseEvents: true, logger: errLogger, useInferredProjectPerProjectRoot: true }); + const { hasError, errorLogger } = createErrorLogger(); + const session = createSession(host, { canUseEvents: true, logger: errorLogger, useInferredProjectPerProjectRoot: true }); const folderPath = "/user/someuser/projects/someFolder"; const projectService = session.getProjectService(); @@ -2967,13 +3068,13 @@ namespace ts.projectSystem { // Run the last one = get error request host.runQueuedTimeoutCallbacks(newTimeoutId); - assert.isFalse(hasError); + assert.isFalse(hasError()); host.checkTimeoutQueueLength(2); checkErrorMessage(session, "syntaxDiag", { file: untitledFile, diagnostics: [] }); session.clearMessages(); host.runQueuedImmediateCallbacks(); - assert.isFalse(hasError); + assert.isFalse(hasError()); checkErrorMessage(session, "semanticDiag", { file: untitledFile, diagnostics: [] }); checkCompleteEvent(session, 2, expectedSequenceId); @@ -3039,6 +3140,31 @@ namespace ts.projectSystem { session.clearMessages(); } }); + + it("Getting errors before opening file", () => { + const file: FileOrFolder = { + path: "/a/b/project/file.ts", + content: "let x: number = false;" + }; + const host = createServerHost([file, libFile]); + const { hasError, errorLogger } = createErrorLogger(); + const session = createSession(host, { canUseEvents: true, logger: errorLogger }); + + session.clearMessages(); + const expectedSequenceId = session.getNextSeq(); + session.executeCommandSeq({ + command: server.CommandNames.Geterr, + arguments: { + delay: 0, + files: [file.path] + } + }); + + host.runQueuedImmediateCallbacks(); + assert.isFalse(hasError()); + checkCompleteEvent(session, 1, expectedSequenceId); + session.clearMessages(); + }); }); describe("tsserverProjectSystem autoDiscovery", () => { @@ -6649,12 +6775,18 @@ namespace ts.projectSystem { }, }) }; + const typingsCachePackageLockJson: FileOrFolder = { + path: `${typingsCache}/package-lock.json`, + content: JSON.stringify({ + dependencies: { + }, + }) + }; - const files = [file, packageJsonInCurrentDirectory, packageJsonOfPkgcurrentdirectory, indexOfPkgcurrentdirectory, typingsCachePackageJson]; + const files = [file, packageJsonInCurrentDirectory, packageJsonOfPkgcurrentdirectory, indexOfPkgcurrentdirectory, typingsCachePackageJson, typingsCachePackageLockJson]; const host = createServerHost(files, { currentDirectory }); - const typesRegistry = createMap(); - typesRegistry.set("pkgcurrentdirectory", void 0); + const typesRegistry = createTypesRegistry("pkgcurrentdirectory"); const typingsInstaller = new TestTypingsInstaller(typingsCache, /*throttleLimit*/ 5, host, typesRegistry); const projectService = createProjectService(host, { typingsInstaller }); diff --git a/src/harness/unittests/typingsInstaller.ts b/src/harness/unittests/typingsInstaller.ts index a84520095a4..b5265c5e5f2 100644 --- a/src/harness/unittests/typingsInstaller.ts +++ b/src/harness/unittests/typingsInstaller.ts @@ -1,6 +1,7 @@ /// /// /// +/// namespace ts.projectSystem { import TI = server.typingsInstaller; @@ -10,15 +11,7 @@ namespace ts.projectSystem { interface InstallerParams { globalTypingsCacheLocation?: string; throttleLimit?: number; - typesRegistry?: Map; - } - - function createTypesRegistry(...list: string[]): Map { - const map = createMap(); - for (const l of list) { - map.set(l, undefined); - } - return map; + typesRegistry?: Map>; } class Installer extends TestTypingsInstaller { @@ -50,7 +43,7 @@ namespace ts.projectSystem { const logs: string[] = []; return { log(message) { - logs.push(message); + logs.push(message); }, finish() { return logs; @@ -1053,6 +1046,142 @@ namespace ts.projectSystem { const version2 = proj.getCachedUnresolvedImportsPerFile_TestOnly().getVersion(); assert.notEqual(version1, version2, "set of unresolved imports should change"); }); + + it("expired cache entry (inferred project, should install typings)", () => { + const file1 = { + path: "/a/b/app.js", + content: "" + }; + const packageJson = { + path: "/a/b/package.json", + content: JSON.stringify({ + name: "test", + dependencies: { + jquery: "^3.1.0" + } + }) + }; + const jquery = { + path: "/a/data/node_modules/@types/jquery/index.d.ts", + content: "declare const $: { x: number }" + }; + const cacheConfig = { + path: "/a/data/package.json", + content: JSON.stringify({ + dependencies: { + "types-registry": "^0.1.317" + }, + devDependencies: { + "@types/jquery": "^1.0.0" + } + }) + }; + const cacheLockConfig = { + path: "/a/data/package-lock.json", + content: JSON.stringify({ + dependencies: { + "@types/jquery": { + version: "1.0.0" + } + } + }) + }; + const host = createServerHost([file1, packageJson, jquery, cacheConfig, cacheLockConfig]); + const installer = new (class extends Installer { + constructor() { + super(host, { typesRegistry: createTypesRegistry("jquery") }); + } + installWorker(_requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction) { + const installedTypings = ["@types/jquery"]; + const typingFiles = [jquery]; + executeCommand(this, host, installedTypings, typingFiles, cb); + } + })(); + + const projectService = createProjectService(host, { useSingleInferredProject: true, typingsInstaller: installer }); + projectService.openClientFile(file1.path); + + checkNumberOfProjects(projectService, { inferredProjects: 1 }); + const p = projectService.inferredProjects[0]; + checkProjectActualFiles(p, [file1.path]); + + installer.installAll(/*expectedCount*/ 1); + + checkNumberOfProjects(projectService, { inferredProjects: 1 }); + checkProjectActualFiles(p, [file1.path, jquery.path]); + }); + + it("non-expired cache entry (inferred project, should not install typings)", () => { + const file1 = { + path: "/a/b/app.js", + content: "" + }; + const packageJson = { + path: "/a/b/package.json", + content: JSON.stringify({ + name: "test", + dependencies: { + jquery: "^3.1.0" + } + }) + }; + const timestamps = { + path: "/a/data/timestamps.json", + content: JSON.stringify({ + entries: { + "@types/jquery": Date.now() + } + }) + }; + const cacheConfig = { + path: "/a/data/package.json", + content: JSON.stringify({ + dependencies: { + "types-registry": "^0.1.317" + }, + devDependencies: { + "@types/jquery": "^1.3.0" + } + }) + }; + const cacheLockConfig = { + path: "/a/data/package-lock.json", + content: JSON.stringify({ + dependencies: { + "@types/jquery": { + version: "1.3.0" + } + } + }) + }; + const jquery = { + path: "/a/data/node_modules/@types/jquery/index.d.ts", + content: "declare const $: { x: number }" + }; + const host = createServerHost([file1, packageJson, timestamps, cacheConfig, cacheLockConfig, jquery]); + const installer = new (class extends Installer { + constructor() { + super(host, { typesRegistry: createTypesRegistry("jquery") }); + } + installWorker(_requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction) { + const installedTypings: string[] = []; + const typingFiles: FileOrFolder[] = []; + executeCommand(this, host, installedTypings, typingFiles, cb); + } + })(); + + const projectService = createProjectService(host, { useSingleInferredProject: true, typingsInstaller: installer }); + projectService.openClientFile(file1.path); + + checkNumberOfProjects(projectService, { inferredProjects: 1 }); + const p = projectService.inferredProjects[0]; + checkProjectActualFiles(p, [file1.path]); + + installer.installAll(/*expectedCount*/ 0); + + checkNumberOfProjects(projectService, { inferredProjects: 1 }); + checkProjectActualFiles(p, [file1.path]); + }); }); describe("Validate package name:", () => { @@ -1132,7 +1261,7 @@ namespace ts.projectSystem { const host = createServerHost([app, jquery, chroma]); const logger = trackingLogger(); - const result = JsTyping.discoverTypings(host, logger.log, [app.path, jquery.path, chroma.path], getDirectoryPath(app.path), safeList, emptyMap, { enable: true }, emptyArray); + const result = JsTyping.discoverTypings(host, logger.log, [app.path, jquery.path, chroma.path], getDirectoryPath(app.path), safeList, emptyMap, { enable: true }, emptyArray, emptyMap); const finish = logger.finish(); assert.deepEqual(finish, [ 'Inferred typings from file names: ["jquery","chroma-js"]', @@ -1148,11 +1277,11 @@ namespace ts.projectSystem { content: "" }; const host = createServerHost([f]); - const cache = createMap(); + const cache = createMap(); for (const name of JsTyping.nodeCoreModuleList) { const logger = trackingLogger(); - const result = JsTyping.discoverTypings(host, logger.log, [f.path], getDirectoryPath(f.path), emptySafeList, cache, { enable: true }, [name, "somename"]); + const result = JsTyping.discoverTypings(host, logger.log, [f.path], getDirectoryPath(f.path), emptySafeList, cache, { enable: true }, [name, "somename"], emptyMap); assert.deepEqual(logger.finish(), [ 'Inferred typings from unresolved imports: ["node","somename"]', 'Result: {"cachedTypingPaths":[],"newTypingNames":["node","somename"],"filesToWatch":["/a/b/bower_components","/a/b/node_modules"]}', @@ -1171,9 +1300,10 @@ namespace ts.projectSystem { content: "" }; const host = createServerHost([f, node]); - const cache = createMapFromTemplate({ node: node.path }); + const cache = createMapFromTemplate({ node: { typingLocation: node.path, version: Semver.parse("1.3.0") } }); + const registry = createTypesRegistry("node"); const logger = trackingLogger(); - const result = JsTyping.discoverTypings(host, logger.log, [f.path], getDirectoryPath(f.path), emptySafeList, cache, { enable: true }, ["fs", "bar"]); + const result = JsTyping.discoverTypings(host, logger.log, [f.path], getDirectoryPath(f.path), emptySafeList, cache, { enable: true }, ["fs", "bar"], registry); assert.deepEqual(logger.finish(), [ 'Inferred typings from unresolved imports: ["node","bar"]', 'Result: {"cachedTypingPaths":["/a/b/node.d.ts"],"newTypingNames":["bar"],"filesToWatch":["/a/b/bower_components","/a/b/node_modules"]}', @@ -1196,9 +1326,9 @@ namespace ts.projectSystem { content: JSON.stringify({ name: "b" }), }; const host = createServerHost([app, a, b]); - const cache = createMap(); + const cache = createMap(); const logger = trackingLogger(); - const result = JsTyping.discoverTypings(host, logger.log, [app.path], getDirectoryPath(app.path), emptySafeList, cache, { enable: true }, /*unresolvedImports*/ []); + const result = JsTyping.discoverTypings(host, logger.log, [app.path], getDirectoryPath(app.path), emptySafeList, cache, { enable: true }, /*unresolvedImports*/ [], emptyMap); assert.deepEqual(logger.finish(), [ 'Searching for typing names in /node_modules; all files: ["/node_modules/a/package.json"]', ' Found package names: ["a"]', @@ -1211,6 +1341,94 @@ namespace ts.projectSystem { filesToWatch: ["/bower_components", "/node_modules"], }); }); + + it("should install expired typings", () => { + const app = { + path: "/a/app.js", + content: "" + }; + const cachePath = "/a/cache/"; + const commander = { + path: cachePath + "node_modules/@types/commander/index.d.ts", + content: "export let x: number" + }; + const node = { + path: cachePath + "node_modules/@types/node/index.d.ts", + content: "export let y: number" + }; + const host = createServerHost([app]); + const cache = createMapFromTemplate({ + node: { typingLocation: node.path, version: Semver.parse("1.3.0") }, + commander: { typingLocation: commander.path, version: Semver.parse("1.0.0") } + }); + const registry = createTypesRegistry("node", "commander"); + const logger = trackingLogger(); + const result = JsTyping.discoverTypings(host, logger.log, [app.path], getDirectoryPath(app.path), emptySafeList, cache, { enable: true }, ["http", "commander"], registry); + assert.deepEqual(logger.finish(), [ + 'Inferred typings from unresolved imports: ["node","commander"]', + 'Result: {"cachedTypingPaths":["/a/cache/node_modules/@types/node/index.d.ts"],"newTypingNames":["commander"],"filesToWatch":["/a/bower_components","/a/node_modules"]}', + ]); + assert.deepEqual(result.cachedTypingPaths, [node.path]); + assert.deepEqual(result.newTypingNames, ["commander"]); + }); + + it("should install expired typings with prerelease version of tsserver", () => { + const app = { + path: "/a/app.js", + content: "" + }; + const cachePath = "/a/cache/"; + const node = { + path: cachePath + "node_modules/@types/node/index.d.ts", + content: "export let y: number" + }; + const host = createServerHost([app]); + const cache = createMapFromTemplate({ + node: { typingLocation: node.path, version: Semver.parse("1.0.0") } + }); + const registry = createTypesRegistry("node"); + registry.delete(`ts${ts.versionMajorMinor}`); + const logger = trackingLogger(); + const result = JsTyping.discoverTypings(host, logger.log, [app.path], getDirectoryPath(app.path), emptySafeList, cache, { enable: true }, ["http"], registry); + assert.deepEqual(logger.finish(), [ + 'Inferred typings from unresolved imports: ["node"]', + 'Result: {"cachedTypingPaths":[],"newTypingNames":["node"],"filesToWatch":["/a/bower_components","/a/node_modules"]}', + ]); + assert.deepEqual(result.cachedTypingPaths, []); + assert.deepEqual(result.newTypingNames, ["node"]); + }); + + + it("prerelease typings are properly handled", () => { + const app = { + path: "/a/app.js", + content: "" + }; + const cachePath = "/a/cache/"; + const commander = { + path: cachePath + "node_modules/@types/commander/index.d.ts", + content: "export let x: number" + }; + const node = { + path: cachePath + "node_modules/@types/node/index.d.ts", + content: "export let y: number" + }; + const host = createServerHost([app]); + const cache = createMapFromTemplate({ + node: { typingLocation: node.path, version: Semver.parse("1.3.0-next.0") }, + commander: { typingLocation: commander.path, version: Semver.parse("1.3.0-next.0") } + }); + const registry = createTypesRegistry("node", "commander"); + registry.get("node")[`ts${ts.versionMajorMinor}`] = "1.3.0-next.1"; + const logger = trackingLogger(); + const result = JsTyping.discoverTypings(host, logger.log, [app.path], getDirectoryPath(app.path), emptySafeList, cache, { enable: true }, ["http", "commander"], registry); + assert.deepEqual(logger.finish(), [ + 'Inferred typings from unresolved imports: ["node","commander"]', + 'Result: {"cachedTypingPaths":[],"newTypingNames":["node","commander"],"filesToWatch":["/a/bower_components","/a/node_modules"]}', + ]); + assert.deepEqual(result.cachedTypingPaths, []); + assert.deepEqual(result.newTypingNames, ["node", "commander"]); + }); }); describe("telemetry events", () => { @@ -1273,12 +1491,22 @@ namespace ts.projectSystem { path: "/a/package.json", content: JSON.stringify({ dependencies: { commander: "1.0.0" } }) }; + const packageLockFile = { + path: "/a/cache/package-lock.json", + content: JSON.stringify({ + dependencies: { + "@types/commander": { + version: "1.0.0" + } + } + }) + }; const cachePath = "/a/cache/"; const commander = { path: cachePath + "node_modules/@types/commander/index.d.ts", content: "export let x: number" }; - const host = createServerHost([f1, packageFile]); + const host = createServerHost([f1, packageFile, packageLockFile]); let beginEvent: server.BeginInstallTypes; let endEvent: server.EndInstallTypes; const installer = new (class extends Installer { diff --git a/src/harness/virtualFileSystemWithWatch.ts b/src/harness/virtualFileSystemWithWatch.ts index 381917d71c7..93fdc6cdbc6 100644 --- a/src/harness/virtualFileSystemWithWatch.ts +++ b/src/harness/virtualFileSystemWithWatch.ts @@ -246,8 +246,12 @@ interface Array {}` } export interface ReloadWatchInvokeOptions { + /** Invokes the directory watcher for the parent instead of the file changed */ invokeDirectoryWatcherInsteadOfFileChanged: boolean; + /** When new file is created, do not invoke watches for it */ ignoreWatchInvokedWithTriggerAsFileCreate: boolean; + /** Invoke the file delete, followed by create instead of file changed */ + invokeFileDeleteCreateAsPartInsteadOfChange: boolean; } export class TestServerHost implements server.ServerHost, FormatDiagnosticsHost, ModuleResolutionHost { @@ -315,12 +319,18 @@ interface Array {}` if (isString(fileOrDirectory.content)) { // Update file if (currentEntry.content !== fileOrDirectory.content) { - currentEntry.content = fileOrDirectory.content; - if (options && options.invokeDirectoryWatcherInsteadOfFileChanged) { - this.invokeDirectoryWatcher(getDirectoryPath(currentEntry.fullPath), currentEntry.fullPath); + if (options && options.invokeFileDeleteCreateAsPartInsteadOfChange) { + this.removeFileOrFolder(currentEntry, returnFalse); + this.ensureFileOrFolder(fileOrDirectory); } else { - this.invokeFileWatcher(currentEntry.fullPath, FileWatcherEventKind.Changed); + currentEntry.content = fileOrDirectory.content; + if (options && options.invokeDirectoryWatcherInsteadOfFileChanged) { + this.invokeDirectoryWatcher(getDirectoryPath(currentEntry.fullPath), currentEntry.fullPath); + } + else { + this.invokeFileWatcher(currentEntry.fullPath, FileWatcherEventKind.Changed); + } } } } @@ -395,9 +405,11 @@ interface Array {}` ensureFileOrFolder(fileOrDirectory: FileOrFolder, ignoreWatchInvokedWithTriggerAsFileCreate?: boolean) { if (isString(fileOrDirectory.content)) { const file = this.toFile(fileOrDirectory); - Debug.assert(!this.fs.get(file.path)); - const baseFolder = this.ensureFolder(getDirectoryPath(file.fullPath)); - this.addFileOrFolderInFolder(baseFolder, file, ignoreWatchInvokedWithTriggerAsFileCreate); + // file may already exist when updating existing type declaration file + if (!this.fs.get(file.path)) { + const baseFolder = this.ensureFolder(getDirectoryPath(file.fullPath)); + this.addFileOrFolderInFolder(baseFolder, file, ignoreWatchInvokedWithTriggerAsFileCreate); + } } else if (isString(fileOrDirectory.symLink)) { const symLink = this.toSymLink(fileOrDirectory); diff --git a/src/lib/dom.generated.d.ts b/src/lib/dom.generated.d.ts index 951d34377a6..ff764a8a06e 100644 --- a/src/lib/dom.generated.d.ts +++ b/src/lib/dom.generated.d.ts @@ -1169,21 +1169,13 @@ interface WheelEventInit extends MouseEventInit { deltaZ?: number; } -interface EventListener { - (evt: Event): void; -} +type EventListener = (evt: Event) => void | { handleEvent(evt: Event): void; }; -interface WebKitEntriesCallback { - (evt: Event): void; -} +type WebKitEntriesCallback = (entries: WebKitEntry[]) => void | { handleEvent(entries: WebKitEntry[]): void; }; -interface WebKitErrorCallback { - (evt: Event): void; -} +type WebKitErrorCallback = (err: DOMError) => void | { handleEvent(err: DOMError): void; }; -interface WebKitFileCallback { - (evt: Event): void; -} +type WebKitFileCallback = (file: File) => void | { handleEvent(file: File): void; }; interface AnalyserNode extends AudioNode { fftSize: number; @@ -1257,9 +1249,9 @@ interface ApplicationCache extends EventTarget { readonly UNCACHED: number; readonly UPDATEREADY: number; addEventListener(type: K, listener: (this: ApplicationCache, ev: ApplicationCacheEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: ApplicationCache, ev: ApplicationCacheEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var ApplicationCache: { @@ -1316,9 +1308,9 @@ interface AudioBufferSourceNode extends AudioNode { start(when?: number, offset?: number, duration?: number): void; stop(when?: number): void; addEventListener(type: K, listener: (this: AudioBufferSourceNode, ev: AudioBufferSourceNodeEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: AudioBufferSourceNode, ev: AudioBufferSourceNodeEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var AudioBufferSourceNode: { @@ -1360,9 +1352,9 @@ interface AudioContextBase extends EventTarget { decodeAudioData(audioData: ArrayBuffer, successCallback?: DecodeSuccessCallback, errorCallback?: DecodeErrorCallback): Promise; resume(): Promise; addEventListener(type: K, listener: (this: AudioContext, ev: AudioContextEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: AudioContext, ev: AudioContextEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } interface AudioContext extends AudioContextBase { @@ -1470,9 +1462,9 @@ interface AudioTrackList extends EventTarget { getTrackById(id: string): AudioTrack | null; item(index: number): AudioTrack; addEventListener(type: K, listener: (this: AudioTrackList, ev: AudioTrackListEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: AudioTrackList, ev: AudioTrackListEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; [index: number]: AudioTrack; } @@ -2391,9 +2383,9 @@ declare var CustomEvent: { interface DataCue extends TextTrackCue { data: ArrayBuffer; addEventListener(type: K, listener: (this: DataCue, ev: TextTrackCueEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: DataCue, ev: TextTrackCueEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var DataCue: { @@ -3080,6 +3072,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * Gets or sets the version attribute specified in the declaration of an XML document. */ xmlVersion: string | null; + onvisibilitychange: (this: Document, ev: Event) => any; adoptNode(source: T): T; captureEvents(): void; caretRangeFromPoint(x: number, y: number): Range; @@ -3108,8 +3101,8 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * Creates an instance of the element for the specified tag. * @param tagName The name of an element. */ - createElement(tagName: K): HTMLElementTagNameMap[K]; - createElement(tagName: string): HTMLElement; + createElement(tagName: K, options?: ElementCreationOptions): HTMLElementTagNameMap[K]; + createElement(tagName: string, options?: ElementCreationOptions): HTMLElement; createElementNS(namespaceURI: "http://www.w3.org/1999/xhtml", qualifiedName: string): HTMLElement; createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "a"): SVGAElement; createElementNS(namespaceURI: "http://www.w3.org/2000/svg", qualifiedName: "circle"): SVGCircleElement; @@ -3317,9 +3310,9 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven */ writeln(...content: string[]): void; addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var Document: { @@ -3647,9 +3640,9 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec insertAdjacentText(where: InsertPosition, text: string): void; attachShadow(shadowRootInitDict: ShadowRootInit): ShadowRoot; addEventListener(type: K, listener: (this: Element, ev: ElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: Element, ev: ElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var Element: { @@ -3704,9 +3697,9 @@ declare var Event: { }; interface EventTarget { - addEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; dispatchEvent(evt: Event): boolean; - removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var EventTarget: { @@ -3787,9 +3780,9 @@ interface FileReader extends EventTarget, MSBaseReader { readAsDataURL(blob: Blob): void; readAsText(blob: Blob, encoding?: string): void; addEventListener(type: K, listener: (this: FileReader, ev: MSBaseReaderEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: FileReader, ev: MSBaseReaderEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var FileReader: { @@ -4022,9 +4015,9 @@ interface HTMLAnchorElement extends HTMLElement { */ toString(): string; addEventListener(type: K, listener: (this: HTMLAnchorElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLAnchorElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLAnchorElement: { @@ -4098,9 +4091,9 @@ interface HTMLAppletElement extends HTMLElement { vspace: number; width: number; addEventListener(type: K, listener: (this: HTMLAppletElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLAppletElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLAppletElement: { @@ -4168,9 +4161,9 @@ interface HTMLAreaElement extends HTMLElement { */ toString(): string; addEventListener(type: K, listener: (this: HTMLAreaElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLAreaElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLAreaElement: { @@ -4188,9 +4181,9 @@ declare var HTMLAreasCollection: { interface HTMLAudioElement extends HTMLMediaElement { addEventListener(type: K, listener: (this: HTMLAudioElement, ev: HTMLMediaElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLAudioElement, ev: HTMLMediaElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLAudioElement: { @@ -4208,9 +4201,9 @@ interface HTMLBaseElement extends HTMLElement { */ target: string; addEventListener(type: K, listener: (this: HTMLBaseElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLBaseElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLBaseElement: { @@ -4228,9 +4221,9 @@ interface HTMLBaseFontElement extends HTMLElement, DOML2DeprecatedColorProperty */ size: number; addEventListener(type: K, listener: (this: HTMLBaseFontElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLBaseFontElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLBaseFontElement: { @@ -4284,9 +4277,9 @@ interface HTMLBodyElement extends HTMLElement { text: any; vLink: any; addEventListener(type: K, listener: (this: HTMLBodyElement, ev: HTMLBodyElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLBodyElement, ev: HTMLBodyElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLBodyElement: { @@ -4300,9 +4293,9 @@ interface HTMLBRElement extends HTMLElement { */ clear: string; addEventListener(type: K, listener: (this: HTMLBRElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLBRElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLBRElement: { @@ -4375,9 +4368,9 @@ interface HTMLButtonElement extends HTMLElement { */ setCustomValidity(error: string): void; addEventListener(type: K, listener: (this: HTMLButtonElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLButtonElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLButtonElement: { @@ -4412,9 +4405,9 @@ interface HTMLCanvasElement extends HTMLElement { toDataURL(type?: string, ...args: any[]): string; toBlob(callback: (result: Blob | null) => void, type?: string, ...arguments: any[]): void; addEventListener(type: K, listener: (this: HTMLCanvasElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLCanvasElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLCanvasElement: { @@ -4449,9 +4442,9 @@ declare var HTMLCollection: { interface HTMLDataElement extends HTMLElement { value: string; addEventListener(type: K, listener: (this: HTMLDataElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLDataElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLDataElement: { @@ -4462,9 +4455,9 @@ declare var HTMLDataElement: { interface HTMLDataListElement extends HTMLElement { options: HTMLCollectionOf; addEventListener(type: K, listener: (this: HTMLDataListElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLDataListElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLDataListElement: { @@ -4475,9 +4468,9 @@ declare var HTMLDataListElement: { interface HTMLDirectoryElement extends HTMLElement { compact: boolean; addEventListener(type: K, listener: (this: HTMLDirectoryElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLDirectoryElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLDirectoryElement: { @@ -4495,9 +4488,9 @@ interface HTMLDivElement extends HTMLElement { */ noWrap: boolean; addEventListener(type: K, listener: (this: HTMLDivElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLDivElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLDivElement: { @@ -4508,9 +4501,9 @@ declare var HTMLDivElement: { interface HTMLDListElement extends HTMLElement { compact: boolean; addEventListener(type: K, listener: (this: HTMLDListElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLDListElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLDListElement: { @@ -4520,9 +4513,9 @@ declare var HTMLDListElement: { interface HTMLDocument extends Document { addEventListener(type: K, listener: (this: HTMLDocument, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLDocument, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLDocument: { @@ -4694,10 +4687,11 @@ interface HTMLElement extends Element { dragDrop(): boolean; focus(): void; msGetInputContext(): MSInputMethodContext; + animate(keyframes: AnimationKeyFrame | AnimationKeyFrame[], options: number | AnimationOptions): Animation; addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLElement: { @@ -4753,9 +4747,9 @@ interface HTMLEmbedElement extends HTMLElement, GetSVGDocument { */ width: string; addEventListener(type: K, listener: (this: HTMLEmbedElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLEmbedElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLEmbedElement: { @@ -4796,9 +4790,9 @@ interface HTMLFieldSetElement extends HTMLElement { */ setCustomValidity(error: string): void; addEventListener(type: K, listener: (this: HTMLFieldSetElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLFieldSetElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLFieldSetElement: { @@ -4812,9 +4806,9 @@ interface HTMLFontElement extends HTMLElement, DOML2DeprecatedColorProperty, DOM */ face: string; addEventListener(type: K, listener: (this: HTMLFontElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLFontElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLFontElement: { @@ -4901,9 +4895,9 @@ interface HTMLFormElement extends HTMLElement { reportValidity(): boolean; reportValidity(): boolean; addEventListener(type: K, listener: (this: HTMLFormElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLFormElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; [name: string]: any; } @@ -4978,9 +4972,9 @@ interface HTMLFrameElement extends HTMLElement, GetSVGDocument { */ width: string | number; addEventListener(type: K, listener: (this: HTMLFrameElement, ev: HTMLFrameElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLFrameElement, ev: HTMLFrameElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLFrameElement: { @@ -5048,9 +5042,9 @@ interface HTMLFrameSetElement extends HTMLElement { */ rows: string; addEventListener(type: K, listener: (this: HTMLFrameSetElement, ev: HTMLFrameSetElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLFrameSetElement, ev: HTMLFrameSetElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLFrameSetElement: { @@ -5061,9 +5055,9 @@ declare var HTMLFrameSetElement: { interface HTMLHeadElement extends HTMLElement { profile: string; addEventListener(type: K, listener: (this: HTMLHeadElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLHeadElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLHeadElement: { @@ -5077,9 +5071,9 @@ interface HTMLHeadingElement extends HTMLElement { */ align: string; addEventListener(type: K, listener: (this: HTMLHeadingElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLHeadingElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLHeadingElement: { @@ -5101,9 +5095,9 @@ interface HTMLHRElement extends HTMLElement, DOML2DeprecatedColorProperty, DOML2 */ width: number; addEventListener(type: K, listener: (this: HTMLHRElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLHRElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLHRElement: { @@ -5117,9 +5111,9 @@ interface HTMLHtmlElement extends HTMLElement { */ version: string; addEventListener(type: K, listener: (this: HTMLHtmlElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLHtmlElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLHtmlElement: { @@ -5208,9 +5202,9 @@ interface HTMLIFrameElement extends HTMLElement, GetSVGDocument { */ srcdoc: string; addEventListener(type: K, listener: (this: HTMLIFrameElement, ev: HTMLIFrameElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLIFrameElement, ev: HTMLIFrameElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLIFrameElement: { @@ -5301,9 +5295,9 @@ interface HTMLImageElement extends HTMLElement { readonly y: number; msGetAsCastingSource(): any; addEventListener(type: K, listener: (this: HTMLImageElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLImageElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLImageElement: { @@ -5516,9 +5510,9 @@ interface HTMLInputElement extends HTMLElement { */ stepUp(n?: number): void; addEventListener(type: K, listener: (this: HTMLInputElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLInputElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLInputElement: { @@ -5537,9 +5531,9 @@ interface HTMLLabelElement extends HTMLElement { htmlFor: string; readonly control: HTMLInputElement | null; addEventListener(type: K, listener: (this: HTMLLabelElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLLabelElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLLabelElement: { @@ -5557,9 +5551,9 @@ interface HTMLLegendElement extends HTMLElement { */ readonly form: HTMLFormElement | null; addEventListener(type: K, listener: (this: HTMLLegendElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLLegendElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLLegendElement: { @@ -5574,9 +5568,9 @@ interface HTMLLIElement extends HTMLElement { */ value: number; addEventListener(type: K, listener: (this: HTMLLIElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLLIElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLLIElement: { @@ -5621,9 +5615,9 @@ interface HTMLLinkElement extends HTMLElement, LinkStyle { import?: Document; integrity: string; addEventListener(type: K, listener: (this: HTMLLinkElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLLinkElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLLinkElement: { @@ -5641,9 +5635,9 @@ interface HTMLMapElement extends HTMLElement { */ name: string; addEventListener(type: K, listener: (this: HTMLMapElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLMapElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLMapElement: { @@ -5675,9 +5669,9 @@ interface HTMLMarqueeElement extends HTMLElement { start(): void; stop(): void; addEventListener(type: K, listener: (this: HTMLMarqueeElement, ev: HTMLMarqueeElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLMarqueeElement, ev: HTMLMarqueeElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLMarqueeElement: { @@ -5859,9 +5853,9 @@ interface HTMLMediaElement extends HTMLElement { readonly NETWORK_LOADING: number; readonly NETWORK_NO_SOURCE: number; addEventListener(type: K, listener: (this: HTMLMediaElement, ev: HTMLMediaElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLMediaElement, ev: HTMLMediaElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLMediaElement: { @@ -5882,9 +5876,9 @@ interface HTMLMenuElement extends HTMLElement { compact: boolean; type: string; addEventListener(type: K, listener: (this: HTMLMenuElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLMenuElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLMenuElement: { @@ -5918,9 +5912,9 @@ interface HTMLMetaElement extends HTMLElement { */ url: string; addEventListener(type: K, listener: (this: HTMLMetaElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLMetaElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLMetaElement: { @@ -5936,9 +5930,9 @@ interface HTMLMeterElement extends HTMLElement { optimum: number; value: number; addEventListener(type: K, listener: (this: HTMLMeterElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLMeterElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLMeterElement: { @@ -5956,9 +5950,9 @@ interface HTMLModElement extends HTMLElement { */ dateTime: string; addEventListener(type: K, listener: (this: HTMLModElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLModElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLModElement: { @@ -5968,10 +5962,6 @@ declare var HTMLModElement: { interface HTMLObjectElement extends HTMLElement, GetSVGDocument { align: string; - /** - * Sets or retrieves a text alternative to the graphic. - */ - alt: string; /** * Gets or sets the optional alternative HTML script to execute if the object fails to load. */ @@ -6076,9 +6066,9 @@ interface HTMLObjectElement extends HTMLElement, GetSVGDocument { */ setCustomValidity(error: string): void; addEventListener(type: K, listener: (this: HTMLObjectElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLObjectElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLObjectElement: { @@ -6094,9 +6084,9 @@ interface HTMLOListElement extends HTMLElement { start: number; type: string; addEventListener(type: K, listener: (this: HTMLOListElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLOListElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLOListElement: { @@ -6135,9 +6125,9 @@ interface HTMLOptGroupElement extends HTMLElement { */ value: string; addEventListener(type: K, listener: (this: HTMLOptGroupElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLOptGroupElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLOptGroupElement: { @@ -6176,9 +6166,9 @@ interface HTMLOptionElement extends HTMLElement { */ value: string; addEventListener(type: K, listener: (this: HTMLOptionElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLOptionElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLOptionElement: { @@ -6212,9 +6202,9 @@ interface HTMLOutputElement extends HTMLElement { reportValidity(): boolean; setCustomValidity(error: string): void; addEventListener(type: K, listener: (this: HTMLOutputElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLOutputElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLOutputElement: { @@ -6229,9 +6219,9 @@ interface HTMLParagraphElement extends HTMLElement { align: string; clear: string; addEventListener(type: K, listener: (this: HTMLParagraphElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLParagraphElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLParagraphElement: { @@ -6257,9 +6247,9 @@ interface HTMLParamElement extends HTMLElement { */ valueType: string; addEventListener(type: K, listener: (this: HTMLParamElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLParamElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLParamElement: { @@ -6269,9 +6259,9 @@ declare var HTMLParamElement: { interface HTMLPictureElement extends HTMLElement { addEventListener(type: K, listener: (this: HTMLPictureElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLPictureElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLPictureElement: { @@ -6285,9 +6275,9 @@ interface HTMLPreElement extends HTMLElement { */ width: number; addEventListener(type: K, listener: (this: HTMLPreElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLPreElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLPreElement: { @@ -6313,9 +6303,9 @@ interface HTMLProgressElement extends HTMLElement { */ value: number; addEventListener(type: K, listener: (this: HTMLProgressElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLProgressElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLProgressElement: { @@ -6329,9 +6319,9 @@ interface HTMLQuoteElement extends HTMLElement { */ cite: string; addEventListener(type: K, listener: (this: HTMLQuoteElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLQuoteElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLQuoteElement: { @@ -6372,9 +6362,9 @@ interface HTMLScriptElement extends HTMLElement { type: string; integrity: string; addEventListener(type: K, listener: (this: HTMLScriptElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLScriptElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLScriptElement: { @@ -6470,9 +6460,9 @@ interface HTMLSelectElement extends HTMLElement { */ setCustomValidity(error: string): void; addEventListener(type: K, listener: (this: HTMLSelectElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLSelectElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; [name: string]: any; } @@ -6498,9 +6488,9 @@ interface HTMLSourceElement extends HTMLElement { */ type: string; addEventListener(type: K, listener: (this: HTMLSourceElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLSourceElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLSourceElement: { @@ -6510,9 +6500,9 @@ declare var HTMLSourceElement: { interface HTMLSpanElement extends HTMLElement { addEventListener(type: K, listener: (this: HTMLSpanElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLSpanElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLSpanElement: { @@ -6531,9 +6521,9 @@ interface HTMLStyleElement extends HTMLElement, LinkStyle { */ type: string; addEventListener(type: K, listener: (this: HTMLStyleElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLStyleElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLStyleElement: { @@ -6551,9 +6541,9 @@ interface HTMLTableCaptionElement extends HTMLElement { */ vAlign: string; addEventListener(type: K, listener: (this: HTMLTableCaptionElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLTableCaptionElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLTableCaptionElement: { @@ -6608,9 +6598,9 @@ interface HTMLTableCellElement extends HTMLElement, HTMLTableAlignment { */ width: string; addEventListener(type: K, listener: (this: HTMLTableCellElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLTableCellElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLTableCellElement: { @@ -6632,9 +6622,9 @@ interface HTMLTableColElement extends HTMLElement, HTMLTableAlignment { */ width: any; addEventListener(type: K, listener: (this: HTMLTableColElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLTableColElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLTableColElement: { @@ -6644,9 +6634,9 @@ declare var HTMLTableColElement: { interface HTMLTableDataCellElement extends HTMLTableCellElement { addEventListener(type: K, listener: (this: HTMLTableDataCellElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLTableDataCellElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLTableDataCellElement: { @@ -6759,9 +6749,9 @@ interface HTMLTableElement extends HTMLElement { */ insertRow(index?: number): HTMLTableRowElement; addEventListener(type: K, listener: (this: HTMLTableElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLTableElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLTableElement: { @@ -6775,9 +6765,9 @@ interface HTMLTableHeaderCellElement extends HTMLTableCellElement { */ scope: string; addEventListener(type: K, listener: (this: HTMLTableHeaderCellElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLTableHeaderCellElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLTableHeaderCellElement: { @@ -6818,9 +6808,9 @@ interface HTMLTableRowElement extends HTMLElement, HTMLTableAlignment { */ insertCell(index?: number): HTMLTableDataCellElement; addEventListener(type: K, listener: (this: HTMLTableRowElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLTableRowElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLTableRowElement: { @@ -6848,9 +6838,9 @@ interface HTMLTableSectionElement extends HTMLElement, HTMLTableAlignment { */ insertRow(index?: number): HTMLTableRowElement; addEventListener(type: K, listener: (this: HTMLTableSectionElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLTableSectionElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLTableSectionElement: { @@ -6861,9 +6851,9 @@ declare var HTMLTableSectionElement: { interface HTMLTemplateElement extends HTMLElement { readonly content: DocumentFragment; addEventListener(type: K, listener: (this: HTMLTemplateElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLTemplateElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLTemplateElement: { @@ -6971,9 +6961,9 @@ interface HTMLTextAreaElement extends HTMLElement { */ setSelectionRange(start: number, end: number, direction?: "forward" | "backward" | "none"): void; addEventListener(type: K, listener: (this: HTMLTextAreaElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLTextAreaElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLTextAreaElement: { @@ -6984,9 +6974,9 @@ declare var HTMLTextAreaElement: { interface HTMLTimeElement extends HTMLElement { dateTime: string; addEventListener(type: K, listener: (this: HTMLTimeElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLTimeElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLTimeElement: { @@ -7000,9 +6990,9 @@ interface HTMLTitleElement extends HTMLElement { */ text: string; addEventListener(type: K, listener: (this: HTMLTitleElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLTitleElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLTitleElement: { @@ -7023,9 +7013,9 @@ interface HTMLTrackElement extends HTMLElement { readonly LOADING: number; readonly NONE: number; addEventListener(type: K, listener: (this: HTMLTrackElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLTrackElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLTrackElement: { @@ -7041,9 +7031,9 @@ interface HTMLUListElement extends HTMLElement { compact: boolean; type: string; addEventListener(type: K, listener: (this: HTMLUListElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLUListElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLUListElement: { @@ -7053,9 +7043,9 @@ declare var HTMLUListElement: { interface HTMLUnknownElement extends HTMLElement { addEventListener(type: K, listener: (this: HTMLUnknownElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLUnknownElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLUnknownElement: { @@ -7110,9 +7100,9 @@ interface HTMLVideoElement extends HTMLMediaElement { webkitExitFullscreen(): void; webkitExitFullScreen(): void; addEventListener(type: K, listener: (this: HTMLVideoElement, ev: HTMLVideoElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: HTMLVideoElement, ev: HTMLVideoElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var HTMLVideoElement: { @@ -7172,9 +7162,9 @@ interface IDBDatabase extends EventTarget { addEventListener(type: "versionchange", listener: (this: IDBDatabase, ev: IDBVersionChangeEvent) => any, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: "versionchange", listener: (this: IDBDatabase, ev: IDBVersionChangeEvent) => any, options?: boolean | EventListenerOptions): void; addEventListener(type: K, listener: (this: IDBDatabase, ev: IDBDatabaseEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: IDBDatabase, ev: IDBDatabaseEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var IDBDatabase: { @@ -7259,9 +7249,9 @@ interface IDBOpenDBRequest extends IDBRequest { onblocked: (this: IDBOpenDBRequest, ev: Event) => any; onupgradeneeded: (this: IDBOpenDBRequest, ev: IDBVersionChangeEvent) => any; addEventListener(type: K, listener: (this: IDBOpenDBRequest, ev: IDBOpenDBRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: IDBOpenDBRequest, ev: IDBOpenDBRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var IDBOpenDBRequest: { @@ -7283,9 +7273,9 @@ interface IDBRequest extends EventTarget { source: IDBObjectStore | IDBIndex | IDBCursor; readonly transaction: IDBTransaction; addEventListener(type: K, listener: (this: IDBRequest, ev: IDBRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: IDBRequest, ev: IDBRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var IDBRequest: { @@ -7312,9 +7302,9 @@ interface IDBTransaction extends EventTarget { readonly READ_WRITE: string; readonly VERSION_CHANGE: string; addEventListener(type: K, listener: (this: IDBTransaction, ev: IDBTransactionEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: IDBTransaction, ev: IDBTransactionEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var IDBTransaction: { @@ -7484,9 +7474,9 @@ interface MediaDevices extends EventTarget { getSupportedConstraints(): MediaTrackSupportedConstraints; getUserMedia(constraints: MediaStreamConstraints): Promise; addEventListener(type: K, listener: (this: MediaDevices, ev: MediaDevicesEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: MediaDevices, ev: MediaDevicesEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var MediaDevices: { @@ -7658,9 +7648,9 @@ interface MediaStream extends EventTarget { removeTrack(track: MediaStreamTrack): void; stop(): void; addEventListener(type: K, listener: (this: MediaStream, ev: MediaStreamEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: MediaStream, ev: MediaStreamEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var MediaStream: { @@ -7732,9 +7722,9 @@ interface MediaStreamTrack extends EventTarget { getSettings(): MediaTrackSettings; stop(): void; addEventListener(type: K, listener: (this: MediaStreamTrack, ev: MediaStreamTrackEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: MediaStreamTrack, ev: MediaStreamTrackEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var MediaStreamTrack: { @@ -7784,9 +7774,9 @@ interface MessagePort extends EventTarget { postMessage(message?: any, transfer?: any[]): void; start(): void; addEventListener(type: K, listener: (this: MessagePort, ev: MessagePortEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: MessagePort, ev: MessagePortEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var MessagePort: { @@ -7891,9 +7881,9 @@ interface MSAppAsyncOperation extends EventTarget { readonly ERROR: number; readonly STARTED: number; addEventListener(type: K, listener: (this: MSAppAsyncOperation, ev: MSAppAsyncOperationEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: MSAppAsyncOperation, ev: MSAppAsyncOperationEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var MSAppAsyncOperation: { @@ -8049,9 +8039,9 @@ interface MSHTMLWebViewElement extends HTMLElement { refresh(): void; stop(): void; addEventListener(type: K, listener: (this: MSHTMLWebViewElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: MSHTMLWebViewElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var MSHTMLWebViewElement: { @@ -8077,9 +8067,9 @@ interface MSInputMethodContext extends EventTarget { hasComposition(): boolean; isCandidateWindowVisible(): boolean; addEventListener(type: K, listener: (this: MSInputMethodContext, ev: MSInputMethodContextEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: MSInputMethodContext, ev: MSInputMethodContextEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var MSInputMethodContext: { @@ -8245,9 +8235,9 @@ interface MSStreamReader extends EventTarget, MSBaseReader { readAsDataURL(stream: MSStream, size?: number): void; readAsText(stream: MSStream, encoding?: string, size?: number): void; addEventListener(type: K, listener: (this: MSStreamReader, ev: MSBaseReaderEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: MSStreamReader, ev: MSBaseReaderEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var MSStreamReader: { @@ -8276,9 +8266,9 @@ interface MSWebViewAsyncOperation extends EventTarget { readonly TYPE_CREATE_DATA_PACKAGE_FROM_SELECTION: number; readonly TYPE_INVOKE_SCRIPT: number; addEventListener(type: K, listener: (this: MSWebViewAsyncOperation, ev: MSWebViewAsyncOperationEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: MSWebViewAsyncOperation, ev: MSWebViewAsyncOperationEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var MSWebViewAsyncOperation: { @@ -8569,9 +8559,9 @@ interface Notification extends EventTarget { readonly title: string; close(): void; addEventListener(type: K, listener: (this: Notification, ev: NotificationEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: Notification, ev: NotificationEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var Notification: { @@ -8651,9 +8641,9 @@ interface OfflineAudioContext extends AudioContextBase { startRendering(): Promise; suspend(suspendTime: number): Promise; addEventListener(type: K, listener: (this: OfflineAudioContext, ev: OfflineAudioContextEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: OfflineAudioContext, ev: OfflineAudioContextEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var OfflineAudioContext: { @@ -8674,9 +8664,9 @@ interface OscillatorNode extends AudioNode { start(when?: number): void; stop(when?: number): void; addEventListener(type: K, listener: (this: OscillatorNode, ev: OscillatorNodeEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: OscillatorNode, ev: OscillatorNodeEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var OscillatorNode: { @@ -8771,9 +8761,9 @@ interface PaymentRequest extends EventTarget { abort(): Promise; show(): Promise; addEventListener(type: K, listener: (this: PaymentRequest, ev: PaymentRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: PaymentRequest, ev: PaymentRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var PaymentRequest: { @@ -9124,7 +9114,7 @@ declare var ProgressEvent: { }; interface PushManager { - getSubscription(): Promise; + getSubscription(): Promise; permissionState(options?: PushSubscriptionOptionsInit): Promise; subscribe(options?: PushSubscriptionOptionsInit): Promise; } @@ -9281,9 +9271,9 @@ interface RTCDtlsTransport extends RTCStatsProvider { start(remoteParameters: RTCDtlsParameters): void; stop(): void; addEventListener(type: K, listener: (this: RTCDtlsTransport, ev: RTCDtlsTransportEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: RTCDtlsTransport, ev: RTCDtlsTransportEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var RTCDtlsTransport: { @@ -9313,9 +9303,9 @@ interface RTCDtmfSender extends EventTarget { readonly toneBuffer: string; insertDTMF(tones: string, duration?: number, interToneGap?: number): void; addEventListener(type: K, listener: (this: RTCDtmfSender, ev: RTCDtmfSenderEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: RTCDtmfSender, ev: RTCDtmfSenderEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var RTCDtmfSender: { @@ -9366,9 +9356,9 @@ interface RTCIceGatherer extends RTCStatsProvider { getLocalCandidates(): RTCIceCandidateDictionary[]; getLocalParameters(): RTCIceParameters; addEventListener(type: K, listener: (this: RTCIceGatherer, ev: RTCIceGathererEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: RTCIceGatherer, ev: RTCIceGathererEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var RTCIceGatherer: { @@ -9406,9 +9396,9 @@ interface RTCIceTransport extends RTCStatsProvider { start(gatherer: RTCIceGatherer, remoteParameters: RTCIceParameters, role?: RTCIceRole): void; stop(): void; addEventListener(type: K, listener: (this: RTCIceTransport, ev: RTCIceTransportEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: RTCIceTransport, ev: RTCIceTransportEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var RTCIceTransport: { @@ -9463,9 +9453,9 @@ interface RTCPeerConnection extends EventTarget { setLocalDescription(description: RTCSessionDescription, successCallback?: VoidFunction, failureCallback?: RTCPeerConnectionErrorCallback): Promise; setRemoteDescription(description: RTCSessionDescription, successCallback?: VoidFunction, failureCallback?: RTCPeerConnectionErrorCallback): Promise; addEventListener(type: K, listener: (this: RTCPeerConnection, ev: RTCPeerConnectionEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: RTCPeerConnection, ev: RTCPeerConnectionEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var RTCPeerConnection: { @@ -9497,9 +9487,9 @@ interface RTCRtpReceiver extends RTCStatsProvider { setTransport(transport: RTCDtlsTransport | RTCSrtpSdesTransport, rtcpTransport?: RTCDtlsTransport): void; stop(): void; addEventListener(type: K, listener: (this: RTCRtpReceiver, ev: RTCRtpReceiverEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: RTCRtpReceiver, ev: RTCRtpReceiverEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var RTCRtpReceiver: { @@ -9524,9 +9514,9 @@ interface RTCRtpSender extends RTCStatsProvider { setTransport(transport: RTCDtlsTransport | RTCSrtpSdesTransport, rtcpTransport?: RTCDtlsTransport): void; stop(): void; addEventListener(type: K, listener: (this: RTCRtpSender, ev: RTCRtpSenderEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: RTCRtpSender, ev: RTCRtpSenderEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var RTCRtpSender: { @@ -9554,9 +9544,9 @@ interface RTCSrtpSdesTransport extends EventTarget { onerror: ((this: RTCSrtpSdesTransport, ev: Event) => any) | null; readonly transport: RTCIceTransport; addEventListener(type: K, listener: (this: RTCSrtpSdesTransport, ev: RTCSrtpSdesTransportEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: RTCSrtpSdesTransport, ev: RTCSrtpSdesTransportEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var RTCSrtpSdesTransport: { @@ -9628,9 +9618,9 @@ interface Screen extends EventTarget { msLockOrientation(orientations: string | string[]): boolean; msUnlockOrientation(): void; addEventListener(type: K, listener: (this: Screen, ev: ScreenEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: Screen, ev: ScreenEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var Screen: { @@ -9656,9 +9646,9 @@ interface ScriptProcessorNode extends AudioNode { readonly bufferSize: number; onaudioprocess: (this: ScriptProcessorNode, ev: AudioProcessingEvent) => any; addEventListener(type: K, listener: (this: ScriptProcessorNode, ev: ScriptProcessorNodeEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: ScriptProcessorNode, ev: ScriptProcessorNodeEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var ScriptProcessorNode: { @@ -9710,9 +9700,9 @@ interface ServiceWorker extends EventTarget, AbstractWorker { readonly state: ServiceWorkerState; postMessage(message: any, transfer?: any[]): void; addEventListener(type: K, listener: (this: ServiceWorker, ev: ServiceWorkerEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: ServiceWorker, ev: ServiceWorkerEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var ServiceWorker: { @@ -9734,9 +9724,9 @@ interface ServiceWorkerContainer extends EventTarget { getRegistrations(): Promise; register(scriptURL: USVString, options?: RegistrationOptions): Promise; addEventListener(type: K, listener: (this: ServiceWorkerContainer, ev: ServiceWorkerContainerEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: ServiceWorkerContainer, ev: ServiceWorkerContainerEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var ServiceWorkerContainer: { @@ -9774,9 +9764,9 @@ interface ServiceWorkerRegistration extends EventTarget { unregister(): Promise; update(): Promise; addEventListener(type: K, listener: (this: ServiceWorkerRegistration, ev: ServiceWorkerRegistrationEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: ServiceWorkerRegistration, ev: ServiceWorkerRegistrationEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var ServiceWorkerRegistration: { @@ -9830,9 +9820,9 @@ interface SpeechSynthesis extends EventTarget { resume(): void; speak(utterance: SpeechSynthesisUtterance): void; addEventListener(type: K, listener: (this: SpeechSynthesis, ev: SpeechSynthesisEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SpeechSynthesis, ev: SpeechSynthesisEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SpeechSynthesis: { @@ -9877,9 +9867,9 @@ interface SpeechSynthesisUtterance extends EventTarget { voice: SpeechSynthesisVoice; volume: number; addEventListener(type: K, listener: (this: SpeechSynthesisUtterance, ev: SpeechSynthesisUtteranceEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SpeechSynthesisUtterance, ev: SpeechSynthesisUtteranceEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SpeechSynthesisUtterance: { @@ -10014,9 +10004,9 @@ declare var SubtleCrypto: { interface SVGAElement extends SVGGraphicsElement, SVGURIReference { readonly target: SVGAnimatedString; addEventListener(type: K, listener: (this: SVGAElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGAElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGAElement: { @@ -10173,9 +10163,9 @@ interface SVGCircleElement extends SVGGraphicsElement { readonly cy: SVGAnimatedLength; readonly r: SVGAnimatedLength; addEventListener(type: K, listener: (this: SVGCircleElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGCircleElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGCircleElement: { @@ -10186,9 +10176,9 @@ declare var SVGCircleElement: { interface SVGClipPathElement extends SVGGraphicsElement, SVGUnitTypes { readonly clipPathUnits: SVGAnimatedEnumeration; addEventListener(type: K, listener: (this: SVGClipPathElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGClipPathElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGClipPathElement: { @@ -10211,9 +10201,9 @@ interface SVGComponentTransferFunctionElement extends SVGElement { readonly SVG_FECOMPONENTTRANSFER_TYPE_TABLE: number; readonly SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; addEventListener(type: K, listener: (this: SVGComponentTransferFunctionElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGComponentTransferFunctionElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGComponentTransferFunctionElement: { @@ -10229,9 +10219,9 @@ declare var SVGComponentTransferFunctionElement: { interface SVGDefsElement extends SVGGraphicsElement { addEventListener(type: K, listener: (this: SVGDefsElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGDefsElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGDefsElement: { @@ -10241,9 +10231,9 @@ declare var SVGDefsElement: { interface SVGDescElement extends SVGElement { addEventListener(type: K, listener: (this: SVGDescElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGDescElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGDescElement: { @@ -10281,9 +10271,9 @@ interface SVGElement extends Element { readonly viewportElement: SVGElement; xmlbase: string; addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGElement: { @@ -10323,9 +10313,9 @@ interface SVGEllipseElement extends SVGGraphicsElement { readonly rx: SVGAnimatedLength; readonly ry: SVGAnimatedLength; addEventListener(type: K, listener: (this: SVGEllipseElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGEllipseElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGEllipseElement: { @@ -10355,9 +10345,9 @@ interface SVGFEBlendElement extends SVGElement, SVGFilterPrimitiveStandardAttrib readonly SVG_FEBLEND_MODE_SOFT_LIGHT: number; readonly SVG_FEBLEND_MODE_UNKNOWN: number; addEventListener(type: K, listener: (this: SVGFEBlendElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGFEBlendElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGFEBlendElement: { @@ -10392,9 +10382,9 @@ interface SVGFEColorMatrixElement extends SVGElement, SVGFilterPrimitiveStandard readonly SVG_FECOLORMATRIX_TYPE_SATURATE: number; readonly SVG_FECOLORMATRIX_TYPE_UNKNOWN: number; addEventListener(type: K, listener: (this: SVGFEColorMatrixElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGFEColorMatrixElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGFEColorMatrixElement: { @@ -10410,9 +10400,9 @@ declare var SVGFEColorMatrixElement: { interface SVGFEComponentTransferElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { readonly in1: SVGAnimatedString; addEventListener(type: K, listener: (this: SVGFEComponentTransferElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGFEComponentTransferElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGFEComponentTransferElement: { @@ -10436,9 +10426,9 @@ interface SVGFECompositeElement extends SVGElement, SVGFilterPrimitiveStandardAt readonly SVG_FECOMPOSITE_OPERATOR_UNKNOWN: number; readonly SVG_FECOMPOSITE_OPERATOR_XOR: number; addEventListener(type: K, listener: (this: SVGFECompositeElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGFECompositeElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGFECompositeElement: { @@ -10471,9 +10461,9 @@ interface SVGFEConvolveMatrixElement extends SVGElement, SVGFilterPrimitiveStand readonly SVG_EDGEMODE_UNKNOWN: number; readonly SVG_EDGEMODE_WRAP: number; addEventListener(type: K, listener: (this: SVGFEConvolveMatrixElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGFEConvolveMatrixElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGFEConvolveMatrixElement: { @@ -10492,9 +10482,9 @@ interface SVGFEDiffuseLightingElement extends SVGElement, SVGFilterPrimitiveStan readonly kernelUnitLengthY: SVGAnimatedNumber; readonly surfaceScale: SVGAnimatedNumber; addEventListener(type: K, listener: (this: SVGFEDiffuseLightingElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGFEDiffuseLightingElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGFEDiffuseLightingElement: { @@ -10514,9 +10504,9 @@ interface SVGFEDisplacementMapElement extends SVGElement, SVGFilterPrimitiveStan readonly SVG_CHANNEL_R: number; readonly SVG_CHANNEL_UNKNOWN: number; addEventListener(type: K, listener: (this: SVGFEDisplacementMapElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGFEDisplacementMapElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGFEDisplacementMapElement: { @@ -10533,9 +10523,9 @@ interface SVGFEDistantLightElement extends SVGElement { readonly azimuth: SVGAnimatedNumber; readonly elevation: SVGAnimatedNumber; addEventListener(type: K, listener: (this: SVGFEDistantLightElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGFEDistantLightElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGFEDistantLightElement: { @@ -10545,9 +10535,9 @@ declare var SVGFEDistantLightElement: { interface SVGFEFloodElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { addEventListener(type: K, listener: (this: SVGFEFloodElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGFEFloodElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGFEFloodElement: { @@ -10557,9 +10547,9 @@ declare var SVGFEFloodElement: { interface SVGFEFuncAElement extends SVGComponentTransferFunctionElement { addEventListener(type: K, listener: (this: SVGFEFuncAElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGFEFuncAElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGFEFuncAElement: { @@ -10569,9 +10559,9 @@ declare var SVGFEFuncAElement: { interface SVGFEFuncBElement extends SVGComponentTransferFunctionElement { addEventListener(type: K, listener: (this: SVGFEFuncBElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGFEFuncBElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGFEFuncBElement: { @@ -10581,9 +10571,9 @@ declare var SVGFEFuncBElement: { interface SVGFEFuncGElement extends SVGComponentTransferFunctionElement { addEventListener(type: K, listener: (this: SVGFEFuncGElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGFEFuncGElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGFEFuncGElement: { @@ -10593,9 +10583,9 @@ declare var SVGFEFuncGElement: { interface SVGFEFuncRElement extends SVGComponentTransferFunctionElement { addEventListener(type: K, listener: (this: SVGFEFuncRElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGFEFuncRElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGFEFuncRElement: { @@ -10609,9 +10599,9 @@ interface SVGFEGaussianBlurElement extends SVGElement, SVGFilterPrimitiveStandar readonly stdDeviationY: SVGAnimatedNumber; setStdDeviation(stdDeviationX: number, stdDeviationY: number): void; addEventListener(type: K, listener: (this: SVGFEGaussianBlurElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGFEGaussianBlurElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGFEGaussianBlurElement: { @@ -10622,9 +10612,9 @@ declare var SVGFEGaussianBlurElement: { interface SVGFEImageElement extends SVGElement, SVGFilterPrimitiveStandardAttributes, SVGURIReference { readonly preserveAspectRatio: SVGAnimatedPreserveAspectRatio; addEventListener(type: K, listener: (this: SVGFEImageElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGFEImageElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGFEImageElement: { @@ -10634,9 +10624,9 @@ declare var SVGFEImageElement: { interface SVGFEMergeElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { addEventListener(type: K, listener: (this: SVGFEMergeElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGFEMergeElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGFEMergeElement: { @@ -10647,9 +10637,9 @@ declare var SVGFEMergeElement: { interface SVGFEMergeNodeElement extends SVGElement { readonly in1: SVGAnimatedString; addEventListener(type: K, listener: (this: SVGFEMergeNodeElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGFEMergeNodeElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGFEMergeNodeElement: { @@ -10666,9 +10656,9 @@ interface SVGFEMorphologyElement extends SVGElement, SVGFilterPrimitiveStandardA readonly SVG_MORPHOLOGY_OPERATOR_ERODE: number; readonly SVG_MORPHOLOGY_OPERATOR_UNKNOWN: number; addEventListener(type: K, listener: (this: SVGFEMorphologyElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGFEMorphologyElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGFEMorphologyElement: { @@ -10684,9 +10674,9 @@ interface SVGFEOffsetElement extends SVGElement, SVGFilterPrimitiveStandardAttri readonly dy: SVGAnimatedNumber; readonly in1: SVGAnimatedString; addEventListener(type: K, listener: (this: SVGFEOffsetElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGFEOffsetElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGFEOffsetElement: { @@ -10699,9 +10689,9 @@ interface SVGFEPointLightElement extends SVGElement { readonly y: SVGAnimatedNumber; readonly z: SVGAnimatedNumber; addEventListener(type: K, listener: (this: SVGFEPointLightElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGFEPointLightElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGFEPointLightElement: { @@ -10717,9 +10707,9 @@ interface SVGFESpecularLightingElement extends SVGElement, SVGFilterPrimitiveSta readonly specularExponent: SVGAnimatedNumber; readonly surfaceScale: SVGAnimatedNumber; addEventListener(type: K, listener: (this: SVGFESpecularLightingElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGFESpecularLightingElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGFESpecularLightingElement: { @@ -10737,9 +10727,9 @@ interface SVGFESpotLightElement extends SVGElement { readonly y: SVGAnimatedNumber; readonly z: SVGAnimatedNumber; addEventListener(type: K, listener: (this: SVGFESpotLightElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGFESpotLightElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGFESpotLightElement: { @@ -10750,9 +10740,9 @@ declare var SVGFESpotLightElement: { interface SVGFETileElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { readonly in1: SVGAnimatedString; addEventListener(type: K, listener: (this: SVGFETileElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGFETileElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGFETileElement: { @@ -10774,9 +10764,9 @@ interface SVGFETurbulenceElement extends SVGElement, SVGFilterPrimitiveStandardA readonly SVG_TURBULENCE_TYPE_TURBULENCE: number; readonly SVG_TURBULENCE_TYPE_UNKNOWN: number; addEventListener(type: K, listener: (this: SVGFETurbulenceElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGFETurbulenceElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGFETurbulenceElement: { @@ -10801,9 +10791,9 @@ interface SVGFilterElement extends SVGElement, SVGUnitTypes, SVGURIReference { readonly y: SVGAnimatedLength; setFilterRes(filterResX: number, filterResY: number): void; addEventListener(type: K, listener: (this: SVGFilterElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGFilterElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGFilterElement: { @@ -10817,9 +10807,9 @@ interface SVGForeignObjectElement extends SVGGraphicsElement { readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; addEventListener(type: K, listener: (this: SVGForeignObjectElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGForeignObjectElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGForeignObjectElement: { @@ -10829,9 +10819,9 @@ declare var SVGForeignObjectElement: { interface SVGGElement extends SVGGraphicsElement { addEventListener(type: K, listener: (this: SVGGElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGGElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGGElement: { @@ -10848,9 +10838,9 @@ interface SVGGradientElement extends SVGElement, SVGUnitTypes, SVGURIReference { readonly SVG_SPREADMETHOD_REPEAT: number; readonly SVG_SPREADMETHOD_UNKNOWN: number; addEventListener(type: K, listener: (this: SVGGradientElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGGradientElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGGradientElement: { @@ -10871,9 +10861,9 @@ interface SVGGraphicsElement extends SVGElement, SVGTests { getScreenCTM(): SVGMatrix; getTransformToElement(element: SVGElement): SVGMatrix; addEventListener(type: K, listener: (this: SVGGraphicsElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGGraphicsElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGGraphicsElement: { @@ -10888,9 +10878,9 @@ interface SVGImageElement extends SVGGraphicsElement, SVGURIReference { readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; addEventListener(type: K, listener: (this: SVGImageElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGImageElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGImageElement: { @@ -10956,9 +10946,9 @@ interface SVGLinearGradientElement extends SVGGradientElement { readonly y1: SVGAnimatedLength; readonly y2: SVGAnimatedLength; addEventListener(type: K, listener: (this: SVGLinearGradientElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGLinearGradientElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGLinearGradientElement: { @@ -10972,9 +10962,9 @@ interface SVGLineElement extends SVGGraphicsElement { readonly y1: SVGAnimatedLength; readonly y2: SVGAnimatedLength; addEventListener(type: K, listener: (this: SVGLineElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGLineElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGLineElement: { @@ -10999,9 +10989,9 @@ interface SVGMarkerElement extends SVGElement, SVGFitToViewBox { readonly SVG_MARKERUNITS_UNKNOWN: number; readonly SVG_MARKERUNITS_USERSPACEONUSE: number; addEventListener(type: K, listener: (this: SVGMarkerElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGMarkerElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGMarkerElement: { @@ -11023,9 +11013,9 @@ interface SVGMaskElement extends SVGElement, SVGTests, SVGUnitTypes { readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; addEventListener(type: K, listener: (this: SVGMaskElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGMaskElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGMaskElement: { @@ -11060,9 +11050,9 @@ declare var SVGMatrix: { interface SVGMetadataElement extends SVGElement { addEventListener(type: K, listener: (this: SVGMetadataElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGMetadataElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGMetadataElement: { @@ -11120,9 +11110,9 @@ interface SVGPathElement extends SVGGraphicsElement { getPointAtLength(distance: number): SVGPoint; getTotalLength(): number; addEventListener(type: K, listener: (this: SVGPathElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGPathElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGPathElement: { @@ -11415,9 +11405,9 @@ interface SVGPatternElement extends SVGElement, SVGTests, SVGUnitTypes, SVGFitTo readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; addEventListener(type: K, listener: (this: SVGPatternElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGPatternElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGPatternElement: { @@ -11454,9 +11444,9 @@ declare var SVGPointList: { interface SVGPolygonElement extends SVGGraphicsElement, SVGAnimatedPoints { addEventListener(type: K, listener: (this: SVGPolygonElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGPolygonElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGPolygonElement: { @@ -11466,9 +11456,9 @@ declare var SVGPolygonElement: { interface SVGPolylineElement extends SVGGraphicsElement, SVGAnimatedPoints { addEventListener(type: K, listener: (this: SVGPolylineElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGPolylineElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGPolylineElement: { @@ -11521,9 +11511,9 @@ interface SVGRadialGradientElement extends SVGGradientElement { readonly fy: SVGAnimatedLength; readonly r: SVGAnimatedLength; addEventListener(type: K, listener: (this: SVGRadialGradientElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGRadialGradientElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGRadialGradientElement: { @@ -11551,9 +11541,9 @@ interface SVGRectElement extends SVGGraphicsElement { readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; addEventListener(type: K, listener: (this: SVGRectElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGRectElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGRectElement: { @@ -11564,9 +11554,9 @@ declare var SVGRectElement: { interface SVGScriptElement extends SVGElement, SVGURIReference { type: string; addEventListener(type: K, listener: (this: SVGScriptElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGScriptElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGScriptElement: { @@ -11577,9 +11567,9 @@ declare var SVGScriptElement: { interface SVGStopElement extends SVGElement { readonly offset: SVGAnimatedNumber; addEventListener(type: K, listener: (this: SVGStopElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGStopElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGStopElement: { @@ -11609,9 +11599,9 @@ interface SVGStyleElement extends SVGElement { title: string; type: string; addEventListener(type: K, listener: (this: SVGStyleElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGStyleElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGStyleElement: { @@ -11672,9 +11662,9 @@ interface SVGSVGElement extends SVGGraphicsElement, DocumentEvent, SVGFitToViewB unsuspendRedraw(suspendHandleID: number): void; unsuspendRedrawAll(): void; addEventListener(type: K, listener: (this: SVGSVGElement, ev: SVGSVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGSVGElement, ev: SVGSVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGSVGElement: { @@ -11684,9 +11674,9 @@ declare var SVGSVGElement: { interface SVGSwitchElement extends SVGGraphicsElement { addEventListener(type: K, listener: (this: SVGSwitchElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGSwitchElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGSwitchElement: { @@ -11696,9 +11686,9 @@ declare var SVGSwitchElement: { interface SVGSymbolElement extends SVGElement, SVGFitToViewBox { addEventListener(type: K, listener: (this: SVGSymbolElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGSymbolElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGSymbolElement: { @@ -11722,9 +11712,9 @@ interface SVGTextContentElement extends SVGGraphicsElement { readonly LENGTHADJUST_SPACINGANDGLYPHS: number; readonly LENGTHADJUST_UNKNOWN: number; addEventListener(type: K, listener: (this: SVGTextContentElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGTextContentElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGTextContentElement: { @@ -11737,9 +11727,9 @@ declare var SVGTextContentElement: { interface SVGTextElement extends SVGTextPositioningElement { addEventListener(type: K, listener: (this: SVGTextElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGTextElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGTextElement: { @@ -11758,9 +11748,9 @@ interface SVGTextPathElement extends SVGTextContentElement, SVGURIReference { readonly TEXTPATH_SPACINGTYPE_EXACT: number; readonly TEXTPATH_SPACINGTYPE_UNKNOWN: number; addEventListener(type: K, listener: (this: SVGTextPathElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGTextPathElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGTextPathElement: { @@ -11781,9 +11771,9 @@ interface SVGTextPositioningElement extends SVGTextContentElement { readonly x: SVGAnimatedLengthList; readonly y: SVGAnimatedLengthList; addEventListener(type: K, listener: (this: SVGTextPositioningElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGTextPositioningElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGTextPositioningElement: { @@ -11793,9 +11783,9 @@ declare var SVGTextPositioningElement: { interface SVGTitleElement extends SVGElement { addEventListener(type: K, listener: (this: SVGTitleElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGTitleElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGTitleElement: { @@ -11854,9 +11844,9 @@ declare var SVGTransformList: { interface SVGTSpanElement extends SVGTextPositioningElement { addEventListener(type: K, listener: (this: SVGTSpanElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGTSpanElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGTSpanElement: { @@ -11879,9 +11869,9 @@ interface SVGUseElement extends SVGGraphicsElement, SVGURIReference { readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; addEventListener(type: K, listener: (this: SVGUseElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGUseElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGUseElement: { @@ -11892,9 +11882,9 @@ declare var SVGUseElement: { interface SVGViewElement extends SVGElement, SVGZoomAndPan, SVGFitToViewBox { readonly viewTarget: SVGStringList; addEventListener(type: K, listener: (this: SVGViewElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: SVGViewElement, ev: SVGElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var SVGViewElement: { @@ -12015,9 +12005,9 @@ interface TextTrack extends EventTarget { readonly NONE: number; readonly SHOWING: number; addEventListener(type: K, listener: (this: TextTrack, ev: TextTrackEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: TextTrack, ev: TextTrackEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var TextTrack: { @@ -12048,9 +12038,9 @@ interface TextTrackCue extends EventTarget { readonly track: TextTrack; getCueAsHTML(): DocumentFragment; addEventListener(type: K, listener: (this: TextTrackCue, ev: TextTrackCueEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: TextTrackCue, ev: TextTrackCueEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var TextTrackCue: { @@ -12079,9 +12069,9 @@ interface TextTrackList extends EventTarget { onaddtrack: ((this: TextTrackList, ev: TrackEvent) => any) | null; item(index: number): TextTrack; addEventListener(type: K, listener: (this: TextTrackList, ev: TextTrackListEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: TextTrackList, ev: TextTrackListEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; [index: number]: TextTrack; } @@ -12290,9 +12280,9 @@ interface VideoTrackList extends EventTarget { getTrackById(id: string): VideoTrack | null; item(index: number): VideoTrack; addEventListener(type: K, listener: (this: VideoTrackList, ev: VideoTrackListEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: VideoTrackList, ev: VideoTrackListEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; [index: number]: VideoTrack; } @@ -12565,24 +12555,24 @@ interface WebGLRenderingContext { texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, width: number, height: number, format: number, type: number, pixels: ArrayBufferView | null): void; texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, pixels: ImageBitmap | ImageData | HTMLVideoElement | HTMLImageElement | HTMLCanvasElement): void; uniform1f(location: WebGLUniformLocation | null, x: number): void; - uniform1fv(location: WebGLUniformLocation, v: Float32Array | number[]): void; + uniform1fv(location: WebGLUniformLocation, v: Float32Array | ArrayLike): void; uniform1i(location: WebGLUniformLocation | null, x: number): void; - uniform1iv(location: WebGLUniformLocation, v: Int32Array | number[]): void; + uniform1iv(location: WebGLUniformLocation, v: Int32Array | ArrayLike): void; uniform2f(location: WebGLUniformLocation | null, x: number, y: number): void; - uniform2fv(location: WebGLUniformLocation, v: Float32Array | number[]): void; + uniform2fv(location: WebGLUniformLocation, v: Float32Array | ArrayLike): void; uniform2i(location: WebGLUniformLocation | null, x: number, y: number): void; - uniform2iv(location: WebGLUniformLocation, v: Int32Array | number[]): void; + uniform2iv(location: WebGLUniformLocation, v: Int32Array | ArrayLike): void; uniform3f(location: WebGLUniformLocation | null, x: number, y: number, z: number): void; - uniform3fv(location: WebGLUniformLocation, v: Float32Array | number[]): void; + uniform3fv(location: WebGLUniformLocation, v: Float32Array | ArrayLike): void; uniform3i(location: WebGLUniformLocation | null, x: number, y: number, z: number): void; - uniform3iv(location: WebGLUniformLocation, v: Int32Array | number[]): void; + uniform3iv(location: WebGLUniformLocation, v: Int32Array | ArrayLike): void; uniform4f(location: WebGLUniformLocation | null, x: number, y: number, z: number, w: number): void; - uniform4fv(location: WebGLUniformLocation, v: Float32Array | number[]): void; + uniform4fv(location: WebGLUniformLocation, v: Float32Array | ArrayLike): void; uniform4i(location: WebGLUniformLocation | null, x: number, y: number, z: number, w: number): void; - uniform4iv(location: WebGLUniformLocation, v: Int32Array | number[]): void; - uniformMatrix2fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array | number[]): void; - uniformMatrix3fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array | number[]): void; - uniformMatrix4fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array | number[]): void; + uniform4iv(location: WebGLUniformLocation, v: Int32Array | ArrayLike): void; + uniformMatrix2fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array | ArrayLike): void; + uniformMatrix3fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array | ArrayLike): void; + uniformMatrix4fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array | ArrayLike): void; useProgram(program: WebGLProgram | null): void; validateProgram(program: WebGLProgram | null): void; vertexAttrib1f(indx: number, x: number): void; @@ -13333,9 +13323,9 @@ declare var WebKitPoint: { interface webkitRTCPeerConnection extends RTCPeerConnection { addEventListener(type: K, listener: (this: webkitRTCPeerConnection, ev: RTCPeerConnectionEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: webkitRTCPeerConnection, ev: RTCPeerConnectionEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var webkitRTCPeerConnection: { @@ -13362,15 +13352,15 @@ interface WebSocket extends EventTarget { readonly readyState: number; readonly url: string; close(code?: number, reason?: string): void; - send(data: any): void; + send(data: USVString | ArrayBuffer | Blob | ArrayBufferView): void; readonly CLOSED: number; readonly CLOSING: number; readonly CONNECTING: number; readonly OPEN: number; addEventListener(type: K, listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var WebSocket: { @@ -13683,9 +13673,9 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window scrollTo(options?: ScrollToOptions): void; scrollBy(options?: ScrollToOptions): void; addEventListener(type: K, listener: (this: Window, ev: WindowEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: Window, ev: WindowEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var Window: { @@ -13702,9 +13692,9 @@ interface Worker extends EventTarget, AbstractWorker { postMessage(message: any, transfer?: any[]): void; terminate(): void; addEventListener(type: K, listener: (this: Worker, ev: WorkerEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: Worker, ev: WorkerEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var Worker: { @@ -13714,9 +13704,9 @@ declare var Worker: { interface XMLDocument extends Document { addEventListener(type: K, listener: (this: XMLDocument, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: XMLDocument, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var XMLDocument: { @@ -13758,9 +13748,9 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { readonly OPENED: number; readonly UNSENT: number; addEventListener(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var XMLHttpRequest: { @@ -13775,9 +13765,9 @@ declare var XMLHttpRequest: { interface XMLHttpRequestUpload extends EventTarget, XMLHttpRequestEventTarget { addEventListener(type: K, listener: (this: XMLHttpRequestUpload, ev: XMLHttpRequestEventTargetEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: XMLHttpRequestUpload, ev: XMLHttpRequestEventTargetEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var XMLHttpRequestUpload: { @@ -13883,9 +13873,9 @@ interface AbstractWorkerEventMap { interface AbstractWorker { onerror: (this: AbstractWorker, ev: ErrorEvent) => any; addEventListener(type: K, listener: (this: AbstractWorker, ev: AbstractWorkerEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: AbstractWorker, ev: AbstractWorkerEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } interface Body { @@ -14031,9 +14021,9 @@ interface GlobalEventHandlers { onpointerup: (this: GlobalEventHandlers, ev: PointerEvent) => any; onwheel: (this: GlobalEventHandlers, ev: WheelEvent) => any; addEventListener(type: K, listener: (this: GlobalEventHandlers, ev: GlobalEventHandlersEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: GlobalEventHandlers, ev: GlobalEventHandlersEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } interface GlobalFetch { @@ -14086,9 +14076,9 @@ interface MSBaseReader { readonly EMPTY: number; readonly LOADING: number; addEventListener(type: K, listener: (this: MSBaseReader, ev: MSBaseReaderEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: MSBaseReader, ev: MSBaseReaderEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } interface MSFileSaver { @@ -14237,9 +14227,9 @@ interface XMLHttpRequestEventTarget { onprogress: (this: XMLHttpRequest, ev: ProgressEvent) => any; ontimeout: (this: XMLHttpRequest, ev: ProgressEvent) => any; addEventListener(type: K, listener: (this: XMLHttpRequestEventTarget, ev: XMLHttpRequestEventTargetEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: XMLHttpRequestEventTarget, ev: XMLHttpRequestEventTargetEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } interface BroadcastChannel extends EventTarget { @@ -14249,9 +14239,9 @@ interface BroadcastChannel extends EventTarget { close(): void; postMessage(message: any): void; addEventListener(type: K, listener: (this: BroadcastChannel, ev: BroadcastChannelEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: BroadcastChannel, ev: BroadcastChannelEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var BroadcastChannel: { @@ -14358,10 +14348,6 @@ interface FilePropertyBag extends BlobPropertyBag { lastModified?: number; } -interface EventListenerObject { - handleEvent(evt: Event): void; -} - interface ProgressEventInit extends EventInit { lengthComputable?: boolean; loaded?: number; @@ -14570,7 +14556,7 @@ interface ParentNode { interface DocumentOrShadowRoot { readonly activeElement: Element | null; - readonly stylesheets: StyleSheetList; + readonly styleSheets: StyleSheetList; getSelection(): Selection | null; elementFromPoint(x: number, y: number): Element | null; elementsFromPoint(x: number, y: number): Element[]; @@ -14599,6 +14585,10 @@ interface ElementDefinitionOptions { extends: string; } +interface ElementCreationOptions { + is?: string; +} + interface CustomElementRegistry { define(name: string, constructor: Function, options?: ElementDefinitionOptions): void; get(name: string): any; @@ -14863,7 +14853,74 @@ interface EventSourceInit { readonly withCredentials: boolean; } -declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; +interface AnimationOptions { + id?: string; + delay?: number; + direction?: "normal" | "reverse" | "alternate" | "alternate-reverse"; + duration?: number; + easing?: string; + endDelay?: number; + fill?: "none" | "forwards" | "backwards" | "both"| "auto"; + iterationStart?: number; + iterations?: number; +} + +interface AnimationTimeline { + readonly currentTime: number | null; +} + +interface ComputedTimingProperties { + endTime: number; + activeDuration: number; + localTime: number | null; + progress: number | null; + currentIteration: number | null; +} + +interface AnimationEffectReadOnly { + readonly timing: number; + getComputedTiming(): ComputedTimingProperties; +} + +interface AnimationPlaybackEventInit extends EventInit { + currentTime?: number | null; + timelineTime?: number | null; +} + +interface AnimationPlaybackEvent extends Event { + readonly currentTime: number | null; + readonly timelineTime: number | null; +} + +declare var AnimationPlaybackEvent: { + prototype: AnimationPlaybackEvent; + new(type: string, eventInitDict?: AnimationPlaybackEventInit): AnimationPlaybackEvent; +}; + +interface Animation { + currentTime: number | null; + effect: AnimationEffectReadOnly; + readonly finished: Promise; + id: string; + readonly pending: boolean; + readonly playState: "idle" | "running" | "paused" | "finished"; + playbackRate: number; + readonly ready: Promise; + startTime: number; + timeline: AnimationTimeline; + oncancel: (this: Animation, ev: AnimationPlaybackEvent) => any; + onfinish: (this: Animation, ev: AnimationPlaybackEvent) => any; + cancel(): void; + finish(): void; + pause(): void; + play(): void; + reverse(): void; +} + +declare var Animation: { + prototype: Animation; + new(effect?: AnimationEffectReadOnly, timeline?: AnimationTimeline): Animation; +}; interface DecodeErrorCallback { (error: DOMException): void; @@ -14875,7 +14932,7 @@ interface ErrorEventHandler { (message: string, filename?: string, lineno?: number, colno?: number, error?: Error): void; } interface ForEachCallback { - (keyId: BufferSource, status: MediaKeyStatus): void; + (keyId: any, status: MediaKeyStatus): void; } interface FrameRequestCallback { (time: number): void; @@ -15027,6 +15084,7 @@ interface HTMLElementTagNameMap { "script": HTMLScriptElement; "section": HTMLElement; "select": HTMLSelectElement; + "slot": HTMLSlotElement; "small": HTMLElement; "source": HTMLSourceElement; "span": HTMLSpanElement; @@ -15326,9 +15384,9 @@ declare function atob(encodedString: string): string; declare function btoa(rawString: string): string; declare function fetch(input: RequestInfo, init?: RequestInit): Promise; declare function addEventListener(type: K, listener: (this: Window, ev: WindowEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; -declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; +declare function addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; declare function removeEventListener(type: K, listener: (this: Window, ev: WindowEventMap[K]) => any, options?: boolean | EventListenerOptions): void; -declare function removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; +declare function removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; type AAGUID = string; type AlgorithmIdentifier = string | Algorithm; type BodyInit = Blob | BufferSource | FormData | string; @@ -15373,6 +15431,7 @@ type ScrollRestoration = "auto" | "manual"; type FormDataEntryValue = string | File; type InsertPosition = "beforebegin" | "afterbegin" | "beforeend" | "afterend"; type HeadersInit = Headers | string[][] | { [key: string]: string }; +type AnimationKeyFrame = {offset?: number | null | (number | null)[]} & {[key: string]: string | number | number[] | string[]}; type AppendMode = "segments" | "sequence"; type AudioContextState = "suspended" | "running" | "closed"; type BiquadFilterType = "lowpass" | "highpass" | "bandpass" | "lowshelf" | "highshelf" | "peaking" | "notch" | "allpass"; diff --git a/src/lib/es2015.core.d.ts b/src/lib/es2015.core.d.ts index eef20591a84..68be040c29d 100644 --- a/src/lib/es2015.core.d.ts +++ b/src/lib/es2015.core.d.ts @@ -69,7 +69,7 @@ interface ArrayConstructor { } interface DateConstructor { - new (value: Date): Date; + new (value: number | string | Date): Date; } interface Function { diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 707f749e365..1f352cd6f39 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -985,7 +985,7 @@ interface ReadonlyArray { */ toString(): string; /** - * Returns a string representation of an array. The elements are converted to string using thier toLocalString methods. + * Returns a string representation of an array. The elements are converted to string using their toLocalString methods. */ toLocaleString(): string; /** @@ -1104,7 +1104,7 @@ interface Array { */ toString(): string; /** - * Returns a string representation of an array. The elements are converted to string using thier toLocalString methods. + * Returns a string representation of an array. The elements are converted to string using their toLocalString methods. */ toLocaleString(): string; /** @@ -1317,6 +1317,13 @@ type Partial = { [P in keyof T]?: T[P]; }; +/** + * Make all properties in T required + */ +type Required = { + [P in keyof T]-?: T[P]; +}; + /** * Make all properties in T readonly */ @@ -1338,6 +1345,31 @@ type Record = { [P in K]: T; }; +/** + * Exclude from T those types that are assignable to U + */ +type Exclude = T extends U ? never : T; + +/** + * Extract from T those types that are assignable to U + */ +type Extract = T extends U ? T : never; + +/** + * Exclude null and undefined from T + */ +type NonNullable = T extends null | undefined ? never : T; + +/** + * Obtain the return type of a function type + */ +type ReturnType any> = T extends (...args: any[]) => infer R ? R : any; + +/** + * Obtain the return type of a constructor function type + */ +type InstanceType any> = T extends new (...args: any[]) => infer R ? R : any; + /** * Marker for contextual 'this' type */ diff --git a/src/lib/webworker.generated.d.ts b/src/lib/webworker.generated.d.ts index 1b0ce074f00..187aa6072b2 100644 --- a/src/lib/webworker.generated.d.ts +++ b/src/lib/webworker.generated.d.ts @@ -128,21 +128,7 @@ interface SyncEventInit extends ExtendableEventInit { lastChance?: boolean; } -interface EventListener { - (evt: Event): void; -} - -interface WebKitEntriesCallback { - (evt: Event): void; -} - -interface WebKitErrorCallback { - (evt: Event): void; -} - -interface WebKitFileCallback { - (evt: Event): void; -} +type EventListener = (evt: Event) => void | { handleEvent(evt: Event): void; }; interface AudioBuffer { readonly duration: number; @@ -404,9 +390,9 @@ declare var Event: { }; interface EventTarget { - addEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; dispatchEvent(evt: Event): boolean; - removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var EventTarget: { @@ -444,9 +430,9 @@ interface FileReader extends EventTarget, MSBaseReader { readAsDataURL(blob: Blob): void; readAsText(blob: Blob, encoding?: string): void; addEventListener(type: K, listener: (this: FileReader, ev: MSBaseReaderEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: FileReader, ev: MSBaseReaderEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var FileReader: { @@ -529,9 +515,9 @@ interface IDBDatabase extends EventTarget { addEventListener(type: "versionchange", listener: (this: IDBDatabase, ev: IDBVersionChangeEvent) => any, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: "versionchange", listener: (this: IDBDatabase, ev: IDBVersionChangeEvent) => any, options?: boolean | EventListenerOptions): void; addEventListener(type: K, listener: (this: IDBDatabase, ev: IDBDatabaseEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: IDBDatabase, ev: IDBDatabaseEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var IDBDatabase: { @@ -616,9 +602,9 @@ interface IDBOpenDBRequest extends IDBRequest { onblocked: (this: IDBOpenDBRequest, ev: Event) => any; onupgradeneeded: (this: IDBOpenDBRequest, ev: IDBVersionChangeEvent) => any; addEventListener(type: K, listener: (this: IDBOpenDBRequest, ev: IDBOpenDBRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: IDBOpenDBRequest, ev: IDBOpenDBRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var IDBOpenDBRequest: { @@ -640,9 +626,9 @@ interface IDBRequest extends EventTarget { source: IDBObjectStore | IDBIndex | IDBCursor; readonly transaction: IDBTransaction; addEventListener(type: K, listener: (this: IDBRequest, ev: IDBRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: IDBRequest, ev: IDBRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var IDBRequest: { @@ -669,9 +655,9 @@ interface IDBTransaction extends EventTarget { readonly READ_WRITE: string; readonly VERSION_CHANGE: string; addEventListener(type: K, listener: (this: IDBTransaction, ev: IDBTransactionEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: IDBTransaction, ev: IDBTransactionEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var IDBTransaction: { @@ -737,9 +723,9 @@ interface MessagePort extends EventTarget { postMessage(message?: any, transfer?: any[]): void; start(): void; addEventListener(type: K, listener: (this: MessagePort, ev: MessagePortEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: MessagePort, ev: MessagePortEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var MessagePort: { @@ -768,9 +754,9 @@ interface Notification extends EventTarget { readonly title: string; close(): void; addEventListener(type: K, listener: (this: Notification, ev: NotificationEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: Notification, ev: NotificationEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var Notification: { @@ -892,7 +878,7 @@ declare var ProgressEvent: { }; interface PushManager { - getSubscription(): Promise; + getSubscription(): Promise; permissionState(options?: PushSubscriptionOptionsInit): Promise; subscribe(options?: PushSubscriptionOptionsInit): Promise; } @@ -999,9 +985,9 @@ interface ServiceWorker extends EventTarget, AbstractWorker { readonly state: ServiceWorkerState; postMessage(message: any, transfer?: any[]): void; addEventListener(type: K, listener: (this: ServiceWorker, ev: ServiceWorkerEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: ServiceWorker, ev: ServiceWorkerEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var ServiceWorker: { @@ -1026,9 +1012,9 @@ interface ServiceWorkerRegistration extends EventTarget { unregister(): Promise; update(): Promise; addEventListener(type: K, listener: (this: ServiceWorkerRegistration, ev: ServiceWorkerRegistrationEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: ServiceWorkerRegistration, ev: ServiceWorkerRegistrationEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var ServiceWorkerRegistration: { @@ -1088,15 +1074,15 @@ interface WebSocket extends EventTarget { readonly readyState: number; readonly url: string; close(code?: number, reason?: string): void; - send(data: any): void; + send(data: USVString | ArrayBuffer | Blob | ArrayBufferView): void; readonly CLOSED: number; readonly CLOSING: number; readonly CONNECTING: number; readonly OPEN: number; addEventListener(type: K, listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var WebSocket: { @@ -1117,9 +1103,9 @@ interface Worker extends EventTarget, AbstractWorker { postMessage(message: any, transfer?: any[]): void; terminate(): void; addEventListener(type: K, listener: (this: Worker, ev: WorkerEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: Worker, ev: WorkerEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var Worker: { @@ -1160,9 +1146,9 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { readonly OPENED: number; readonly UNSENT: number; addEventListener(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var XMLHttpRequest: { @@ -1177,9 +1163,9 @@ declare var XMLHttpRequest: { interface XMLHttpRequestUpload extends EventTarget, XMLHttpRequestEventTarget { addEventListener(type: K, listener: (this: XMLHttpRequestUpload, ev: XMLHttpRequestEventTargetEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: XMLHttpRequestUpload, ev: XMLHttpRequestEventTargetEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var XMLHttpRequestUpload: { @@ -1194,9 +1180,9 @@ interface AbstractWorkerEventMap { interface AbstractWorker { onerror: (this: AbstractWorker, ev: ErrorEvent) => any; addEventListener(type: K, listener: (this: AbstractWorker, ev: AbstractWorkerEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: AbstractWorker, ev: AbstractWorkerEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } interface Body { @@ -1234,9 +1220,9 @@ interface MSBaseReader { readonly EMPTY: number; readonly LOADING: number; addEventListener(type: K, listener: (this: MSBaseReader, ev: MSBaseReaderEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: MSBaseReader, ev: MSBaseReaderEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } interface NavigatorBeacon { @@ -1291,9 +1277,9 @@ interface XMLHttpRequestEventTarget { onprogress: (this: XMLHttpRequest, ev: ProgressEvent) => any; ontimeout: (this: XMLHttpRequest, ev: ProgressEvent) => any; addEventListener(type: K, listener: (this: XMLHttpRequestEventTarget, ev: XMLHttpRequestEventTargetEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: XMLHttpRequestEventTarget, ev: XMLHttpRequestEventTargetEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } interface Client { @@ -1329,9 +1315,9 @@ interface DedicatedWorkerGlobalScope extends WorkerGlobalScope { close(): void; postMessage(message: any, transfer?: any[]): void; addEventListener(type: K, listener: (this: DedicatedWorkerGlobalScope, ev: DedicatedWorkerGlobalScopeEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: DedicatedWorkerGlobalScope, ev: DedicatedWorkerGlobalScopeEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var DedicatedWorkerGlobalScope: { @@ -1442,9 +1428,9 @@ interface ServiceWorkerGlobalScope extends WorkerGlobalScope { readonly registration: ServiceWorkerRegistration; skipWaiting(): Promise; addEventListener(type: K, listener: (this: ServiceWorkerGlobalScope, ev: ServiceWorkerGlobalScopeEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: ServiceWorkerGlobalScope, ev: ServiceWorkerGlobalScopeEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var ServiceWorkerGlobalScope: { @@ -1489,9 +1475,9 @@ interface WorkerGlobalScope extends EventTarget, WorkerUtils, WindowConsole, Glo createImageBitmap(image: ImageBitmap | ImageData | Blob, options?: ImageBitmapOptions): Promise; createImageBitmap(image: ImageBitmap | ImageData | Blob, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise; addEventListener(type: K, listener: (this: WorkerGlobalScope, ev: WorkerGlobalScopeEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: WorkerGlobalScope, ev: WorkerGlobalScopeEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var WorkerGlobalScope: { @@ -1549,9 +1535,9 @@ interface BroadcastChannel extends EventTarget { close(): void; postMessage(message: any): void; addEventListener(type: K, listener: (this: BroadcastChannel, ev: BroadcastChannelEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: BroadcastChannel, ev: BroadcastChannelEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; } declare var BroadcastChannel: { @@ -1631,10 +1617,6 @@ interface FilePropertyBag extends BlobPropertyBag { lastModified?: number; } -interface EventListenerObject { - handleEvent(evt: Event): void; -} - interface ProgressEventInit extends EventInit { lengthComputable?: boolean; loaded?: number; @@ -1861,8 +1843,6 @@ interface EventSourceInit { readonly withCredentials: boolean; } -declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; - interface DecodeErrorCallback { (error: DOMException): void; } @@ -1873,7 +1853,7 @@ interface ErrorEventHandler { (message: string, filename?: string, lineno?: number, colno?: number, error?: Error): void; } interface ForEachCallback { - (keyId: BufferSource, status: MediaKeyStatus): void; + (keyId: any, status: MediaKeyStatus): void; } interface FunctionStringCallback { (data: string): void; @@ -1919,9 +1899,9 @@ declare var console: Console; declare function fetch(input: RequestInfo, init?: RequestInit): Promise; declare function dispatchEvent(evt: Event): boolean; declare function addEventListener(type: K, listener: (this: DedicatedWorkerGlobalScope, ev: DedicatedWorkerGlobalScopeEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; -declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; +declare function addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void; declare function removeEventListener(type: K, listener: (this: DedicatedWorkerGlobalScope, ev: DedicatedWorkerGlobalScopeEventMap[K]) => any, options?: boolean | EventListenerOptions): void; -declare function removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; +declare function removeEventListener(type: string, listener: EventListener, options?: boolean | EventListenerOptions): void; type AlgorithmIdentifier = string | Algorithm; type BodyInit = Blob | BufferSource | FormData | string; type IDBKeyPath = string; diff --git a/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl index ffaf6621ac5..8de5fe09f4e 100644 --- a/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -8778,6 +8778,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl index 6251fa14008..d718a152291 100644 --- a/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -8760,6 +8760,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl index 3507c91d278..c5a24f11483 100644 --- a/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -8778,6 +8778,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl index 1bcd0308ab4..0245b3da775 100644 --- a/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -8768,6 +8768,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl index 343994d2cab..541710c9ffb 100644 --- a/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -8762,6 +8762,15 @@ + + + + + + + + + diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 5d71ff4c2d3..3d0d623c6d4 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -376,9 +376,9 @@ namespace ts.server { private safelist: SafeList = defaultTypeSafeList; private legacySafelist: { [key: string]: string } = {}; - private changedFiles: ScriptInfo[]; private pendingProjectUpdates = createMap(); - private pendingInferredProjectUpdate: boolean; + /* @internal */ + pendingEnsureProjectForOpenFiles: boolean; readonly currentDirectory: string; readonly toCanonicalFileName: (f: string) => string; @@ -483,11 +483,6 @@ namespace ts.server { return getNormalizedAbsolutePath(fileName, this.host.getCurrentDirectory()); } - /* @internal */ - getChangedFiles_TestOnly() { - return this.changedFiles; - } - /* @internal */ ensureInferredProjectsUpToDate_TestOnly() { this.ensureProjectStructuresUptoDate(); @@ -552,19 +547,18 @@ namespace ts.server { this.typingsCache.deleteTypingsForProject(response.projectName); break; } - this.delayUpdateProjectGraphAndInferredProjectsRefresh(project); + this.delayUpdateProjectGraphAndEnsureProjectStructureForOpenFiles(project); } - private delayInferredProjectsRefresh() { - this.pendingInferredProjectUpdate = true; - this.throttledOperations.schedule("*refreshInferredProjects*", /*delay*/ 250, () => { + private delayEnsureProjectForOpenFiles() { + this.pendingEnsureProjectForOpenFiles = true; + this.throttledOperations.schedule("*ensureProjectForOpenFiles*", /*delay*/ 250, () => { if (this.pendingProjectUpdates.size !== 0) { - this.delayInferredProjectsRefresh(); + this.delayEnsureProjectForOpenFiles(); } else { - if (this.pendingInferredProjectUpdate) { - this.pendingInferredProjectUpdate = false; - this.refreshInferredProjects(); + if (this.pendingEnsureProjectForOpenFiles) { + this.ensureProjectForOpenFiles(); } // Send the event to notify that there were background project updates // send current list of open files @@ -574,6 +568,7 @@ namespace ts.server { } private delayUpdateProjectGraph(project: Project) { + project.markAsDirty(); const projectName = project.getProjectName(); this.pendingProjectUpdates.set(projectName, project); this.throttledOperations.schedule(projectName, /*delay*/ 250, () => { @@ -603,17 +598,16 @@ namespace ts.server { } /* @internal */ - delayUpdateProjectGraphAndInferredProjectsRefresh(project: Project) { - project.markAsDirty(); + delayUpdateProjectGraphAndEnsureProjectStructureForOpenFiles(project: Project) { this.delayUpdateProjectGraph(project); - this.delayInferredProjectsRefresh(); + this.delayEnsureProjectForOpenFiles(); } - private delayUpdateProjectGraphs(projects: Project[]) { + private delayUpdateProjectGraphs(projects: ReadonlyArray) { for (const project of projects) { this.delayUpdateProjectGraph(project); } - this.delayInferredProjectsRefresh(); + this.delayEnsureProjectForOpenFiles(); } setCompilerOptionsForInferredProjects(projectCompilerOptions: protocol.ExternalProjectCompilerOptions, projectRootPath?: string): void { @@ -632,7 +626,6 @@ namespace ts.server { this.compilerOptionsForInferredProjects = compilerOptions; } - const projectsToUpdate: Project[] = []; for (const project of this.inferredProjects) { // Only update compiler options in the following cases: // - Inferred projects without a projectRootPath, if the new options do not apply to @@ -648,11 +641,11 @@ namespace ts.server { project.setCompilerOptions(compilerOptions); project.compileOnSaveEnabled = compilerOptions.compileOnSave; project.markAsDirty(); - projectsToUpdate.push(project); + this.delayUpdateProjectGraph(project); } } - this.delayUpdateProjectGraphs(projectsToUpdate); + this.delayEnsureProjectForOpenFiles(); } findProject(projectName: string): Project | undefined { @@ -668,7 +661,7 @@ namespace ts.server { getDefaultProjectForFile(fileName: NormalizedPath, ensureProject: boolean) { let scriptInfo = this.getScriptInfoForNormalizedPath(fileName); - if (ensureProject && !scriptInfo || scriptInfo.isOrphan()) { + if (ensureProject && (!scriptInfo || scriptInfo.isOrphan())) { this.ensureProjectStructuresUptoDate(); scriptInfo = this.getScriptInfoForNormalizedPath(fileName); if (!scriptInfo) { @@ -687,41 +680,27 @@ namespace ts.server { /** * Ensures the project structures are upto date * This means, - * - if there are changedFiles (the files were updated but their containing project graph was not upto date), - * their project graph is updated - * - If there are pendingProjectUpdates (scheduled to be updated with delay so they can batch update the graph if there are several changes in short time span) - * their project graph is updated - * - If there were project graph updates and/or there was pending inferred project update and/or called forced the inferred project structure refresh - * Inferred projects are created/updated/deleted based on open files states - * @param forceInferredProjectsRefresh when true updates the inferred projects even if there is no pending work to update the files/project structures + * - we go through all the projects and update them if they are dirty + * - if updates reflect some change in structure or there was pending request to ensure projects for open files + * ensure that each open script info has project */ - private ensureProjectStructuresUptoDate(forceInferredProjectsRefresh?: boolean) { - if (this.changedFiles) { - let projectsToUpdate: Project[]; - if (this.changedFiles.length === 1) { - // simpliest case - no allocations - projectsToUpdate = this.changedFiles[0].containingProjects; - } - else { - projectsToUpdate = []; - for (const f of this.changedFiles) { - addRange(projectsToUpdate, f.containingProjects); - } - } - this.changedFiles = undefined; - this.updateProjectGraphs(projectsToUpdate); - } + private ensureProjectStructuresUptoDate() { + let hasChanges = this.pendingEnsureProjectForOpenFiles; + this.pendingProjectUpdates.clear(); + const updateGraph = (project: Project) => { + hasChanges = this.updateProjectIfDirty(project) || hasChanges; + }; - if (this.pendingProjectUpdates.size !== 0) { - const projectsToUpdate = arrayFrom(this.pendingProjectUpdates.values()); - this.pendingProjectUpdates.clear(); - this.updateProjectGraphs(projectsToUpdate); + this.externalProjects.forEach(updateGraph); + this.configuredProjects.forEach(updateGraph); + this.inferredProjects.forEach(updateGraph); + if (hasChanges) { + this.ensureProjectForOpenFiles(); } + } - if (this.pendingInferredProjectUpdate || forceInferredProjectsRefresh) { - this.pendingInferredProjectUpdate = false; - this.refreshInferredProjects(); - } + private updateProjectIfDirty(project: Project) { + return project.dirty && project.updateGraph(); } getFormatCodeOptions(file?: NormalizedPath) { @@ -735,14 +714,6 @@ namespace ts.server { return formatCodeSettings || this.hostConfiguration.formatCodeOptions; } - private updateProjectGraphs(projects: Project[]) { - for (const p of projects) { - if (!p.updateGraph()) { - this.pendingInferredProjectUpdate = true; - } - } - } - private onSourceFileChanged(fileName: NormalizedPath, eventKind: FileWatcherEventKind) { const info = this.getScriptInfoForNormalizedPath(fileName); if (!info) { @@ -770,8 +741,6 @@ namespace ts.server { private handleDeletedFile(info: ScriptInfo) { this.stopWatchingScriptInfo(info); - // TODO: handle isOpen = true case - if (!info.isScriptOpen()) { this.deleteScriptInfo(info); @@ -808,7 +777,7 @@ namespace ts.server { // Reload is pending, do the reload if (project.pendingReload !== ConfigFileProgramReloadLevel.Full) { project.pendingReload = ConfigFileProgramReloadLevel.Partial; - this.delayUpdateProjectGraphAndInferredProjectsRefresh(project); + this.delayUpdateProjectGraphAndEnsureProjectStructureForOpenFiles(project); } }, flags, @@ -1317,7 +1286,11 @@ namespace ts.server { this.logger.info("Open files: "); this.openFiles.forEach((projectRootPath, path) => { - this.logger.info(`\tFileName: ${this.getScriptInfoForPath(path as Path).fileName} ProjectRootPath: ${projectRootPath}`); + const info = this.getScriptInfoForPath(path as Path); + this.logger.info(`\tFileName: ${info.fileName} ProjectRootPath: ${projectRootPath}`); + if (writeProjectFileNames) { + this.logger.info(`\t\tProjects: ${info.containingProjects.map(p => p.getProjectName())}`); + } }); this.logger.endGroup(); @@ -1377,9 +1350,10 @@ namespace ts.server { return { projectOptions, configFileErrors: errors, configFileSpecs: parsedCommandLine.configFileSpecs }; } - private exceededTotalSizeLimitForNonTsFiles(name: string, options: CompilerOptions, fileNames: T[], propertyReader: FilePropertyReader) { + /** Get a filename if the language service exceeds the maximum allowed program size; otherwise returns undefined. */ + private getFilenameForExceededTotalSizeLimitForNonTsFiles(name: string, options: CompilerOptions, fileNames: T[], propertyReader: FilePropertyReader): string | undefined { if (options && options.disableSizeLimit || !this.host.getFileSize) { - return false; + return; } let availableSpace = maxProgramSizeForNonTsFiles; @@ -1396,20 +1370,16 @@ namespace ts.server { totalNonTsFileSize += this.host.getFileSize(fileName); - if (totalNonTsFileSize > maxProgramSizeForNonTsFiles) { + if (totalNonTsFileSize > maxProgramSizeForNonTsFiles || totalNonTsFileSize > availableSpace) { this.logger.info(getExceedLimitMessage({ propertyReader, hasTypeScriptFileExtension, host: this.host }, totalNonTsFileSize)); // Keep the size as zero since it's disabled - return true; + return fileName; } } - if (totalNonTsFileSize > availableSpace) { - this.logger.info(getExceedLimitMessage({ propertyReader, hasTypeScriptFileExtension, host: this.host }, totalNonTsFileSize)); - return true; - } - this.projectToSizeMap.set(name, totalNonTsFileSize); - return false; + + return; function getExceedLimitMessage(context: { propertyReader: FilePropertyReader, hasTypeScriptFileExtension: (filename: string) => boolean, host: ServerHost }, totalNonTsFileSize: number) { const files = getTop5LargestFiles(context); @@ -1432,7 +1402,7 @@ namespace ts.server { this, this.documentRegistry, compilerOptions, - /*languageServiceEnabled*/ !this.exceededTotalSizeLimitForNonTsFiles(projectFileName, compilerOptions, files, externalFilePropertyReader), + /*lastFileExceededProgramSize*/ this.getFilenameForExceededTotalSizeLimitForNonTsFiles(projectFileName, compilerOptions, files, externalFilePropertyReader), options.compileOnSave === undefined ? true : options.compileOnSave); project.excludedFiles = excludedFiles; @@ -1498,14 +1468,14 @@ namespace ts.server { const cachedDirectoryStructureHost = createCachedDirectoryStructureHost(this.host, this.host.getCurrentDirectory(), this.host.useCaseSensitiveFileNames); const { projectOptions, configFileErrors, configFileSpecs } = this.convertConfigFileContentToProjectOptions(configFileName, cachedDirectoryStructureHost); this.logger.info(`Opened configuration file ${configFileName}`); - const languageServiceEnabled = !this.exceededTotalSizeLimitForNonTsFiles(configFileName, projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader); + const lastFileExceededProgramSize = this.getFilenameForExceededTotalSizeLimitForNonTsFiles(configFileName, projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader); const project = new ConfiguredProject( configFileName, this, this.documentRegistry, projectOptions.configHasFilesProperty, projectOptions.compilerOptions, - languageServiceEnabled, + lastFileExceededProgramSize, projectOptions.compileOnSave === undefined ? false : projectOptions.compileOnSave, cachedDirectoryStructureHost); @@ -1518,7 +1488,7 @@ namespace ts.server { WatchType.ConfigFilePath, project ); - if (languageServiceEnabled) { + if (!lastFileExceededProgramSize) { project.watchWildcards(projectOptions.wildcardDirectories); } @@ -1631,8 +1601,9 @@ namespace ts.server { // Update the project project.configFileSpecs = configFileSpecs; project.setProjectErrors(configFileErrors); - if (this.exceededTotalSizeLimitForNonTsFiles(project.canonicalConfigFilePath, projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader)) { - project.disableLanguageService(); + const lastFileExceededProgramSize = this.getFilenameForExceededTotalSizeLimitForNonTsFiles(project.canonicalConfigFilePath, projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader); + if (lastFileExceededProgramSize) { + project.disableLanguageService(lastFileExceededProgramSize); project.stopWatchingWildCards(); } else { @@ -1898,7 +1869,7 @@ namespace ts.server { // Reload Projects this.reloadConfiguredProjectForFiles(this.openFiles, /*delayReload*/ false, returnTrue); - this.refreshInferredProjects(); + this.ensureProjectForOpenFiles(); } private delayReloadConfiguredProjectForFiles(configFileExistenceInfo: ConfigFileExistenceInfo, ignoreIfNotRootOfInferredProject: boolean) { @@ -1910,7 +1881,7 @@ namespace ts.server { isRootOfInferredProject => isRootOfInferredProject : // Reload open files if they are root of inferred project returnTrue // Reload all the open files impacted by config file ); - this.delayInferredProjectsRefresh(); + this.delayEnsureProjectForOpenFiles(); } /** @@ -1994,8 +1965,8 @@ namespace ts.server { * This will go through open files and assign them to inferred project if open file is not part of any other project * After that all the inferred project graphs are updated */ - private refreshInferredProjects() { - this.logger.info("refreshInferredProjects: updating project structure from ..."); + private ensureProjectForOpenFiles() { + this.logger.info("Structure before ensureProjectForOpenFiles:"); this.printProjects(); this.openFiles.forEach((projectRootPath, path) => { @@ -2009,12 +1980,10 @@ namespace ts.server { this.removeRootOfInferredProjectIfNowPartOfOtherProject(info); } }); + this.pendingEnsureProjectForOpenFiles = false; + this.inferredProjects.forEach(p => this.updateProjectIfDirty(p)); - for (const p of this.inferredProjects) { - p.updateGraph(); - } - - this.logger.info("refreshInferredProjects: updated project structure ..."); + this.logger.info("Structure after ensureProjectForOpenFiles:"); this.printProjects(); } @@ -2040,7 +2009,6 @@ namespace ts.server { openClientFileWithNormalizedPath(fileName: NormalizedPath, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean, projectRootPath?: NormalizedPath): OpenConfiguredProjectResult { let configFileName: NormalizedPath; - let sendConfigFileDiagEvent = false; let configFileErrors: ReadonlyArray; const info = this.getOrCreateScriptInfoOpenedByClientForNormalizedPath(fileName, projectRootPath ? this.getNormalizedAbsolutePath(projectRootPath) : this.currentDirectory, fileContent, scriptKind, hasMixedContent); @@ -2051,8 +2019,15 @@ namespace ts.server { project = this.findConfiguredProjectByProjectName(configFileName); if (!project) { project = this.createConfiguredProject(configFileName); - // Send the event only if the project got created as part of this open request - sendConfigFileDiagEvent = true; + // Send the event only if the project got created as part of this open request and info is part of the project + if (info.isOrphan()) { + // Since the file isnt part of configured project, do not send config file info + configFileName = undefined; + } + else { + configFileErrors = project.getAllProjectErrors(); + this.sendConfigFileDiagEvent(project as ConfiguredProject, fileName); + } } else { // Ensure project is ready to check if it contains opened script info @@ -2060,30 +2035,20 @@ namespace ts.server { } } } - if (project && !project.languageServiceEnabled) { - // if project language service is disabled then we create a program only for open files. - // this means that project should be marked as dirty to force rebuilding of the program - // on the next request - project.markAsDirty(); - } + + // Project we have at this point is going to be updated since its either found through + // - external project search, which updates the project before checking if info is present in it + // - configured project - either created or updated to ensure we know correct status of info // At this point if file is part of any any configured or external project, then it would be present in the containing projects // So if it still doesnt have any containing projects, it needs to be part of inferred project if (info.isOrphan()) { - // Since the file isnt part of configured project, do not send config file event - configFileName = undefined; - sendConfigFileDiagEvent = false; - this.assignOrphanScriptInfoToInferredProject(info, projectRootPath); } + Debug.assert(!info.isOrphan()); this.openFiles.set(info.path, projectRootPath); - if (sendConfigFileDiagEvent) { - configFileErrors = project.getAllProjectErrors(); - this.sendConfigFileDiagEvent(project as ConfiguredProject, fileName); - } - // Remove the configured projects that have zero references from open files. // This was postponed from closeOpenFile to after opening next file, // so that we can reuse the project if we need to right away @@ -2155,11 +2120,6 @@ namespace ts.server { this.closeClientFile(file); } } - // if files were open or closed then explicitly refresh list of inferred projects - // otherwise if there were only changes in files - record changed files in `changedFiles` and defer the update - if (openFiles || closedFiles) { - this.ensureProjectStructuresUptoDate(/*refreshInferredProjects*/ true); - } } /* @internal */ @@ -2169,49 +2129,33 @@ namespace ts.server { const change = changes[i]; scriptInfo.editContent(change.span.start, change.span.start + change.span.length, change.newText); } - if (!this.changedFiles) { - this.changedFiles = [scriptInfo]; - } - else if (!contains(this.changedFiles, scriptInfo)) { - this.changedFiles.push(scriptInfo); - } } - private closeConfiguredProjectReferencedFromExternalProject(configFile: NormalizedPath): boolean { + private closeConfiguredProjectReferencedFromExternalProject(configFile: NormalizedPath) { const configuredProject = this.findConfiguredProjectByProjectName(configFile); if (configuredProject) { configuredProject.deleteExternalProjectReference(); if (!configuredProject.hasOpenRef()) { this.removeProject(configuredProject); - return true; + return; } } - return false; } - closeExternalProject(uncheckedFileName: string, suppressRefresh = false): void { + closeExternalProject(uncheckedFileName: string): void { const fileName = toNormalizedPath(uncheckedFileName); const configFiles = this.externalProjectToConfiguredProjectMap.get(fileName); if (configFiles) { - let shouldRefreshInferredProjects = false; for (const configFile of configFiles) { - if (this.closeConfiguredProjectReferencedFromExternalProject(configFile)) { - shouldRefreshInferredProjects = true; - } + this.closeConfiguredProjectReferencedFromExternalProject(configFile); } this.externalProjectToConfiguredProjectMap.delete(fileName); - if (shouldRefreshInferredProjects && !suppressRefresh) { - this.ensureProjectStructuresUptoDate(/*refreshInferredProjects*/ true); - } } else { // close external project const externalProject = this.findExternalProjectByProjectName(uncheckedFileName); if (externalProject) { this.removeProject(externalProject); - if (!suppressRefresh) { - this.ensureProjectStructuresUptoDate(/*refreshInferredProjects*/ true); - } } } } @@ -2224,17 +2168,15 @@ namespace ts.server { }); for (const externalProject of projects) { - this.openExternalProject(externalProject, /*suppressRefreshOfInferredProjects*/ true); + this.openExternalProject(externalProject); // delete project that is present in input list projectsToClose.delete(externalProject.projectFileName); } // close projects that were missing in the input list forEachKey(projectsToClose, externalProjectName => { - this.closeExternalProject(externalProjectName, /*suppressRefresh*/ true); + this.closeExternalProject(externalProjectName); }); - - this.ensureProjectStructuresUptoDate(/*refreshInferredProjects*/ true); } /** Makes a filename safe to insert in a RegExp */ @@ -2355,7 +2297,7 @@ namespace ts.server { return excludedFiles; } - openExternalProject(proj: protocol.ExternalProject, suppressRefreshOfInferredProjects = false): void { + openExternalProject(proj: protocol.ExternalProject): void { // typingOptions has been deprecated and is only supported for backward compatibility // purposes. It should be removed in future releases - use typeAcquisition instead. if (proj.typingOptions && !proj.typeAcquisition) { @@ -2396,8 +2338,9 @@ namespace ts.server { externalProject.excludedFiles = excludedFiles; if (!tsConfigFiles) { const compilerOptions = convertCompilerOptions(proj.options); - if (this.exceededTotalSizeLimitForNonTsFiles(proj.projectFileName, compilerOptions, proj.rootFiles, externalFilePropertyReader)) { - externalProject.disableLanguageService(); + const lastFileExceededProgramSize = this.getFilenameForExceededTotalSizeLimitForNonTsFiles(proj.projectFileName, compilerOptions, proj.rootFiles, externalFilePropertyReader); + if (lastFileExceededProgramSize) { + externalProject.disableLanguageService(lastFileExceededProgramSize); } else { externalProject.enableLanguageService(); @@ -2408,13 +2351,13 @@ namespace ts.server { } // some config files were added to external project (that previously were not there) // close existing project and later we'll open a set of configured projects for these files - this.closeExternalProject(proj.projectFileName, /*suppressRefresh*/ true); + this.closeExternalProject(proj.projectFileName); } else if (this.externalProjectToConfiguredProjectMap.get(proj.projectFileName)) { // this project used to include config files if (!tsConfigFiles) { // config files were removed from the project - close existing external project which in turn will close configured projects - this.closeExternalProject(proj.projectFileName, /*suppressRefresh*/ true); + this.closeExternalProject(proj.projectFileName); } else { // project previously had some config files - compare them with new set of files and close all configured projects that correspond to unused files @@ -2464,9 +2407,6 @@ namespace ts.server { this.externalProjectToConfiguredProjectMap.delete(proj.projectFileName); this.createExternalProject(proj.projectFileName, rootFiles, proj.options, proj.typeAcquisition, excludedFiles); } - if (!suppressRefreshOfInferredProjects) { - this.ensureProjectStructuresUptoDate(/*refreshInferredProjects*/ true); - } } } } diff --git a/src/server/project.ts b/src/server/project.ts index 47365547479..dc949b4b221 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -126,6 +126,8 @@ namespace ts.server { private cachedUnresolvedImportsPerFile = new UnresolvedImportsMap(); private lastCachedUnresolvedImportsList: SortedReadonlyArray; + private lastFileExceededProgramSize: string | undefined; + // wrapper over the real language service that will suppress all semantic operations protected languageService: LanguageService; @@ -166,6 +168,9 @@ namespace ts.server { */ private projectStateVersion = 0; + /*@internal*/ + dirty = false; + /*@internal*/ hasChangedAutomaticTypeDirectiveNames = false; @@ -212,7 +217,7 @@ namespace ts.server { readonly projectService: ProjectService, private documentRegistry: DocumentRegistry, hasExplicitListOfFiles: boolean, - languageServiceEnabled: boolean, + lastFileExceededProgramSize: string | undefined, private compilerOptions: CompilerOptions, public compileOnSaveEnabled: boolean, directoryStructureHost: DirectoryStructureHost, @@ -244,10 +249,11 @@ namespace ts.server { // Use the current directory as resolution root only if the project created using current directory string this.resolutionCache = createResolutionCache(this, currentDirectory && this.currentDirectory, /*logChangesWhenResolvingModule*/ true); this.languageService = createLanguageService(this, this.documentRegistry); - if (!languageServiceEnabled) { - this.disableLanguageService(); + if (lastFileExceededProgramSize) { + this.disableLanguageService(lastFileExceededProgramSize); } this.markAsDirty(); + this.projectService.pendingEnsureProjectForOpenFiles = true; } isKnownTypesPackageName(name: string): boolean { @@ -397,7 +403,7 @@ namespace ts.server { /*@internal*/ onInvalidatedResolution() { - this.projectService.delayUpdateProjectGraphAndInferredProjectsRefresh(this); + this.projectService.delayUpdateProjectGraphAndEnsureProjectStructureForOpenFiles(this); } /*@internal*/ @@ -415,7 +421,7 @@ namespace ts.server { /*@internal*/ onChangedAutomaticTypeDirectiveNames() { this.hasChangedAutomaticTypeDirectiveNames = true; - this.projectService.delayUpdateProjectGraphAndInferredProjectsRefresh(this); + this.projectService.delayUpdateProjectGraphAndEnsureProjectStructureForOpenFiles(this); } /*@internal*/ @@ -497,15 +503,17 @@ namespace ts.server { return; } this.languageServiceEnabled = true; + this.lastFileExceededProgramSize = undefined; this.projectService.onUpdateLanguageServiceStateForProject(this, /*languageServiceEnabled*/ true); } - disableLanguageService() { + disableLanguageService(lastFileExceededProgramSize?: string) { if (!this.languageServiceEnabled) { return; } this.languageService.cleanupSemanticCache(); this.languageServiceEnabled = false; + this.lastFileExceededProgramSize = lastFileExceededProgramSize; this.builderState = undefined; this.resolutionCache.closeTypeRootsWatch(); this.projectService.onUpdateLanguageServiceStateForProject(this, /*languageServiceEnabled*/ false); @@ -561,6 +569,7 @@ namespace ts.server { for (const root of this.rootFiles) { root.detachFromProject(this); } + this.projectService.pendingEnsureProjectForOpenFiles = true; this.rootFiles = undefined; this.rootFilesMap = undefined; @@ -744,7 +753,10 @@ namespace ts.server { } markAsDirty() { - this.projectStateVersion++; + if (!this.dirty) { + this.projectStateVersion++; + this.dirty = true; + } } /* @internal */ @@ -819,7 +831,9 @@ namespace ts.server { } const cachedTypings = this.projectService.typingsCache.getTypingsForProject(this, this.lastCachedUnresolvedImportsList, hasChanges); - if (this.setTypings(cachedTypings)) { + if (!arrayIsEqualTo(this.typingFiles, cachedTypings)) { + this.typingFiles = cachedTypings; + this.markAsDirty(); hasChanges = this.updateGraphWorker() || hasChanges; } } @@ -843,15 +857,6 @@ namespace ts.server { return include.filter(i => existing.indexOf(i) < 0); } - private setTypings(typings: SortedReadonlyArray): boolean { - if (arrayIsEqualTo(this.typingFiles, typings)) { - return false; - } - this.typingFiles = typings; - this.markAsDirty(); - return true; - } - private updateGraphWorker() { const oldProgram = this.program; Debug.assert(!this.isClosed(), "Called update graph worker of closed project"); @@ -860,6 +865,7 @@ namespace ts.server { this.hasInvalidatedResolution = this.resolutionCache.createHasInvalidatedResolution(); this.resolutionCache.startCachingPerDirectoryResolution(); this.program = this.languageService.getProgram(); + this.dirty = false; this.resolutionCache.finishCachingPerDirectoryResolution(); // bump up the version if @@ -906,7 +912,7 @@ namespace ts.server { compareStringsCaseSensitive ); const elapsed = timestamp() - start; - this.writeLog(`Finishing updateGraphWorker: Project: ${this.getProjectName()} structureChanged: ${hasChanges} Elapsed: ${elapsed}ms`); + this.writeLog(`Finishing updateGraphWorker: Project: ${this.getProjectName()} Version: ${this.getProjectVersion()} structureChanged: ${hasChanges} Elapsed: ${elapsed}ms`); return hasChanges; } @@ -932,7 +938,7 @@ namespace ts.server { fileWatcher.close(); // When a missing file is created, we should update the graph. - this.projectService.delayUpdateProjectGraphAndInferredProjectsRefresh(this); + this.projectService.delayUpdateProjectGraphAndEnsureProjectStructureForOpenFiles(this); } }, WatchType.MissingFilePath, @@ -993,12 +999,13 @@ namespace ts.server { getChangesSinceVersion(lastKnownVersion?: number): ProjectFilesWithTSDiagnostics { this.updateGraph(); - const info = { + const info: protocol.ProjectVersionInfo = { projectName: this.getProjectName(), version: this.projectStructureVersion, isInferred: this.projectKind === ProjectKind.Inferred, options: this.getCompilationSettings(), - languageServiceDisabled: !this.languageServiceEnabled + languageServiceDisabled: !this.languageServiceEnabled, + lastFileExceededProgramSize: this.lastFileExceededProgramSize }; const updatedFileNames = this.updatedFileNames; this.updatedFileNames = undefined; @@ -1182,7 +1189,7 @@ namespace ts.server { projectService, documentRegistry, /*files*/ undefined, - /*languageServiceEnabled*/ true, + /*lastFileExceededProgramSize*/ undefined, compilerOptions, /*compileOnSaveEnabled*/ false, projectService.host, @@ -1261,7 +1268,7 @@ namespace ts.server { documentRegistry: DocumentRegistry, hasExplicitListOfFiles: boolean, compilerOptions: CompilerOptions, - languageServiceEnabled: boolean, + lastFileExceededProgramSize: string | undefined, public compileOnSaveEnabled: boolean, cachedDirectoryStructureHost: CachedDirectoryStructureHost) { super(configFileName, @@ -1269,7 +1276,7 @@ namespace ts.server { projectService, documentRegistry, hasExplicitListOfFiles, - languageServiceEnabled, + lastFileExceededProgramSize, compilerOptions, compileOnSaveEnabled, cachedDirectoryStructureHost, @@ -1456,7 +1463,7 @@ namespace ts.server { projectService: ProjectService, documentRegistry: DocumentRegistry, compilerOptions: CompilerOptions, - languageServiceEnabled: boolean, + lastFileExceededProgramSize: string | undefined, public compileOnSaveEnabled: boolean, projectFilePath?: string) { super(externalProjectName, @@ -1464,7 +1471,7 @@ namespace ts.server { projectService, documentRegistry, /*hasExplicitListOfFiles*/ true, - languageServiceEnabled, + lastFileExceededProgramSize, compilerOptions, compileOnSaveEnabled, projectService.host, diff --git a/src/server/protocol.ts b/src/server/protocol.ts index b4ff0aa4037..45c08034e6e 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -1104,11 +1104,14 @@ namespace ts.server.protocol { * Current set of compiler options for project */ options: ts.CompilerOptions; - /** * true if project language service is disabled */ languageServiceDisabled: boolean; + /** + * Filename of the last file analyzed before disabling the language service. undefined, if the language service is enabled. + */ + lastFileExceededProgramSize: string | undefined; } /** diff --git a/src/server/server.ts b/src/server/server.ts index 722193829f9..7f545ff3875 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -253,7 +253,7 @@ namespace ts.server { private requestMap = createMap(); // Maps operation ID to newest requestQueue entry with that ID /** We will lazily request the types registry on the first call to `isKnownTypesPackageName` and store it in `typesRegistryCache`. */ private requestedRegistry: boolean; - private typesRegistryCache: Map | undefined; + private typesRegistryCache: Map> | undefined; // This number is essentially arbitrary. Processing more than one typings request // at a time makes sense, but having too many in the pipe results in a hang diff --git a/src/server/session.ts b/src/server/session.ts index 0704bde9e36..356ea0d254e 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -1769,7 +1769,7 @@ namespace ts.server { return this.requiredResponse(response); }, [CommandNames.OpenExternalProject]: (request: protocol.OpenExternalProjectRequest) => { - this.projectService.openExternalProject(request.arguments, /*suppressRefreshOfInferredProjects*/ false); + this.projectService.openExternalProject(request.arguments); // TODO: GH#20447 report errors return this.requiredResponse(/*response*/ true); }, diff --git a/src/server/types.ts b/src/server/types.ts index 93ffeeccff1..617a3be419a 100644 --- a/src/server/types.ts +++ b/src/server/types.ts @@ -22,10 +22,6 @@ declare namespace ts.server { require?(initialPath: string, moduleName: string): RequireResult; } - export interface SortedArray extends Array { - " __sortedArrayBrand": any; - } - export interface SortedReadonlyArray extends ReadonlyArray { " __sortedArrayBrand": any; } @@ -79,7 +75,7 @@ declare namespace ts.server { /* @internal */ export interface TypesRegistryResponse extends TypingInstallerResponse { readonly kind: EventTypesRegistry; - readonly typesRegistry: MapLike; + readonly typesRegistry: MapLike>; } export interface PackageInstalledResponse extends ProjectResponse { diff --git a/src/server/typingsInstaller/nodeTypingsInstaller.ts b/src/server/typingsInstaller/nodeTypingsInstaller.ts index 36f5adab400..e51ec68561c 100644 --- a/src/server/typingsInstaller/nodeTypingsInstaller.ts +++ b/src/server/typingsInstaller/nodeTypingsInstaller.ts @@ -41,15 +41,15 @@ namespace ts.server.typingsInstaller { } interface TypesRegistryFile { - entries: MapLike; + entries: MapLike>; } - function loadTypesRegistryFile(typesRegistryFilePath: string, host: InstallTypingHost, log: Log): Map { + function loadTypesRegistryFile(typesRegistryFilePath: string, host: InstallTypingHost, log: Log): Map> { if (!host.fileExists(typesRegistryFilePath)) { if (log.isEnabled()) { log.writeLine(`Types registry file '${typesRegistryFilePath}' does not exist`); } - return createMap(); + return createMap>(); } try { const content = JSON.parse(host.readFile(typesRegistryFilePath)); @@ -59,7 +59,7 @@ namespace ts.server.typingsInstaller { if (log.isEnabled()) { log.writeLine(`Error when loading types registry file '${typesRegistryFilePath}': ${(e).message}, ${(e).stack}`); } - return createMap(); + return createMap>(); } } @@ -77,7 +77,7 @@ namespace ts.server.typingsInstaller { export class NodeTypingsInstaller extends TypingsInstaller { private readonly nodeExecSync: ExecSync; private readonly npmPath: string; - readonly typesRegistry: Map; + readonly typesRegistry: Map>; private delayedInitializationError: InitializationFailedResponse | undefined; @@ -141,7 +141,7 @@ namespace ts.server.typingsInstaller { this.closeProject(req); break; case "typesRegistry": { - const typesRegistry: { [key: string]: void } = {}; + const typesRegistry: { [key: string]: MapLike } = {}; this.typesRegistry.forEach((value, key) => { typesRegistry[key] = value; }); diff --git a/src/server/typingsInstaller/typingsInstaller.ts b/src/server/typingsInstaller/typingsInstaller.ts index 283770d1dc8..465f281006e 100644 --- a/src/server/typingsInstaller/typingsInstaller.ts +++ b/src/server/typingsInstaller/typingsInstaller.ts @@ -1,6 +1,7 @@ /// /// /// +/// /// /// @@ -9,6 +10,10 @@ namespace ts.server.typingsInstaller { devDependencies: MapLike; } + interface NpmLock { + dependencies: { [packageName: string]: { version: string } }; + } + export interface Log { isEnabled(): boolean; writeLine(text: string): void; @@ -42,7 +47,7 @@ namespace ts.server.typingsInstaller { } export abstract class TypingsInstaller { - private readonly packageNameToTypingLocation: Map = createMap(); + private readonly packageNameToTypingLocation: Map = createMap(); private readonly missingTypingsSet: Map = createMap(); private readonly knownCachesSet: Map = createMap(); private readonly projectWatchers: Map = createMap(); @@ -52,7 +57,7 @@ namespace ts.server.typingsInstaller { private installRunCount = 1; private inFlightRequestCount = 0; - abstract readonly typesRegistry: Map; + abstract readonly typesRegistry: Map>; constructor( protected readonly installTypingHost: InstallTypingHost, @@ -117,7 +122,8 @@ namespace ts.server.typingsInstaller { this.safeList, this.packageNameToTypingLocation, req.typeAcquisition, - req.unresolvedImports); + req.unresolvedImports, + this.typesRegistry); if (this.log.isEnabled()) { this.log.writeLine(`Finished typings discovery: ${JSON.stringify(discoverTypingsResult)}`); @@ -156,23 +162,30 @@ namespace ts.server.typingsInstaller { if (this.log.isEnabled()) { this.log.writeLine(`Processing cache location '${cacheLocation}'`); } - if (this.knownCachesSet.get(cacheLocation)) { + if (this.knownCachesSet.has(cacheLocation)) { if (this.log.isEnabled()) { this.log.writeLine(`Cache location was already processed...`); } return; } const packageJson = combinePaths(cacheLocation, "package.json"); + const packageLockJson = combinePaths(cacheLocation, "package-lock.json"); if (this.log.isEnabled()) { this.log.writeLine(`Trying to find '${packageJson}'...`); } - if (this.installTypingHost.fileExists(packageJson)) { + if (this.installTypingHost.fileExists(packageJson) && this.installTypingHost.fileExists(packageLockJson)) { const npmConfig = JSON.parse(this.installTypingHost.readFile(packageJson)); + const npmLock = JSON.parse(this.installTypingHost.readFile(packageLockJson)); if (this.log.isEnabled()) { this.log.writeLine(`Loaded content of '${packageJson}': ${JSON.stringify(npmConfig)}`); + this.log.writeLine(`Loaded content of '${packageLockJson}'`); } - if (npmConfig.devDependencies) { + if (npmConfig.devDependencies && npmLock.dependencies) { for (const key in npmConfig.devDependencies) { + if (!hasProperty(npmLock.dependencies, key)) { + // if package in package.json but not package-lock.json, skip adding to cache so it is reinstalled on next use + continue; + } // key is @types/ const packageName = getBaseFileName(key); if (!packageName) { @@ -184,10 +197,11 @@ namespace ts.server.typingsInstaller { continue; } const existingTypingFile = this.packageNameToTypingLocation.get(packageName); - if (existingTypingFile === typingFile) { - continue; - } if (existingTypingFile) { + if (existingTypingFile.typingLocation === typingFile) { + continue; + } + if (this.log.isEnabled()) { this.log.writeLine(`New typing for package ${packageName} from '${typingFile}' conflicts with existing typing file '${existingTypingFile}'`); } @@ -195,7 +209,11 @@ namespace ts.server.typingsInstaller { if (this.log.isEnabled()) { this.log.writeLine(`Adding entry into typings cache: '${packageName}' => '${typingFile}'`); } - this.packageNameToTypingLocation.set(packageName, typingFile); + const info = getProperty(npmLock.dependencies, key); + const version = info && info.version; + const semver = Semver.parse(version); + const newTyping: JsTyping.CachedTyping = { typingLocation: typingFile, version: semver }; + this.packageNameToTypingLocation.set(packageName, newTyping); } } } @@ -211,10 +229,6 @@ namespace ts.server.typingsInstaller { if (this.log.isEnabled()) this.log.writeLine(`'${typing}' is in missingTypingsSet - skipping...`); return false; } - if (this.packageNameToTypingLocation.get(typing)) { - if (this.log.isEnabled()) this.log.writeLine(`'${typing}' already has a typing - skipping...`); - return false; - } const validationResult = JsTyping.validatePackageName(typing); if (validationResult !== JsTyping.PackageNameValidationResult.Ok) { // add typing name to missing set so we won't process it again @@ -226,6 +240,10 @@ namespace ts.server.typingsInstaller { if (this.log.isEnabled()) this.log.writeLine(`Entry for package '${typing}' does not exist in local types registry - skipping...`); return false; } + if (this.packageNameToTypingLocation.get(typing) && JsTyping.isTypingUpToDate(this.packageNameToTypingLocation.get(typing), this.typesRegistry.get(typing))) { + if (this.log.isEnabled()) this.log.writeLine(`'${typing}' already has an up-to-date typing - skipping...`); + return false; + } return true; }); } @@ -294,9 +312,12 @@ namespace ts.server.typingsInstaller { this.missingTypingsSet.set(packageName, true); continue; } - if (!this.packageNameToTypingLocation.has(packageName)) { - this.packageNameToTypingLocation.set(packageName, typingFile); - } + + // packageName is guaranteed to exist in typesRegistry by filterTypings + const distTags = this.typesRegistry.get(packageName); + const newVersion = Semver.parse(distTags[`ts${ts.versionMajorMinor}`] || distTags[latestDistTag]); + const newTyping: JsTyping.CachedTyping = { typingLocation: typingFile, version: newVersion }; + this.packageNameToTypingLocation.set(packageName, newTyping); installedTypingFiles.push(typingFile); } if (this.log.isEnabled()) { @@ -390,4 +411,6 @@ namespace ts.server.typingsInstaller { export function typingsName(packageName: string): string { return `@types/${packageName}@ts${versionMajorMinor}`; } + + const latestDistTag = "latest"; } \ No newline at end of file diff --git a/src/server/utilities.ts b/src/server/utilities.ts index c44419f8cf3..a086d95f910 100644 --- a/src/server/utilities.ts +++ b/src/server/utilities.ts @@ -232,18 +232,6 @@ namespace ts.server { return base === "tsconfig.json" || base === "jsconfig.json" ? base : undefined; } - export function insertSorted(array: SortedArray, insert: T, compare: Comparer): void { - if (array.length === 0) { - array.push(insert); - return; - } - - const insertIndex = binarySearch(array, insert, identity, compare); - if (insertIndex < 0) { - array.splice(~insertIndex, 0, insert); - } - } - export function removeSorted(array: SortedArray, remove: T, compare: Comparer): void { if (!array || array.length === 0) { return; diff --git a/src/services/codefixes/fixAddMissingMember.ts b/src/services/codefixes/fixAddMissingMember.ts index f7f5aa0a22f..7dbbc39843f 100644 --- a/src/services/codefixes/fixAddMissingMember.ts +++ b/src/services/codefixes/fixAddMissingMember.ts @@ -86,7 +86,7 @@ namespace ts.codefix { else { const leftExpressionType = checker.getTypeAtLocation(parent.expression); const { symbol } = leftExpressionType; - if (!(leftExpressionType.flags & TypeFlags.Object && symbol.flags & SymbolFlags.Class)) { + if (!(symbol && leftExpressionType.flags & TypeFlags.Object && symbol.flags & SymbolFlags.Class)) { return undefined; } const classDeclaration = cast(first(symbol.declarations), isClassLike); diff --git a/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts b/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts index 1595bbf3c13..8d47e74d8a4 100644 --- a/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts +++ b/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts @@ -34,7 +34,7 @@ namespace ts.codefix { function getNodes(sourceFile: SourceFile, pos: number): { readonly constructor: ConstructorDeclaration, readonly superCall: ExpressionStatement } { const token = getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); - Debug.assert(token.kind === SyntaxKind.ThisKeyword); + if (token.kind !== SyntaxKind.ThisKeyword) return undefined; const constructor = getContainingFunction(token) as ConstructorDeclaration; const superCall = findSuperCall(constructor.body); // figure out if the `this` access is actually inside the supercall diff --git a/src/services/codefixes/fixExtendsInterfaceBecomesImplements.ts b/src/services/codefixes/fixExtendsInterfaceBecomesImplements.ts index d98ca556f47..551662210c1 100644 --- a/src/services/codefixes/fixExtendsInterfaceBecomesImplements.ts +++ b/src/services/codefixes/fixExtendsInterfaceBecomesImplements.ts @@ -27,7 +27,7 @@ namespace ts.codefix { } function doChanges(changes: textChanges.ChangeTracker, sourceFile: SourceFile, extendsToken: Node, heritageClauses: ReadonlyArray): void { - changes.replaceRange(sourceFile, { pos: extendsToken.getStart(), end: extendsToken.end }, createToken(SyntaxKind.ImplementsKeyword)); + changes.replaceNode(sourceFile, extendsToken, createToken(SyntaxKind.ImplementsKeyword), textChanges.useNonAdjustedPositions); // If there is already an implements clause, replace the implements keyword with a comma. if (heritageClauses.length === 2 && diff --git a/src/services/codefixes/fixForgottenThisPropertyAccess.ts b/src/services/codefixes/fixForgottenThisPropertyAccess.ts index 837487f1b8c..e71c06399c2 100644 --- a/src/services/codefixes/fixForgottenThisPropertyAccess.ts +++ b/src/services/codefixes/fixForgottenThisPropertyAccess.ts @@ -7,6 +7,9 @@ namespace ts.codefix { getCodeActions(context) { const { sourceFile } = context; const token = getNode(sourceFile, context.span.start); + if (!token) { + return undefined; + } const changes = textChanges.ChangeTracker.with(context, t => doChange(t, sourceFile, token)); return [{ description: getLocaleSpecificMessage(Diagnostics.Add_this_to_unresolved_variable), changes, fixId }]; }, @@ -16,13 +19,17 @@ namespace ts.codefix { }), }); - function getNode(sourceFile: SourceFile, pos: number): Identifier { - return cast(getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false), isIdentifier); + function getNode(sourceFile: SourceFile, pos: number): Identifier | undefined { + const node = getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + return isIdentifier(node) ? node : undefined; } - function doChange(changes: textChanges.ChangeTracker, sourceFile: SourceFile, token: Identifier): void { + function doChange(changes: textChanges.ChangeTracker, sourceFile: SourceFile, token: Identifier | undefined): void { + if (!token) { + return; + } // TODO (https://github.com/Microsoft/TypeScript/issues/21246): use shared helper suppressLeadingAndTrailingTrivia(token); - changes.replaceRange(sourceFile, { pos: token.getStart(), end: token.end }, createPropertyAccess(createThis(), token)); + changes.replaceNode(sourceFile, token, createPropertyAccess(createThis(), token), textChanges.useNonAdjustedPositions); } -} \ No newline at end of file +} diff --git a/src/services/codefixes/fixUnusedIdentifier.ts b/src/services/codefixes/fixUnusedIdentifier.ts index 59d19a1bd9b..cb94c2112af 100644 --- a/src/services/codefixes/fixUnusedIdentifier.ts +++ b/src/services/codefixes/fixUnusedIdentifier.ts @@ -140,7 +140,7 @@ namespace ts.codefix { // and trailing trivia will remain. suppressLeadingAndTrailingTrivia(newFunction); - changes.replaceRange(sourceFile, { pos: oldFunction.getStart(), end: oldFunction.end }, newFunction); + changes.replaceNode(sourceFile, oldFunction, newFunction, textChanges.useNonAdjustedPositions); } else { changes.deleteNodeInList(sourceFile, parent); diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index 11ec6c44371..9f9bc959bf0 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -24,7 +24,7 @@ namespace ts.codefix { } interface ImportCodeFixContext extends SymbolContext { - symbolToken: Identifier | undefined; + symbolToken: Node; program: Program; checker: TypeChecker; compilerOptions: CompilerOptions; @@ -38,12 +38,11 @@ namespace ts.codefix { return { description, changes, fixId: undefined }; } - function convertToImportCodeFixContext(context: CodeFixContext): ImportCodeFixContext { + function convertToImportCodeFixContext(context: CodeFixContext, symbolToken: Node, symbolName: string): ImportCodeFixContext { const useCaseSensitiveFileNames = context.host.useCaseSensitiveFileNames ? context.host.useCaseSensitiveFileNames() : false; const { program } = context; const checker = program.getTypeChecker(); - // This will always be an Identifier, since the diagnostics we fix only fail on identifiers. - const symbolToken = cast(getTokenAtPosition(context.sourceFile, context.span.start, /*includeJsDocComment*/ false), isIdentifier); + return { host: context.host, formatContext: context.formatContext, @@ -53,8 +52,8 @@ namespace ts.codefix { compilerOptions: program.getCompilerOptions(), cachedImportDeclarations: [], getCanonicalFileName: createGetCanonicalFileName(useCaseSensitiveFileNames), - symbolName: symbolToken.getText(), - symbolToken, + symbolName, + symbolToken }; } @@ -95,7 +94,7 @@ namespace ts.codefix { allSourceFiles: ReadonlyArray, formatContext: ts.formatting.FormatContext, getCanonicalFileName: GetCanonicalFileName, - symbolToken: Identifier | undefined, + symbolToken: Node | undefined, ): { readonly moduleSpecifier: string, readonly codeAction: CodeAction } { const exportInfos = getAllReExportingModules(exportedSymbol, checker, allSourceFiles); Debug.assert(exportInfos.some(info => info.moduleSymbol === moduleSymbol)); @@ -132,12 +131,12 @@ namespace ts.codefix { // 1. change "member3" to "ns.member3" // 2. add "member3" to the second import statement's import list // and it is up to the user to decide which one fits best. - const useExistingImportActions = !context.symbolToken ? emptyArray : mapDefined(existingImports, ({ declaration }) => { + const useExistingImportActions = !context.symbolToken || !isIdentifier(context.symbolToken) ? emptyArray : mapDefined(existingImports, ({ declaration }) => { const namespace = getNamespaceImportName(declaration); if (namespace) { const moduleSymbol = context.checker.getAliasedSymbol(context.checker.getSymbolAtLocation(namespace)); if (moduleSymbol && moduleSymbol.exports.has(escapeLeadingUnderscores(context.symbolName))) { - return getCodeActionForUseExistingNamespaceImport(namespace.text, context, context.symbolToken); + return getCodeActionForUseExistingNamespaceImport(namespace.text, context, context.symbolToken as Identifier); } } }); @@ -638,37 +637,48 @@ namespace ts.codefix { * become "ns.foo" */ const changes = ChangeTracker.with(context, tracker => - tracker.changeIdentifierToPropertyAccess(sourceFile, namespacePrefix, symbolToken)); + tracker.replaceNode(sourceFile, symbolToken, createPropertyAccess(createIdentifier(namespacePrefix), symbolToken))); return createCodeAction(Diagnostics.Change_0_to_1, [symbolName, `${namespacePrefix}.${symbolName}`], changes); } function getImportCodeActions(context: CodeFixContext): CodeAction[] { - const importFixContext = convertToImportCodeFixContext(context); return context.errorCode === Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code - ? getActionsForUMDImport(importFixContext) - : getActionsForNonUMDImport(importFixContext, context.program.getSourceFiles(), context.cancellationToken); + ? getActionsForUMDImport(context) + : getActionsForNonUMDImport(context); } - function getActionsForUMDImport(context: ImportCodeFixContext): CodeAction[] { - const { checker, symbolToken, compilerOptions } = context; - const umdSymbol = checker.getSymbolAtLocation(symbolToken); - let symbol: ts.Symbol; - let symbolName: string; - if (umdSymbol.flags & ts.SymbolFlags.Alias) { - symbol = checker.getAliasedSymbol(umdSymbol); - symbolName = context.symbolName; + function getActionsForUMDImport(context: CodeFixContext): CodeAction[] { + const token = getTokenAtPosition(context.sourceFile, context.span.start, /*includeJsDocComment*/ false); + const checker = context.program.getTypeChecker(); + + let umdSymbol: Symbol | undefined; + + if (isIdentifier(token)) { + // try the identifier to see if it is the umd symbol + umdSymbol = checker.getSymbolAtLocation(token); } - else if (isJsxOpeningLikeElement(symbolToken.parent) && symbolToken.parent.tagName === symbolToken) { + + if (!isUMDExportSymbol(umdSymbol)) { // The error wasn't for the symbolAtLocation, it was for the JSX tag itself, which needs access to e.g. `React`. - symbol = checker.getAliasedSymbol(checker.resolveName(checker.getJsxNamespace(), symbolToken.parent.tagName, SymbolFlags.Value, /*excludeGlobals*/ false)); - symbolName = symbol.name; - } - else { - throw Debug.fail("Either the symbol or the JSX namespace should be a UMD global if we got here"); + const parent = token.parent; + const isNodeOpeningLikeElement = isJsxOpeningLikeElement(parent); + if ((isJsxOpeningLikeElement && (parent).tagName === token) || parent.kind === SyntaxKind.JsxOpeningFragment) { + umdSymbol = checker.resolveName(checker.getJsxNamespace(), + isNodeOpeningLikeElement ? (parent).tagName : parent, SymbolFlags.Value, /*excludeGlobals*/ false); + } } - return getCodeActionsForImport([{ moduleSymbol: symbol, importKind: getUmdImportKind(compilerOptions) }], { ...context, symbolName }); + if (isUMDExportSymbol(umdSymbol)) { + const symbol = checker.getAliasedSymbol(umdSymbol); + if (symbol) { + return getCodeActionsForImport([{ moduleSymbol: symbol, importKind: getUmdImportKind(context.program.getCompilerOptions()) }], + convertToImportCodeFixContext(context, token, umdSymbol.name)); + } + } + + return undefined; } + function getUmdImportKind(compilerOptions: CompilerOptions) { // Import a synthetic `default` if enabled. if (getAllowSyntheticDefaultImports(compilerOptions)) { @@ -693,8 +703,19 @@ namespace ts.codefix { } } - function getActionsForNonUMDImport(context: ImportCodeFixContext, allSourceFiles: ReadonlyArray, cancellationToken: CancellationToken): CodeAction[] { - const { sourceFile, checker, symbolName, symbolToken } = context; + function getActionsForNonUMDImport(context: CodeFixContext): CodeAction[] { + // This will always be an Identifier, since the diagnostics we fix only fail on identifiers. + const { sourceFile, span, program, cancellationToken } = context; + const checker = program.getTypeChecker(); + const symbolToken = getTokenAtPosition(sourceFile, span.start, /*includeJsDocComment*/ false); + const isJsxNamespace = isJsxOpeningLikeElement(symbolToken.parent) && symbolToken.parent.tagName === symbolToken; + if (!isJsxNamespace && !isIdentifier(symbolToken)) { + return undefined; + } + const symbolName = isJsxNamespace ? checker.getJsxNamespace() : (symbolToken).text; + const allSourceFiles = program.getSourceFiles(); + const compilerOptions = program.getCompilerOptions(); + // "default" is a keyword and not a legal identifier for the import, so we don't expect it here Debug.assert(symbolName !== "default"); const currentTokenMeaning = getMeaningFromLocation(symbolToken); @@ -715,7 +736,7 @@ namespace ts.codefix { if (( localSymbol && localSymbol.escapedName === symbolName || getEscapedNameForExportDefault(defaultExport) === symbolName || - moduleSymbolToValidIdentifier(moduleSymbol, context.compilerOptions.target) === symbolName + moduleSymbolToValidIdentifier(moduleSymbol, compilerOptions.target) === symbolName ) && checkSymbolHasMeaning(localSymbol || defaultExport, currentTokenMeaning)) { addSymbol(moduleSymbol, localSymbol || defaultExport, ImportKind.Default); } @@ -744,7 +765,7 @@ namespace ts.codefix { } }); - return arrayFrom(flatMapIterator(originalSymbolToExportInfos.values(), exportInfos => getCodeActionsForImport(exportInfos, context))); + return arrayFrom(flatMapIterator(originalSymbolToExportInfos.values(), exportInfos => getCodeActionsForImport(exportInfos, convertToImportCodeFixContext(context, symbolToken, symbolName)))); } function checkSymbolHasMeaning({ declarations }: Symbol, meaning: SemanticMeaning): boolean { diff --git a/src/services/codefixes/inferFromUsage.ts b/src/services/codefixes/inferFromUsage.ts index 2f3dae01acf..902764a1729 100644 --- a/src/services/codefixes/inferFromUsage.ts +++ b/src/services/codefixes/inferFromUsage.ts @@ -74,11 +74,11 @@ namespace ts.codefix { // Variable and Property declarations case Diagnostics.Member_0_implicitly_has_an_1_type.code: case Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code: - return getCodeActionForVariableDeclaration(token.parent, sourceFile, program, cancellationToken); + return getCodeActionForVariableDeclaration(token.parent, program, cancellationToken); case Diagnostics.Variable_0_implicitly_has_an_1_type.code: { const symbol = program.getTypeChecker().getSymbolAtLocation(token); - return symbol && symbol.valueDeclaration && getCodeActionForVariableDeclaration(symbol.valueDeclaration, sourceFile, program, cancellationToken); + return symbol && symbol.valueDeclaration && getCodeActionForVariableDeclaration(symbol.valueDeclaration, program, cancellationToken); } } @@ -86,17 +86,17 @@ namespace ts.codefix { if (containingFunction === undefined) { return undefined; } - switch (errorCode) { + switch (errorCode) { // Parameter declarations case Diagnostics.Parameter_0_implicitly_has_an_1_type.code: if (isSetAccessor(containingFunction)) { - return getCodeActionForSetAccessor(containingFunction, sourceFile, program, cancellationToken); + return getCodeActionForSetAccessor(containingFunction, program, cancellationToken); } // falls through case Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code: return !seenFunctions || addToSeen(seenFunctions, getNodeId(containingFunction)) - ? getCodeActionForParameters(token.parent, containingFunction, sourceFile, program, cancellationToken) + ? getCodeActionForParameters(cast(token.parent, isParameter), containingFunction, sourceFile, program, cancellationToken) : undefined; // Get Accessor declarations @@ -106,7 +106,7 @@ namespace ts.codefix { // Set Accessor declarations case Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation.code: - return isSetAccessor(containingFunction) ? getCodeActionForSetAccessor(containingFunction, sourceFile, program, cancellationToken) : undefined; + return isSetAccessor(containingFunction) ? getCodeActionForSetAccessor(containingFunction, program, cancellationToken) : undefined; default: throw Debug.fail(String(errorCode)); @@ -127,9 +127,9 @@ namespace ts.codefix { } } - function getCodeActionForVariableDeclaration(declaration: VariableDeclaration | PropertyDeclaration | PropertySignature, sourceFile: SourceFile, program: Program, cancellationToken: CancellationToken): Fix | undefined { + function getCodeActionForVariableDeclaration(declaration: VariableDeclaration | PropertyDeclaration | PropertySignature, program: Program, cancellationToken: CancellationToken): Fix | undefined { if (!isIdentifier(declaration.name)) return undefined; - const type = inferTypeForVariableFromUsage(declaration.name, sourceFile, program, cancellationToken); + const type = inferTypeForVariableFromUsage(declaration.name, program, cancellationToken); return makeFix(declaration, declaration.name.getEnd(), type, program); } @@ -151,7 +151,7 @@ namespace ts.codefix { } const types = inferTypeForParametersFromUsage(containingFunction, sourceFile, program, cancellationToken) || - containingFunction.parameters.map(p => isIdentifier(p.name) ? inferTypeForVariableFromUsage(p.name, sourceFile, program, cancellationToken) : undefined); + containingFunction.parameters.map(p => isIdentifier(p.name) ? inferTypeForVariableFromUsage(p.name, program, cancellationToken) : undefined); if (!types) return undefined; // We didn't actually find a set of type inference positions matching each parameter position @@ -164,14 +164,14 @@ namespace ts.codefix { return textChanges.length ? { declaration: parameterDeclaration, textChanges } : undefined; } - function getCodeActionForSetAccessor(setAccessorDeclaration: SetAccessorDeclaration, sourceFile: SourceFile, program: Program, cancellationToken: CancellationToken): Fix | undefined { + function getCodeActionForSetAccessor(setAccessorDeclaration: SetAccessorDeclaration, program: Program, cancellationToken: CancellationToken): Fix | undefined { const setAccessorParameter = setAccessorDeclaration.parameters[0]; if (!setAccessorParameter || !isIdentifier(setAccessorDeclaration.name) || !isIdentifier(setAccessorParameter.name)) { return undefined; } - const type = inferTypeForVariableFromUsage(setAccessorDeclaration.name, sourceFile, program, cancellationToken) || - inferTypeForVariableFromUsage(setAccessorParameter.name, sourceFile, program, cancellationToken); + const type = inferTypeForVariableFromUsage(setAccessorDeclaration.name, program, cancellationToken) || + inferTypeForVariableFromUsage(setAccessorParameter.name, program, cancellationToken); return makeFix(setAccessorParameter, setAccessorParameter.name.getEnd(), type, program); } @@ -180,7 +180,7 @@ namespace ts.codefix { return undefined; } - const type = inferTypeForVariableFromUsage(getAccessorDeclaration.name, sourceFile, program, cancellationToken); + const type = inferTypeForVariableFromUsage(getAccessorDeclaration.name, program, cancellationToken); const closeParenToken = findChildOfKind(getAccessorDeclaration, SyntaxKind.CloseParenToken, sourceFile); return makeFix(getAccessorDeclaration, closeParenToken.getEnd(), type, program); } @@ -194,23 +194,14 @@ namespace ts.codefix { return typeString === undefined ? undefined : createTextChangeFromStartLength(start, 0, `: ${typeString}`); } - function getReferences(token: PropertyName | Token, sourceFile: SourceFile, program: Program, cancellationToken: CancellationToken): Identifier[] { - const references = FindAllReferences.findReferencedSymbols( - program, - cancellationToken, - program.getSourceFiles(), - sourceFile, - token.getStart(sourceFile)); - - if (!references || references.length !== 1) { - return []; - } - - return references[0].references.map(r => getTokenAtPosition(program.getSourceFile(r.fileName), r.textSpan.start, /*includeJsDocComment*/ false)); + function getReferences(token: PropertyName | Token, program: Program, cancellationToken: CancellationToken): ReadonlyArray { + // Position shouldn't matter since token is not a SourceFile. + return mapDefined(FindAllReferences.getReferenceEntriesForNode(-1, token, program, program.getSourceFiles(), cancellationToken), entry => + entry.type === "node" ? tryCast(entry.node, isIdentifier) : undefined); } - function inferTypeForVariableFromUsage(token: Identifier, sourceFile: SourceFile, program: Program, cancellationToken: CancellationToken): Type | undefined { - return InferFromReference.inferTypeFromReferences(getReferences(token, sourceFile, program, cancellationToken), program.getTypeChecker(), cancellationToken); + function inferTypeForVariableFromUsage(token: Identifier, program: Program, cancellationToken: CancellationToken): Type | undefined { + return InferFromReference.inferTypeFromReferences(getReferences(token, program, cancellationToken), program.getTypeChecker(), cancellationToken); } function inferTypeForParametersFromUsage(containingFunction: FunctionLikeDeclaration, sourceFile: SourceFile, program: Program, cancellationToken: CancellationToken): (Type | undefined)[] | undefined { @@ -224,7 +215,7 @@ namespace ts.codefix { findChildOfKind>(containingFunction, SyntaxKind.ConstructorKeyword, sourceFile) : containingFunction.name; if (searchToken) { - return InferFromReference.inferTypeForParametersFromReferences(getReferences(searchToken, sourceFile, program, cancellationToken), containingFunction, program.getTypeChecker(), cancellationToken); + return InferFromReference.inferTypeForParametersFromReferences(getReferences(searchToken, program, cancellationToken), containingFunction, program.getTypeChecker(), cancellationToken); } } } @@ -292,7 +283,7 @@ namespace ts.codefix { stringIndexContext?: UsageContext; } - export function inferTypeFromReferences(references: Identifier[], checker: TypeChecker, cancellationToken: CancellationToken): Type | undefined { + export function inferTypeFromReferences(references: ReadonlyArray, checker: TypeChecker, cancellationToken: CancellationToken): Type | undefined { const usageContext: UsageContext = {}; for (const reference of references) { cancellationToken.throwIfCancellationRequested(); @@ -301,43 +292,45 @@ namespace ts.codefix { return getTypeFromUsageContext(usageContext, checker); } - export function inferTypeForParametersFromReferences(references: Identifier[], declaration: FunctionLikeDeclaration, checker: TypeChecker, cancellationToken: CancellationToken): (Type | undefined)[] | undefined { + export function inferTypeForParametersFromReferences(references: ReadonlyArray, declaration: FunctionLikeDeclaration, checker: TypeChecker, cancellationToken: CancellationToken): (Type | undefined)[] | undefined { if (references.length === 0) { return undefined; } - if (declaration.parameters) { - const usageContext: UsageContext = {}; - for (const reference of references) { - cancellationToken.throwIfCancellationRequested(); - inferTypeFromContext(reference, checker, usageContext); - } - const isConstructor = declaration.kind === SyntaxKind.Constructor; - const callContexts = isConstructor ? usageContext.constructContexts : usageContext.callContexts; - if (callContexts) { - const paramTypes: Type[] = []; - for (let parameterIndex = 0; parameterIndex < declaration.parameters.length; parameterIndex++) { - let types: Type[] = []; - const isRestParameter = ts.isRestParameter(declaration.parameters[parameterIndex]); - for (const callContext of callContexts) { - if (callContext.argumentTypes.length > parameterIndex) { - if (isRestParameter) { - types = concatenate(types, map(callContext.argumentTypes.slice(parameterIndex), a => checker.getBaseTypeOfLiteralType(a))); - } - else { - types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[parameterIndex])); - } - } - } - if (types.length) { - const type = checker.getWidenedType(checker.getUnionType(types, UnionReduction.Subtype)); - paramTypes[parameterIndex] = isRestParameter ? checker.createArrayType(type) : type; + if (!declaration.parameters) { + return undefined; + } + + const usageContext: UsageContext = {}; + for (const reference of references) { + cancellationToken.throwIfCancellationRequested(); + inferTypeFromContext(reference, checker, usageContext); + } + const isConstructor = declaration.kind === SyntaxKind.Constructor; + const callContexts = isConstructor ? usageContext.constructContexts : usageContext.callContexts; + return callContexts && declaration.parameters.map((parameter, parameterIndex) => { + const types: Type[] = []; + const isRestParameter = ts.isRestParameter(parameter); + for (const callContext of callContexts) { + if (callContext.argumentTypes.length <= parameterIndex) { + continue; + } + + if (isRestParameter) { + for (let i = parameterIndex; i < callContext.argumentTypes.length; i++) { + types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[i])); } } - return paramTypes; + else { + types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[parameterIndex])); + } } - } - return undefined; + if (!types.length) { + return undefined; + } + const type = checker.getWidenedType(checker.getUnionType(types, UnionReduction.Subtype)); + return isRestParameter ? checker.createArrayType(type) : type; + }); } function inferTypeFromContext(node: Expression, checker: TypeChecker, usageContext: UsageContext): void { diff --git a/src/services/completions.ts b/src/services/completions.ts index f02367b72c8..68ec65a1e19 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -42,7 +42,7 @@ namespace ts.Completions { const contextToken = findPrecedingToken(position, sourceFile); if (isInString(sourceFile, position, contextToken)) { - return !contextToken || !isStringLiteral(contextToken) && !isNoSubstitutionTemplateLiteral(contextToken) + return !contextToken || !isStringLiteralLike(contextToken) ? undefined : convertStringLiteralCompletions(getStringLiteralCompletionEntries(sourceFile, contextToken, position, typeChecker, compilerOptions, host), sourceFile, typeChecker, log); } @@ -358,8 +358,7 @@ namespace ts.Completions { case SyntaxKind.LiteralType: switch (node.parent.parent.kind) { case SyntaxKind.TypeReference: - // TODO: GH#21168 - return undefined; + return { kind: StringLiteralCompletionKind.Types, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(node.parent as LiteralTypeNode), typeChecker) }; case SyntaxKind.IndexedAccessType: // Get all apparent property names // i.e. interface Foo { @@ -612,7 +611,7 @@ namespace ts.Completions { allSourceFiles, formatContext, getCanonicalFileName, - tryCast(previousToken, isIdentifier)); + previousToken); return { sourceDisplay: [textPart(moduleSpecifier)], codeActions: [codeAction] }; } @@ -712,7 +711,7 @@ namespace ts.Completions { function getFirstSymbolInChain(symbol: Symbol, enclosingDeclaration: Node, checker: TypeChecker): Symbol | undefined { const chain = checker.getAccessibleSymbolChain(symbol, enclosingDeclaration, /*meaning*/ SymbolFlags.All, /*useOnlyExternalAliasing*/ false); if (chain) return first(chain); - return isModuleSymbol(symbol.parent) ? symbol : symbol.parent && getFirstSymbolInChain(symbol.parent, enclosingDeclaration, checker); + return symbol.parent && (isModuleSymbol(symbol.parent) ? symbol : getFirstSymbolInChain(symbol.parent, enclosingDeclaration, checker)); } function isModuleSymbol(symbol: Symbol): boolean { @@ -862,6 +861,23 @@ namespace ts.Completions { parent = parent.parent; } + // Fix location + if (currentToken.parent === location) { + switch (currentToken.kind) { + case SyntaxKind.GreaterThanToken: + if (currentToken.parent.kind === SyntaxKind.JsxElement || currentToken.parent.kind === SyntaxKind.JsxOpeningElement) { + location = currentToken; + } + break; + + case SyntaxKind.SlashToken: + if (currentToken.parent.kind === SyntaxKind.JsxSelfClosingElement) { + location = currentToken; + } + break; + } + } + switch (parent.kind) { case SyntaxKind.JsxClosingElement: if (contextToken.kind === SyntaxKind.SlashToken) { @@ -912,7 +928,7 @@ namespace ts.Completions { getTypeScriptMemberSymbols(); } else if (isRightOfOpenTag) { - const tagSymbols = typeChecker.getJsxIntrinsicTagNames(); + const tagSymbols = Debug.assertEachDefined(typeChecker.getJsxIntrinsicTagNames(), "getJsxIntrinsicTagNames() should all be defined"); if (tryGetGlobalSymbols()) { symbols = tagSymbols.concat(symbols.filter(s => !!(s.flags & (SymbolFlags.Value | SymbolFlags.Alias)))); } @@ -924,8 +940,7 @@ namespace ts.Completions { else if (isStartingCloseTag) { const tagName = (contextToken.parent.parent).openingElement.tagName; const tagSymbol = typeChecker.getSymbolAtLocation(tagName); - - if (!typeChecker.isUnknownSymbol(tagSymbol)) { + if (tagSymbol) { symbols = [tagSymbol]; } completionKind = CompletionKind.MemberLike; @@ -971,7 +986,7 @@ namespace ts.Completions { if (symbol.flags & (SymbolFlags.Module | SymbolFlags.Enum)) { // Extract module or enum members - const exportedSymbols = typeChecker.getExportsOfModule(symbol); + const exportedSymbols = Debug.assertEachDefined(typeChecker.getExportsOfModule(symbol), "getExportsOfModule() should all be defined"); const isValidValueAccess = (symbol: Symbol) => typeChecker.isValidPropertyAccess((node.parent), symbol.name); const isValidTypeAccess = (symbol: Symbol) => symbolCanBeReferencedAtTypeLocation(symbol); const isValidAccess = isRhsOfImportDeclaration ? @@ -1043,10 +1058,6 @@ namespace ts.Completions { return true; } - if (tryGetFunctionLikeBodyCompletionContainer(contextToken)) { - keywordFilters = KeywordCompletionFilters.FunctionLikeBodyKeywords; - } - if (classLikeContainer = tryGetClassLikeCompletionContainer(contextToken)) { // cursor inside class declaration getGetClassLikeCompletionSymbols(classLikeContainer); @@ -1068,6 +1079,10 @@ namespace ts.Completions { } } + if (tryGetFunctionLikeBodyCompletionContainer(contextToken)) { + keywordFilters = KeywordCompletionFilters.FunctionLikeBodyKeywords; + } + // Get all entities in the current scope. completionKind = CompletionKind.None; isNewIdentifierLocation = isNewIdentifierDefinitionLocation(contextToken); @@ -1111,7 +1126,7 @@ namespace ts.Completions { const symbolMeanings = SymbolFlags.Type | SymbolFlags.Value | SymbolFlags.Namespace | SymbolFlags.Alias; - symbols = typeChecker.getSymbolsInScope(scopeNode, symbolMeanings); + symbols = Debug.assertEachDefined(typeChecker.getSymbolsInScope(scopeNode, symbolMeanings), "getSymbolsInScope() should all be defined"); // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions` if (options.includeInsertTextCompletions && scopeNode.kind !== SyntaxKind.SourceFile) { @@ -1452,7 +1467,7 @@ namespace ts.Completions { if (typeMembers && typeMembers.length > 0) { // Add filtered items to the completion list - symbols = filterObjectMembersList(typeMembers, existingMembers); + symbols = filterObjectMembersList(typeMembers, Debug.assertDefined(existingMembers)); } return true; } @@ -1926,11 +1941,7 @@ namespace ts.Completions { existingImportsOrExports.set(name.escapedText, true); } - if (existingImportsOrExports.size === 0) { - return filter(exportsOfModule, e => e.escapedName !== InternalSymbolName.Default); - } - - return filter(exportsOfModule, e => e.escapedName !== InternalSymbolName.Default && !existingImportsOrExports.get(e.escapedName)); + return exportsOfModule.filter(e => e.escapedName !== InternalSymbolName.Default && !existingImportsOrExports.get(e.escapedName)); } /** @@ -1940,7 +1951,7 @@ namespace ts.Completions { * do not occur at the current position and have not otherwise been typed. */ function filterObjectMembersList(contextualMemberSymbols: Symbol[], existingMembers: ReadonlyArray): Symbol[] { - if (!existingMembers || existingMembers.length === 0) { + if (existingMembers.length === 0) { return contextualMemberSymbols; } @@ -1980,7 +1991,7 @@ namespace ts.Completions { existingMemberNames.set(existingName, true); } - return filter(contextualMemberSymbols, m => !existingMemberNames.get(m.escapedName)); + return contextualMemberSymbols.filter(m => !existingMemberNames.get(m.escapedName)); } /** @@ -2066,7 +2077,7 @@ namespace ts.Completions { } } - return filter(symbols, a => !seenNames.get(a.escapedName)); + return symbols.filter(a => !seenNames.get(a.escapedName)); } function isCurrentlyEditingNode(node: Node): boolean { @@ -2248,13 +2259,13 @@ namespace ts.Completions { */ function getPropertiesForCompletion(type: Type, checker: TypeChecker, isForAccess: boolean): Symbol[] { if (!(type.flags & TypeFlags.Union)) { - return type.getApparentProperties(); + return Debug.assertEachDefined(type.getApparentProperties(), "getApparentProperties() should all be defined"); } const { types } = type as UnionType; // If we're providing completions for an object literal, skip primitive, array-like, or callable types since those shouldn't be implemented by object literals. const filteredTypes = isForAccess ? types : types.filter(memberType => !(memberType.flags & TypeFlags.Primitive || checker.isArrayLikeType(memberType) || typeHasCallOrConstructSignatures(memberType, checker))); - return checker.getAllPossiblePropertiesOfTypes(filteredTypes); + return Debug.assertEachDefined(checker.getAllPossiblePropertiesOfTypes(filteredTypes), "getAllPossiblePropertiesOfTypes() should all be defined"); } } diff --git a/src/services/documentHighlights.ts b/src/services/documentHighlights.ts index 8e2c0d1900f..dd5281f15bc 100644 --- a/src/services/documentHighlights.ts +++ b/src/services/documentHighlights.ts @@ -1,6 +1,6 @@ /* @internal */ namespace ts.DocumentHighlights { - export function getDocumentHighlights(program: Program, cancellationToken: CancellationToken, sourceFile: SourceFile, position: number, sourceFilesToSearch: SourceFile[]): DocumentHighlights[] | undefined { + export function getDocumentHighlights(program: Program, cancellationToken: CancellationToken, sourceFile: SourceFile, position: number, sourceFilesToSearch: ReadonlyArray): DocumentHighlights[] | undefined { const node = getTouchingWord(sourceFile, position, /*includeJsDocComment*/ true); if (node.parent && (isJsxOpeningElement(node.parent) && node.parent.tagName === node || isJsxClosingElement(node.parent))) { @@ -21,12 +21,12 @@ namespace ts.DocumentHighlights { }; } - function getSemanticDocumentHighlights(position: number, node: Node, program: Program, cancellationToken: CancellationToken, sourceFilesToSearch: SourceFile[]): DocumentHighlights[] { + function getSemanticDocumentHighlights(position: number, node: Node, program: Program, cancellationToken: CancellationToken, sourceFilesToSearch: ReadonlyArray): DocumentHighlights[] { const referenceEntries = FindAllReferences.getReferenceEntriesForNode(position, node, program, sourceFilesToSearch, cancellationToken); return referenceEntries && convertReferencedSymbols(referenceEntries); } - function convertReferencedSymbols(referenceEntries: FindAllReferences.Entry[]): DocumentHighlights[] { + function convertReferencedSymbols(referenceEntries: ReadonlyArray): DocumentHighlights[] { const fileNameToDocumentHighlights = createMap(); for (const entry of referenceEntries) { const { fileName, span } = FindAllReferences.toHighlightSpan(entry); @@ -189,11 +189,6 @@ namespace ts.DocumentHighlights { } function getModifierOccurrences(modifier: SyntaxKind, declaration: Node): Node[] { - // Make sure we only highlight the keyword when it makes sense to do so. - if (!isLegalModifier(modifier, declaration)) { - return undefined; - } - const modifierFlag = modifierToFlag(modifier); return mapDefined(getNodesToSearchForModifier(declaration, modifierFlag), node => { if (getModifierFlags(node) & modifierFlag) { @@ -205,7 +200,8 @@ namespace ts.DocumentHighlights { } function getNodesToSearchForModifier(declaration: Node, modifierFlag: ModifierFlags): ReadonlyArray { - const container = declaration.parent; + // Types of node whose children might have modifiers. + const container = declaration.parent as ModuleBlock | SourceFile | Block | CaseClause | DefaultClause | ConstructorDeclaration | MethodDeclaration | FunctionDeclaration | ClassLikeDeclaration; switch (container.kind) { case SyntaxKind.ModuleBlock: case SyntaxKind.SourceFile: @@ -213,22 +209,25 @@ namespace ts.DocumentHighlights { case SyntaxKind.CaseClause: case SyntaxKind.DefaultClause: // Container is either a class declaration or the declaration is a classDeclaration - if (modifierFlag & ModifierFlags.Abstract) { - return [...(declaration).members, declaration]; + if (modifierFlag & ModifierFlags.Abstract && isClassDeclaration(declaration)) { + return [...declaration.members, declaration]; } else { - return (container).statements; + return container.statements; } case SyntaxKind.Constructor: - return [...(container).parameters, ...(container.parent).members]; + case SyntaxKind.MethodDeclaration: + case SyntaxKind.FunctionDeclaration: { + return [...container.parameters, ...(isClassLike(container.parent) ? container.parent.members : [])]; + } case SyntaxKind.ClassDeclaration: case SyntaxKind.ClassExpression: - const nodes = (container).members; + const nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search // the constructor's parameter list for instance members as well. if (modifierFlag & ModifierFlags.AccessibilityModifier) { - const constructor = find((container).members, isConstructorDeclaration); + const constructor = find(container.members, isConstructorDeclaration); if (constructor) { return [...nodes, ...constructor.parameters]; } @@ -238,34 +237,7 @@ namespace ts.DocumentHighlights { } return nodes; default: - Debug.fail("Invalid container kind."); - } - } - - function isLegalModifier(modifier: SyntaxKind, declaration: Node): boolean { - const container = declaration.parent; - switch (modifier) { - case SyntaxKind.PrivateKeyword: - case SyntaxKind.ProtectedKeyword: - case SyntaxKind.PublicKeyword: - switch (container.kind) { - case SyntaxKind.ClassDeclaration: - case SyntaxKind.ClassExpression: - return true; - case SyntaxKind.Constructor: - return declaration.kind === SyntaxKind.Parameter; - default: - return false; - } - case SyntaxKind.StaticKeyword: - return container.kind === SyntaxKind.ClassDeclaration || container.kind === SyntaxKind.ClassExpression; - case SyntaxKind.ExportKeyword: - case SyntaxKind.DeclareKeyword: - return container.kind === SyntaxKind.ModuleBlock || container.kind === SyntaxKind.SourceFile; - case SyntaxKind.AbstractKeyword: - return container.kind === SyntaxKind.ClassDeclaration || declaration.kind === SyntaxKind.ClassDeclaration; - default: - return false; + Debug.assertNever(container, "Invalid container kind."); } } diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index 07cd2c683a9..b1e6909f093 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -272,7 +272,7 @@ namespace ts.FindAllReferences.Core { } function isModuleReferenceLocation(node: ts.Node): boolean { - if (node.kind !== SyntaxKind.StringLiteral && node.kind !== SyntaxKind.NoSubstitutionTemplateLiteral) { + if (!isStringLiteralLike(node)) { return false; } switch (node.parent.kind) { @@ -416,10 +416,16 @@ namespace ts.FindAllReferences.Core { } // If the symbol is declared as part of a declaration like `{ type: "a" } | { type: "b" }`, use the property on the union type to get more references. - return firstDefined(symbol.declarations, decl => - isTypeLiteralNode(decl.parent) && isUnionTypeNode(decl.parent.parent) + return firstDefined(symbol.declarations, decl => { + if (!decl.parent) { + // Assertions for GH#21814. We should be handling SourceFile symbols in `getReferencedSymbolsForModule` instead of getting here. + Debug.assert(decl.kind === SyntaxKind.SourceFile); + Debug.fail(`Unexpected symbol at ${Debug.showSyntaxKind(node)}: ${Debug.showSymbol(symbol)}`); + } + return isTypeLiteralNode(decl.parent) && isUnionTypeNode(decl.parent.parent) ? checker.getPropertyOfType(checker.getTypeFromTypeNode(decl.parent.parent), symbol.name) - : undefined) || symbol; + : undefined; + }) || symbol; } /** @@ -703,7 +709,7 @@ namespace ts.FindAllReferences.Core { return exposedByParent ? scope.getSourceFile() : scope; } - function getPossibleSymbolReferencePositions(sourceFile: SourceFile, symbolName: string, container: Node = sourceFile): number[] { + function getPossibleSymbolReferencePositions(sourceFile: SourceFile, symbolName: string, container: Node = sourceFile): ReadonlyArray { const positions: number[] = []; /// TODO: Cache symbol existence for files to save text search @@ -914,7 +920,8 @@ namespace ts.FindAllReferences.Core { // At `export { x } from "foo"`, also search for the imported symbol `"foo".x`. if (search.comingFrom !== ImportExport.Export && exportDeclaration.moduleSpecifier && !propertyName) { - searchForImportedSymbol(state.checker.getExportSpecifierLocalTargetSymbol(exportSpecifier), state); + const imported = state.checker.getExportSpecifierLocalTargetSymbol(exportSpecifier); + if (imported) searchForImportedSymbol(imported, state); } function addRef() { @@ -923,7 +930,7 @@ namespace ts.FindAllReferences.Core { } function getLocalSymbolForExportSpecifier(referenceLocation: Identifier, referenceSymbol: Symbol, exportSpecifier: ExportSpecifier, checker: TypeChecker): Symbol { - return isExportSpecifierAlias(referenceLocation, exportSpecifier) ? checker.getExportSpecifierLocalTargetSymbol(exportSpecifier) : referenceSymbol; + return isExportSpecifierAlias(referenceLocation, exportSpecifier) && checker.getExportSpecifierLocalTargetSymbol(exportSpecifier) || referenceSymbol; } function isExportSpecifierAlias(referenceLocation: Identifier, exportSpecifier: ExportSpecifier): boolean { @@ -1344,63 +1351,63 @@ namespace ts.FindAllReferences.Core { const references: Entry[] = []; - let possiblePositions: number[]; + let possiblePositions: ReadonlyArray; if (searchSpaceNode.kind === SyntaxKind.SourceFile) { forEach(sourceFiles, sourceFile => { cancellationToken.throwIfCancellationRequested(); possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this"); - getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); + getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, staticFlag, references); }); } else { const sourceFile = searchSpaceNode.getSourceFile(); possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", searchSpaceNode); - getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, references); + getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, staticFlag, references); } return [{ definition: { type: "this", node: thisOrSuperKeyword }, references }]; + } - function getThisReferencesInFile(sourceFile: SourceFile, searchSpaceNode: Node, possiblePositions: number[], result: Entry[]): void { - forEach(possiblePositions, position => { - const node = getTouchingWord(sourceFile, position, /*includeJsDocComment*/ false); - if (!node || !isThis(node)) { - return; - } + function getThisReferencesInFile(sourceFile: SourceFile, searchSpaceNode: Node, possiblePositions: ReadonlyArray, staticFlag: ModifierFlags, result: Push): void { + forEach(possiblePositions, position => { + const node = getTouchingWord(sourceFile, position, /*includeJsDocComment*/ false); + if (!node || !isThis(node)) { + return; + } - const container = getThisContainer(node, /* includeArrowFunctions */ false); + const container = getThisContainer(node, /* includeArrowFunctions */ false); - switch (searchSpaceNode.kind) { - case SyntaxKind.FunctionExpression: - case SyntaxKind.FunctionDeclaration: - if (searchSpaceNode.symbol === container.symbol) { - result.push(nodeEntry(node)); - } - break; - case SyntaxKind.MethodDeclaration: - case SyntaxKind.MethodSignature: - if (isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { - result.push(nodeEntry(node)); - } - break; - case SyntaxKind.ClassExpression: - case SyntaxKind.ClassDeclaration: - // Make sure the container belongs to the same class - // and has the appropriate static modifier from the original container. - if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (getModifierFlags(container) & ModifierFlags.Static) === staticFlag) { - result.push(nodeEntry(node)); - } - break; - case SyntaxKind.SourceFile: - if (container.kind === SyntaxKind.SourceFile && !isExternalModule(container)) { - result.push(nodeEntry(node)); - } - break; - } - }); - } + switch (searchSpaceNode.kind) { + case SyntaxKind.FunctionExpression: + case SyntaxKind.FunctionDeclaration: + if (searchSpaceNode.symbol === container.symbol) { + result.push(nodeEntry(node)); + } + break; + case SyntaxKind.MethodDeclaration: + case SyntaxKind.MethodSignature: + if (isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { + result.push(nodeEntry(node)); + } + break; + case SyntaxKind.ClassExpression: + case SyntaxKind.ClassDeclaration: + // Make sure the container belongs to the same class + // and has the appropriate static modifier from the original container. + if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (getModifierFlags(container) & ModifierFlags.Static) === staticFlag) { + result.push(nodeEntry(node)); + } + break; + case SyntaxKind.SourceFile: + if (container.kind === SyntaxKind.SourceFile && !isExternalModule(container)) { + result.push(nodeEntry(node)); + } + break; + } + }); } function getReferencesForStringLiteral(node: StringLiteral, sourceFiles: ReadonlyArray, cancellationToken: CancellationToken): SymbolAndEntries[] { @@ -1417,7 +1424,7 @@ namespace ts.FindAllReferences.Core { references }]; - function getReferencesForStringLiteralInFile(sourceFile: SourceFile, searchText: string, possiblePositions: number[], references: Push): void { + function getReferencesForStringLiteralInFile(sourceFile: SourceFile, searchText: string, possiblePositions: ReadonlyArray, references: Push): void { for (const position of possiblePositions) { const node = getTouchingWord(sourceFile, position, /*includeJsDocComment*/ false); if (node && node.kind === SyntaxKind.StringLiteral && (node as StringLiteral).text === searchText) { diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index f6a9dee4cfe..815237df228 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -92,6 +92,9 @@ namespace ts.formatting { rule("SpaceBetweenCloseBraceAndWhile", SyntaxKind.CloseBraceToken, SyntaxKind.WhileKeyword, [isNonJsxSameLineTokenContext], RuleAction.Space), rule("NoSpaceBetweenEmptyBraceBrackets", SyntaxKind.OpenBraceToken, SyntaxKind.CloseBraceToken, [isNonJsxSameLineTokenContext, isObjectContext], RuleAction.Delete), + // Add a space after control dec context if the next character is an open bracket ex: 'if (false)[a, b] = [1, 2];' -> 'if (false) [a, b] = [1, 2];' + rule("SpaceAfterConditionalClosingParen", SyntaxKind.CloseParenToken, SyntaxKind.OpenBracketToken, [isControlDeclContext], RuleAction.Space), + rule("NoSpaceBetweenFunctionKeywordAndStar", SyntaxKind.FunctionKeyword, SyntaxKind.AsteriskToken, [isFunctionDeclarationOrFunctionExpressionContext], RuleAction.Delete), rule("SpaceAfterStarInGeneratorDeclaration", SyntaxKind.AsteriskToken, [SyntaxKind.Identifier, SyntaxKind.OpenParenToken], [isFunctionDeclarationOrFunctionExpressionContext], RuleAction.Space), @@ -162,6 +165,7 @@ namespace ts.formatting { SyntaxKind.TypeKeyword, SyntaxKind.FromKeyword, SyntaxKind.KeyOfKeyword, + SyntaxKind.InferKeyword, ], anyToken, [isNonJsxSameLineTokenContext], @@ -409,6 +413,7 @@ namespace ts.formatting { switch (context.contextNode.kind) { case SyntaxKind.BinaryExpression: case SyntaxKind.ConditionalExpression: + case SyntaxKind.ConditionalType: case SyntaxKind.AsExpression: case SyntaxKind.ExportSpecifier: case SyntaxKind.ImportSpecifier: @@ -461,7 +466,8 @@ namespace ts.formatting { } function isConditionalOperatorContext(context: FormattingContext): boolean { - return context.contextNode.kind === SyntaxKind.ConditionalExpression; + return context.contextNode.kind === SyntaxKind.ConditionalExpression || + context.contextNode.kind === SyntaxKind.ConditionalType; } function isSameLineTokenOrBeforeBlockContext(context: FormattingContext): boolean { @@ -469,7 +475,9 @@ namespace ts.formatting { } function isBraceWrappedContext(context: FormattingContext): boolean { - return context.contextNode.kind === SyntaxKind.ObjectBindingPattern || isSingleLineBlockContext(context); + return context.contextNode.kind === SyntaxKind.ObjectBindingPattern || + context.contextNode.kind === SyntaxKind.MappedType || + isSingleLineBlockContext(context); } // This check is done before an open brace in a control construct, a function, or a typescript block declaration diff --git a/src/services/goToDefinition.ts b/src/services/goToDefinition.ts index 1f7e2ea0be9..6be00efd53f 100644 --- a/src/services/goToDefinition.ts +++ b/src/services/goToDefinition.ts @@ -149,10 +149,7 @@ namespace ts.GoToDefinition { // Check if position is on triple slash reference. const comment = findReferenceInPosition(sourceFile.referencedFiles, position) || findReferenceInPosition(sourceFile.typeReferenceDirectives, position); if (comment) { - return { - definitions, - textSpan: createTextSpanFromBounds(comment.pos, comment.end) - }; + return { definitions, textSpan: createTextSpanFromRange(comment) }; } const node = getTouchingPropertyName(sourceFile, position, /*includeJsDocComment*/ true); @@ -191,7 +188,7 @@ namespace ts.GoToDefinition { function getConstructSignatureDefinition(): DefinitionInfo[] | undefined { // Applicable only if we are in a new expression, or we are on a constructor declaration // and in either case the symbol has a construct signature definition, i.e. class - if (isNewExpressionTarget(node) || node.kind === SyntaxKind.ConstructorKeyword && symbol.flags & SymbolFlags.Class) { + if (symbol.flags & SymbolFlags.Class && (isNewExpressionTarget(node) || node.kind === SyntaxKind.ConstructorKeyword)) { const cls = find(symbol.declarations, isClassLike) || Debug.fail("Expected declaration to have at least one class-like declaration"); return getSignatureDefinition(cls.members, /*selectConstructors*/ true); } @@ -217,6 +214,7 @@ namespace ts.GoToDefinition { function isSignatureDeclaration(node: Node): boolean { switch (node.kind) { case ts.SyntaxKind.Constructor: + case ts.SyntaxKind.ConstructSignature: case ts.SyntaxKind.FunctionDeclaration: case ts.SyntaxKind.MethodDeclaration: case ts.SyntaxKind.MethodSignature: @@ -257,7 +255,7 @@ namespace ts.GoToDefinition { return createDefinitionInfo(decl, symbolKind, symbolName, containerName); } - export function findReferenceInPosition(refs: ReadonlyArray, pos: number): FileReference { + export function findReferenceInPosition(refs: ReadonlyArray, pos: number): FileReference | undefined { for (const ref of refs) { if (ref.pos <= pos && pos <= ref.end) { return ref; diff --git a/src/services/importTracker.ts b/src/services/importTracker.ts index e0ad6f40d75..d3e57b124de 100644 --- a/src/services/importTracker.ts +++ b/src/services/importTracker.ts @@ -107,6 +107,11 @@ namespace ts.FindAllReferences { if (namedBindings && namedBindings.kind === SyntaxKind.NamespaceImport) { handleNamespaceImport(direct, namedBindings.name); } + else if (isDefaultImport(direct)) { + const sourceFileLike = getSourceFileLikeForImportDeclaration(direct); + addIndirectUser(sourceFileLike); // Add a check for indirect uses to handle synthetic default imports + directImports.push(direct); + } else { directImports.push(direct); } @@ -512,29 +517,12 @@ namespace ts.FindAllReferences { const sym = useLhsSymbol ? checker.getSymbolAtLocation(cast(node.left, isPropertyAccessExpression).name) : symbol; // Better detection for GH#20803 if (sym && !(checker.getMergedSymbol(sym.parent).flags & SymbolFlags.Module)) { - Debug.fail(`Special property assignment kind does not have a module as its parent. Assignment is ${showSymbol(sym)}, parent is ${showSymbol(sym.parent)}`); + Debug.fail(`Special property assignment kind does not have a module as its parent. Assignment is ${Debug.showSymbol(sym)}, parent is ${Debug.showSymbol(sym.parent)}`); } return sym && exportInfo(sym, kind); } } - function showSymbol(s: Symbol): string { - const decls = s.declarations.map(d => (ts as any).SyntaxKind[d.kind]).join(","); - const flags = showFlags(s.flags, (ts as any).SymbolFlags); - return `{ declarations: ${decls}, flags: ${flags} }`; - } - - function showFlags(f: number, flags: any) { - const out = []; - for (let pow = 0; pow <= 30; pow++) { - const n = 1 << pow; - if (f & n) { - out.push(flags[n]); - } - } - return out.join("|"); - } - function getImport(): ImportedSymbol | undefined { const isImport = isNodeImport(node); if (!isImport) return undefined; @@ -572,17 +560,17 @@ namespace ts.FindAllReferences { function getExportEqualsLocalSymbol(importedSymbol: Symbol, checker: TypeChecker): Symbol { if (importedSymbol.flags & SymbolFlags.Alias) { - return checker.getImmediateAliasedSymbol(importedSymbol); + return Debug.assertDefined(checker.getImmediateAliasedSymbol(importedSymbol)); } const decl = importedSymbol.valueDeclaration; if (isExportAssignment(decl)) { // `export = class {}` - return decl.expression.symbol; + return Debug.assertDefined(decl.expression.symbol); } else if (isBinaryExpression(decl)) { // `module.exports = class {}` - return decl.right.symbol; + return Debug.assertDefined(decl.right.symbol); } - Debug.fail(); + return Debug.fail(); } // If a reference is a class expression, the exported node would be its parent. @@ -618,7 +606,9 @@ namespace ts.FindAllReferences { } export function getExportInfo(exportSymbol: Symbol, exportKind: ExportKind, checker: TypeChecker): ExportInfo | undefined { - const exportingModuleSymbol = checker.getMergedSymbol(exportSymbol.parent); // Need to get merged symbol in case there's an augmentation. + const moduleSymbol = exportSymbol.parent; + if (!moduleSymbol) return undefined; // This can happen if an `export` is not at the top-level (which is a compile error). + const exportingModuleSymbol = checker.getMergedSymbol(moduleSymbol); // Need to get merged symbol in case there's an augmentation. // `export` may appear in a namespace. In that case, just rely on global search. return isExternalModuleSymbol(exportingModuleSymbol) ? { exportingModuleSymbol, exportKind } : undefined; } diff --git a/src/services/jsTyping.ts b/src/services/jsTyping.ts index 1c2f87fa428..bd6c2e5cb9f 100644 --- a/src/services/jsTyping.ts +++ b/src/services/jsTyping.ts @@ -4,6 +4,7 @@ /// /// /// +/// /* @internal */ namespace ts.JsTyping { @@ -26,6 +27,17 @@ namespace ts.JsTyping { typings?: string; } + export interface CachedTyping { + typingLocation: string; + version: Semver; + } + + /* @internal */ + export function isTypingUpToDate(cachedTyping: JsTyping.CachedTyping, availableTypingVersions: MapLike) { + const availableVersion = Semver.parse(getProperty(availableTypingVersions, `ts${ts.versionMajorMinor}`) || getProperty(availableTypingVersions, "latest")); + return !availableVersion.greaterThan(cachedTyping.version); + } + /* @internal */ export const nodeCoreModuleList: ReadonlyArray = [ "buffer", "querystring", "events", "http", "cluster", @@ -60,7 +72,7 @@ namespace ts.JsTyping { * @param fileNames are the file names that belong to the same project * @param projectRootPath is the path to the project root directory * @param safeListPath is the path used to retrieve the safe list - * @param packageNameToTypingLocation is the map of package names to their cached typing locations + * @param packageNameToTypingLocation is the map of package names to their cached typing locations and installed versions * @param typeAcquisition is used to customize the typing acquisition process * @param compilerOptions are used as a source for typing inference */ @@ -70,9 +82,10 @@ namespace ts.JsTyping { fileNames: string[], projectRootPath: Path, safeList: SafeList, - packageNameToTypingLocation: ReadonlyMap, + packageNameToTypingLocation: ReadonlyMap, typeAcquisition: TypeAcquisition, - unresolvedImports: ReadonlyArray): + unresolvedImports: ReadonlyArray, + typesRegistry: ReadonlyMap>): { cachedTypingPaths: string[], newTypingNames: string[], filesToWatch: string[] } { if (!typeAcquisition || !typeAcquisition.enable) { @@ -122,9 +135,9 @@ namespace ts.JsTyping { addInferredTypings(module, "Inferred typings from unresolved imports"); } // Add the cached typing locations for inferred typings that are already installed - packageNameToTypingLocation.forEach((typingLocation, name) => { - if (inferredTypings.has(name) && inferredTypings.get(name) === undefined) { - inferredTypings.set(name, typingLocation); + packageNameToTypingLocation.forEach((typing, name) => { + if (inferredTypings.has(name) && inferredTypings.get(name) === undefined && isTypingUpToDate(typing, typesRegistry.get(name))) { + inferredTypings.set(name, typing.typingLocation); } }); diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts index 599187cab79..19a74c5af57 100644 --- a/src/services/navigationBar.ts +++ b/src/services/navigationBar.ts @@ -632,9 +632,7 @@ namespace ts.NavigationBar { } function getNodeSpan(node: Node): TextSpan { - return node.kind === SyntaxKind.SourceFile - ? createTextSpanFromBounds(node.getFullStart(), node.getEnd()) - : createTextSpanFromNode(node, curSourceFile); + return node.kind === SyntaxKind.SourceFile ? createTextSpanFromRange(node) : createTextSpanFromNode(node, curSourceFile); } function getModifiers(node: ts.Node): string { diff --git a/src/services/pathCompletions.ts b/src/services/pathCompletions.ts index 0dfae889747..fd639aef817 100644 --- a/src/services/pathCompletions.ts +++ b/src/services/pathCompletions.ts @@ -462,7 +462,7 @@ namespace ts.Completions.PathCompletions { } function normalizeAndPreserveTrailingSlash(path: string) { - if (path === "./") { + if (normalizeSlashes(path) === "./") { // normalizePath turns "./" into "". "" + "/" would then be a rooted path instead of a relative one, so avoid this particular case. // There is no problem for adding "/" to a non-empty string -- it's only a problem at the beginning. return ""; diff --git a/src/services/refactors/annotateWithTypeFromJSDoc.ts b/src/services/refactors/annotateWithTypeFromJSDoc.ts index 3116634cb52..6f87332aa96 100644 --- a/src/services/refactors/annotateWithTypeFromJSDoc.ts +++ b/src/services/refactors/annotateWithTypeFromJSDoc.ts @@ -76,7 +76,7 @@ namespace ts.refactor.annotateWithTypeFromJSDoc { const changeTracker = textChanges.ChangeTracker.fromContext(context); const declarationWithType = addType(decl, transformJSDocType(jsdocType) as TypeNode); suppressLeadingAndTrailingTrivia(declarationWithType); - changeTracker.replaceRange(sourceFile, { pos: decl.getStart(), end: decl.end }, declarationWithType); + changeTracker.replaceNode(sourceFile, decl, declarationWithType, textChanges.useNonAdjustedPositions); return { edits: changeTracker.getChanges(), renameFilename: undefined, @@ -91,7 +91,7 @@ namespace ts.refactor.annotateWithTypeFromJSDoc { const changeTracker = textChanges.ChangeTracker.fromContext(context); const functionWithType = addTypesToFunctionLike(decl); suppressLeadingAndTrailingTrivia(functionWithType); - changeTracker.replaceRange(sourceFile, { pos: decl.getStart(), end: decl.end }, functionWithType); + changeTracker.replaceNode(sourceFile, decl, functionWithType, textChanges.useNonAdjustedPositions); return { edits: changeTracker.getChanges(), renameFilename: undefined, diff --git a/src/services/refactors/convertToEs6Module.ts b/src/services/refactors/convertToEs6Module.ts index fd73d1c3f13..f1f3c16b6bb 100644 --- a/src/services/refactors/convertToEs6Module.ts +++ b/src/services/refactors/convertToEs6Module.ts @@ -33,14 +33,17 @@ namespace ts.refactor { return isExportsOrModuleExportsOrAlias(sourceFile, node as PropertyAccessExpression) || isExportsOrModuleExportsOrAlias(sourceFile, (node as PropertyAccessExpression).expression); case SyntaxKind.VariableDeclarationList: - const decl = (node as VariableDeclarationList).declarations[0]; - return isExportsOrModuleExportsOrAlias(sourceFile, decl.initializer); + return isVariableDeclarationTriggerLocation(firstOrUndefined((node as VariableDeclarationList).declarations)); case SyntaxKind.VariableDeclaration: - return isExportsOrModuleExportsOrAlias(sourceFile, (node as VariableDeclaration).initializer); + return isVariableDeclarationTriggerLocation(node as VariableDeclaration); default: return isExpression(node) && isExportsOrModuleExportsOrAlias(sourceFile, node) || !onSecondTry && isAtTriggerLocation(sourceFile, node.parent, /*onSecondTry*/ true); } + + function isVariableDeclarationTriggerLocation(decl: VariableDeclaration | undefined) { + return !!decl && !!decl.initializer && isExportsOrModuleExportsOrAlias(sourceFile, decl.initializer); + } } function isAtTopLevelRequire(call: CallExpression): boolean { @@ -375,7 +378,14 @@ namespace ts.refactor { function convertExportsDotXEquals(name: string | undefined, exported: Expression): Statement { const modifiers = [createToken(SyntaxKind.ExportKeyword)]; switch (exported.kind) { - case SyntaxKind.FunctionExpression: + case SyntaxKind.FunctionExpression: { + const { name: expressionName } = exported as FunctionExpression; + if (expressionName && expressionName.text !== name) { + // `exports.f = function g() {}` -> `export const f = function g() {}` + return exportConst(); + } + } + // falls through case SyntaxKind.ArrowFunction: // `exports.f = function() {}` --> `export function f() {}` return functionExpressionToDeclaration(name, modifiers, exported as FunctionExpression | ArrowFunction); @@ -383,8 +393,12 @@ namespace ts.refactor { // `exports.C = class {}` --> `export class C {}` return classExpressionToDeclaration(name, modifiers, exported as ClassExpression); default: - // `exports.x = 0;` --> `export const x = 0;` - return makeConst(modifiers, createIdentifier(name), exported); + return exportConst(); + } + + function exportConst() { + // `exports.x = 0;` --> `export const x = 0;` + return makeConst(modifiers, createIdentifier(name), exported); } } diff --git a/src/services/refactors/extractSymbol.ts b/src/services/refactors/extractSymbol.ts index 74a944077ec..bf410ab27a9 100644 --- a/src/services/refactors/extractSymbol.ts +++ b/src/services/refactors/extractSymbol.ts @@ -687,7 +687,7 @@ namespace ts.refactor.extractSymbol { } function getDescriptionForClassLikeDeclaration(scope: ClassLikeDeclaration): string { return scope.kind === SyntaxKind.ClassDeclaration - ? `class '${scope.name.text}'` + ? scope.name ? `class '${scope.name.text}'` : "anonymous class declaration" : scope.name ? `class expression '${scope.name.text}'` : "anonymous class expression"; } function getDescriptionForModuleLikeDeclaration(scope: SourceFile | ModuleBlock): string | SpecialScope { @@ -968,7 +968,7 @@ namespace ts.refactor.extractSymbol { } if (isReadonlyArray(range.range)) { - changeTracker.replaceNodesWithNodes(context.file, range.range, newNodes); + changeTracker.replaceNodeRangeWithNodes(context.file, first(range.range), last(range.range), newNodes); } else { changeTracker.replaceNodeWithNodes(context.file, range.range, newNodes); @@ -1053,7 +1053,7 @@ namespace ts.refactor.extractSymbol { changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariable, /*blankLineBetween*/ true); // Consume - changeTracker.replaceRange(context.file, { pos: node.getStart(), end: node.end }, localReference); + changeTracker.replaceNode(context.file, node, localReference, textChanges.useNonAdjustedPositions); } else { const newVariableDeclaration = createVariableDeclaration(localNameText, variableType, initializer); @@ -1070,7 +1070,7 @@ namespace ts.refactor.extractSymbol { // Consume const localReference = createIdentifier(localNameText); - changeTracker.replaceRange(context.file, { pos: node.getStart(), end: node.end }, localReference); + changeTracker.replaceNode(context.file, node, localReference, textChanges.useNonAdjustedPositions); } else if (node.parent.kind === SyntaxKind.ExpressionStatement && scope === findAncestor(node, isScope)) { // If the parent is an expression statement and the target scope is the immediately enclosing one, @@ -1078,7 +1078,7 @@ namespace ts.refactor.extractSymbol { const newVariableStatement = createVariableStatement( /*modifiers*/ undefined, createVariableDeclarationList([newVariableDeclaration], NodeFlags.Const)); - changeTracker.replaceRange(context.file, { pos: node.parent.getStart(), end: node.parent.end }, newVariableStatement); + changeTracker.replaceNode(context.file, node.parent, newVariableStatement, textChanges.useNonAdjustedPositions); } else { const newVariableStatement = createVariableStatement( @@ -1097,11 +1097,11 @@ namespace ts.refactor.extractSymbol { // Consume if (node.parent.kind === SyntaxKind.ExpressionStatement) { // If the parent is an expression statement, delete it. - changeTracker.deleteRange(context.file, { pos: node.parent.getStart(), end: node.parent.end }); + changeTracker.deleteNode(context.file, node.parent, textChanges.useNonAdjustedPositions); } else { const localReference = createIdentifier(localNameText); - changeTracker.replaceRange(context.file, { pos: node.getStart(), end: node.end }, localReference); + changeTracker.replaceNode(context.file, node, localReference, textChanges.useNonAdjustedPositions); } } } @@ -1689,7 +1689,8 @@ namespace ts.refactor.extractSymbol { return symbolId; } // find first declaration in this file - const declInFile = find(symbol.getDeclarations(), d => d.getSourceFile() === sourceFile); + const decls = symbol.getDeclarations(); + const declInFile = decls && find(decls, d => d.getSourceFile() === sourceFile); if (!declInFile) { return undefined; } @@ -1782,7 +1783,8 @@ namespace ts.refactor.extractSymbol { if (!symbol) { return undefined; } - if (symbol.getDeclarations().some(d => d.parent === scopeDecl)) { + const decls = symbol.getDeclarations(); + if (decls && decls.some(d => d.parent === scopeDecl)) { return createIdentifier(symbol.name); } const prefix = tryReplaceWithQualifiedNameOrPropertyAccess(symbol.parent, scopeDecl, isTypeNode); diff --git a/src/services/refactors/useDefaultImport.ts b/src/services/refactors/useDefaultImport.ts index 6ee43cc7503..080092e16ab 100644 --- a/src/services/refactors/useDefaultImport.ts +++ b/src/services/refactors/useDefaultImport.ts @@ -7,7 +7,7 @@ namespace ts.refactor.installTypesForPackage { function getAvailableActions(context: RefactorContext): ApplicableRefactorInfo[] | undefined { const { file, startPosition, program } = context; - if (!program.getCompilerOptions().allowSyntheticDefaultImports) { + if (!getAllowSyntheticDefaultImports(program.getCompilerOptions())) { return undefined; } @@ -17,8 +17,8 @@ namespace ts.refactor.installTypesForPackage { } const module = getResolvedModule(file, importInfo.moduleSpecifier.text); - const resolvedFile = program.getSourceFile(module.resolvedFileName); - if (!(resolvedFile.externalModuleIndicator && isExportAssignment(resolvedFile.externalModuleIndicator) && resolvedFile.externalModuleIndicator.isExportEquals)) { + const resolvedFile = module && program.getSourceFile(module.resolvedFileName); + if (!(resolvedFile && resolvedFile.externalModuleIndicator && isExportAssignment(resolvedFile.externalModuleIndicator) && resolvedFile.externalModuleIndicator.isExportEquals)) { return undefined; } @@ -69,7 +69,7 @@ namespace ts.refactor.installTypesForPackage { case SyntaxKind.ImportDeclaration: const d = node as ImportDeclaration; const { importClause } = d; - return !importClause.name && importClause.namedBindings.kind === SyntaxKind.NamespaceImport && isStringLiteral(d.moduleSpecifier) + return importClause && !importClause.name && importClause.namedBindings.kind === SyntaxKind.NamespaceImport && isStringLiteral(d.moduleSpecifier) ? { importStatement: d, name: importClause.namedBindings.name, moduleSpecifier: d.moduleSpecifier } : undefined; // For known child node kinds of convertible imports, try again with parent node. diff --git a/src/services/semver.ts b/src/services/semver.ts new file mode 100644 index 00000000000..1c58da8c8f7 --- /dev/null +++ b/src/services/semver.ts @@ -0,0 +1,61 @@ +/* @internal */ +namespace ts { + function stringToInt(str: string): number { + const n = parseInt(str, 10); + if (isNaN(n)) { + throw new Error(`Error in parseInt(${JSON.stringify(str)})`); + } + return n; + } + + const isPrereleaseRegex = /^(.*)-next.\d+/; + const prereleaseSemverRegex = /^(\d+)\.(\d+)\.0-next.(\d+)$/; + const semverRegex = /^(\d+)\.(\d+)\.(\d+)$/; + + export class Semver { + static parse(semver: string): Semver { + const isPrerelease = isPrereleaseRegex.test(semver); + const result = Semver.tryParse(semver, isPrerelease); + if (!result) { + throw new Error(`Unexpected semver: ${semver} (isPrerelease: ${isPrerelease})`); + } + return result; + } + + static fromRaw({ major, minor, patch, isPrerelease }: Semver): Semver { + return new Semver(major, minor, patch, isPrerelease); + } + + // This must parse the output of `versionString`. + private static tryParse(semver: string, isPrerelease: boolean): Semver | undefined { + // Per the semver spec : + // "A normal version number MUST take the form X.Y.Z where X, Y, and Z are non-negative integers, and MUST NOT contain leading zeroes." + const rgx = isPrerelease ? prereleaseSemverRegex : semverRegex; + const match = rgx.exec(semver); + return match ? new Semver(stringToInt(match[1]), stringToInt(match[2]), stringToInt(match[3]), isPrerelease) : undefined; + } + + private constructor( + readonly major: number, readonly minor: number, readonly patch: number, + /** + * If true, this is `major.minor.0-next.patch`. + * If false, this is `major.minor.patch`. + */ + readonly isPrerelease: boolean) { } + + get versionString(): string { + return this.isPrerelease ? `${this.major}.${this.minor}.0-next.${this.patch}` : `${this.major}.${this.minor}.${this.patch}`; + } + + equals(sem: Semver): boolean { + return this.major === sem.major && this.minor === sem.minor && this.patch === sem.patch && this.isPrerelease === sem.isPrerelease; + } + + greaterThan(sem: Semver): boolean { + return this.major > sem.major || this.major === sem.major + && (this.minor > sem.minor || this.minor === sem.minor + && (!this.isPrerelease && sem.isPrerelease || this.isPrerelease === sem.isPrerelease + && this.patch > sem.patch)); + } + } +} \ No newline at end of file diff --git a/src/services/services.ts b/src/services/services.ts index 422248465c9..b8c086a67e7 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -121,7 +121,7 @@ namespace ts { const textPos = scanner.getTextPos(); if (textPos <= end) { if (token === SyntaxKind.Identifier) { - Debug.fail(`Did not expect ${(ts as any).SyntaxKind[this.kind]} to have an Identifier in its trivia`); + Debug.fail(`Did not expect ${Debug.showSyntaxKind(this)} to have an Identifier in its trivia`); } nodes.push(createNode(token, pos, textPos, this)); } @@ -1580,7 +1580,7 @@ namespace ts { return results; } - function getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[] { + function getDocumentHighlights(fileName: string, position: number, filesToSearch: ReadonlyArray): DocumentHighlights[] { synchronizeHostData(); const sourceFilesToSearch = map(filesToSearch, f => Debug.assertDefined(program.getSourceFile(f))); const sourceFile = getValidSourceFile(fileName); diff --git a/src/services/shims.ts b/src/services/shims.ts index 30a836a113f..11e397f526a 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -24,6 +24,17 @@ let debugObjectHost: { CollectGarbage(): void } = (function (this: any) { return /* @internal */ namespace ts { + interface DiscoverTypingsInfo { + fileNames: string[]; // The file names that belong to the same project. + projectRootPath: string; // The path to the project root directory + safeListPath: string; // The path used to retrieve the safe list + packageNameToTypingLocation: Map; // The map of package names to their cached typing locations and installed versions + typeAcquisition: TypeAcquisition; // Used to customize the type acquisition process + compilerOptions: CompilerOptions; // Used as a source for typing inference + unresolvedImports: ReadonlyArray; // List of unresolved module ids from imports + typesRegistry: ReadonlyMap>; // The map of available typings in npm to maps of TS versions to their latest supported versions + } + export interface ScriptSnapshotShim { /** Gets a portion of the script snapshot specified by [start, end). */ getText(start: number, end: number): string; @@ -1159,7 +1170,8 @@ namespace ts { this.safeList, info.packageNameToTypingLocation, info.typeAcquisition, - info.unresolvedImports); + info.unresolvedImports, + info.typesRegistry); }); } } diff --git a/src/services/symbolDisplay.ts b/src/services/symbolDisplay.ts index 9ec99f6ccaf..387d027d999 100644 --- a/src/services/symbolDisplay.ts +++ b/src/services/symbolDisplay.ts @@ -79,6 +79,8 @@ namespace ts.SymbolDisplay { switch (location.parent && location.parent.kind) { // If we've typed a character of the attribute name, will be 'JsxAttribute', else will be 'JsxOpeningElement'. case SyntaxKind.JsxOpeningElement: + case SyntaxKind.JsxElement: + case SyntaxKind.JsxSelfClosingElement: return location.kind === SyntaxKind.Identifier ? ScriptElementKind.memberVariableElement : ScriptElementKind.jsxAttribute; case SyntaxKind.JsxAttribute: return ScriptElementKind.jsxAttribute; diff --git a/src/services/textChanges.ts b/src/services/textChanges.ts index 83b434aac7d..d3f6cde8e8d 100644 --- a/src/services/textChanges.ts +++ b/src/services/textChanges.ts @@ -28,9 +28,11 @@ namespace ts.textChanges { } export interface ConfigurableStart { + /** True to use getStart() (NB, not getFullStart()) without adjustment. */ useNonAdjustedStartPosition?: boolean; } export interface ConfigurableEnd { + /** True to use getEnd() without adjustment. */ useNonAdjustedEndPosition?: boolean; } @@ -70,6 +72,11 @@ namespace ts.textChanges { */ export type ConfigurableStartEnd = ConfigurableStart & ConfigurableEnd; + export const useNonAdjustedPositions: ConfigurableStartEnd = { + useNonAdjustedStartPosition: true, + useNonAdjustedEndPosition: true, + }; + export interface InsertNodeOptions { /** * Text to be inserted before the new node @@ -117,13 +124,10 @@ namespace ts.textChanges { readonly options?: never; } - interface ChangeMultipleNodesOptions extends ChangeNodeOptions { - nodeSeparator: string; - } interface ReplaceWithMultipleNodes extends BaseChange { readonly kind: ChangeKind.ReplaceWithMultipleNodes; readonly nodes: ReadonlyArray; - readonly options?: ChangeMultipleNodesOptions; + readonly options?: ChangeNodeOptions; } export function getSeparatorCharacter(separator: Token) { @@ -132,7 +136,7 @@ namespace ts.textChanges { export function getAdjustedStartPosition(sourceFile: SourceFile, node: Node, options: ConfigurableStart, position: Position) { if (options.useNonAdjustedStartPosition) { - return node.getFullStart(); + return node.getStart(); } const fullStart = node.getFullStart(); const start = node.getStart(sourceFile); @@ -280,51 +284,41 @@ namespace ts.textChanges { return this; } - public replaceRange(sourceFile: SourceFile, range: TextRange, newNode: Node, options: InsertNodeOptions = {}) { + // TODO (https://github.com/Microsoft/TypeScript/issues/21246): default should probably be useNonAdjustedPositions + public replaceRange(sourceFile: SourceFile, range: TextRange, newNode: Node, options: ChangeNodeOptions = {}) { this.changes.push({ kind: ChangeKind.ReplaceWithSingleNode, sourceFile, range, options, node: newNode }); return this; } + // TODO (https://github.com/Microsoft/TypeScript/issues/21246): default should probably be useNonAdjustedPositions public replaceNode(sourceFile: SourceFile, oldNode: Node, newNode: Node, options: ChangeNodeOptions = {}) { - const startPosition = getAdjustedStartPosition(sourceFile, oldNode, options, Position.Start); - const endPosition = getAdjustedEndPosition(sourceFile, oldNode, options); - return this.replaceWithSingle(sourceFile, startPosition, endPosition, newNode, options); + const pos = getAdjustedStartPosition(sourceFile, oldNode, options, Position.Start); + const end = getAdjustedEndPosition(sourceFile, oldNode, options); + return this.replaceRange(sourceFile, { pos, end }, newNode, options); } + // TODO (https://github.com/Microsoft/TypeScript/issues/21246): default should probably be useNonAdjustedPositions public replaceNodeRange(sourceFile: SourceFile, startNode: Node, endNode: Node, newNode: Node, options: ChangeNodeOptions = {}) { - const startPosition = getAdjustedStartPosition(sourceFile, startNode, options, Position.Start); - const endPosition = getAdjustedEndPosition(sourceFile, endNode, options); - return this.replaceWithSingle(sourceFile, startPosition, endPosition, newNode, options); + const pos = getAdjustedStartPosition(sourceFile, startNode, options, Position.Start); + const end = getAdjustedEndPosition(sourceFile, endNode, options); + return this.replaceRange(sourceFile, { pos, end }, newNode, options); } - private replaceWithSingle(sourceFile: SourceFile, startPosition: number, endPosition: number, newNode: Node, options: ChangeNodeOptions): this { - this.changes.push({ - kind: ChangeKind.ReplaceWithSingleNode, - sourceFile, - options, - node: newNode, - range: { pos: startPosition, end: endPosition } - }); + public replaceRangeWithNodes(sourceFile: SourceFile, range: TextRange, newNodes: ReadonlyArray, options: ChangeNodeOptions = useNonAdjustedPositions) { + this.changes.push({ kind: ChangeKind.ReplaceWithMultipleNodes, sourceFile, range, options, nodes: newNodes }); return this; } - private replaceWithMultiple(sourceFile: SourceFile, startPosition: number, endPosition: number, newNodes: ReadonlyArray, options: ChangeMultipleNodesOptions): this { - this.changes.push({ - kind: ChangeKind.ReplaceWithMultipleNodes, - sourceFile, - options, - nodes: newNodes, - range: { pos: startPosition, end: endPosition } - }); - return this; + public replaceNodeWithNodes(sourceFile: SourceFile, oldNode: Node, newNodes: ReadonlyArray, options: ChangeNodeOptions = useNonAdjustedPositions) { + const pos = getAdjustedStartPosition(sourceFile, oldNode, options, Position.Start); + const end = getAdjustedEndPosition(sourceFile, oldNode, options); + return this.replaceRangeWithNodes(sourceFile, { pos, end }, newNodes, options); } - public replaceNodeWithNodes(sourceFile: SourceFile, oldNode: Node, newNodes: ReadonlyArray): void { - this.replaceWithMultiple(sourceFile, oldNode.getStart(sourceFile), oldNode.getEnd(), newNodes, { nodeSeparator: this.newLineCharacter }); - } - - public replaceNodesWithNodes(sourceFile: SourceFile, oldNodes: ReadonlyArray, newNodes: ReadonlyArray): void { - this.replaceWithMultiple(sourceFile, first(oldNodes).getStart(sourceFile), last(oldNodes).getEnd(), newNodes, { nodeSeparator: this.newLineCharacter }); + public replaceNodeRangeWithNodes(sourceFile: SourceFile, startNode: Node, endNode: Node, newNodes: ReadonlyArray, options: ChangeNodeOptions = useNonAdjustedPositions) { + const pos = getAdjustedStartPosition(sourceFile, startNode, options, Position.Start); + const end = getAdjustedEndPosition(sourceFile, endNode, options); + return this.replaceRangeWithNodes(sourceFile, { pos, end }, newNodes, options); } private insertNodeAt(sourceFile: SourceFile, pos: number, newNode: Node, options: InsertNodeOptions = {}) { @@ -341,18 +335,13 @@ namespace ts.textChanges { } public insertNodeBefore(sourceFile: SourceFile, before: Node, newNode: Node, blankLineBetween = false) { - const startPosition = getAdjustedStartPosition(sourceFile, before, {}, Position.Start); - return this.replaceWithSingle(sourceFile, startPosition, startPosition, newNode, this.getOptionsForInsertNodeBefore(before, blankLineBetween)); + const pos = getAdjustedStartPosition(sourceFile, before, {}, Position.Start); + return this.replaceRange(sourceFile, { pos, end: pos }, newNode, this.getOptionsForInsertNodeBefore(before, blankLineBetween)); } public insertModifierBefore(sourceFile: SourceFile, modifier: SyntaxKind, before: Node): void { const pos = before.getStart(sourceFile); - this.replaceWithSingle(sourceFile, pos, pos, createToken(modifier), { suffix: " " }); - } - - public changeIdentifierToPropertyAccess(sourceFile: SourceFile, prefix: string, node: Identifier): void { - const startPosition = getAdjustedStartPosition(sourceFile, node, {}, Position.Start); - this.replaceWithSingle(sourceFile, startPosition, startPosition, createPropertyAccess(createIdentifier(prefix), ""), {}); + this.replaceRange(sourceFile, { pos, end: pos }, createToken(modifier), { suffix: " " }); } private getOptionsForInsertNodeBefore(before: Node, doubleNewlines: boolean): ChangeNodeOptions { @@ -390,8 +379,8 @@ namespace ts.textChanges { } public insertNodeAtEndOfScope(sourceFile: SourceFile, scope: Node, newNode: Node): void { - const startPosition = getAdjustedStartPosition(sourceFile, scope.getLastToken(), {}, Position.Start); - this.replaceWithSingle(sourceFile, startPosition, startPosition, newNode, { + const pos = getAdjustedStartPosition(sourceFile, scope.getLastToken(), {}, Position.Start); + this.replaceRange(sourceFile, { pos, end: pos }, newNode, { prefix: isLineBreak(sourceFile.text.charCodeAt(scope.getLastToken().pos)) ? this.newLineCharacter : this.newLineCharacter + this.newLineCharacter, suffix: this.newLineCharacter }); @@ -433,7 +422,7 @@ namespace ts.textChanges { } } const endPosition = getAdjustedEndPosition(sourceFile, after, {}); - return this.replaceWithSingle(sourceFile, endPosition, endPosition, newNode, this.getInsertNodeAfterOptions(after)); + return this.replaceRange(sourceFile, { pos: endPosition, end: endPosition }, newNode, this.getInsertNodeAfterOptions(after)); } private getInsertNodeAfterOptions(node: Node): InsertNodeOptions { @@ -629,7 +618,7 @@ namespace ts.textChanges { } private computeSpan(change: Change, _sourceFile: SourceFile): TextSpan { - return createTextSpanFromBounds(change.range.pos, change.range.end); + return createTextSpanFromRange(change.range); } private computeNewText(change: Change, sourceFile: SourceFile): string { @@ -643,8 +632,14 @@ namespace ts.textChanges { const pos = change.range.pos; const posStartsLine = getLineStartPositionForPosition(pos, sourceFile) === pos; if (change.kind === ChangeKind.ReplaceWithMultipleNodes) { - const parts = change.nodes.map(n => this.getFormattedTextOfNode(n, sourceFile, pos, options)); - text = parts.join(change.options.nodeSeparator); + const lastIndex = change.nodes.length - 1; + const parts = change.nodes.map((n, index) => { + const formatted = this.getFormattedTextOfNode(n, sourceFile, pos, options); + return index === lastIndex || endsWith(formatted, this.newLineCharacter) + ? formatted + : (formatted + this.newLineCharacter); + }); + text = parts.join(""); } else { Debug.assert(change.kind === ChangeKind.ReplaceWithSingleNode, "change.kind === ReplaceWithSingleNode"); diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json index 13a7a30d845..ef0d68b2041 100644 --- a/src/services/tsconfig.json +++ b/src/services/tsconfig.json @@ -66,6 +66,7 @@ "services.ts", "transform.ts", "transpile.ts", + "semver.ts", "shims.ts", "signatureHelp.ts", "symbolDisplay.ts", diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 8b4bb1ad212..8df8a902734 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -761,23 +761,12 @@ namespace ts { Debug.assert(!(result && isWhiteSpaceOnlyJsxText(result))); return result; - function findRightmostToken(n: Node): Node { - if (isToken(n)) { + function find(n: Node): Node | undefined { + if (isNonWhitespaceToken(n)) { return n; } - const children = n.getChildren(); - const candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length); - return candidate && findRightmostToken(candidate); - - } - - function find(n: Node): Node { - if (isToken(n)) { - return n; - } - - const children = n.getChildren(); + const children = n.getChildren(sourceFile); for (let i = 0; i < children.length; i++) { const child = children[i]; // Note that the span of a node's tokens is [node.getStart(...), node.end). @@ -795,7 +784,7 @@ namespace ts { if (lookInPreviousChild) { // actual start of the node is past the position - previous token should be at the end of previous child const candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i); - return candidate && findRightmostToken(candidate); + return candidate && findRightmostToken(candidate, sourceFile); } else { // candidate should be in this node @@ -812,23 +801,37 @@ namespace ts { // Namely we are skipping the check: 'position < node.end' if (children.length) { const candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length); - return candidate && findRightmostToken(candidate); + return candidate && findRightmostToken(candidate, sourceFile); } } + } - /** - * Finds the rightmost child to the left of `children[exclusiveStartPosition]` which is a non-all-whitespace token or has constituent tokens. - */ - function findRightmostChildNodeWithTokens(children: Node[], exclusiveStartPosition: number): Node { - for (let i = exclusiveStartPosition - 1; i >= 0; i--) { - const child = children[i]; + function isNonWhitespaceToken(n: Node): boolean { + return isToken(n) && !isWhiteSpaceOnlyJsxText(n); + } - if (isWhiteSpaceOnlyJsxText(child)) { - Debug.assert(i > 0, "`JsxText` tokens should not be the first child of `JsxElement | JsxSelfClosingElement`"); - } - else if (nodeHasTokens(children[i])) { - return children[i]; - } + function findRightmostToken(n: Node, sourceFile: SourceFile): Node | undefined { + if (isNonWhitespaceToken(n)) { + return n; + } + + const children = n.getChildren(sourceFile); + const candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length); + return candidate && findRightmostToken(candidate, sourceFile); + } + + /** + * Finds the rightmost child to the left of `children[exclusiveStartPosition]` which is a non-all-whitespace token or has constituent tokens. + */ + function findRightmostChildNodeWithTokens(children: Node[], exclusiveStartPosition: number): Node | undefined { + for (let i = exclusiveStartPosition - 1; i >= 0; i--) { + const child = children[i]; + + if (isWhiteSpaceOnlyJsxText(child)) { + Debug.assert(i > 0, "`JsxText` tokens should not be the first child of `JsxElement | JsxSelfClosingElement`"); + } + else if (nodeHasTokens(children[i])) { + return children[i]; } } } @@ -893,7 +896,7 @@ namespace ts { return false; } - export function isWhiteSpaceOnlyJsxText(node: Node): node is JsxText { + function isWhiteSpaceOnlyJsxText(node: Node): boolean { return isJsxText(node) && node.containsOnlyWhiteSpaces; } diff --git a/tests/baselines/reference/ClassDeclaration21.symbols b/tests/baselines/reference/ClassDeclaration21.symbols index f9bd42a3a4f..3d0b571ea37 100644 --- a/tests/baselines/reference/ClassDeclaration21.symbols +++ b/tests/baselines/reference/ClassDeclaration21.symbols @@ -3,5 +3,8 @@ class C { >C : Symbol(C, Decl(ClassDeclaration21.ts, 0, 0)) 0(); +>0 : Symbol(C[0], Decl(ClassDeclaration21.ts, 0, 9)) + 1() { } +>1 : Symbol(C[1], Decl(ClassDeclaration21.ts, 1, 8)) } diff --git a/tests/baselines/reference/ClassDeclaration21.types b/tests/baselines/reference/ClassDeclaration21.types index fa41bb54676..32ed0db413e 100644 --- a/tests/baselines/reference/ClassDeclaration21.types +++ b/tests/baselines/reference/ClassDeclaration21.types @@ -3,5 +3,8 @@ class C { >C : C 0(); +>0 : () => any + 1() { } +>1 : () => void } diff --git a/tests/baselines/reference/ClassDeclaration22.symbols b/tests/baselines/reference/ClassDeclaration22.symbols index 059ff9e825c..b53258c6ee5 100644 --- a/tests/baselines/reference/ClassDeclaration22.symbols +++ b/tests/baselines/reference/ClassDeclaration22.symbols @@ -3,5 +3,8 @@ class C { >C : Symbol(C, Decl(ClassDeclaration22.ts, 0, 0)) "foo"(); +>"foo" : Symbol(C["foo"], Decl(ClassDeclaration22.ts, 0, 9)) + "bar"() { } +>"bar" : Symbol(C["bar"], Decl(ClassDeclaration22.ts, 1, 12)) } diff --git a/tests/baselines/reference/ClassDeclaration22.types b/tests/baselines/reference/ClassDeclaration22.types index 359ac950462..768160a8ac9 100644 --- a/tests/baselines/reference/ClassDeclaration22.types +++ b/tests/baselines/reference/ClassDeclaration22.types @@ -3,5 +3,8 @@ class C { >C : C "foo"(); +>"foo" : () => any + "bar"() { } +>"bar" : () => void } diff --git a/tests/baselines/reference/ExportAssignment7.types b/tests/baselines/reference/ExportAssignment7.types index 2f0871f48a5..cf1f3ef7956 100644 --- a/tests/baselines/reference/ExportAssignment7.types +++ b/tests/baselines/reference/ExportAssignment7.types @@ -4,5 +4,5 @@ export class C { } export = B; ->B : No type information available! +>B : any diff --git a/tests/baselines/reference/ExportAssignment8.types b/tests/baselines/reference/ExportAssignment8.types index 1b141b0b216..86db65f2fbd 100644 --- a/tests/baselines/reference/ExportAssignment8.types +++ b/tests/baselines/reference/ExportAssignment8.types @@ -1,6 +1,6 @@ === tests/cases/compiler/ExportAssignment8.ts === export = B; ->B : No type information available! +>B : any export class C { >C : C diff --git a/tests/baselines/reference/aliasErrors.types b/tests/baselines/reference/aliasErrors.types index 6dc25ef9a33..c8e1b04fa76 100644 --- a/tests/baselines/reference/aliasErrors.types +++ b/tests/baselines/reference/aliasErrors.types @@ -28,31 +28,31 @@ import beez = foo.bar; import m = no; >m : any ->no : No type information available! +>no : any import m2 = no.mod; >m2 : any ->no : No type information available! ->mod : No type information available! +>no : any +>mod : any import n = 5; >n : any -> : No type information available! +> : any >5 : 5 import o = "s"; >o : any -> : No type information available! +> : any >"s" : "s" import q = null; >q : any -> : No type information available! +> : any >null : null import r = undefined; >r : any ->undefined : No type information available! +>undefined : any var p = new provide.Provide(); diff --git a/tests/baselines/reference/aliasOnMergedModuleInterface.symbols b/tests/baselines/reference/aliasOnMergedModuleInterface.symbols index c4f5c0730a1..253c5639f5d 100644 --- a/tests/baselines/reference/aliasOnMergedModuleInterface.symbols +++ b/tests/baselines/reference/aliasOnMergedModuleInterface.symbols @@ -19,6 +19,7 @@ var x: foo.A = foo.bar("hello"); // foo.A should be ok but foo.bar should be err === tests/cases/compiler/aliasOnMergedModuleInterface_0.ts === declare module "foo" +>"foo" : Symbol("foo", Decl(aliasOnMergedModuleInterface_0.ts, 0, 0)) { module B { >B : Symbol(B, Decl(aliasOnMergedModuleInterface_0.ts, 1, 1), Decl(aliasOnMergedModuleInterface_0.ts, 5, 5)) diff --git a/tests/baselines/reference/aliasOnMergedModuleInterface.types b/tests/baselines/reference/aliasOnMergedModuleInterface.types index 9ba023a8dd8..fb9c197feec 100644 --- a/tests/baselines/reference/aliasOnMergedModuleInterface.types +++ b/tests/baselines/reference/aliasOnMergedModuleInterface.types @@ -26,6 +26,7 @@ var x: foo.A = foo.bar("hello"); // foo.A should be ok but foo.bar should be err === tests/cases/compiler/aliasOnMergedModuleInterface_0.ts === declare module "foo" +>"foo" : typeof "foo" { module B { >B : any diff --git a/tests/baselines/reference/ambientDeclarations.symbols b/tests/baselines/reference/ambientDeclarations.symbols index ef5c5403ccf..1436c698cff 100644 --- a/tests/baselines/reference/ambientDeclarations.symbols +++ b/tests/baselines/reference/ambientDeclarations.symbols @@ -160,6 +160,8 @@ var q = M1.fn(); // Ambient external module in the global module // Ambient external module with a string literal name that is a top level external module name declare module 'external1' { +>'external1' : Symbol('external1', Decl(ambientDeclarations.ts, 67, 16)) + var q; >q : Symbol(q, Decl(ambientDeclarations.ts, 72, 7)) } diff --git a/tests/baselines/reference/ambientDeclarations.types b/tests/baselines/reference/ambientDeclarations.types index a571eb9fa7b..3d0b53ee19d 100644 --- a/tests/baselines/reference/ambientDeclarations.types +++ b/tests/baselines/reference/ambientDeclarations.types @@ -163,6 +163,8 @@ var q = M1.fn(); // Ambient external module in the global module // Ambient external module with a string literal name that is a top level external module name declare module 'external1' { +>'external1' : typeof 'external1' + var q; >q : any } diff --git a/tests/baselines/reference/ambientDeclarationsExternal.symbols b/tests/baselines/reference/ambientDeclarationsExternal.symbols index 57d3fdf914f..49f0775e136 100644 --- a/tests/baselines/reference/ambientDeclarationsExternal.symbols +++ b/tests/baselines/reference/ambientDeclarationsExternal.symbols @@ -20,6 +20,8 @@ var n: number; === tests/cases/conformance/ambient/decls.ts === // Ambient external module with export assignment declare module 'equ' { +>'equ' : Symbol('equ', Decl(decls.ts, 0, 0)) + var x; >x : Symbol(x, Decl(decls.ts, 2, 7)) @@ -28,6 +30,8 @@ declare module 'equ' { } declare module 'equ2' { +>'equ2' : Symbol('equ2', Decl(decls.ts, 4, 1)) + var x: number; >x : Symbol(x, Decl(decls.ts, 7, 7)) } diff --git a/tests/baselines/reference/ambientDeclarationsExternal.types b/tests/baselines/reference/ambientDeclarationsExternal.types index 4cf7d6b0bcb..522c9bd1442 100644 --- a/tests/baselines/reference/ambientDeclarationsExternal.types +++ b/tests/baselines/reference/ambientDeclarationsExternal.types @@ -20,6 +20,8 @@ var n: number; === tests/cases/conformance/ambient/decls.ts === // Ambient external module with export assignment declare module 'equ' { +>'equ' : typeof 'equ' + var x; >x : any @@ -28,6 +30,8 @@ declare module 'equ' { } declare module 'equ2' { +>'equ2' : typeof 'equ2' + var x: number; >x : number } diff --git a/tests/baselines/reference/ambientDeclarationsPatterns.symbols b/tests/baselines/reference/ambientDeclarationsPatterns.symbols index 4c0acc93f8f..22fc2937872 100644 --- a/tests/baselines/reference/ambientDeclarationsPatterns.symbols +++ b/tests/baselines/reference/ambientDeclarationsPatterns.symbols @@ -25,23 +25,31 @@ foo(fileText); === tests/cases/conformance/ambient/declarations.d.ts === declare module "foo*baz" { +>"foo*baz" : Symbol("foo*baz", Decl(declarations.d.ts, 0, 0), Decl(declarations.d.ts, 2, 1)) + export function foo(s: string): void; >foo : Symbol(foo, Decl(declarations.d.ts, 0, 26)) >s : Symbol(s, Decl(declarations.d.ts, 1, 24)) } // Augmentations still work declare module "foo*baz" { +>"foo*baz" : Symbol("foo*baz", Decl(declarations.d.ts, 0, 0), Decl(declarations.d.ts, 2, 1)) + export const baz: string; >baz : Symbol(baz, Decl(declarations.d.ts, 5, 16)) } // Longest prefix wins declare module "foos*" { +>"foos*" : Symbol("foos*", Decl(declarations.d.ts, 6, 1)) + export const foos: string; >foos : Symbol(foos, Decl(declarations.d.ts, 10, 16)) } declare module "*!text" { +>"*!text" : Symbol("*!text", Decl(declarations.d.ts, 11, 1)) + const x: string; >x : Symbol(x, Decl(declarations.d.ts, 14, 9)) diff --git a/tests/baselines/reference/ambientDeclarationsPatterns.types b/tests/baselines/reference/ambientDeclarationsPatterns.types index adf8ae1ab3b..77cef7515b2 100644 --- a/tests/baselines/reference/ambientDeclarationsPatterns.types +++ b/tests/baselines/reference/ambientDeclarationsPatterns.types @@ -28,23 +28,31 @@ foo(fileText); === tests/cases/conformance/ambient/declarations.d.ts === declare module "foo*baz" { +>"foo*baz" : typeof "foo*baz" + export function foo(s: string): void; >foo : (s: string) => void >s : string } // Augmentations still work declare module "foo*baz" { +>"foo*baz" : typeof "foo*baz" + export const baz: string; >baz : string } // Longest prefix wins declare module "foos*" { +>"foos*" : typeof "foos*" + export const foos: string; >foos : string } declare module "*!text" { +>"*!text" : typeof "*!text" + const x: string; >x : string diff --git a/tests/baselines/reference/ambientDeclarationsPatterns_tooManyAsterisks.symbols b/tests/baselines/reference/ambientDeclarationsPatterns_tooManyAsterisks.symbols index 63d50b6c85e..1ebc29ee92a 100644 --- a/tests/baselines/reference/ambientDeclarationsPatterns_tooManyAsterisks.symbols +++ b/tests/baselines/reference/ambientDeclarationsPatterns_tooManyAsterisks.symbols @@ -1,4 +1,4 @@ === tests/cases/conformance/ambient/ambientDeclarationsPatterns_tooManyAsterisks.ts === declare module "too*many*asterisks" { } -No type information for this code. -No type information for this code. \ No newline at end of file +>"too*many*asterisks" : Symbol("too*many*asterisks", Decl(ambientDeclarationsPatterns_tooManyAsterisks.ts, 0, 0)) + diff --git a/tests/baselines/reference/ambientDeclarationsPatterns_tooManyAsterisks.types b/tests/baselines/reference/ambientDeclarationsPatterns_tooManyAsterisks.types index 63d50b6c85e..93ea5f185d0 100644 --- a/tests/baselines/reference/ambientDeclarationsPatterns_tooManyAsterisks.types +++ b/tests/baselines/reference/ambientDeclarationsPatterns_tooManyAsterisks.types @@ -1,4 +1,4 @@ === tests/cases/conformance/ambient/ambientDeclarationsPatterns_tooManyAsterisks.ts === declare module "too*many*asterisks" { } -No type information for this code. -No type information for this code. \ No newline at end of file +>"too*many*asterisks" : typeof "too*many*asterisks" + diff --git a/tests/baselines/reference/ambientErrors.symbols b/tests/baselines/reference/ambientErrors.symbols index 684e87b1fd4..d9c3647fcc6 100644 --- a/tests/baselines/reference/ambientErrors.symbols +++ b/tests/baselines/reference/ambientErrors.symbols @@ -90,13 +90,17 @@ module M2 { >M2 : Symbol(M2, Decl(ambientErrors.ts, 42, 1)) declare module 'nope' { } +>'nope' : Symbol('nope', Decl(ambientErrors.ts, 45, 11)) } // Ambient external module with a string literal name that isn't a top level external module name declare module '../foo' { } +>'../foo' : Symbol('../foo', Decl(ambientErrors.ts, 47, 1)) // Ambient external module with export assignment and other exported members declare module 'bar' { +>'bar' : Symbol('bar', Decl(ambientErrors.ts, 50, 27)) + var n; >n : Symbol(n, Decl(ambientErrors.ts, 54, 7)) diff --git a/tests/baselines/reference/ambientErrors.types b/tests/baselines/reference/ambientErrors.types index 3cd46066219..bd4033e9397 100644 --- a/tests/baselines/reference/ambientErrors.types +++ b/tests/baselines/reference/ambientErrors.types @@ -97,13 +97,17 @@ module M2 { >M2 : any declare module 'nope' { } +>'nope' : typeof 'nope' } // Ambient external module with a string literal name that isn't a top level external module name declare module '../foo' { } +>'../foo' : typeof '../foo' // Ambient external module with export assignment and other exported members declare module 'bar' { +>'bar' : typeof 'bar' + var n; >n : any diff --git a/tests/baselines/reference/ambientExportDefaultErrors.symbols b/tests/baselines/reference/ambientExportDefaultErrors.symbols index bfec3520347..b3e6b79cd3e 100644 --- a/tests/baselines/reference/ambientExportDefaultErrors.symbols +++ b/tests/baselines/reference/ambientExportDefaultErrors.symbols @@ -18,6 +18,8 @@ export as namespace Foo2; === tests/cases/compiler/indirection.d.ts === /// declare module "indirect" { +>"indirect" : Symbol("indirect", Decl(indirection.d.ts, 0, 0)) + export default typeof Foo.default; >Foo.default : Symbol(Foo.default, Decl(foo.d.ts, 0, 0)) >Foo : Symbol(Foo, Decl(foo.d.ts, 0, 21)) @@ -27,6 +29,8 @@ declare module "indirect" { === tests/cases/compiler/indirection2.d.ts === /// declare module "indirect2" { +>"indirect2" : Symbol("indirect2", Decl(indirection2.d.ts, 0, 0)) + export = typeof Foo2; >Foo2 : Symbol(Foo2, Decl(foo2.d.ts, 0, 15)) } diff --git a/tests/baselines/reference/ambientExportDefaultErrors.types b/tests/baselines/reference/ambientExportDefaultErrors.types index 97d2051a70a..c9c2351d444 100644 --- a/tests/baselines/reference/ambientExportDefaultErrors.types +++ b/tests/baselines/reference/ambientExportDefaultErrors.types @@ -26,6 +26,8 @@ export as namespace Foo2; === tests/cases/compiler/indirection.d.ts === /// declare module "indirect" { +>"indirect" : typeof "indirect" + export default typeof Foo.default; >typeof Foo.default : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >Foo.default : number @@ -36,6 +38,8 @@ declare module "indirect" { === tests/cases/compiler/indirection2.d.ts === /// declare module "indirect2" { +>"indirect2" : typeof "indirect2" + export = typeof Foo2; >typeof Foo2 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >Foo2 : number diff --git a/tests/baselines/reference/ambientExternalModuleInAnotherExternalModule.symbols b/tests/baselines/reference/ambientExternalModuleInAnotherExternalModule.symbols index 7ab22e063e3..837de2d5ddc 100644 --- a/tests/baselines/reference/ambientExternalModuleInAnotherExternalModule.symbols +++ b/tests/baselines/reference/ambientExternalModuleInAnotherExternalModule.symbols @@ -6,6 +6,8 @@ export = D; >D : Symbol(D, Decl(ambientExternalModuleInAnotherExternalModule.ts, 0, 0)) declare module "ext" { +>"ext" : Symbol("ext", Decl(ambientExternalModuleInAnotherExternalModule.ts, 1, 11)) + export class C { } >C : Symbol(C, Decl(ambientExternalModuleInAnotherExternalModule.ts, 3, 22)) } diff --git a/tests/baselines/reference/ambientExternalModuleInAnotherExternalModule.types b/tests/baselines/reference/ambientExternalModuleInAnotherExternalModule.types index e7d852d7a3d..f335f5255d2 100644 --- a/tests/baselines/reference/ambientExternalModuleInAnotherExternalModule.types +++ b/tests/baselines/reference/ambientExternalModuleInAnotherExternalModule.types @@ -6,6 +6,8 @@ export = D; >D : D declare module "ext" { +>"ext" : typeof "ext" + export class C { } >C : C } diff --git a/tests/baselines/reference/ambientExternalModuleInsideNonAmbient.symbols b/tests/baselines/reference/ambientExternalModuleInsideNonAmbient.symbols index a2b535c5b80..bb83ea46ae1 100644 --- a/tests/baselines/reference/ambientExternalModuleInsideNonAmbient.symbols +++ b/tests/baselines/reference/ambientExternalModuleInsideNonAmbient.symbols @@ -3,4 +3,5 @@ module M { >M : Symbol(M, Decl(ambientExternalModuleInsideNonAmbient.ts, 0, 0)) export declare module "M" { } +>"M" : Symbol("M", Decl(ambientExternalModuleInsideNonAmbient.ts, 0, 10)) } diff --git a/tests/baselines/reference/ambientExternalModuleInsideNonAmbient.types b/tests/baselines/reference/ambientExternalModuleInsideNonAmbient.types index d635bfd1d1e..be88c42d3f9 100644 --- a/tests/baselines/reference/ambientExternalModuleInsideNonAmbient.types +++ b/tests/baselines/reference/ambientExternalModuleInsideNonAmbient.types @@ -3,4 +3,5 @@ module M { >M : any export declare module "M" { } +>"M" : typeof "M" } diff --git a/tests/baselines/reference/ambientExternalModuleInsideNonAmbientExternalModule.symbols b/tests/baselines/reference/ambientExternalModuleInsideNonAmbientExternalModule.symbols index 10841ebc4cd..8ef83c37ebf 100644 --- a/tests/baselines/reference/ambientExternalModuleInsideNonAmbientExternalModule.symbols +++ b/tests/baselines/reference/ambientExternalModuleInsideNonAmbientExternalModule.symbols @@ -1,3 +1,4 @@ === tests/cases/conformance/ambient/ambientExternalModuleInsideNonAmbientExternalModule.ts === export declare module "M" { } -No type information for this code. \ No newline at end of file +>"M" : Symbol("M", Decl(ambientExternalModuleInsideNonAmbientExternalModule.ts, 0, 0)) + diff --git a/tests/baselines/reference/ambientExternalModuleInsideNonAmbientExternalModule.types b/tests/baselines/reference/ambientExternalModuleInsideNonAmbientExternalModule.types index 10841ebc4cd..9a4bb0c94ef 100644 --- a/tests/baselines/reference/ambientExternalModuleInsideNonAmbientExternalModule.types +++ b/tests/baselines/reference/ambientExternalModuleInsideNonAmbientExternalModule.types @@ -1,3 +1,4 @@ === tests/cases/conformance/ambient/ambientExternalModuleInsideNonAmbientExternalModule.ts === export declare module "M" { } -No type information for this code. \ No newline at end of file +>"M" : any + diff --git a/tests/baselines/reference/ambientExternalModuleMerging.symbols b/tests/baselines/reference/ambientExternalModuleMerging.symbols index 7fea7fea89f..b99157b1142 100644 --- a/tests/baselines/reference/ambientExternalModuleMerging.symbols +++ b/tests/baselines/reference/ambientExternalModuleMerging.symbols @@ -17,12 +17,16 @@ var y = M.y; === tests/cases/conformance/ambient/ambientExternalModuleMerging_declare.ts === declare module "M" { +>"M" : Symbol("M", Decl(ambientExternalModuleMerging_declare.ts, 0, 0), Decl(ambientExternalModuleMerging_declare.ts, 2, 1)) + export var x: string; >x : Symbol(x, Decl(ambientExternalModuleMerging_declare.ts, 1, 14)) } // Merge declare module "M" { +>"M" : Symbol("M", Decl(ambientExternalModuleMerging_declare.ts, 0, 0), Decl(ambientExternalModuleMerging_declare.ts, 2, 1)) + export var y: string; >y : Symbol(y, Decl(ambientExternalModuleMerging_declare.ts, 6, 14)) } diff --git a/tests/baselines/reference/ambientExternalModuleMerging.types b/tests/baselines/reference/ambientExternalModuleMerging.types index 1c1be0fd256..8150f6c6dfc 100644 --- a/tests/baselines/reference/ambientExternalModuleMerging.types +++ b/tests/baselines/reference/ambientExternalModuleMerging.types @@ -17,12 +17,16 @@ var y = M.y; === tests/cases/conformance/ambient/ambientExternalModuleMerging_declare.ts === declare module "M" { +>"M" : typeof "M" + export var x: string; >x : string } // Merge declare module "M" { +>"M" : typeof "M" + export var y: string; >y : string } diff --git a/tests/baselines/reference/ambientExternalModuleReopen.symbols b/tests/baselines/reference/ambientExternalModuleReopen.symbols index a2a1ba72fab..74bc430550b 100644 --- a/tests/baselines/reference/ambientExternalModuleReopen.symbols +++ b/tests/baselines/reference/ambientExternalModuleReopen.symbols @@ -1,9 +1,13 @@ === tests/cases/compiler/ambientExternalModuleReopen.ts === declare module "fs" { +>"fs" : Symbol("fs", Decl(ambientExternalModuleReopen.ts, 0, 0), Decl(ambientExternalModuleReopen.ts, 2, 1)) + var x: string; >x : Symbol(x, Decl(ambientExternalModuleReopen.ts, 1, 7)) } declare module 'fs' { +>'fs' : Symbol("fs", Decl(ambientExternalModuleReopen.ts, 0, 0), Decl(ambientExternalModuleReopen.ts, 2, 1)) + var y: number; >y : Symbol(y, Decl(ambientExternalModuleReopen.ts, 4, 7)) } diff --git a/tests/baselines/reference/ambientExternalModuleReopen.types b/tests/baselines/reference/ambientExternalModuleReopen.types index 842d634344c..dffba752e05 100644 --- a/tests/baselines/reference/ambientExternalModuleReopen.types +++ b/tests/baselines/reference/ambientExternalModuleReopen.types @@ -1,9 +1,13 @@ === tests/cases/compiler/ambientExternalModuleReopen.ts === declare module "fs" { +>"fs" : typeof "fs" + var x: string; >x : string } declare module 'fs' { +>'fs' : typeof "fs" + var y: number; >y : number } diff --git a/tests/baselines/reference/ambientExternalModuleWithInternalImportDeclaration.symbols b/tests/baselines/reference/ambientExternalModuleWithInternalImportDeclaration.symbols index d7e3b5925b1..621c7b3ebfc 100644 --- a/tests/baselines/reference/ambientExternalModuleWithInternalImportDeclaration.symbols +++ b/tests/baselines/reference/ambientExternalModuleWithInternalImportDeclaration.symbols @@ -9,6 +9,8 @@ var c = new A(); === tests/cases/compiler/ambientExternalModuleWithInternalImportDeclaration_0.ts === declare module 'M' { +>'M' : Symbol('M', Decl(ambientExternalModuleWithInternalImportDeclaration_0.ts, 0, 0)) + module C { >C : Symbol(C, Decl(ambientExternalModuleWithInternalImportDeclaration_0.ts, 0, 20), Decl(ambientExternalModuleWithInternalImportDeclaration_0.ts, 3, 5)) diff --git a/tests/baselines/reference/ambientExternalModuleWithInternalImportDeclaration.types b/tests/baselines/reference/ambientExternalModuleWithInternalImportDeclaration.types index 4e9043d1b75..17372294131 100644 --- a/tests/baselines/reference/ambientExternalModuleWithInternalImportDeclaration.types +++ b/tests/baselines/reference/ambientExternalModuleWithInternalImportDeclaration.types @@ -10,6 +10,8 @@ var c = new A(); === tests/cases/compiler/ambientExternalModuleWithInternalImportDeclaration_0.ts === declare module 'M' { +>'M' : typeof 'M' + module C { >C : typeof C diff --git a/tests/baselines/reference/ambientExternalModuleWithRelativeExternalImportDeclaration.symbols b/tests/baselines/reference/ambientExternalModuleWithRelativeExternalImportDeclaration.symbols index 1e8ad3c5fa5..3c7754d0135 100644 --- a/tests/baselines/reference/ambientExternalModuleWithRelativeExternalImportDeclaration.symbols +++ b/tests/baselines/reference/ambientExternalModuleWithRelativeExternalImportDeclaration.symbols @@ -1,5 +1,7 @@ === tests/cases/compiler/ambientExternalModuleWithRelativeExternalImportDeclaration.ts === declare module "OuterModule" { +>"OuterModule" : Symbol("OuterModule", Decl(ambientExternalModuleWithRelativeExternalImportDeclaration.ts, 0, 0)) + import m2 = require("./SubModule"); >m2 : Symbol(m2, Decl(ambientExternalModuleWithRelativeExternalImportDeclaration.ts, 0, 30)) diff --git a/tests/baselines/reference/ambientExternalModuleWithRelativeExternalImportDeclaration.types b/tests/baselines/reference/ambientExternalModuleWithRelativeExternalImportDeclaration.types index 0d173e5e7a9..4072b2fcedd 100644 --- a/tests/baselines/reference/ambientExternalModuleWithRelativeExternalImportDeclaration.types +++ b/tests/baselines/reference/ambientExternalModuleWithRelativeExternalImportDeclaration.types @@ -1,5 +1,7 @@ === tests/cases/compiler/ambientExternalModuleWithRelativeExternalImportDeclaration.ts === declare module "OuterModule" { +>"OuterModule" : typeof "OuterModule" + import m2 = require("./SubModule"); >m2 : any diff --git a/tests/baselines/reference/ambientExternalModuleWithRelativeModuleName.symbols b/tests/baselines/reference/ambientExternalModuleWithRelativeModuleName.symbols index a8ef371e805..350a84a0b4a 100644 --- a/tests/baselines/reference/ambientExternalModuleWithRelativeModuleName.symbols +++ b/tests/baselines/reference/ambientExternalModuleWithRelativeModuleName.symbols @@ -1,10 +1,14 @@ === tests/cases/compiler/ambientExternalModuleWithRelativeModuleName.ts === declare module "./relativeModule" { +>"./relativeModule" : Symbol("./relativeModule", Decl(ambientExternalModuleWithRelativeModuleName.ts, 0, 0)) + var x: string; >x : Symbol(x, Decl(ambientExternalModuleWithRelativeModuleName.ts, 1, 7)) } declare module ".\\relativeModule" { +>".\\relativeModule" : Symbol(".\\relativeModule", Decl(ambientExternalModuleWithRelativeModuleName.ts, 2, 1)) + var x: string; >x : Symbol(x, Decl(ambientExternalModuleWithRelativeModuleName.ts, 5, 7)) } diff --git a/tests/baselines/reference/ambientExternalModuleWithRelativeModuleName.types b/tests/baselines/reference/ambientExternalModuleWithRelativeModuleName.types index ab0f2b62f58..d585e8ed6a1 100644 --- a/tests/baselines/reference/ambientExternalModuleWithRelativeModuleName.types +++ b/tests/baselines/reference/ambientExternalModuleWithRelativeModuleName.types @@ -1,10 +1,14 @@ === tests/cases/compiler/ambientExternalModuleWithRelativeModuleName.ts === declare module "./relativeModule" { +>"./relativeModule" : typeof "./relativeModule" + var x: string; >x : string } declare module ".\\relativeModule" { +>".\\relativeModule" : typeof ".\\relativeModule" + var x: string; >x : string } diff --git a/tests/baselines/reference/ambientExternalModuleWithoutInternalImportDeclaration.symbols b/tests/baselines/reference/ambientExternalModuleWithoutInternalImportDeclaration.symbols index 15ddf4ac488..6827122959d 100644 --- a/tests/baselines/reference/ambientExternalModuleWithoutInternalImportDeclaration.symbols +++ b/tests/baselines/reference/ambientExternalModuleWithoutInternalImportDeclaration.symbols @@ -9,6 +9,8 @@ var c = new A(); === tests/cases/compiler/ambientExternalModuleWithoutInternalImportDeclaration_0.ts === declare module 'M' { +>'M' : Symbol('M', Decl(ambientExternalModuleWithoutInternalImportDeclaration_0.ts, 0, 0)) + module C { >C : Symbol(C, Decl(ambientExternalModuleWithoutInternalImportDeclaration_0.ts, 0, 20), Decl(ambientExternalModuleWithoutInternalImportDeclaration_0.ts, 3, 5)) diff --git a/tests/baselines/reference/ambientExternalModuleWithoutInternalImportDeclaration.types b/tests/baselines/reference/ambientExternalModuleWithoutInternalImportDeclaration.types index 0029817400b..c943603fb52 100644 --- a/tests/baselines/reference/ambientExternalModuleWithoutInternalImportDeclaration.types +++ b/tests/baselines/reference/ambientExternalModuleWithoutInternalImportDeclaration.types @@ -10,6 +10,8 @@ var c = new A(); === tests/cases/compiler/ambientExternalModuleWithoutInternalImportDeclaration_0.ts === declare module 'M' { +>'M' : typeof 'M' + module C { >C : typeof C diff --git a/tests/baselines/reference/ambientRequireFunction.symbols b/tests/baselines/reference/ambientRequireFunction.symbols index 11f91a66357..b2e94e89a2c 100644 --- a/tests/baselines/reference/ambientRequireFunction.symbols +++ b/tests/baselines/reference/ambientRequireFunction.symbols @@ -18,6 +18,8 @@ declare function require(moduleName: string): any; >moduleName : Symbol(moduleName, Decl(node.d.ts, 0, 25)) declare module "fs" { +>"fs" : Symbol("fs", Decl(node.d.ts, 0, 50)) + export function readFileSync(s: string): string; >readFileSync : Symbol(readFileSync, Decl(node.d.ts, 2, 21)) >s : Symbol(s, Decl(node.d.ts, 3, 33)) diff --git a/tests/baselines/reference/ambientRequireFunction.types b/tests/baselines/reference/ambientRequireFunction.types index 5ae9a85188c..ed34aa4309f 100644 --- a/tests/baselines/reference/ambientRequireFunction.types +++ b/tests/baselines/reference/ambientRequireFunction.types @@ -21,6 +21,8 @@ declare function require(moduleName: string): any; >moduleName : string declare module "fs" { +>"fs" : typeof "fs" + export function readFileSync(s: string): string; >readFileSync : (s: string) => string >s : string diff --git a/tests/baselines/reference/ambientShorthand.symbols b/tests/baselines/reference/ambientShorthand.symbols index 6747fd65173..c2231ac5c3d 100644 --- a/tests/baselines/reference/ambientShorthand.symbols +++ b/tests/baselines/reference/ambientShorthand.symbols @@ -18,7 +18,9 @@ foo(bar, baz, boom); === tests/cases/conformance/ambient/declarations.d.ts === declare module "jquery" -No type information for this code.// Semicolon is optional -No type information for this code.declare module "fs"; -No type information for this code. -No type information for this code. \ No newline at end of file +>"jquery" : Symbol("jquery", Decl(declarations.d.ts, 0, 0)) + +// Semicolon is optional +declare module "fs"; +>"fs" : Symbol("fs", Decl(declarations.d.ts, 0, 23)) + diff --git a/tests/baselines/reference/ambientShorthand.types b/tests/baselines/reference/ambientShorthand.types index 054349b1a6a..4c93cc7fd8f 100644 --- a/tests/baselines/reference/ambientShorthand.types +++ b/tests/baselines/reference/ambientShorthand.types @@ -19,7 +19,9 @@ foo(bar, baz, boom); === tests/cases/conformance/ambient/declarations.d.ts === declare module "jquery" -No type information for this code.// Semicolon is optional -No type information for this code.declare module "fs"; -No type information for this code. -No type information for this code. \ No newline at end of file +>"jquery" : any + +// Semicolon is optional +declare module "fs"; +>"fs" : any + diff --git a/tests/baselines/reference/ambientShorthand_declarationEmit.symbols b/tests/baselines/reference/ambientShorthand_declarationEmit.symbols index f1b3284b0f2..f1eabac0e9e 100644 --- a/tests/baselines/reference/ambientShorthand_declarationEmit.symbols +++ b/tests/baselines/reference/ambientShorthand_declarationEmit.symbols @@ -1,4 +1,4 @@ === tests/cases/conformance/ambient/ambientShorthand_declarationEmit.ts === declare module "foo"; -No type information for this code. -No type information for this code. \ No newline at end of file +>"foo" : Symbol("foo", Decl(ambientShorthand_declarationEmit.ts, 0, 0)) + diff --git a/tests/baselines/reference/ambientShorthand_declarationEmit.types b/tests/baselines/reference/ambientShorthand_declarationEmit.types index f1b3284b0f2..c5c8411bb03 100644 --- a/tests/baselines/reference/ambientShorthand_declarationEmit.types +++ b/tests/baselines/reference/ambientShorthand_declarationEmit.types @@ -1,4 +1,4 @@ === tests/cases/conformance/ambient/ambientShorthand_declarationEmit.ts === declare module "foo"; -No type information for this code. -No type information for this code. \ No newline at end of file +>"foo" : any + diff --git a/tests/baselines/reference/ambientShorthand_duplicate.symbols b/tests/baselines/reference/ambientShorthand_duplicate.symbols index 05856b47b92..6d5716a193c 100644 --- a/tests/baselines/reference/ambientShorthand_duplicate.symbols +++ b/tests/baselines/reference/ambientShorthand_duplicate.symbols @@ -6,5 +6,5 @@ import foo from "foo"; === tests/cases/conformance/ambient/declarations1.d.ts === declare module "foo"; -No type information for this code. -No type information for this code. \ No newline at end of file +>"foo" : Symbol("foo", Decl(declarations1.d.ts, 0, 0)) + diff --git a/tests/baselines/reference/ambientShorthand_duplicate.types b/tests/baselines/reference/ambientShorthand_duplicate.types index 1520c5447ec..8abf9f7b230 100644 --- a/tests/baselines/reference/ambientShorthand_duplicate.types +++ b/tests/baselines/reference/ambientShorthand_duplicate.types @@ -6,5 +6,5 @@ import foo from "foo"; === tests/cases/conformance/ambient/declarations1.d.ts === declare module "foo"; -No type information for this code. -No type information for this code. \ No newline at end of file +>"foo" : any + diff --git a/tests/baselines/reference/ambientShorthand_merging.symbols b/tests/baselines/reference/ambientShorthand_merging.symbols index 8a0ca5acb74..d37bdb06078 100644 --- a/tests/baselines/reference/ambientShorthand_merging.symbols +++ b/tests/baselines/reference/ambientShorthand_merging.symbols @@ -7,5 +7,5 @@ import foo, {bar} from "foo"; === tests/cases/conformance/ambient/declarations1.d.ts === declare module "foo"; -No type information for this code. -No type information for this code. \ No newline at end of file +>"foo" : Symbol("foo", Decl(declarations1.d.ts, 0, 0)) + diff --git a/tests/baselines/reference/ambientShorthand_merging.types b/tests/baselines/reference/ambientShorthand_merging.types index 78390a35dd8..ad9827f47eb 100644 --- a/tests/baselines/reference/ambientShorthand_merging.types +++ b/tests/baselines/reference/ambientShorthand_merging.types @@ -7,5 +7,5 @@ import foo, {bar} from "foo"; === tests/cases/conformance/ambient/declarations1.d.ts === declare module "foo"; -No type information for this code. -No type information for this code. \ No newline at end of file +>"foo" : any + diff --git a/tests/baselines/reference/ambientShorthand_reExport.symbols b/tests/baselines/reference/ambientShorthand_reExport.symbols index 1e8d5318011..3aa3ddcec3d 100644 --- a/tests/baselines/reference/ambientShorthand_reExport.symbols +++ b/tests/baselines/reference/ambientShorthand_reExport.symbols @@ -1,7 +1,8 @@ === tests/cases/conformance/ambient/declarations.d.ts === declare module "jquery"; -No type information for this code. -No type information for this code.=== tests/cases/conformance/ambient/reExportX.ts === +>"jquery" : Symbol("jquery", Decl(declarations.d.ts, 0, 0)) + +=== tests/cases/conformance/ambient/reExportX.ts === export {x} from "jquery"; >x : Symbol(x, Decl(reExportX.ts, 0, 8)) diff --git a/tests/baselines/reference/ambientShorthand_reExport.types b/tests/baselines/reference/ambientShorthand_reExport.types index 5765c7e0331..e3e6c9742fd 100644 --- a/tests/baselines/reference/ambientShorthand_reExport.types +++ b/tests/baselines/reference/ambientShorthand_reExport.types @@ -1,7 +1,8 @@ === tests/cases/conformance/ambient/declarations.d.ts === declare module "jquery"; -No type information for this code. -No type information for this code.=== tests/cases/conformance/ambient/reExportX.ts === +>"jquery" : any + +=== tests/cases/conformance/ambient/reExportX.ts === export {x} from "jquery"; >x : any diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 5e413f16d87..370d841a7f1 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -477,6 +477,8 @@ declare namespace ts { type AtToken = Token; type ReadonlyToken = Token; type AwaitKeywordToken = Token; + type PlusToken = Token; + type MinusToken = Token; type Modifier = Token | Token | Token | Token | Token | Token | Token | Token | Token | Token | Token; type ModifiersArray = NodeArray; interface Identifier extends PrimaryExpression, Declaration { @@ -650,10 +652,12 @@ declare namespace ts { } interface MethodSignature extends SignatureDeclarationBase, TypeElement { kind: SyntaxKind.MethodSignature; + parent?: ClassLikeDeclaration | InterfaceDeclaration | TypeLiteralNode; name: PropertyName; } interface MethodDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.MethodDeclaration; + parent?: ClassLikeDeclaration | ObjectLiteralExpression; name: PropertyName; body?: FunctionBody; } @@ -764,9 +768,9 @@ declare namespace ts { } interface MappedTypeNode extends TypeNode, Declaration { kind: SyntaxKind.MappedType; - readonlyToken?: ReadonlyToken; + readonlyToken?: ReadonlyToken | PlusToken | MinusToken; typeParameter: TypeParameterDeclaration; - questionToken?: QuestionToken; + questionToken?: QuestionToken | PlusToken | MinusToken; type?: TypeNode; } interface LiteralTypeNode extends TypeNode { @@ -776,6 +780,7 @@ declare namespace ts { interface StringLiteral extends LiteralExpression { kind: SyntaxKind.StringLiteral; } + type StringLiteralLike = StringLiteral | NoSubstitutionTemplateLiteral; interface Expression extends Node { _expressionBrand: any; } @@ -1838,6 +1843,7 @@ declare namespace ts { InObjectTypeLiteral = 4194304, InTypeAlias = 8388608, InInitialEntityName = 16777216, + InReverseMappedType = 33554432, } enum TypeFormatFlags { None = 0, @@ -2373,15 +2379,6 @@ declare namespace ts { exclude?: string[]; [option: string]: string[] | boolean | undefined; } - interface DiscoverTypingsInfo { - fileNames: string[]; - projectRootPath: string; - safeListPath: string; - packageNameToTypingLocation: Map; - typeAcquisition: TypeAcquisition; - compilerOptions: CompilerOptions; - unresolvedImports: ReadonlyArray; - } enum ModuleKind { None = 0, CommonJS = 1, @@ -2775,6 +2772,9 @@ declare namespace ts { span: TextSpan; newLength: number; } + interface SortedArray extends Array { + " __sortedArrayBrand": any; + } interface SyntaxList extends Node { _children: Node[]; } @@ -3214,6 +3214,7 @@ declare namespace ts { /** * True if node is of some token syntax kind. * For example, this is true for an IfKeyword but not for an IfStatement. + * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. */ function isToken(n: Node): boolean; function isLiteralExpression(node: Node): node is LiteralExpression; @@ -3249,6 +3250,7 @@ declare namespace ts { function isSetAccessor(node: Node): node is SetAccessorDeclaration; function isGetAccessor(node: Node): node is GetAccessorDeclaration; function isObjectLiteralElement(node: Node): node is ObjectLiteralElement; + function isStringLiteralLike(node: Node): node is StringLiteralLike; } declare namespace ts { type ErrorCallback = (message: DiagnosticMessage, length: number) => void; @@ -3517,8 +3519,8 @@ declare namespace ts { function updateTypeOperatorNode(node: TypeOperatorNode, type: TypeNode): TypeOperatorNode; function createIndexedAccessTypeNode(objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode; function updateIndexedAccessTypeNode(node: IndexedAccessTypeNode, objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode; - function createMappedTypeNode(readonlyToken: ReadonlyToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | undefined, type: TypeNode | undefined): MappedTypeNode; - function updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | undefined, type: TypeNode | undefined): MappedTypeNode; + function createMappedTypeNode(readonlyToken: ReadonlyToken | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined): MappedTypeNode; + function updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyToken | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined): MappedTypeNode; function createLiteralTypeNode(literal: LiteralTypeNode["literal"]): LiteralTypeNode; function updateLiteralTypeNode(node: LiteralTypeNode, literal: LiteralTypeNode["literal"]): LiteralTypeNode; function createObjectBindingPattern(elements: ReadonlyArray): ObjectBindingPattern; @@ -4854,9 +4856,6 @@ declare namespace ts.server { trace?(s: string): void; require?(initialPath: string, moduleName: string): RequireResult; } - interface SortedArray extends Array { - " __sortedArrayBrand": any; - } interface SortedReadonlyArray extends ReadonlyArray { " __sortedArrayBrand": any; } @@ -7444,6 +7443,7 @@ declare namespace ts.server { private plugins; private cachedUnresolvedImportsPerFile; private lastCachedUnresolvedImportsList; + private lastFileExceededProgramSize; protected languageService: LanguageService; languageServiceEnabled: boolean; readonly trace?: (s: string) => void; @@ -7518,7 +7518,7 @@ declare namespace ts.server { */ emitFile(scriptInfo: ScriptInfo, writeFile: (path: string, data: string, writeByteOrderMark?: boolean) => void): boolean; enableLanguageService(): void; - disableLanguageService(): void; + disableLanguageService(lastFileExceededProgramSize?: string): void; getProjectName(): string; abstract getTypeAcquisition(): TypeAcquisition; protected removeLocalTypingsFromTypeAcquisition(newTypeAcquisition: TypeAcquisition): TypeAcquisition; @@ -7548,7 +7548,6 @@ declare namespace ts.server { */ updateGraph(): boolean; protected removeExistingTypings(include: string[]): string[]; - private setTypings(typings); private updateGraphWorker(); private detachScriptInfoFromProject(uncheckedFileName); private addMissingFileWatcher(missingFilePath); @@ -7784,9 +7783,7 @@ declare namespace ts.server { private readonly hostConfiguration; private safelist; private legacySafelist; - private changedFiles; private pendingProjectUpdates; - private pendingInferredProjectUpdate; readonly currentDirectory: string; readonly toCanonicalFileName: (f: string) => string; readonly host: ServerHost; @@ -7808,7 +7805,7 @@ declare namespace ts.server { toPath(fileName: string): Path; private loadTypesMap(); updateTypingsForProject(response: SetTypings | InvalidateCachedTypings | PackageInstalledResponse): void; - private delayInferredProjectsRefresh(); + private delayEnsureProjectForOpenFiles(); private delayUpdateProjectGraph(project); private sendProjectsUpdatedInBackgroundEvent(); private delayUpdateProjectGraphs(projects); @@ -7819,17 +7816,13 @@ declare namespace ts.server { /** * Ensures the project structures are upto date * This means, - * - if there are changedFiles (the files were updated but their containing project graph was not upto date), - * their project graph is updated - * - If there are pendingProjectUpdates (scheduled to be updated with delay so they can batch update the graph if there are several changes in short time span) - * their project graph is updated - * - If there were project graph updates and/or there was pending inferred project update and/or called forced the inferred project structure refresh - * Inferred projects are created/updated/deleted based on open files states - * @param forceInferredProjectsRefresh when true updates the inferred projects even if there is no pending work to update the files/project structures + * - we go through all the projects and update them if they are dirty + * - if updates reflect some change in structure or there was pending request to ensure projects for open files + * ensure that each open script info has project */ - private ensureProjectStructuresUptoDate(forceInferredProjectsRefresh?); + private ensureProjectStructuresUptoDate(); + private updateProjectIfDirty(project); getFormatCodeOptions(file?: NormalizedPath): FormatCodeSettings; - private updateProjectGraphs(projects); private onSourceFileChanged(fileName, eventKind); private handleDeletedFile(info); private onConfigChangedForConfiguredProject(project, eventKind); @@ -7891,7 +7884,8 @@ declare namespace ts.server { private getConfiguredProjectByCanonicalConfigFilePath(canonicalConfigFilePath); private findExternalProjectByProjectName(projectFileName); private convertConfigFileContentToProjectOptions(configFilename, cachedDirectoryStructureHost); - private exceededTotalSizeLimitForNonTsFiles(name, options, fileNames, propertyReader); + /** Get a filename if the language service exceeds the maximum allowed program size; otherwise returns undefined. */ + private getFilenameForExceededTotalSizeLimitForNonTsFiles(name, options, fileNames, propertyReader); private createExternalProject(projectFileName, files, options, typeAcquisition, excludedFiles); private sendProjectTelemetry(projectKey, project, projectOptions?); private addFilesToNonInferredProjectAndUpdateGraph(project, files, propertyReader, typeAcquisition); @@ -7941,7 +7935,7 @@ declare namespace ts.server { * This will go through open files and assign them to inferred project if open file is not part of any other project * After that all the inferred project graphs are updated */ - private refreshInferredProjects(); + private ensureProjectForOpenFiles(); /** * Open file whose contents is managed by the client * @param filename is absolute pathname @@ -7957,14 +7951,14 @@ declare namespace ts.server { closeClientFile(uncheckedFileName: string): void; private collectChanges(lastKnownProjectVersions, currentProjects, result); private closeConfiguredProjectReferencedFromExternalProject(configFile); - closeExternalProject(uncheckedFileName: string, suppressRefresh?: boolean): void; + closeExternalProject(uncheckedFileName: string): void; openExternalProjects(projects: protocol.ExternalProject[]): void; /** Makes a filename safe to insert in a RegExp */ private static readonly filenameEscapeRegexp; private static escapeFilenameForRegex(filename); resetSafeList(): void; applySafeList(proj: protocol.ExternalProject): NormalizedPath[]; - openExternalProject(proj: protocol.ExternalProject, suppressRefreshOfInferredProjects?: boolean): void; + openExternalProject(proj: protocol.ExternalProject): void; } } diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 3a1fa35146c..baed457b3b0 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -477,6 +477,8 @@ declare namespace ts { type AtToken = Token; type ReadonlyToken = Token; type AwaitKeywordToken = Token; + type PlusToken = Token; + type MinusToken = Token; type Modifier = Token | Token | Token | Token | Token | Token | Token | Token | Token | Token | Token; type ModifiersArray = NodeArray; interface Identifier extends PrimaryExpression, Declaration { @@ -650,10 +652,12 @@ declare namespace ts { } interface MethodSignature extends SignatureDeclarationBase, TypeElement { kind: SyntaxKind.MethodSignature; + parent?: ClassLikeDeclaration | InterfaceDeclaration | TypeLiteralNode; name: PropertyName; } interface MethodDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.MethodDeclaration; + parent?: ClassLikeDeclaration | ObjectLiteralExpression; name: PropertyName; body?: FunctionBody; } @@ -764,9 +768,9 @@ declare namespace ts { } interface MappedTypeNode extends TypeNode, Declaration { kind: SyntaxKind.MappedType; - readonlyToken?: ReadonlyToken; + readonlyToken?: ReadonlyToken | PlusToken | MinusToken; typeParameter: TypeParameterDeclaration; - questionToken?: QuestionToken; + questionToken?: QuestionToken | PlusToken | MinusToken; type?: TypeNode; } interface LiteralTypeNode extends TypeNode { @@ -776,6 +780,7 @@ declare namespace ts { interface StringLiteral extends LiteralExpression { kind: SyntaxKind.StringLiteral; } + type StringLiteralLike = StringLiteral | NoSubstitutionTemplateLiteral; interface Expression extends Node { _expressionBrand: any; } @@ -1838,6 +1843,7 @@ declare namespace ts { InObjectTypeLiteral = 4194304, InTypeAlias = 8388608, InInitialEntityName = 16777216, + InReverseMappedType = 33554432, } enum TypeFormatFlags { None = 0, @@ -2373,15 +2379,6 @@ declare namespace ts { exclude?: string[]; [option: string]: string[] | boolean | undefined; } - interface DiscoverTypingsInfo { - fileNames: string[]; - projectRootPath: string; - safeListPath: string; - packageNameToTypingLocation: Map; - typeAcquisition: TypeAcquisition; - compilerOptions: CompilerOptions; - unresolvedImports: ReadonlyArray; - } enum ModuleKind { None = 0, CommonJS = 1, @@ -2775,6 +2772,9 @@ declare namespace ts { span: TextSpan; newLength: number; } + interface SortedArray extends Array { + " __sortedArrayBrand": any; + } interface SyntaxList extends Node { _children: Node[]; } @@ -3269,6 +3269,7 @@ declare namespace ts { /** * True if node is of some token syntax kind. * For example, this is true for an IfKeyword but not for an IfStatement. + * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. */ function isToken(n: Node): boolean; function isLiteralExpression(node: Node): node is LiteralExpression; @@ -3304,6 +3305,7 @@ declare namespace ts { function isSetAccessor(node: Node): node is SetAccessorDeclaration; function isGetAccessor(node: Node): node is GetAccessorDeclaration; function isObjectLiteralElement(node: Node): node is ObjectLiteralElement; + function isStringLiteralLike(node: Node): node is StringLiteralLike; } declare namespace ts { function createNode(kind: SyntaxKind, pos?: number, end?: number): Node; @@ -3464,8 +3466,8 @@ declare namespace ts { function updateTypeOperatorNode(node: TypeOperatorNode, type: TypeNode): TypeOperatorNode; function createIndexedAccessTypeNode(objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode; function updateIndexedAccessTypeNode(node: IndexedAccessTypeNode, objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode; - function createMappedTypeNode(readonlyToken: ReadonlyToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | undefined, type: TypeNode | undefined): MappedTypeNode; - function updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | undefined, type: TypeNode | undefined): MappedTypeNode; + function createMappedTypeNode(readonlyToken: ReadonlyToken | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined): MappedTypeNode; + function updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyToken | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined): MappedTypeNode; function createLiteralTypeNode(literal: LiteralTypeNode["literal"]): LiteralTypeNode; function updateLiteralTypeNode(node: LiteralTypeNode, literal: LiteralTypeNode["literal"]): LiteralTypeNode; function createObjectBindingPattern(elements: ReadonlyArray): ObjectBindingPattern; diff --git a/tests/baselines/reference/arityAndOrderCompatibility01.symbols b/tests/baselines/reference/arityAndOrderCompatibility01.symbols index 3a5d55dc1e6..16c1118738e 100644 --- a/tests/baselines/reference/arityAndOrderCompatibility01.symbols +++ b/tests/baselines/reference/arityAndOrderCompatibility01.symbols @@ -4,7 +4,11 @@ interface StrNum extends Array { >Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) 0: string; +>0 : Symbol(StrNum[0], Decl(arityAndOrderCompatibility01.ts, 0, 47)) + 1: number; +>1 : Symbol(StrNum[1], Decl(arityAndOrderCompatibility01.ts, 1, 14)) + length: 2; >length : Symbol(StrNum.length, Decl(arityAndOrderCompatibility01.ts, 2, 14)) } @@ -20,7 +24,11 @@ var z: { >z : Symbol(z, Decl(arityAndOrderCompatibility01.ts, 8, 3)) 0: string; +>0 : Symbol(0, Decl(arityAndOrderCompatibility01.ts, 8, 8)) + 1: number; +>1 : Symbol(1, Decl(arityAndOrderCompatibility01.ts, 9, 14)) + length: 2; >length : Symbol(length, Decl(arityAndOrderCompatibility01.ts, 10, 14)) } diff --git a/tests/baselines/reference/arityAndOrderCompatibility01.types b/tests/baselines/reference/arityAndOrderCompatibility01.types index 80e91fbd2e7..6fdbab7a587 100644 --- a/tests/baselines/reference/arityAndOrderCompatibility01.types +++ b/tests/baselines/reference/arityAndOrderCompatibility01.types @@ -4,7 +4,11 @@ interface StrNum extends Array { >Array : T[] 0: string; +>0 : string + 1: number; +>1 : number + length: 2; >length : 2 } @@ -20,7 +24,11 @@ var z: { >z : { 0: string; 1: number; length: 2; } 0: string; +>0 : string + 1: number; +>1 : number + length: 2; >length : 2 } diff --git a/tests/baselines/reference/arrayLiterals3.symbols b/tests/baselines/reference/arrayLiterals3.symbols index 8a94e9ee462..d1773ef97d7 100644 --- a/tests/baselines/reference/arrayLiterals3.symbols +++ b/tests/baselines/reference/arrayLiterals3.symbols @@ -38,7 +38,10 @@ interface tup { >tup : Symbol(tup, Decl(arrayLiterals3.ts, 23, 67)) 0: number[]|string[]; +>0 : Symbol(tup[0], Decl(arrayLiterals3.ts, 25, 15)) + 1: number[]|string[]; +>1 : Symbol(tup[1], Decl(arrayLiterals3.ts, 26, 25)) } interface myArray extends Array { } >myArray : Symbol(myArray, Decl(arrayLiterals3.ts, 28, 1)) diff --git a/tests/baselines/reference/arrayLiterals3.types b/tests/baselines/reference/arrayLiterals3.types index 926f1448a44..7d890f38fb4 100644 --- a/tests/baselines/reference/arrayLiterals3.types +++ b/tests/baselines/reference/arrayLiterals3.types @@ -64,7 +64,10 @@ interface tup { >tup : tup 0: number[]|string[]; +>0 : number[] | string[] + 1: number[]|string[]; +>1 : number[] | string[] } interface myArray extends Array { } >myArray : myArray diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembersNumericNames.symbols b/tests/baselines/reference/assignmentCompatWithObjectMembersNumericNames.symbols index ce633683339..4bd6397936d 100644 --- a/tests/baselines/reference/assignmentCompatWithObjectMembersNumericNames.symbols +++ b/tests/baselines/reference/assignmentCompatWithObjectMembersNumericNames.symbols @@ -4,9 +4,11 @@ class S { 1: string; } >S : Symbol(S, Decl(assignmentCompatWithObjectMembersNumericNames.ts, 0, 0)) +>1 : Symbol(S[1], Decl(assignmentCompatWithObjectMembersNumericNames.ts, 3, 9)) class T { 1.: string; } >T : Symbol(T, Decl(assignmentCompatWithObjectMembersNumericNames.ts, 3, 22)) +>1. : Symbol(T[1.], Decl(assignmentCompatWithObjectMembersNumericNames.ts, 4, 9)) var s: S; >s : Symbol(s, Decl(assignmentCompatWithObjectMembersNumericNames.ts, 5, 3)) @@ -18,10 +20,12 @@ var t: T; interface S2 { 1: string; bar?: string } >S2 : Symbol(S2, Decl(assignmentCompatWithObjectMembersNumericNames.ts, 6, 9)) +>1 : Symbol(S2[1], Decl(assignmentCompatWithObjectMembersNumericNames.ts, 8, 14)) >bar : Symbol(S2.bar, Decl(assignmentCompatWithObjectMembersNumericNames.ts, 8, 25)) interface T2 { 1.0: string; baz?: string } >T2 : Symbol(T2, Decl(assignmentCompatWithObjectMembersNumericNames.ts, 8, 40)) +>1.0 : Symbol(T2[1.0], Decl(assignmentCompatWithObjectMembersNumericNames.ts, 9, 14)) >baz : Symbol(T2.baz, Decl(assignmentCompatWithObjectMembersNumericNames.ts, 9, 27)) var s2: S2; @@ -34,17 +38,21 @@ var t2: T2; var a: { 1.: string; bar?: string } >a : Symbol(a, Decl(assignmentCompatWithObjectMembersNumericNames.ts, 13, 3)) +>1. : Symbol(1., Decl(assignmentCompatWithObjectMembersNumericNames.ts, 13, 8)) >bar : Symbol(bar, Decl(assignmentCompatWithObjectMembersNumericNames.ts, 13, 20)) var b: { 1.0: string; baz?: string } >b : Symbol(b, Decl(assignmentCompatWithObjectMembersNumericNames.ts, 14, 3)) +>1.0 : Symbol(1.0, Decl(assignmentCompatWithObjectMembersNumericNames.ts, 14, 8)) >baz : Symbol(baz, Decl(assignmentCompatWithObjectMembersNumericNames.ts, 14, 21)) var a2 = { 1.0: '' }; >a2 : Symbol(a2, Decl(assignmentCompatWithObjectMembersNumericNames.ts, 16, 3)) +>1.0 : Symbol(1.0, Decl(assignmentCompatWithObjectMembersNumericNames.ts, 16, 10)) var b2 = { 1: '' }; >b2 : Symbol(b2, Decl(assignmentCompatWithObjectMembersNumericNames.ts, 17, 3)) +>1 : Symbol(1, Decl(assignmentCompatWithObjectMembersNumericNames.ts, 17, 10)) s = t; >s : Symbol(s, Decl(assignmentCompatWithObjectMembersNumericNames.ts, 5, 3)) diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembersNumericNames.types b/tests/baselines/reference/assignmentCompatWithObjectMembersNumericNames.types index 0c44316d324..aea92a9aa3f 100644 --- a/tests/baselines/reference/assignmentCompatWithObjectMembersNumericNames.types +++ b/tests/baselines/reference/assignmentCompatWithObjectMembersNumericNames.types @@ -4,9 +4,11 @@ class S { 1: string; } >S : S +>1 : string class T { 1.: string; } >T : T +>1. : string var s: S; >s : S @@ -18,10 +20,12 @@ var t: T; interface S2 { 1: string; bar?: string } >S2 : S2 +>1 : string >bar : string interface T2 { 1.0: string; baz?: string } >T2 : T2 +>1.0 : string >baz : string var s2: S2; @@ -34,20 +38,24 @@ var t2: T2; var a: { 1.: string; bar?: string } >a : { 1.: string; bar?: string; } +>1. : string >bar : string var b: { 1.0: string; baz?: string } >b : { 1.0: string; baz?: string; } +>1.0 : string >baz : string var a2 = { 1.0: '' }; >a2 : { 1.0: string; } >{ 1.0: '' } : { 1.0: string; } +>1.0 : string >'' : "" var b2 = { 1: '' }; >b2 : { 1: string; } >{ 1: '' } : { 1: string; } +>1 : string >'' : "" s = t; diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembersStringNumericNames.symbols b/tests/baselines/reference/assignmentCompatWithObjectMembersStringNumericNames.symbols index b33dd82f99a..a55c665b085 100644 --- a/tests/baselines/reference/assignmentCompatWithObjectMembersStringNumericNames.symbols +++ b/tests/baselines/reference/assignmentCompatWithObjectMembersStringNumericNames.symbols @@ -7,9 +7,11 @@ module JustStrings { class S { '1': string; } >S : Symbol(S, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 3, 20)) +>'1' : Symbol(S['1'], Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 4, 13)) class T { '1.': string; } >T : Symbol(T, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 4, 28)) +>'1.' : Symbol(T['1.'], Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 5, 13)) var s: S; >s : Symbol(s, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 6, 7)) @@ -21,10 +23,12 @@ module JustStrings { interface S2 { '1': string; bar?: string } >S2 : Symbol(S2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 7, 13)) +>'1' : Symbol(S2['1'], Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 9, 18)) >bar : Symbol(S2.bar, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 9, 31)) interface T2 { '1.0': string; baz?: string } >T2 : Symbol(T2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 9, 46)) +>'1.0' : Symbol(T2['1.0'], Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 10, 18)) >baz : Symbol(T2.baz, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 10, 33)) var s2: S2; @@ -37,17 +41,21 @@ module JustStrings { var a: { '1.': string; bar?: string } >a : Symbol(a, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 14, 7)) +>'1.' : Symbol('1.', Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 14, 12)) >bar : Symbol(bar, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 14, 26)) var b: { '1.0': string; baz?: string } >b : Symbol(b, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 15, 7)) +>'1.0' : Symbol('1.0', Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 15, 12)) >baz : Symbol(baz, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 15, 27)) var a2 = { '1.0': '' }; >a2 : Symbol(a2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 17, 7)) +>'1.0' : Symbol('1.0', Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 17, 14)) var b2 = { '1': '' }; >b2 : Symbol(b2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 18, 7)) +>'1' : Symbol('1', Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 18, 14)) s = t; >s : Symbol(s, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 6, 7)) @@ -131,9 +139,11 @@ module NumbersAndStrings { class S { '1': string; } >S : Symbol(S, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 44, 26)) +>'1' : Symbol(S['1'], Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 45, 13)) class T { 1: string; } >T : Symbol(T, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 45, 28)) +>1 : Symbol(T[1], Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 46, 13)) var s: S; >s : Symbol(s, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 47, 7)) @@ -145,10 +155,12 @@ module NumbersAndStrings { interface S2 { '1': string; bar?: string } >S2 : Symbol(S2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 48, 13)) +>'1' : Symbol(S2['1'], Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 50, 18)) >bar : Symbol(S2.bar, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 50, 31)) interface T2 { 1.0: string; baz?: string } >T2 : Symbol(T2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 50, 46)) +>1.0 : Symbol(T2[1.0], Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 51, 18)) >baz : Symbol(T2.baz, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 51, 31)) var s2: S2; @@ -161,17 +173,21 @@ module NumbersAndStrings { var a: { '1.': string; bar?: string } >a : Symbol(a, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 55, 7)) +>'1.' : Symbol('1.', Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 55, 12)) >bar : Symbol(bar, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 55, 26)) var b: { 1.0: string; baz?: string } >b : Symbol(b, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 56, 7)) +>1.0 : Symbol(1.0, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 56, 12)) >baz : Symbol(baz, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 56, 25)) var a2 = { '1.0': '' }; >a2 : Symbol(a2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 58, 7)) +>'1.0' : Symbol('1.0', Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 58, 14)) var b2 = { 1.: '' }; >b2 : Symbol(b2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 59, 7)) +>1. : Symbol(1., Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 59, 14)) s = t; // ok >s : Symbol(s, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 47, 7)) diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembersStringNumericNames.types b/tests/baselines/reference/assignmentCompatWithObjectMembersStringNumericNames.types index 6d021b024cb..a8be024ca60 100644 --- a/tests/baselines/reference/assignmentCompatWithObjectMembersStringNumericNames.types +++ b/tests/baselines/reference/assignmentCompatWithObjectMembersStringNumericNames.types @@ -7,9 +7,11 @@ module JustStrings { class S { '1': string; } >S : S +>'1' : string class T { '1.': string; } >T : T +>'1.' : string var s: S; >s : S @@ -21,10 +23,12 @@ module JustStrings { interface S2 { '1': string; bar?: string } >S2 : S2 +>'1' : string >bar : string interface T2 { '1.0': string; baz?: string } >T2 : T2 +>'1.0' : string >baz : string var s2: S2; @@ -37,20 +41,24 @@ module JustStrings { var a: { '1.': string; bar?: string } >a : { '1.': string; bar?: string; } +>'1.' : string >bar : string var b: { '1.0': string; baz?: string } >b : { '1.0': string; baz?: string; } +>'1.0' : string >baz : string var a2 = { '1.0': '' }; >a2 : { '1.0': string; } >{ '1.0': '' } : { '1.0': string; } +>'1.0' : string >'' : "" var b2 = { '1': '' }; >b2 : { '1': string; } >{ '1': '' } : { '1': string; } +>'1' : string >'' : "" s = t; @@ -154,9 +162,11 @@ module NumbersAndStrings { class S { '1': string; } >S : S +>'1' : string class T { 1: string; } >T : T +>1 : string var s: S; >s : S @@ -168,10 +178,12 @@ module NumbersAndStrings { interface S2 { '1': string; bar?: string } >S2 : S2 +>'1' : string >bar : string interface T2 { 1.0: string; baz?: string } >T2 : T2 +>1.0 : string >baz : string var s2: S2; @@ -184,20 +196,24 @@ module NumbersAndStrings { var a: { '1.': string; bar?: string } >a : { '1.': string; bar?: string; } +>'1.' : string >bar : string var b: { 1.0: string; baz?: string } >b : { 1.0: string; baz?: string; } +>1.0 : string >baz : string var a2 = { '1.0': '' }; >a2 : { '1.0': string; } >{ '1.0': '' } : { '1.0': string; } +>'1.0' : string >'' : "" var b2 = { 1.: '' }; >b2 : { 1.: string; } >{ 1.: '' } : { 1.: string; } +>1. : string >'' : "" s = t; // ok diff --git a/tests/baselines/reference/asyncAwait_es2017.js b/tests/baselines/reference/asyncAwait_es2017.js index 314c99fa210..70a4c63be2e 100644 --- a/tests/baselines/reference/asyncAwait_es2017.js +++ b/tests/baselines/reference/asyncAwait_es2017.js @@ -14,7 +14,7 @@ let f6 = async function(): MyPromise { } let f7 = async () => { }; let f8 = async (): Promise => { }; -let f9 = async (): MyPromise => { }; +let f9 = async (): MyPromise => { }; let f10 = async () => p; let f11 = async () => mp; let f12 = async (): Promise => mp; @@ -37,6 +37,13 @@ class C { module M { export async function f1() { } +} + +async function f14() { + block: { + await 1; + break block; + } } //// [asyncAwait_es2017.js] @@ -71,3 +78,9 @@ var M; async function f1() { } M.f1 = f1; })(M || (M = {})); +async function f14() { + block: { + await 1; + break block; + } +} diff --git a/tests/baselines/reference/asyncAwait_es2017.symbols b/tests/baselines/reference/asyncAwait_es2017.symbols index 0f302638276..8d8a23011c7 100644 --- a/tests/baselines/reference/asyncAwait_es2017.symbols +++ b/tests/baselines/reference/asyncAwait_es2017.symbols @@ -46,7 +46,7 @@ let f8 = async (): Promise => { }; >f8 : Symbol(f8, Decl(asyncAwait_es2017.ts, 14, 3)) >Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) -let f9 = async (): MyPromise => { }; +let f9 = async (): MyPromise => { }; >f9 : Symbol(f9, Decl(asyncAwait_es2017.ts, 15, 3)) >MyPromise : Symbol(MyPromise, Decl(asyncAwait_es2017.ts, 0, 0), Decl(asyncAwait_es2017.ts, 1, 11)) @@ -116,3 +116,12 @@ module M { export async function f1() { } >f1 : Symbol(f1, Decl(asyncAwait_es2017.ts, 36, 10)) } + +async function f14() { +>f14 : Symbol(f14, Decl(asyncAwait_es2017.ts, 38, 1)) + + block: { + await 1; + break block; + } +} diff --git a/tests/baselines/reference/asyncAwait_es2017.types b/tests/baselines/reference/asyncAwait_es2017.types index a1226d0cbfe..42b54aa56be 100644 --- a/tests/baselines/reference/asyncAwait_es2017.types +++ b/tests/baselines/reference/asyncAwait_es2017.types @@ -51,7 +51,7 @@ let f8 = async (): Promise => { }; >async (): Promise => { } : () => Promise >Promise : Promise -let f9 = async (): MyPromise => { }; +let f9 = async (): MyPromise => { }; >f9 : () => Promise >async (): MyPromise => { } : () => Promise >MyPromise : Promise @@ -127,3 +127,18 @@ module M { export async function f1() { } >f1 : () => Promise } + +async function f14() { +>f14 : () => Promise + + block: { +>block : any + + await 1; +>await 1 : 1 +>1 : 1 + + break block; +>block : any + } +} diff --git a/tests/baselines/reference/asyncAwait_es5.js b/tests/baselines/reference/asyncAwait_es5.js index 653082be8d6..6434ae5a766 100644 --- a/tests/baselines/reference/asyncAwait_es5.js +++ b/tests/baselines/reference/asyncAwait_es5.js @@ -37,6 +37,13 @@ class C { module M { export async function f1() { } +} + +async function f14() { + block: { + await 1; + break block; + } } //// [asyncAwait_es5.js] @@ -188,3 +195,16 @@ var M; } M.f1 = f1; })(M || (M = {})); +function f14() { + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, 1]; + case 1: + _a.sent(); + return [3 /*break*/, 2]; + case 2: return [2 /*return*/]; + } + }); + }); +} diff --git a/tests/baselines/reference/asyncAwait_es5.symbols b/tests/baselines/reference/asyncAwait_es5.symbols index cdc52137ff4..e10fd971b7b 100644 --- a/tests/baselines/reference/asyncAwait_es5.symbols +++ b/tests/baselines/reference/asyncAwait_es5.symbols @@ -116,3 +116,12 @@ module M { export async function f1() { } >f1 : Symbol(f1, Decl(asyncAwait_es5.ts, 36, 10)) } + +async function f14() { +>f14 : Symbol(f14, Decl(asyncAwait_es5.ts, 38, 1)) + + block: { + await 1; + break block; + } +} diff --git a/tests/baselines/reference/asyncAwait_es5.types b/tests/baselines/reference/asyncAwait_es5.types index 4162aa84b76..6be39599fa1 100644 --- a/tests/baselines/reference/asyncAwait_es5.types +++ b/tests/baselines/reference/asyncAwait_es5.types @@ -127,3 +127,18 @@ module M { export async function f1() { } >f1 : () => Promise } + +async function f14() { +>f14 : () => Promise + + block: { +>block : any + + await 1; +>await 1 : 1 +>1 : 1 + + break block; +>block : any + } +} diff --git a/tests/baselines/reference/asyncAwait_es6.js b/tests/baselines/reference/asyncAwait_es6.js index d6635098aed..3cfe3b3ceec 100644 --- a/tests/baselines/reference/asyncAwait_es6.js +++ b/tests/baselines/reference/asyncAwait_es6.js @@ -14,7 +14,7 @@ let f6 = async function(): MyPromise { } let f7 = async () => { }; let f8 = async (): Promise => { }; -let f9 = async (): MyPromise => { }; +let f9 = async (): MyPromise => { }; let f10 = async () => p; let f11 = async () => mp; let f12 = async (): Promise => mp; @@ -37,6 +37,13 @@ class C { module M { export async function f1() { } +} + +async function f14() { + block: { + await 1; + break block; + } } //// [asyncAwait_es6.js] @@ -111,3 +118,11 @@ var M; } M.f1 = f1; })(M || (M = {})); +function f14() { + return __awaiter(this, void 0, void 0, function* () { + block: { + yield 1; + break block; + } + }); +} diff --git a/tests/baselines/reference/asyncAwait_es6.symbols b/tests/baselines/reference/asyncAwait_es6.symbols index 9093fc69064..380ecbcafe3 100644 --- a/tests/baselines/reference/asyncAwait_es6.symbols +++ b/tests/baselines/reference/asyncAwait_es6.symbols @@ -46,7 +46,7 @@ let f8 = async (): Promise => { }; >f8 : Symbol(f8, Decl(asyncAwait_es6.ts, 14, 3)) >Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) -let f9 = async (): MyPromise => { }; +let f9 = async (): MyPromise => { }; >f9 : Symbol(f9, Decl(asyncAwait_es6.ts, 15, 3)) >MyPromise : Symbol(MyPromise, Decl(asyncAwait_es6.ts, 0, 0), Decl(asyncAwait_es6.ts, 1, 11)) @@ -116,3 +116,12 @@ module M { export async function f1() { } >f1 : Symbol(f1, Decl(asyncAwait_es6.ts, 36, 10)) } + +async function f14() { +>f14 : Symbol(f14, Decl(asyncAwait_es6.ts, 38, 1)) + + block: { + await 1; + break block; + } +} diff --git a/tests/baselines/reference/asyncAwait_es6.types b/tests/baselines/reference/asyncAwait_es6.types index 5f0cd2cc35a..de6b7177e42 100644 --- a/tests/baselines/reference/asyncAwait_es6.types +++ b/tests/baselines/reference/asyncAwait_es6.types @@ -51,7 +51,7 @@ let f8 = async (): Promise => { }; >async (): Promise => { } : () => Promise >Promise : Promise -let f9 = async (): MyPromise => { }; +let f9 = async (): MyPromise => { }; >f9 : () => Promise >async (): MyPromise => { } : () => Promise >MyPromise : Promise @@ -127,3 +127,18 @@ module M { export async function f1() { } >f1 : () => Promise } + +async function f14() { +>f14 : () => Promise + + block: { +>block : any + + await 1; +>await 1 : 1 +>1 : 1 + + break block; +>block : any + } +} diff --git a/tests/baselines/reference/augmentExportEquals1.symbols b/tests/baselines/reference/augmentExportEquals1.symbols index 84ec06ca7fe..b2bda7590cd 100644 --- a/tests/baselines/reference/augmentExportEquals1.symbols +++ b/tests/baselines/reference/augmentExportEquals1.symbols @@ -20,6 +20,8 @@ import x = require("./file1"); // augmentation for './file1' // should error since './file1' does not have namespace meaning declare module "./file1" { +>"./file1" : Symbol("./file1", Decl(file2.ts, 0, 30)) + interface A { a } >A : Symbol(A, Decl(file2.ts, 4, 26)) >a : Symbol(A.a, Decl(file2.ts, 5, 17)) diff --git a/tests/baselines/reference/augmentExportEquals1.types b/tests/baselines/reference/augmentExportEquals1.types index afb5dd1edc9..3c9872c8afe 100644 --- a/tests/baselines/reference/augmentExportEquals1.types +++ b/tests/baselines/reference/augmentExportEquals1.types @@ -23,6 +23,8 @@ import x = require("./file1"); // augmentation for './file1' // should error since './file1' does not have namespace meaning declare module "./file1" { +>"./file1" : any + interface A { a } >A : A >a : any diff --git a/tests/baselines/reference/augmentExportEquals1_1.symbols b/tests/baselines/reference/augmentExportEquals1_1.symbols index df793ca841c..6d1ca82a086 100644 --- a/tests/baselines/reference/augmentExportEquals1_1.symbols +++ b/tests/baselines/reference/augmentExportEquals1_1.symbols @@ -8,6 +8,8 @@ let a: x.A; // should not work === tests/cases/compiler/file1.d.ts === declare module "file1" { +>"file1" : Symbol("file1", Decl(file1.d.ts, 0, 0)) + var x: number; >x : Symbol(x, Decl(file1.d.ts, 1, 7)) @@ -23,6 +25,8 @@ import x = require("file1"); // augmentation for 'file1' // should error since 'file1' does not have namespace meaning declare module "file1" { +>"file1" : Symbol("file1", Decl(file2.ts, 1, 28)) + interface A { a } >A : Symbol(A, Decl(file2.ts, 5, 24)) >a : Symbol(A.a, Decl(file2.ts, 6, 17)) diff --git a/tests/baselines/reference/augmentExportEquals1_1.types b/tests/baselines/reference/augmentExportEquals1_1.types index f771e815743..9077a27d327 100644 --- a/tests/baselines/reference/augmentExportEquals1_1.types +++ b/tests/baselines/reference/augmentExportEquals1_1.types @@ -10,6 +10,8 @@ let a: x.A; // should not work === tests/cases/compiler/file1.d.ts === declare module "file1" { +>"file1" : typeof "file1" + var x: number; >x : number @@ -25,6 +27,8 @@ import x = require("file1"); // augmentation for 'file1' // should error since 'file1' does not have namespace meaning declare module "file1" { +>"file1" : any + interface A { a } >A : A >a : any diff --git a/tests/baselines/reference/augmentExportEquals2.symbols b/tests/baselines/reference/augmentExportEquals2.symbols index 29f85da0e1f..18dc793b5c2 100644 --- a/tests/baselines/reference/augmentExportEquals2.symbols +++ b/tests/baselines/reference/augmentExportEquals2.symbols @@ -19,6 +19,8 @@ import x = require("./file1"); // should error since './file1' does not have namespace meaning declare module "./file1" { +>"./file1" : Symbol("./file1", Decl(file2.ts, 0, 30)) + interface A { a } >A : Symbol(A, Decl(file2.ts, 3, 26)) >a : Symbol(A.a, Decl(file2.ts, 4, 17)) diff --git a/tests/baselines/reference/augmentExportEquals2.types b/tests/baselines/reference/augmentExportEquals2.types index 658579598ae..03424f0b6a5 100644 --- a/tests/baselines/reference/augmentExportEquals2.types +++ b/tests/baselines/reference/augmentExportEquals2.types @@ -21,6 +21,8 @@ import x = require("./file1"); // should error since './file1' does not have namespace meaning declare module "./file1" { +>"./file1" : any + interface A { a } >A : A >a : any diff --git a/tests/baselines/reference/augmentExportEquals2_1.symbols b/tests/baselines/reference/augmentExportEquals2_1.symbols index 99ce1e5c85c..4eb0675cf64 100644 --- a/tests/baselines/reference/augmentExportEquals2_1.symbols +++ b/tests/baselines/reference/augmentExportEquals2_1.symbols @@ -8,6 +8,8 @@ let a: x.A; // should not work === tests/cases/compiler/file1.d.ts === declare module "file1" { +>"file1" : Symbol("file1", Decl(file1.d.ts, 0, 0)) + function foo(): void; >foo : Symbol(foo, Decl(file1.d.ts, 0, 24)) @@ -22,6 +24,8 @@ import x = require("file1"); // should error since './file1' does not have namespace meaning declare module "file1" { +>"file1" : Symbol("file1", Decl(file2.ts, 1, 28)) + interface A { a } >A : Symbol(A, Decl(file2.ts, 4, 24)) >a : Symbol(A.a, Decl(file2.ts, 5, 17)) diff --git a/tests/baselines/reference/augmentExportEquals2_1.types b/tests/baselines/reference/augmentExportEquals2_1.types index e47ed79f584..9a619638a01 100644 --- a/tests/baselines/reference/augmentExportEquals2_1.types +++ b/tests/baselines/reference/augmentExportEquals2_1.types @@ -10,6 +10,8 @@ let a: x.A; // should not work === tests/cases/compiler/file1.d.ts === declare module "file1" { +>"file1" : typeof "file1" + function foo(): void; >foo : () => void @@ -24,6 +26,8 @@ import x = require("file1"); // should error since './file1' does not have namespace meaning declare module "file1" { +>"file1" : any + interface A { a } >A : A >a : any diff --git a/tests/baselines/reference/augmentExportEquals3.symbols b/tests/baselines/reference/augmentExportEquals3.symbols index 06ac04b39f3..e4e7a8e1a5f 100644 --- a/tests/baselines/reference/augmentExportEquals3.symbols +++ b/tests/baselines/reference/augmentExportEquals3.symbols @@ -22,6 +22,8 @@ x.b = 1; // OK - './file1' is a namespace declare module "./file1" { +>"./file1" : Symbol(x, Decl(file1.ts, 0, 0), Decl(file1.ts, 0, 17), Decl(file2.ts, 1, 8)) + interface A { a } >A : Symbol(A, Decl(file2.ts, 4, 26)) >a : Symbol(A.a, Decl(file2.ts, 5, 17)) diff --git a/tests/baselines/reference/augmentExportEquals3.types b/tests/baselines/reference/augmentExportEquals3.types index 37362bc9649..67aa8399af3 100644 --- a/tests/baselines/reference/augmentExportEquals3.types +++ b/tests/baselines/reference/augmentExportEquals3.types @@ -25,6 +25,8 @@ x.b = 1; // OK - './file1' is a namespace declare module "./file1" { +>"./file1" : typeof x + interface A { a } >A : A >a : any diff --git a/tests/baselines/reference/augmentExportEquals3_1.symbols b/tests/baselines/reference/augmentExportEquals3_1.symbols index ad3505c2835..2431b293dea 100644 --- a/tests/baselines/reference/augmentExportEquals3_1.symbols +++ b/tests/baselines/reference/augmentExportEquals3_1.symbols @@ -1,5 +1,7 @@ === tests/cases/compiler/file1.d.ts === declare module "file1" { +>"file1" : Symbol("file1", Decl(file1.d.ts, 0, 0)) + function foo(): void; >foo : Symbol(foo, Decl(file1.d.ts, 0, 24), Decl(file1.d.ts, 1, 25), Decl(file2.ts, 2, 8)) @@ -26,6 +28,8 @@ x.b = 1; // OK - './file1' is a namespace declare module "file1" { +>"file1" : Symbol(x, Decl(file1.d.ts, 0, 24), Decl(file1.d.ts, 1, 25), Decl(file2.ts, 2, 8)) + interface A { a } >A : Symbol(A, Decl(file2.ts, 5, 24)) >a : Symbol(A.a, Decl(file2.ts, 6, 17)) diff --git a/tests/baselines/reference/augmentExportEquals3_1.types b/tests/baselines/reference/augmentExportEquals3_1.types index 2457e91530a..f841fb31535 100644 --- a/tests/baselines/reference/augmentExportEquals3_1.types +++ b/tests/baselines/reference/augmentExportEquals3_1.types @@ -1,5 +1,7 @@ === tests/cases/compiler/file1.d.ts === declare module "file1" { +>"file1" : typeof "file1" + function foo(): void; >foo : typeof foo @@ -28,6 +30,8 @@ x.b = 1; // OK - './file1' is a namespace declare module "file1" { +>"file1" : typeof x + interface A { a } >A : A >a : any diff --git a/tests/baselines/reference/augmentExportEquals4.symbols b/tests/baselines/reference/augmentExportEquals4.symbols index 2a4e3dbc147..f1f63762545 100644 --- a/tests/baselines/reference/augmentExportEquals4.symbols +++ b/tests/baselines/reference/augmentExportEquals4.symbols @@ -22,6 +22,8 @@ x.b = 1; // OK - './file1' is a namespace declare module "./file1" { +>"./file1" : Symbol(x, Decl(file1.ts, 0, 0), Decl(file1.ts, 0, 12), Decl(file2.ts, 1, 8)) + interface A { a } >A : Symbol(A, Decl(file2.ts, 4, 26)) >a : Symbol(A.a, Decl(file2.ts, 5, 17)) diff --git a/tests/baselines/reference/augmentExportEquals4.types b/tests/baselines/reference/augmentExportEquals4.types index 295156ffb59..c2823d794e0 100644 --- a/tests/baselines/reference/augmentExportEquals4.types +++ b/tests/baselines/reference/augmentExportEquals4.types @@ -25,6 +25,8 @@ x.b = 1; // OK - './file1' is a namespace declare module "./file1" { +>"./file1" : typeof x + interface A { a } >A : A >a : any diff --git a/tests/baselines/reference/augmentExportEquals4_1.symbols b/tests/baselines/reference/augmentExportEquals4_1.symbols index 1488645898c..d2a3c001825 100644 --- a/tests/baselines/reference/augmentExportEquals4_1.symbols +++ b/tests/baselines/reference/augmentExportEquals4_1.symbols @@ -1,5 +1,7 @@ === tests/cases/compiler/file1.d.ts === declare module "file1" { +>"file1" : Symbol("file1", Decl(file1.d.ts, 0, 0)) + class foo {} >foo : Symbol(foo, Decl(file1.d.ts, 0, 24), Decl(file1.d.ts, 1, 16), Decl(file2.ts, 2, 8)) @@ -26,6 +28,8 @@ x.b = 1; // OK - './file1' is a namespace declare module "file1" { +>"file1" : Symbol(x, Decl(file1.d.ts, 0, 24), Decl(file1.d.ts, 1, 16), Decl(file2.ts, 2, 8)) + interface A { a } >A : Symbol(A, Decl(file2.ts, 5, 24)) >a : Symbol(A.a, Decl(file2.ts, 6, 17)) diff --git a/tests/baselines/reference/augmentExportEquals4_1.types b/tests/baselines/reference/augmentExportEquals4_1.types index 8eaf1c6cbba..9daf444e419 100644 --- a/tests/baselines/reference/augmentExportEquals4_1.types +++ b/tests/baselines/reference/augmentExportEquals4_1.types @@ -1,5 +1,7 @@ === tests/cases/compiler/file1.d.ts === declare module "file1" { +>"file1" : typeof "file1" + class foo {} >foo : foo @@ -28,6 +30,8 @@ x.b = 1; // OK - './file1' is a namespace declare module "file1" { +>"file1" : typeof x + interface A { a } >A : A >a : any diff --git a/tests/baselines/reference/augmentExportEquals5.symbols b/tests/baselines/reference/augmentExportEquals5.symbols index d55e8eed021..0bf821f6cad 100644 --- a/tests/baselines/reference/augmentExportEquals5.symbols +++ b/tests/baselines/reference/augmentExportEquals5.symbols @@ -13,6 +13,8 @@ declare module Express { } declare module "express" { +>"express" : Symbol("express", Decl(express.d.ts, 4, 1)) + function e(): e.Express; >e : Symbol(e, Decl(express.d.ts, 6, 26), Decl(express.d.ts, 7, 28), Decl(augmentation.ts, 1, 29)) >e : Symbol(e, Decl(express.d.ts, 6, 26), Decl(express.d.ts, 7, 28)) @@ -167,6 +169,8 @@ import * as e from "express"; >e : Symbol(e, Decl(augmentation.ts, 1, 6)) declare module "express" { +>"express" : Symbol(e, Decl(express.d.ts, 6, 26), Decl(express.d.ts, 7, 28), Decl(augmentation.ts, 1, 29)) + interface Request { >Request : Symbol(Request, Decl(express.d.ts, 25, 49), Decl(augmentation.ts, 2, 26)) diff --git a/tests/baselines/reference/augmentExportEquals5.types b/tests/baselines/reference/augmentExportEquals5.types index c0444d35358..eaa956e1d4e 100644 --- a/tests/baselines/reference/augmentExportEquals5.types +++ b/tests/baselines/reference/augmentExportEquals5.types @@ -13,6 +13,8 @@ declare module Express { } declare module "express" { +>"express" : typeof "express" + function e(): e.Express; >e : typeof e >e : any @@ -167,6 +169,8 @@ import * as e from "express"; >e : typeof e declare module "express" { +>"express" : typeof e + interface Request { >Request : Request diff --git a/tests/baselines/reference/augmentExportEquals6.symbols b/tests/baselines/reference/augmentExportEquals6.symbols index 33ec14ed334..2125b650464 100644 --- a/tests/baselines/reference/augmentExportEquals6.symbols +++ b/tests/baselines/reference/augmentExportEquals6.symbols @@ -28,6 +28,8 @@ x.B.b = 1; // OK - './file1' is a namespace declare module "./file1" { +>"./file1" : Symbol(x, Decl(file1.ts, 0, 0), Decl(file1.ts, 0, 12), Decl(file2.ts, 1, 10)) + interface A { a: number } >A : Symbol(A, Decl(file1.ts, 1, 15), Decl(file2.ts, 4, 26)) >a : Symbol(A.a, Decl(file2.ts, 5, 17)) diff --git a/tests/baselines/reference/augmentExportEquals6.types b/tests/baselines/reference/augmentExportEquals6.types index 01b7095b169..6948535c6da 100644 --- a/tests/baselines/reference/augmentExportEquals6.types +++ b/tests/baselines/reference/augmentExportEquals6.types @@ -30,6 +30,8 @@ x.B.b = 1; // OK - './file1' is a namespace declare module "./file1" { +>"./file1" : typeof x + interface A { a: number } >A : A >a : number diff --git a/tests/baselines/reference/augmentExportEquals6_1.symbols b/tests/baselines/reference/augmentExportEquals6_1.symbols index 60f8b845657..b75f8131c01 100644 --- a/tests/baselines/reference/augmentExportEquals6_1.symbols +++ b/tests/baselines/reference/augmentExportEquals6_1.symbols @@ -1,5 +1,7 @@ === tests/cases/compiler/file1.d.ts === declare module "file1" { +>"file1" : Symbol("file1", Decl(file1.d.ts, 0, 0)) + class foo {} >foo : Symbol(foo, Decl(file1.d.ts, 0, 24), Decl(file1.d.ts, 1, 16), Decl(file2.ts, 1, 28)) @@ -21,6 +23,8 @@ import x = require("file1"); // OK - './file1' is a namespace declare module "file1" { +>"file1" : Symbol(x, Decl(file1.d.ts, 0, 24), Decl(file1.d.ts, 1, 16), Decl(file2.ts, 1, 28)) + interface A { a: number } >A : Symbol(A, Decl(file1.d.ts, 2, 19), Decl(file2.ts, 4, 24)) >a : Symbol(A.a, Decl(file2.ts, 5, 17)) diff --git a/tests/baselines/reference/augmentExportEquals6_1.types b/tests/baselines/reference/augmentExportEquals6_1.types index a6041ecda81..6929d99ad51 100644 --- a/tests/baselines/reference/augmentExportEquals6_1.types +++ b/tests/baselines/reference/augmentExportEquals6_1.types @@ -1,5 +1,7 @@ === tests/cases/compiler/file1.d.ts === declare module "file1" { +>"file1" : typeof "file1" + class foo {} >foo : foo @@ -21,6 +23,8 @@ import x = require("file1"); // OK - './file1' is a namespace declare module "file1" { +>"file1" : typeof x + interface A { a: number } >A : A >a : number diff --git a/tests/baselines/reference/augmentExportEquals7.symbols b/tests/baselines/reference/augmentExportEquals7.symbols index 42156dafaed..cdcd430e7af 100644 --- a/tests/baselines/reference/augmentExportEquals7.symbols +++ b/tests/baselines/reference/augmentExportEquals7.symbols @@ -13,6 +13,8 @@ import * as lib from "lib"; >lib : Symbol(lib, Decl(index.d.ts, 0, 6)) declare module "lib" { +>"lib" : Symbol("lib", Decl(index.d.ts, 0, 27)) + export function fn(): void; >fn : Symbol(fn, Decl(index.d.ts, 1, 22)) } diff --git a/tests/baselines/reference/augmentExportEquals7.types b/tests/baselines/reference/augmentExportEquals7.types index f2870eab8df..4311a3c112e 100644 --- a/tests/baselines/reference/augmentExportEquals7.types +++ b/tests/baselines/reference/augmentExportEquals7.types @@ -13,6 +13,8 @@ import * as lib from "lib"; >lib : () => void declare module "lib" { +>"lib" : typeof "lib" + export function fn(): void; >fn : () => void } diff --git a/tests/baselines/reference/augmentedTypesClass.errors.txt b/tests/baselines/reference/augmentedTypesClass.errors.txt index 2ff6889e22f..e5fd7a6d82e 100644 --- a/tests/baselines/reference/augmentedTypesClass.errors.txt +++ b/tests/baselines/reference/augmentedTypesClass.errors.txt @@ -1,7 +1,7 @@ tests/cases/compiler/augmentedTypesClass.ts(2,7): error TS2300: Duplicate identifier 'c1'. tests/cases/compiler/augmentedTypesClass.ts(3,5): error TS2300: Duplicate identifier 'c1'. -tests/cases/compiler/augmentedTypesClass.ts(6,7): error TS2300: Duplicate identifier 'c4'. -tests/cases/compiler/augmentedTypesClass.ts(7,6): error TS2300: Duplicate identifier 'c4'. +tests/cases/compiler/augmentedTypesClass.ts(6,7): error TS2567: Enum declarations can only merge with namespace or other enum declarations. +tests/cases/compiler/augmentedTypesClass.ts(7,6): error TS2567: Enum declarations can only merge with namespace or other enum declarations. ==== tests/cases/compiler/augmentedTypesClass.ts (4 errors) ==== @@ -16,7 +16,7 @@ tests/cases/compiler/augmentedTypesClass.ts(7,6): error TS2300: Duplicate identi //// class then enum class c4 { public foo() { } } ~~ -!!! error TS2300: Duplicate identifier 'c4'. +!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. enum c4 { One } // error ~~ -!!! error TS2300: Duplicate identifier 'c4'. \ No newline at end of file +!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. \ No newline at end of file diff --git a/tests/baselines/reference/augmentedTypesClass2.errors.txt b/tests/baselines/reference/augmentedTypesClass2.errors.txt index a27189cf2c2..a7636499803 100644 --- a/tests/baselines/reference/augmentedTypesClass2.errors.txt +++ b/tests/baselines/reference/augmentedTypesClass2.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/augmentedTypesClass2.ts(16,7): error TS2300: Duplicate identifier 'c33'. -tests/cases/compiler/augmentedTypesClass2.ts(21,6): error TS2300: Duplicate identifier 'c33'. +tests/cases/compiler/augmentedTypesClass2.ts(16,7): error TS2567: Enum declarations can only merge with namespace or other enum declarations. +tests/cases/compiler/augmentedTypesClass2.ts(21,6): error TS2567: Enum declarations can only merge with namespace or other enum declarations. ==== tests/cases/compiler/augmentedTypesClass2.ts (2 errors) ==== @@ -20,14 +20,14 @@ tests/cases/compiler/augmentedTypesClass2.ts(21,6): error TS2300: Duplicate iden // class then enum class c33 { ~~~ -!!! error TS2300: Duplicate identifier 'c33'. +!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. foo() { return 1; } } enum c33 { One }; ~~~ -!!! error TS2300: Duplicate identifier 'c33'. +!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. // class then import class c44 { diff --git a/tests/baselines/reference/augmentedTypesEnum.errors.txt b/tests/baselines/reference/augmentedTypesEnum.errors.txt index 3102f9d4786..ca661e5bcf5 100644 --- a/tests/baselines/reference/augmentedTypesEnum.errors.txt +++ b/tests/baselines/reference/augmentedTypesEnum.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/augmentedTypesEnum.ts(2,6): error TS2300: Duplicate identifier 'e1111'. -tests/cases/compiler/augmentedTypesEnum.ts(3,5): error TS2300: Duplicate identifier 'e1111'. -tests/cases/compiler/augmentedTypesEnum.ts(6,6): error TS2300: Duplicate identifier 'e2'. -tests/cases/compiler/augmentedTypesEnum.ts(7,10): error TS2300: Duplicate identifier 'e2'. -tests/cases/compiler/augmentedTypesEnum.ts(9,6): error TS2300: Duplicate identifier 'e3'. -tests/cases/compiler/augmentedTypesEnum.ts(10,5): error TS2300: Duplicate identifier 'e3'. -tests/cases/compiler/augmentedTypesEnum.ts(13,6): error TS2300: Duplicate identifier 'e4'. -tests/cases/compiler/augmentedTypesEnum.ts(14,7): error TS2300: Duplicate identifier 'e4'. +tests/cases/compiler/augmentedTypesEnum.ts(2,6): error TS2567: Enum declarations can only merge with namespace or other enum declarations. +tests/cases/compiler/augmentedTypesEnum.ts(3,5): error TS2567: Enum declarations can only merge with namespace or other enum declarations. +tests/cases/compiler/augmentedTypesEnum.ts(6,6): error TS2567: Enum declarations can only merge with namespace or other enum declarations. +tests/cases/compiler/augmentedTypesEnum.ts(7,10): error TS2567: Enum declarations can only merge with namespace or other enum declarations. +tests/cases/compiler/augmentedTypesEnum.ts(9,6): error TS2567: Enum declarations can only merge with namespace or other enum declarations. +tests/cases/compiler/augmentedTypesEnum.ts(10,5): error TS2567: Enum declarations can only merge with namespace or other enum declarations. +tests/cases/compiler/augmentedTypesEnum.ts(13,6): error TS2567: Enum declarations can only merge with namespace or other enum declarations. +tests/cases/compiler/augmentedTypesEnum.ts(14,7): error TS2567: Enum declarations can only merge with namespace or other enum declarations. tests/cases/compiler/augmentedTypesEnum.ts(18,11): error TS2432: In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element. tests/cases/compiler/augmentedTypesEnum.ts(20,12): error TS2300: Duplicate identifier 'One'. tests/cases/compiler/augmentedTypesEnum.ts(21,12): error TS2300: Duplicate identifier 'One'. @@ -16,33 +16,33 @@ tests/cases/compiler/augmentedTypesEnum.ts(21,12): error TS2432: In an enum with // enum then var enum e1111 { One } // error ~~~~~ -!!! error TS2300: Duplicate identifier 'e1111'. +!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. var e1111 = 1; // error ~~~~~ -!!! error TS2300: Duplicate identifier 'e1111'. +!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. // enum then function enum e2 { One } // error ~~ -!!! error TS2300: Duplicate identifier 'e2'. +!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. function e2() { } // error ~~ -!!! error TS2300: Duplicate identifier 'e2'. +!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. enum e3 { One } // error ~~ -!!! error TS2300: Duplicate identifier 'e3'. +!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. var e3 = () => { } // error ~~ -!!! error TS2300: Duplicate identifier 'e3'. +!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. // enum then class enum e4 { One } // error ~~ -!!! error TS2300: Duplicate identifier 'e4'. +!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. class e4 { public foo() { } } // error ~~ -!!! error TS2300: Duplicate identifier 'e4'. +!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. // enum then enum enum e5 { One } diff --git a/tests/baselines/reference/augmentedTypesEnum2.errors.txt b/tests/baselines/reference/augmentedTypesEnum2.errors.txt index 8c6c7382f85..2d47c26c896 100644 --- a/tests/baselines/reference/augmentedTypesEnum2.errors.txt +++ b/tests/baselines/reference/augmentedTypesEnum2.errors.txt @@ -1,18 +1,18 @@ -tests/cases/compiler/augmentedTypesEnum2.ts(2,6): error TS2300: Duplicate identifier 'e1'. -tests/cases/compiler/augmentedTypesEnum2.ts(4,11): error TS2300: Duplicate identifier 'e1'. -tests/cases/compiler/augmentedTypesEnum2.ts(11,6): error TS2300: Duplicate identifier 'e2'. -tests/cases/compiler/augmentedTypesEnum2.ts(12,7): error TS2300: Duplicate identifier 'e2'. +tests/cases/compiler/augmentedTypesEnum2.ts(2,6): error TS2567: Enum declarations can only merge with namespace or other enum declarations. +tests/cases/compiler/augmentedTypesEnum2.ts(4,11): error TS2567: Enum declarations can only merge with namespace or other enum declarations. +tests/cases/compiler/augmentedTypesEnum2.ts(11,6): error TS2567: Enum declarations can only merge with namespace or other enum declarations. +tests/cases/compiler/augmentedTypesEnum2.ts(12,7): error TS2567: Enum declarations can only merge with namespace or other enum declarations. ==== tests/cases/compiler/augmentedTypesEnum2.ts (4 errors) ==== // enum then interface enum e1 { One } // error ~~ -!!! error TS2300: Duplicate identifier 'e1'. +!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. interface e1 { // error ~~ -!!! error TS2300: Duplicate identifier 'e1'. +!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. foo(): void; } @@ -21,10 +21,10 @@ tests/cases/compiler/augmentedTypesEnum2.ts(12,7): error TS2300: Duplicate ident // enum then class enum e2 { One }; // error ~~ -!!! error TS2300: Duplicate identifier 'e2'. +!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. class e2 { // error ~~ -!!! error TS2300: Duplicate identifier 'e2'. +!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. foo() { return 1; } diff --git a/tests/baselines/reference/augmentedTypesFunction.errors.txt b/tests/baselines/reference/augmentedTypesFunction.errors.txt index 8d1ce671c9e..2b17ee912fb 100644 --- a/tests/baselines/reference/augmentedTypesFunction.errors.txt +++ b/tests/baselines/reference/augmentedTypesFunction.errors.txt @@ -8,8 +8,8 @@ tests/cases/compiler/augmentedTypesFunction.ts(13,10): error TS2300: Duplicate i tests/cases/compiler/augmentedTypesFunction.ts(14,7): error TS2300: Duplicate identifier 'y3'. tests/cases/compiler/augmentedTypesFunction.ts(16,10): error TS2300: Duplicate identifier 'y3a'. tests/cases/compiler/augmentedTypesFunction.ts(17,7): error TS2300: Duplicate identifier 'y3a'. -tests/cases/compiler/augmentedTypesFunction.ts(20,10): error TS2300: Duplicate identifier 'y4'. -tests/cases/compiler/augmentedTypesFunction.ts(21,6): error TS2300: Duplicate identifier 'y4'. +tests/cases/compiler/augmentedTypesFunction.ts(20,10): error TS2567: Enum declarations can only merge with namespace or other enum declarations. +tests/cases/compiler/augmentedTypesFunction.ts(21,6): error TS2567: Enum declarations can only merge with namespace or other enum declarations. ==== tests/cases/compiler/augmentedTypesFunction.ts (12 errors) ==== @@ -54,10 +54,10 @@ tests/cases/compiler/augmentedTypesFunction.ts(21,6): error TS2300: Duplicate id // function then enum function y4() { } // error ~~ -!!! error TS2300: Duplicate identifier 'y4'. +!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. enum y4 { One } // error ~~ -!!! error TS2300: Duplicate identifier 'y4'. +!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. // function then internal module function y5() { } diff --git a/tests/baselines/reference/augmentedTypesInterface.errors.txt b/tests/baselines/reference/augmentedTypesInterface.errors.txt index 51092e1d27f..75828689619 100644 --- a/tests/baselines/reference/augmentedTypesInterface.errors.txt +++ b/tests/baselines/reference/augmentedTypesInterface.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/augmentedTypesInterface.ts(23,11): error TS2300: Duplicate identifier 'i3'. -tests/cases/compiler/augmentedTypesInterface.ts(26,6): error TS2300: Duplicate identifier 'i3'. +tests/cases/compiler/augmentedTypesInterface.ts(23,11): error TS2567: Enum declarations can only merge with namespace or other enum declarations. +tests/cases/compiler/augmentedTypesInterface.ts(26,6): error TS2567: Enum declarations can only merge with namespace or other enum declarations. ==== tests/cases/compiler/augmentedTypesInterface.ts (2 errors) ==== @@ -27,12 +27,12 @@ tests/cases/compiler/augmentedTypesInterface.ts(26,6): error TS2300: Duplicate i // interface then enum interface i3 { // error ~~ -!!! error TS2300: Duplicate identifier 'i3'. +!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. foo(): void; } enum i3 { One }; // error ~~ -!!! error TS2300: Duplicate identifier 'i3'. +!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. // interface then import interface i4 { diff --git a/tests/baselines/reference/augmentedTypesVar.errors.txt b/tests/baselines/reference/augmentedTypesVar.errors.txt index 24c194d25c3..261686f3659 100644 --- a/tests/baselines/reference/augmentedTypesVar.errors.txt +++ b/tests/baselines/reference/augmentedTypesVar.errors.txt @@ -5,8 +5,8 @@ tests/cases/compiler/augmentedTypesVar.ts(13,5): error TS2300: Duplicate identif tests/cases/compiler/augmentedTypesVar.ts(14,7): error TS2300: Duplicate identifier 'x4'. tests/cases/compiler/augmentedTypesVar.ts(16,5): error TS2300: Duplicate identifier 'x4a'. tests/cases/compiler/augmentedTypesVar.ts(17,7): error TS2300: Duplicate identifier 'x4a'. -tests/cases/compiler/augmentedTypesVar.ts(20,5): error TS2300: Duplicate identifier 'x5'. -tests/cases/compiler/augmentedTypesVar.ts(21,6): error TS2300: Duplicate identifier 'x5'. +tests/cases/compiler/augmentedTypesVar.ts(20,5): error TS2567: Enum declarations can only merge with namespace or other enum declarations. +tests/cases/compiler/augmentedTypesVar.ts(21,6): error TS2567: Enum declarations can only merge with namespace or other enum declarations. tests/cases/compiler/augmentedTypesVar.ts(27,5): error TS2300: Duplicate identifier 'x6a'. tests/cases/compiler/augmentedTypesVar.ts(28,8): error TS2300: Duplicate identifier 'x6a'. tests/cases/compiler/augmentedTypesVar.ts(30,5): error TS2300: Duplicate identifier 'x6b'. @@ -49,10 +49,10 @@ tests/cases/compiler/augmentedTypesVar.ts(31,8): error TS2300: Duplicate identif // var then enum var x5 = 1; ~~ -!!! error TS2300: Duplicate identifier 'x5'. +!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. enum x5 { One } // error ~~ -!!! error TS2300: Duplicate identifier 'x5'. +!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. // var then module var x6 = 1; diff --git a/tests/baselines/reference/bangInModuleName.symbols b/tests/baselines/reference/bangInModuleName.symbols index 08bcf487cc8..ca3d4a161f5 100644 --- a/tests/baselines/reference/bangInModuleName.symbols +++ b/tests/baselines/reference/bangInModuleName.symbols @@ -6,9 +6,12 @@ import * as http from 'intern/dojo/node!http'; === tests/cases/compiler/a.d.ts === declare module "http" { +>"http" : Symbol("http", Decl(a.d.ts, 0, 0)) } declare module 'intern/dojo/node!http' { +>'intern/dojo/node!http' : Symbol('intern/dojo/node!http', Decl(a.d.ts, 1, 1)) + import http = require('http'); >http : Symbol(http, Decl(a.d.ts, 3, 40)) diff --git a/tests/baselines/reference/bangInModuleName.types b/tests/baselines/reference/bangInModuleName.types index 93115f76a0e..691ac6add00 100644 --- a/tests/baselines/reference/bangInModuleName.types +++ b/tests/baselines/reference/bangInModuleName.types @@ -6,9 +6,12 @@ import * as http from 'intern/dojo/node!http'; === tests/cases/compiler/a.d.ts === declare module "http" { +>"http" : typeof "http" } declare module 'intern/dojo/node!http' { +>'intern/dojo/node!http' : typeof 'intern/dojo/node!http' + import http = require('http'); >http : typeof http diff --git a/tests/baselines/reference/binaryIntegerLiteral.symbols b/tests/baselines/reference/binaryIntegerLiteral.symbols index 31e28819657..fb15a8b6e6c 100644 --- a/tests/baselines/reference/binaryIntegerLiteral.symbols +++ b/tests/baselines/reference/binaryIntegerLiteral.symbols @@ -15,6 +15,8 @@ var obj1 = { >obj1 : Symbol(obj1, Decl(binaryIntegerLiteral.ts, 5, 3)) 0b11010: "Hello", +>0b11010 : Symbol(0b11010, Decl(binaryIntegerLiteral.ts, 5, 12)) + a: bin1, >a : Symbol(a, Decl(binaryIntegerLiteral.ts, 6, 21)) >bin1 : Symbol(bin1, Decl(binaryIntegerLiteral.ts, 0, 3)) @@ -26,12 +28,15 @@ var obj1 = { >b : Symbol(b, Decl(binaryIntegerLiteral.ts, 8, 9)) 0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111: true, +>0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111 : Symbol(0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111, Decl(binaryIntegerLiteral.ts, 9, 15)) } var obj2 = { >obj2 : Symbol(obj2, Decl(binaryIntegerLiteral.ts, 13, 3)) 0B11010: "World", +>0B11010 : Symbol(0B11010, Decl(binaryIntegerLiteral.ts, 13, 12)) + a: bin2, >a : Symbol(a, Decl(binaryIntegerLiteral.ts, 14, 21)) >bin2 : Symbol(bin2, Decl(binaryIntegerLiteral.ts, 1, 3)) @@ -43,6 +48,7 @@ var obj2 = { >b : Symbol(b, Decl(binaryIntegerLiteral.ts, 16, 9)) 0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111: false, +>0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111 : Symbol(0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111, Decl(binaryIntegerLiteral.ts, 17, 15)) } obj1[0b11010]; // string diff --git a/tests/baselines/reference/binaryIntegerLiteral.types b/tests/baselines/reference/binaryIntegerLiteral.types index 5cee371fdbe..070ae22d796 100644 --- a/tests/baselines/reference/binaryIntegerLiteral.types +++ b/tests/baselines/reference/binaryIntegerLiteral.types @@ -20,6 +20,7 @@ var obj1 = { >{ 0b11010: "Hello", a: bin1, bin1, b: 0b11010, 0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111: true,} : { 0b11010: string; a: number; bin1: number; b: number; 0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111: boolean; } 0b11010: "Hello", +>0b11010 : string >"Hello" : "Hello" a: bin1, @@ -34,6 +35,7 @@ var obj1 = { >0b11010 : 26 0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111: true, +>0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111 : boolean >true : true } @@ -42,6 +44,7 @@ var obj2 = { >{ 0B11010: "World", a: bin2, bin2, b: 0B11010, 0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111: false,} : { 0B11010: string; a: number; bin2: number; b: number; 0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111: boolean; } 0B11010: "World", +>0B11010 : string >"World" : "World" a: bin2, @@ -56,6 +59,7 @@ var obj2 = { >0B11010 : 26 0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111: false, +>0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111 : boolean >false : false } diff --git a/tests/baselines/reference/binaryIntegerLiteralES6.symbols b/tests/baselines/reference/binaryIntegerLiteralES6.symbols index 4fb7aaff82d..15c8c633019 100644 --- a/tests/baselines/reference/binaryIntegerLiteralES6.symbols +++ b/tests/baselines/reference/binaryIntegerLiteralES6.symbols @@ -15,6 +15,8 @@ var obj1 = { >obj1 : Symbol(obj1, Decl(binaryIntegerLiteralES6.ts, 5, 3)) 0b11010: "Hello", +>0b11010 : Symbol(0b11010, Decl(binaryIntegerLiteralES6.ts, 5, 12)) + a: bin1, >a : Symbol(a, Decl(binaryIntegerLiteralES6.ts, 6, 21)) >bin1 : Symbol(bin1, Decl(binaryIntegerLiteralES6.ts, 0, 3)) @@ -26,12 +28,15 @@ var obj1 = { >b : Symbol(b, Decl(binaryIntegerLiteralES6.ts, 8, 9)) 0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111: true, +>0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111 : Symbol(0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111, Decl(binaryIntegerLiteralES6.ts, 9, 15)) } var obj2 = { >obj2 : Symbol(obj2, Decl(binaryIntegerLiteralES6.ts, 13, 3)) 0B11010: "World", +>0B11010 : Symbol(0B11010, Decl(binaryIntegerLiteralES6.ts, 13, 12)) + a: bin2, >a : Symbol(a, Decl(binaryIntegerLiteralES6.ts, 14, 21)) >bin2 : Symbol(bin2, Decl(binaryIntegerLiteralES6.ts, 1, 3)) @@ -43,6 +48,7 @@ var obj2 = { >b : Symbol(b, Decl(binaryIntegerLiteralES6.ts, 16, 9)) 0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111: false, +>0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111 : Symbol(0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111, Decl(binaryIntegerLiteralES6.ts, 17, 15)) } obj1[0b11010]; // string diff --git a/tests/baselines/reference/binaryIntegerLiteralES6.types b/tests/baselines/reference/binaryIntegerLiteralES6.types index ab28010283b..fe9f65a1f71 100644 --- a/tests/baselines/reference/binaryIntegerLiteralES6.types +++ b/tests/baselines/reference/binaryIntegerLiteralES6.types @@ -20,6 +20,7 @@ var obj1 = { >{ 0b11010: "Hello", a: bin1, bin1, b: 0b11010, 0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111: true,} : { 0b11010: string; a: number; bin1: number; b: number; 0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111: boolean; } 0b11010: "Hello", +>0b11010 : string >"Hello" : "Hello" a: bin1, @@ -34,6 +35,7 @@ var obj1 = { >0b11010 : 26 0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111: true, +>0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111 : boolean >true : true } @@ -42,6 +44,7 @@ var obj2 = { >{ 0B11010: "World", a: bin2, bin2, b: 0B11010, 0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111: false,} : { 0B11010: string; a: number; bin2: number; b: number; 0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111: boolean; } 0B11010: "World", +>0B11010 : string >"World" : "World" a: bin2, @@ -56,6 +59,7 @@ var obj2 = { >0B11010 : 26 0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111: false, +>0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111 : boolean >false : false } diff --git a/tests/baselines/reference/binaryIntegerLiteralError.symbols b/tests/baselines/reference/binaryIntegerLiteralError.symbols index bd40cecff8d..dca3aa3d9ff 100644 --- a/tests/baselines/reference/binaryIntegerLiteralError.symbols +++ b/tests/baselines/reference/binaryIntegerLiteralError.symbols @@ -10,7 +10,13 @@ var obj1 = { >obj1 : Symbol(obj1, Decl(binaryIntegerLiteralError.ts, 4, 3)) 0b11010: "hi", +>0b11010 : Symbol(0b11010, Decl(binaryIntegerLiteralError.ts, 4, 12), Decl(binaryIntegerLiteralError.ts, 5, 18), Decl(binaryIntegerLiteralError.ts, 6, 16)) + 26: "Hello", +>26 : Symbol(0b11010, Decl(binaryIntegerLiteralError.ts, 4, 12), Decl(binaryIntegerLiteralError.ts, 5, 18), Decl(binaryIntegerLiteralError.ts, 6, 16)) + "26": "world", +>"26" : Symbol(0b11010, Decl(binaryIntegerLiteralError.ts, 4, 12), Decl(binaryIntegerLiteralError.ts, 5, 18), Decl(binaryIntegerLiteralError.ts, 6, 16)) + }; diff --git a/tests/baselines/reference/binaryIntegerLiteralError.types b/tests/baselines/reference/binaryIntegerLiteralError.types index 5ab51f74666..6d53b3e515e 100644 --- a/tests/baselines/reference/binaryIntegerLiteralError.types +++ b/tests/baselines/reference/binaryIntegerLiteralError.types @@ -15,12 +15,15 @@ var obj1 = { >{ 0b11010: "hi", 26: "Hello", "26": "world",} : { 0b11010: string; } 0b11010: "hi", +>0b11010 : string >"hi" : "hi" 26: "Hello", +>26 : string >"Hello" : "Hello" "26": "world", +>"26" : string >"world" : "world" }; diff --git a/tests/baselines/reference/bitwiseNotOperatorWithEnumType.symbols b/tests/baselines/reference/bitwiseNotOperatorWithEnumType.symbols index 24783a153ae..e734966c594 100644 --- a/tests/baselines/reference/bitwiseNotOperatorWithEnumType.symbols +++ b/tests/baselines/reference/bitwiseNotOperatorWithEnumType.symbols @@ -5,6 +5,7 @@ enum ENUM1 { A, B, "" }; >ENUM1 : Symbol(ENUM1, Decl(bitwiseNotOperatorWithEnumType.ts, 0, 0)) >A : Symbol(ENUM1.A, Decl(bitwiseNotOperatorWithEnumType.ts, 2, 12)) >B : Symbol(ENUM1.B, Decl(bitwiseNotOperatorWithEnumType.ts, 2, 15)) +>"" : Symbol(ENUM1[""], Decl(bitwiseNotOperatorWithEnumType.ts, 2, 18)) // enum type var var ResultIsNumber1 = ~ENUM1; diff --git a/tests/baselines/reference/bitwiseNotOperatorWithEnumType.types b/tests/baselines/reference/bitwiseNotOperatorWithEnumType.types index 03008f67d11..266c62de93e 100644 --- a/tests/baselines/reference/bitwiseNotOperatorWithEnumType.types +++ b/tests/baselines/reference/bitwiseNotOperatorWithEnumType.types @@ -5,6 +5,7 @@ enum ENUM1 { A, B, "" }; >ENUM1 : ENUM1 >A : ENUM1.A >B : ENUM1.B +>"" : ENUM1. // enum type var var ResultIsNumber1 = ~ENUM1; diff --git a/tests/baselines/reference/blockScopedFunctionDeclarationInStrictModule.types b/tests/baselines/reference/blockScopedFunctionDeclarationInStrictModule.types index f0b9693ed70..67785432c1d 100644 --- a/tests/baselines/reference/blockScopedFunctionDeclarationInStrictModule.types +++ b/tests/baselines/reference/blockScopedFunctionDeclarationInStrictModule.types @@ -11,5 +11,5 @@ if (true) { } export = foo; // not ok ->foo : No type information available! +>foo : any diff --git a/tests/baselines/reference/classAbstractManyKeywords.types b/tests/baselines/reference/classAbstractManyKeywords.types index ab7071a8842..75c3baf75b2 100644 --- a/tests/baselines/reference/classAbstractManyKeywords.types +++ b/tests/baselines/reference/classAbstractManyKeywords.types @@ -10,6 +10,6 @@ default abstract class C {} import abstract class D {} >abstract : any -> : No type information available! +> : any >D : D diff --git a/tests/baselines/reference/classWithOnlyPublicMembersEquivalentToInterface.symbols b/tests/baselines/reference/classWithOnlyPublicMembersEquivalentToInterface.symbols index b09c819cf65..e55bfd99aa8 100644 --- a/tests/baselines/reference/classWithOnlyPublicMembersEquivalentToInterface.symbols +++ b/tests/baselines/reference/classWithOnlyPublicMembersEquivalentToInterface.symbols @@ -27,6 +27,7 @@ class C { >Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) 0: number; +>0 : Symbol(C[0], Decl(classWithOnlyPublicMembersEquivalentToInterface.ts, 8, 24)) } interface I { @@ -51,6 +52,7 @@ interface I { >Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) 0: number; +>0 : Symbol(I[0], Decl(classWithOnlyPublicMembersEquivalentToInterface.ts, 17, 24)) } var c: C; diff --git a/tests/baselines/reference/classWithOnlyPublicMembersEquivalentToInterface.types b/tests/baselines/reference/classWithOnlyPublicMembersEquivalentToInterface.types index 272ba94f7f2..65e01240b72 100644 --- a/tests/baselines/reference/classWithOnlyPublicMembersEquivalentToInterface.types +++ b/tests/baselines/reference/classWithOnlyPublicMembersEquivalentToInterface.types @@ -29,6 +29,7 @@ class C { >Object : Object 0: number; +>0 : number } interface I { @@ -53,6 +54,7 @@ interface I { >Object : Object 0: number; +>0 : number } var c: C; diff --git a/tests/baselines/reference/classWithOnlyPublicMembersEquivalentToInterface2.symbols b/tests/baselines/reference/classWithOnlyPublicMembersEquivalentToInterface2.symbols index 80658b0531c..ab337787517 100644 --- a/tests/baselines/reference/classWithOnlyPublicMembersEquivalentToInterface2.symbols +++ b/tests/baselines/reference/classWithOnlyPublicMembersEquivalentToInterface2.symbols @@ -27,6 +27,7 @@ class C { >Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) 0: number; +>0 : Symbol(C[0], Decl(classWithOnlyPublicMembersEquivalentToInterface2.ts, 8, 24)) public static foo: string; // doesn't effect equivalence >foo : Symbol(C.foo, Decl(classWithOnlyPublicMembersEquivalentToInterface2.ts, 9, 14)) @@ -54,6 +55,7 @@ interface I { >Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) 0: number; +>0 : Symbol(I[0], Decl(classWithOnlyPublicMembersEquivalentToInterface2.ts, 19, 24)) } var c: C; diff --git a/tests/baselines/reference/classWithOnlyPublicMembersEquivalentToInterface2.types b/tests/baselines/reference/classWithOnlyPublicMembersEquivalentToInterface2.types index 22440da1768..a5fbc06e0af 100644 --- a/tests/baselines/reference/classWithOnlyPublicMembersEquivalentToInterface2.types +++ b/tests/baselines/reference/classWithOnlyPublicMembersEquivalentToInterface2.types @@ -29,6 +29,7 @@ class C { >Object : Object 0: number; +>0 : number public static foo: string; // doesn't effect equivalence >foo : string @@ -56,6 +57,7 @@ interface I { >Object : Object 0: number; +>0 : number } var c: C; diff --git a/tests/baselines/reference/commonSourceDirectory.symbols b/tests/baselines/reference/commonSourceDirectory.symbols index 5409286ede5..89233ddd3cc 100644 --- a/tests/baselines/reference/commonSourceDirectory.symbols +++ b/tests/baselines/reference/commonSourceDirectory.symbols @@ -18,6 +18,8 @@ export const x = 0; === /types/bar.d.ts === declare module "bar" { +>"bar" : Symbol("bar", Decl(bar.d.ts, 0, 0)) + export const y = 0; >y : Symbol(y, Decl(bar.d.ts, 1, 16)) } diff --git a/tests/baselines/reference/commonSourceDirectory.types b/tests/baselines/reference/commonSourceDirectory.types index ce0169582d7..ea16e24b851 100644 --- a/tests/baselines/reference/commonSourceDirectory.types +++ b/tests/baselines/reference/commonSourceDirectory.types @@ -20,6 +20,8 @@ export const x = 0; === /types/bar.d.ts === declare module "bar" { +>"bar" : typeof "bar" + export const y = 0; >y : 0 >0 : 0 diff --git a/tests/baselines/reference/complexRecursiveCollections.symbols b/tests/baselines/reference/complexRecursiveCollections.symbols index 8533f5220a2..6e0bc95a292 100644 --- a/tests/baselines/reference/complexRecursiveCollections.symbols +++ b/tests/baselines/reference/complexRecursiveCollections.symbols @@ -3800,6 +3800,8 @@ declare module Immutable { } } declare module "immutable" { +>"immutable" : Symbol("immutable", Decl(immutable.ts, 506, 1)) + export = Immutable >Immutable : Symbol(Immutable, Decl(immutable.ts, 0, 0)) } diff --git a/tests/baselines/reference/complexRecursiveCollections.types b/tests/baselines/reference/complexRecursiveCollections.types index e3d4a01196e..1622d9ce360 100644 --- a/tests/baselines/reference/complexRecursiveCollections.types +++ b/tests/baselines/reference/complexRecursiveCollections.types @@ -3800,6 +3800,8 @@ declare module Immutable { } } declare module "immutable" { +>"immutable" : typeof "immutable" + export = Immutable >Immutable : typeof Immutable } diff --git a/tests/baselines/reference/computedPropertiesInDestructuring1_ES6.symbols b/tests/baselines/reference/computedPropertiesInDestructuring1_ES6.symbols index 10864291be1..e3a6c214404 100644 --- a/tests/baselines/reference/computedPropertiesInDestructuring1_ES6.symbols +++ b/tests/baselines/reference/computedPropertiesInDestructuring1_ES6.symbols @@ -16,6 +16,7 @@ let {["bar"]: bar2} = {bar: "bar"}; let {[11]: bar2_1} = {11: "bar"}; >11 : Symbol(bar2_1, Decl(computedPropertiesInDestructuring1_ES6.ts, 5, 5)) >bar2_1 : Symbol(bar2_1, Decl(computedPropertiesInDestructuring1_ES6.ts, 5, 5)) +>11 : Symbol(11, Decl(computedPropertiesInDestructuring1_ES6.ts, 5, 22)) let foo2 = () => "bar"; >foo2 : Symbol(foo2, Decl(computedPropertiesInDestructuring1_ES6.ts, 7, 3)) diff --git a/tests/baselines/reference/computedPropertiesInDestructuring1_ES6.types b/tests/baselines/reference/computedPropertiesInDestructuring1_ES6.types index 79fb8372023..0197c0b4a82 100644 --- a/tests/baselines/reference/computedPropertiesInDestructuring1_ES6.types +++ b/tests/baselines/reference/computedPropertiesInDestructuring1_ES6.types @@ -22,6 +22,7 @@ let {[11]: bar2_1} = {11: "bar"}; >11 : 11 >bar2_1 : string >{11: "bar"} : { 11: string; } +>11 : string >"bar" : "bar" let foo2 = () => "bar"; diff --git a/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.symbols b/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.symbols index fb303b1f8b3..23179820592 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.symbols +++ b/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.symbols @@ -23,6 +23,8 @@ foo({ >p : Symbol(p, Decl(computedPropertyNamesContextualType6_ES5.ts, 6, 5)) 0: () => { }, +>0 : Symbol(0, Decl(computedPropertyNamesContextualType6_ES5.ts, 7, 10)) + ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0] diff --git a/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.types b/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.types index 9c89065ac02..5c46bee4ccf 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.types +++ b/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.types @@ -26,6 +26,7 @@ foo({ >"" : "" 0: () => { }, +>0 : () => void >() => { } : () => void ["hi" + "bye"]: true, diff --git a/tests/baselines/reference/computedPropertyNamesContextualType6_ES6.symbols b/tests/baselines/reference/computedPropertyNamesContextualType6_ES6.symbols index b3e371447e2..d441c593fb3 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType6_ES6.symbols +++ b/tests/baselines/reference/computedPropertyNamesContextualType6_ES6.symbols @@ -23,6 +23,8 @@ foo({ >p : Symbol(p, Decl(computedPropertyNamesContextualType6_ES6.ts, 6, 5)) 0: () => { }, +>0 : Symbol(0, Decl(computedPropertyNamesContextualType6_ES6.ts, 7, 10)) + ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0] diff --git a/tests/baselines/reference/computedPropertyNamesContextualType6_ES6.types b/tests/baselines/reference/computedPropertyNamesContextualType6_ES6.types index 03295db5f70..f0e56a954cb 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType6_ES6.types +++ b/tests/baselines/reference/computedPropertyNamesContextualType6_ES6.types @@ -26,6 +26,7 @@ foo({ >"" : "" 0: () => { }, +>0 : () => void >() => { } : () => void ["hi" + "bye"]: true, diff --git a/tests/baselines/reference/computedPropertyNamesContextualType7_ES5.symbols b/tests/baselines/reference/computedPropertyNamesContextualType7_ES5.symbols index d6889f9912d..77e87a5bf48 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType7_ES5.symbols +++ b/tests/baselines/reference/computedPropertyNamesContextualType7_ES5.symbols @@ -36,6 +36,8 @@ foo({ >foo : Symbol(foo, Decl(computedPropertyNamesContextualType7_ES5.ts, 5, 1)) 0: () => { }, +>0 : Symbol(0, Decl(computedPropertyNamesContextualType7_ES5.ts, 10, 5)) + ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0] diff --git a/tests/baselines/reference/computedPropertyNamesContextualType7_ES5.types b/tests/baselines/reference/computedPropertyNamesContextualType7_ES5.types index b77a129a0b4..e838c06bfa1 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType7_ES5.types +++ b/tests/baselines/reference/computedPropertyNamesContextualType7_ES5.types @@ -38,6 +38,7 @@ foo({ >{ 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: number | boolean | (() => void) | number[]; [x: number]: number | (() => void) | number[]; 0: () => void; } 0: () => { }, +>0 : () => void >() => { } : () => void ["hi" + "bye"]: true, diff --git a/tests/baselines/reference/computedPropertyNamesContextualType7_ES6.symbols b/tests/baselines/reference/computedPropertyNamesContextualType7_ES6.symbols index d04c8f913bd..5f798731dba 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType7_ES6.symbols +++ b/tests/baselines/reference/computedPropertyNamesContextualType7_ES6.symbols @@ -36,6 +36,8 @@ foo({ >foo : Symbol(foo, Decl(computedPropertyNamesContextualType7_ES6.ts, 5, 1)) 0: () => { }, +>0 : Symbol(0, Decl(computedPropertyNamesContextualType7_ES6.ts, 10, 5)) + ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0] diff --git a/tests/baselines/reference/computedPropertyNamesContextualType7_ES6.types b/tests/baselines/reference/computedPropertyNamesContextualType7_ES6.types index f041b2b4eb4..ace52b05bcb 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType7_ES6.types +++ b/tests/baselines/reference/computedPropertyNamesContextualType7_ES6.types @@ -38,6 +38,7 @@ foo({ >{ 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: number | boolean | (() => void) | number[]; [x: number]: number | (() => void) | number[]; 0: () => void; } 0: () => { }, +>0 : () => void >() => { } : () => void ["hi" + "bye"]: true, diff --git a/tests/baselines/reference/conditionalTypes1.errors.txt b/tests/baselines/reference/conditionalTypes1.errors.txt index a7717d18263..869e740ad1a 100644 --- a/tests/baselines/reference/conditionalTypes1.errors.txt +++ b/tests/baselines/reference/conditionalTypes1.errors.txt @@ -1,16 +1,22 @@ -tests/cases/conformance/types/conditional/conditionalTypes1.ts(16,5): error TS2322: Type 'T' is not assignable to type 'Diff'. -tests/cases/conformance/types/conditional/conditionalTypes1.ts(21,5): error TS2322: Type 'T' is not assignable to type 'Diff'. - Type 'string | undefined' is not assignable to type 'Diff'. - Type 'undefined' is not assignable to type 'Diff'. -tests/cases/conformance/types/conditional/conditionalTypes1.ts(22,9): error TS2322: Type 'T' is not assignable to type 'string'. +tests/cases/conformance/types/conditional/conditionalTypes1.ts(12,5): error TS2322: Type 'T' is not assignable to type 'NonNullable'. +tests/cases/conformance/types/conditional/conditionalTypes1.ts(17,5): error TS2322: Type 'T' is not assignable to type 'NonNullable'. + Type 'string | undefined' is not assignable to type 'NonNullable'. + Type 'undefined' is not assignable to type 'NonNullable'. +tests/cases/conformance/types/conditional/conditionalTypes1.ts(18,9): error TS2322: Type 'T' is not assignable to type 'string'. Type 'string | undefined' is not assignable to type 'string'. Type 'undefined' is not assignable to type 'string'. -tests/cases/conformance/types/conditional/conditionalTypes1.ts(28,5): error TS2322: Type 'Partial[keyof T]' is not assignable to type 'Diff[keyof T], null | undefined>'. - Type 'T[keyof T] | undefined' is not assignable to type 'Diff[keyof T], null | undefined>'. - Type 'undefined' is not assignable to type 'Diff[keyof T], null | undefined>'. -tests/cases/conformance/types/conditional/conditionalTypes1.ts(100,5): error TS2322: Type 'Pick' is not assignable to type 'T'. -tests/cases/conformance/types/conditional/conditionalTypes1.ts(101,5): error TS2322: Type 'Pick' is not assignable to type 'T'. -tests/cases/conformance/types/conditional/conditionalTypes1.ts(103,5): error TS2322: Type 'Pick' is not assignable to type 'Pick'. +tests/cases/conformance/types/conditional/conditionalTypes1.ts(24,5): error TS2322: Type 'Partial[keyof T]' is not assignable to type 'NonNullable[keyof T]>'. + Type 'T[keyof T] | undefined' is not assignable to type 'NonNullable[keyof T]>'. + Type 'undefined' is not assignable to type 'NonNullable[keyof T]>'. +tests/cases/conformance/types/conditional/conditionalTypes1.ts(29,5): error TS2322: Type 'T["x"]' is not assignable to type 'NonNullable'. + Type 'string | undefined' is not assignable to type 'NonNullable'. + Type 'undefined' is not assignable to type 'NonNullable'. +tests/cases/conformance/types/conditional/conditionalTypes1.ts(30,9): error TS2322: Type 'T["x"]' is not assignable to type 'string'. + Type 'string | undefined' is not assignable to type 'string'. + Type 'undefined' is not assignable to type 'string'. +tests/cases/conformance/types/conditional/conditionalTypes1.ts(103,5): error TS2322: Type 'Pick' is not assignable to type 'T'. +tests/cases/conformance/types/conditional/conditionalTypes1.ts(104,5): error TS2322: Type 'Pick' is not assignable to type 'T'. +tests/cases/conformance/types/conditional/conditionalTypes1.ts(106,5): error TS2322: Type 'Pick' is not assignable to type 'Pick'. Type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]'. Type 'T[keyof T] extends Function ? keyof T : never' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]'. Type 'keyof T' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]'. @@ -18,8 +24,8 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(103,5): error TS2 Type 'T[keyof T] extends Function ? keyof T : never' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'. Type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'. Type 'T[keyof T] extends Function ? keyof T : never' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'. - Type 'keyof T' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'. -tests/cases/conformance/types/conditional/conditionalTypes1.ts(105,5): error TS2322: Type 'Pick' is not assignable to type 'Pick'. + Type 'keyof T' is not assignable to type 'never'. +tests/cases/conformance/types/conditional/conditionalTypes1.ts(108,5): error TS2322: Type 'Pick' is not assignable to type 'Pick'. Type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]'. Type 'T[keyof T] extends Function ? never : keyof T' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]'. Type 'keyof T' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]'. @@ -27,49 +33,48 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(105,5): error TS2 Type 'T[keyof T] extends Function ? never : keyof T' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'. Type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'. Type 'T[keyof T] extends Function ? never : keyof T' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'. - Type 'keyof T' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'. -tests/cases/conformance/types/conditional/conditionalTypes1.ts(111,5): error TS2322: Type 'keyof T' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]'. + Type 'keyof T' is not assignable to type 'never'. +tests/cases/conformance/types/conditional/conditionalTypes1.ts(114,5): error TS2322: Type 'keyof T' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]'. Type 'keyof T' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'. -tests/cases/conformance/types/conditional/conditionalTypes1.ts(112,5): error TS2322: Type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]'. +tests/cases/conformance/types/conditional/conditionalTypes1.ts(115,5): error TS2322: Type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]'. Type 'T[keyof T] extends Function ? never : keyof T' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]'. Type 'keyof T' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]'. Type 'T[keyof T] extends Function ? never : keyof T' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'. Type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'. Type 'T[keyof T] extends Function ? never : keyof T' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'. - Type 'keyof T' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'. -tests/cases/conformance/types/conditional/conditionalTypes1.ts(113,5): error TS2322: Type 'keyof T' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]'. + Type 'keyof T' is not assignable to type 'never'. +tests/cases/conformance/types/conditional/conditionalTypes1.ts(116,5): error TS2322: Type 'keyof T' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]'. Type 'keyof T' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'. -tests/cases/conformance/types/conditional/conditionalTypes1.ts(114,5): error TS2322: Type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]'. +tests/cases/conformance/types/conditional/conditionalTypes1.ts(117,5): error TS2322: Type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]'. Type 'T[keyof T] extends Function ? keyof T : never' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]'. Type 'keyof T' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]'. Type 'T[keyof T] extends Function ? keyof T : never' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'. Type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'. Type 'T[keyof T] extends Function ? keyof T : never' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'. - Type 'keyof T' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'. -tests/cases/conformance/types/conditional/conditionalTypes1.ts(131,10): error TS2540: Cannot assign to 'id' because it is a constant or a read-only property. -tests/cases/conformance/types/conditional/conditionalTypes1.ts(132,5): error TS2542: Index signature in type 'DeepReadonlyArray' only permits reading. -tests/cases/conformance/types/conditional/conditionalTypes1.ts(133,22): error TS2540: Cannot assign to 'id' because it is a constant or a read-only property. -tests/cases/conformance/types/conditional/conditionalTypes1.ts(134,10): error TS2339: Property 'updatePart' does not exist on type 'DeepReadonlyObject'. -tests/cases/conformance/types/conditional/conditionalTypes1.ts(156,5): error TS2322: Type 'ZeroOf' is not assignable to type 'T'. + Type 'keyof T' is not assignable to type 'never'. +tests/cases/conformance/types/conditional/conditionalTypes1.ts(134,10): error TS2540: Cannot assign to 'id' because it is a constant or a read-only property. +tests/cases/conformance/types/conditional/conditionalTypes1.ts(135,5): error TS2542: Index signature in type 'DeepReadonlyArray' only permits reading. +tests/cases/conformance/types/conditional/conditionalTypes1.ts(136,22): error TS2540: Cannot assign to 'id' because it is a constant or a read-only property. +tests/cases/conformance/types/conditional/conditionalTypes1.ts(137,10): error TS2339: Property 'updatePart' does not exist on type 'DeepReadonlyObject'. +tests/cases/conformance/types/conditional/conditionalTypes1.ts(159,5): error TS2322: Type 'ZeroOf' is not assignable to type 'T'. Type '0 | (T extends string ? "" : false)' is not assignable to type 'T'. Type '0' is not assignable to type 'T'. Type '"" | 0' is not assignable to type 'T'. Type '""' is not assignable to type 'T'. -tests/cases/conformance/types/conditional/conditionalTypes1.ts(157,5): error TS2322: Type 'T' is not assignable to type 'ZeroOf'. +tests/cases/conformance/types/conditional/conditionalTypes1.ts(160,5): error TS2322: Type 'T' is not assignable to type 'ZeroOf'. Type 'string | number' is not assignable to type 'ZeroOf'. Type 'string' is not assignable to type 'ZeroOf'. +tests/cases/conformance/types/conditional/conditionalTypes1.ts(250,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'z' must be of type 'T1', but here has type 'Foo'. +tests/cases/conformance/types/conditional/conditionalTypes1.ts(275,43): error TS2322: Type 'T95' is not assignable to type 'T94'. + Type 'boolean' is not assignable to type 'true'. -==== tests/cases/conformance/types/conditional/conditionalTypes1.ts (18 errors) ==== - type Diff = T extends U ? never : T; - type Filter = T extends U ? T : never; - type NonNullable = Diff; +==== tests/cases/conformance/types/conditional/conditionalTypes1.ts (22 errors) ==== + type T00 = Exclude<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "b" | "d" + type T01 = Extract<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "a" | "c" - type T00 = Diff<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "b" | "d" - type T01 = Filter<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "a" | "c" - - type T02 = Diff void), Function>; // string | number - type T03 = Filter void), Function>; // () => void + type T02 = Exclude void), Function>; // string | number + type T03 = Extract void), Function>; // () => void type T04 = NonNullable; // string | number type T05 = NonNullable<(() => string) | string[] | null | undefined>; // (() => string) | string[] @@ -78,16 +83,16 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(157,5): error TS2 x = y; y = x; // Error ~ -!!! error TS2322: Type 'T' is not assignable to type 'Diff'. +!!! error TS2322: Type 'T' is not assignable to type 'NonNullable'. } function f2(x: T, y: NonNullable) { x = y; y = x; // Error ~ -!!! error TS2322: Type 'T' is not assignable to type 'Diff'. -!!! error TS2322: Type 'string | undefined' is not assignable to type 'Diff'. -!!! error TS2322: Type 'undefined' is not assignable to type 'Diff'. +!!! error TS2322: Type 'T' is not assignable to type 'NonNullable'. +!!! error TS2322: Type 'string | undefined' is not assignable to type 'NonNullable'. +!!! error TS2322: Type 'undefined' is not assignable to type 'NonNullable'. let s1: string = x; // Error ~~ !!! error TS2322: Type 'T' is not assignable to type 'string'. @@ -100,30 +105,45 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(157,5): error TS2 x = y; y = x; // Error ~ -!!! error TS2322: Type 'Partial[keyof T]' is not assignable to type 'Diff[keyof T], null | undefined>'. -!!! error TS2322: Type 'T[keyof T] | undefined' is not assignable to type 'Diff[keyof T], null | undefined>'. -!!! error TS2322: Type 'undefined' is not assignable to type 'Diff[keyof T], null | undefined>'. +!!! error TS2322: Type 'Partial[keyof T]' is not assignable to type 'NonNullable[keyof T]>'. +!!! error TS2322: Type 'T[keyof T] | undefined' is not assignable to type 'NonNullable[keyof T]>'. +!!! error TS2322: Type 'undefined' is not assignable to type 'NonNullable[keyof T]>'. + } + + function f4(x: T["x"], y: NonNullable) { + x = y; + y = x; // Error + ~ +!!! error TS2322: Type 'T["x"]' is not assignable to type 'NonNullable'. +!!! error TS2322: Type 'string | undefined' is not assignable to type 'NonNullable'. +!!! error TS2322: Type 'undefined' is not assignable to type 'NonNullable'. + let s1: string = x; // Error + ~~ +!!! error TS2322: Type 'T["x"]' is not assignable to type 'string'. +!!! error TS2322: Type 'string | undefined' is not assignable to type 'string'. +!!! error TS2322: Type 'undefined' is not assignable to type 'string'. + let s2: string = y; } type Options = { k: "a", a: number } | { k: "b", b: string } | { k: "c", c: boolean }; - type T10 = Diff; // { k: "c", c: boolean } - type T11 = Filter; // { k: "a", a: number } | { k: "b", b: string } + type T10 = Exclude; // { k: "c", c: boolean } + type T11 = Extract; // { k: "a", a: number } | { k: "b", b: string } - type T12 = Diff; // { k: "c", c: boolean } - type T13 = Filter; // { k: "a", a: number } | { k: "b", b: string } + type T12 = Exclude; // { k: "c", c: boolean } + type T13 = Extract; // { k: "a", a: number } | { k: "b", b: string } - type T14 = Diff; // Options - type T15 = Filter; // never + type T14 = Exclude; // Options + type T15 = Extract; // never - declare function f4(p: K): Filter; - let x0 = f4("a"); // { k: "a", a: number } + declare function f5(p: K): Extract; + let x0 = f5("a"); // { k: "a", a: number } - type OptionsOfKind = Filter; + type OptionsOfKind = Extract; type T16 = OptionsOfKind<"a" | "b">; // { k: "a", a: number } | { k: "b", b: string } - type Select = Filter; + type Select = Extract; type T17 = Select; // // { k: "a", a: number } | { k: "b", b: string } @@ -191,7 +211,7 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(157,5): error TS2 !!! error TS2322: Type 'T[keyof T] extends Function ? keyof T : never' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'. !!! error TS2322: Type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'. !!! error TS2322: Type 'T[keyof T] extends Function ? keyof T : never' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'. -!!! error TS2322: Type 'keyof T' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'. +!!! error TS2322: Type 'keyof T' is not assignable to type 'never'. z = x; z = y; // Error ~ @@ -203,7 +223,7 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(157,5): error TS2 !!! error TS2322: Type 'T[keyof T] extends Function ? never : keyof T' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'. !!! error TS2322: Type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'. !!! error TS2322: Type 'T[keyof T] extends Function ? never : keyof T' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'. -!!! error TS2322: Type 'keyof T' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'. +!!! error TS2322: Type 'keyof T' is not assignable to type 'never'. } function f8(x: keyof T, y: FunctionPropertyNames, z: NonFunctionPropertyNames) { @@ -221,7 +241,7 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(157,5): error TS2 !!! error TS2322: Type 'T[keyof T] extends Function ? never : keyof T' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'. !!! error TS2322: Type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'. !!! error TS2322: Type 'T[keyof T] extends Function ? never : keyof T' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'. -!!! error TS2322: Type 'keyof T' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'. +!!! error TS2322: Type 'keyof T' is not assignable to type 'never'. z = x; // Error ~ !!! error TS2322: Type 'keyof T' is not assignable to type '{ [K in keyof T]: T[K] extends Function ? never : K; }[keyof T]'. @@ -234,7 +254,7 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(157,5): error TS2 !!! error TS2322: Type 'T[keyof T] extends Function ? keyof T : never' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'. !!! error TS2322: Type '{ [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'. !!! error TS2322: Type 'T[keyof T] extends Function ? keyof T : never' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'. -!!! error TS2322: Type 'keyof T' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'. +!!! error TS2322: Type 'keyof T' is not assignable to type 'never'. } type DeepReadonly = @@ -344,4 +364,87 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(157,5): error TS2 type T50 = IsNever; // true type T51 = IsNever; // false type T52 = IsNever; // false + + // Repros from #21664 + + type Eq = T extends U ? U extends T ? true : false : false; + type T60 = Eq; // true + type T61 = Eq; // false + type T62 = Eq; // false + type T63 = Eq; // true + + type Eq1 = Eq extends false ? false : true; + type T70 = Eq1; // true + type T71 = Eq1; // false + type T72 = Eq1; // false + type T73 = Eq1; // true + + type Eq2 = Eq extends true ? true : false; + type T80 = Eq2; // true + type T81 = Eq2; // false + type T82 = Eq2; // false + type T83 = Eq2; // true + + // Repro from #21756 + + type Foo = T extends string ? boolean : number; + type Bar = T extends string ? boolean : number; + const convert = (value: Foo): Bar => value; + + type Baz = Foo; + const convert2 = (value: Foo): Baz => value; + + function f31() { + type T1 = T extends string ? boolean : number; + type T2 = T extends string ? boolean : number; + var x: T1; + var x: T2; + } + + function f32() { + type T1 = T & U extends string ? boolean : number; + type T2 = Foo; + var z: T1; + var z: T2; // Error, T2 is distributive, T1 isn't + ~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'z' must be of type 'T1', but here has type 'Foo'. + } + + function f33() { + type T1 = Foo; + type T2 = Bar; + var z: T1; + var z: T2; + } + + // Repro from #21823 + + type T90 = T extends 0 ? 0 : () => 0; + type T91 = T extends 0 ? 0 : () => 0; + const f40 = (a: T90): T91 => a; + const f41 = (a: T91): T90 => a; + + type T92 = T extends () => 0 ? () => 1 : () => 2; + type T93 = T extends () => 0 ? () => 1 : () => 2; + const f42 = (a: T92): T93 => a; + const f43 = (a: T93): T92 => a; + + type T94 = T extends string ? true : 42; + type T95 = T extends string ? boolean : number; + const f44 = (value: T94): T95 => value; + const f45 = (value: T95): T94 => value; // Error + ~~~~~ +!!! error TS2322: Type 'T95' is not assignable to type 'T94'. +!!! error TS2322: Type 'boolean' is not assignable to type 'true'. + + // Repro from #21863 + + function f50() { + type Eq = T extends U ? U extends T ? true : false : false; + type If = S extends false ? U : T; + type Omit = { [P in keyof T]: If, never, P>; }[keyof T]; + type Omit2 = { [P in keyof T]: If, never, P>; }[keyof T]; + type A = Omit<{ a: void; b: never; }>; // 'a' + type B = Omit2<{ a: void; b: never; }>; // 'a' + } \ No newline at end of file diff --git a/tests/baselines/reference/conditionalTypes1.js b/tests/baselines/reference/conditionalTypes1.js index 0da7794a762..9020774d7fe 100644 --- a/tests/baselines/reference/conditionalTypes1.js +++ b/tests/baselines/reference/conditionalTypes1.js @@ -1,13 +1,9 @@ //// [conditionalTypes1.ts] -type Diff = T extends U ? never : T; -type Filter = T extends U ? T : never; -type NonNullable = Diff; +type T00 = Exclude<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "b" | "d" +type T01 = Extract<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "a" | "c" -type T00 = Diff<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "b" | "d" -type T01 = Filter<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "a" | "c" - -type T02 = Diff void), Function>; // string | number -type T03 = Filter void), Function>; // () => void +type T02 = Exclude void), Function>; // string | number +type T03 = Extract void), Function>; // () => void type T04 = NonNullable; // string | number type T05 = NonNullable<(() => string) | string[] | null | undefined>; // (() => string) | string[] @@ -29,25 +25,32 @@ function f3(x: Partial[keyof T], y: NonNullable[keyof T]>) { y = x; // Error } +function f4(x: T["x"], y: NonNullable) { + x = y; + y = x; // Error + let s1: string = x; // Error + let s2: string = y; +} + type Options = { k: "a", a: number } | { k: "b", b: string } | { k: "c", c: boolean }; -type T10 = Diff; // { k: "c", c: boolean } -type T11 = Filter; // { k: "a", a: number } | { k: "b", b: string } +type T10 = Exclude; // { k: "c", c: boolean } +type T11 = Extract; // { k: "a", a: number } | { k: "b", b: string } -type T12 = Diff; // { k: "c", c: boolean } -type T13 = Filter; // { k: "a", a: number } | { k: "b", b: string } +type T12 = Exclude; // { k: "c", c: boolean } +type T13 = Extract; // { k: "a", a: number } | { k: "b", b: string } -type T14 = Diff; // Options -type T15 = Filter; // never +type T14 = Exclude; // Options +type T15 = Extract; // never -declare function f4(p: K): Filter; -let x0 = f4("a"); // { k: "a", a: number } +declare function f5(p: K): Extract; +let x0 = f5("a"); // { k: "a", a: number } -type OptionsOfKind = Filter; +type OptionsOfKind = Extract; type T16 = OptionsOfKind<"a" | "b">; // { k: "a", a: number } | { k: "b", b: string } -type Select = Filter; +type Select = Extract; type T17 = Select; // // { k: "a", a: number } | { k: "b", b: string } @@ -204,6 +207,84 @@ type IsNever = T extends never ? true : false; type T50 = IsNever; // true type T51 = IsNever; // false type T52 = IsNever; // false + +// Repros from #21664 + +type Eq = T extends U ? U extends T ? true : false : false; +type T60 = Eq; // true +type T61 = Eq; // false +type T62 = Eq; // false +type T63 = Eq; // true + +type Eq1 = Eq extends false ? false : true; +type T70 = Eq1; // true +type T71 = Eq1; // false +type T72 = Eq1; // false +type T73 = Eq1; // true + +type Eq2 = Eq extends true ? true : false; +type T80 = Eq2; // true +type T81 = Eq2; // false +type T82 = Eq2; // false +type T83 = Eq2; // true + +// Repro from #21756 + +type Foo = T extends string ? boolean : number; +type Bar = T extends string ? boolean : number; +const convert = (value: Foo): Bar => value; + +type Baz = Foo; +const convert2 = (value: Foo): Baz => value; + +function f31() { + type T1 = T extends string ? boolean : number; + type T2 = T extends string ? boolean : number; + var x: T1; + var x: T2; +} + +function f32() { + type T1 = T & U extends string ? boolean : number; + type T2 = Foo; + var z: T1; + var z: T2; // Error, T2 is distributive, T1 isn't +} + +function f33() { + type T1 = Foo; + type T2 = Bar; + var z: T1; + var z: T2; +} + +// Repro from #21823 + +type T90 = T extends 0 ? 0 : () => 0; +type T91 = T extends 0 ? 0 : () => 0; +const f40 = (a: T90): T91 => a; +const f41 = (a: T91): T90 => a; + +type T92 = T extends () => 0 ? () => 1 : () => 2; +type T93 = T extends () => 0 ? () => 1 : () => 2; +const f42 = (a: T92): T93 => a; +const f43 = (a: T93): T92 => a; + +type T94 = T extends string ? true : 42; +type T95 = T extends string ? boolean : number; +const f44 = (value: T94): T95 => value; +const f45 = (value: T95): T94 => value; // Error + +// Repro from #21863 + +function f50() { + type Eq = T extends U ? U extends T ? true : false : false; + type If = S extends false ? U : T; + type Omit = { [P in keyof T]: If, never, P>; }[keyof T]; + type Omit2 = { [P in keyof T]: If, never, P>; }[keyof T]; + type A = Omit<{ a: void; b: never; }>; // 'a' + type B = Omit2<{ a: void; b: never; }>; // 'a' +} //// [conditionalTypes1.js] @@ -222,7 +303,13 @@ function f3(x, y) { x = y; y = x; // Error } -var x0 = f4("a"); // { k: "a", a: number } +function f4(x, y) { + x = y; + y = x; // Error + var s1 = x; // Error + var s2 = y; +} +var x0 = f5("a"); // { k: "a", a: number } function f7(x, y, z) { x = y; // Error x = z; // Error @@ -265,21 +352,44 @@ function f21(x, y) { x = y; // Error y = x; // Error } +var convert = function (value) { return value; }; +var convert2 = function (value) { return value; }; +function f31() { + var x; + var x; +} +function f32() { + var z; + var z; // Error, T2 is distributive, T1 isn't +} +function f33() { + var z; + var z; +} +var f40 = function (a) { return a; }; +var f41 = function (a) { return a; }; +var f42 = function (a) { return a; }; +var f43 = function (a) { return a; }; +var f44 = function (value) { return value; }; +var f45 = function (value) { return value; }; // Error +// Repro from #21863 +function f50() { +} //// [conditionalTypes1.d.ts] -declare type Diff = T extends U ? never : T; -declare type Filter = T extends U ? T : never; -declare type NonNullable = Diff; -declare type T00 = Diff<"a" | "b" | "c" | "d", "a" | "c" | "f">; -declare type T01 = Filter<"a" | "b" | "c" | "d", "a" | "c" | "f">; -declare type T02 = Diff void), Function>; -declare type T03 = Filter void), Function>; +declare type T00 = Exclude<"a" | "b" | "c" | "d", "a" | "c" | "f">; +declare type T01 = Extract<"a" | "b" | "c" | "d", "a" | "c" | "f">; +declare type T02 = Exclude void), Function>; +declare type T03 = Extract void), Function>; declare type T04 = NonNullable; declare type T05 = NonNullable<(() => string) | string[] | null | undefined>; declare function f1(x: T, y: NonNullable): void; declare function f2(x: T, y: NonNullable): void; declare function f3(x: Partial[keyof T], y: NonNullable[keyof T]>): void; +declare function f4(x: T["x"], y: NonNullable): void; declare type Options = { k: "a"; a: number; @@ -290,40 +400,40 @@ declare type Options = { k: "c"; c: boolean; }; -declare type T10 = Diff; -declare type T11 = Filter; -declare type T12 = Diff; -declare type T13 = Filter; -declare type T14 = Diff; -declare type T15 = Filter; -declare function f4(p: K): Filter(p: K): Extract; declare let x0: { k: "a"; a: number; }; -declare type OptionsOfKind = Filter = Extract; declare type T16 = OptionsOfKind<"a" | "b">; -declare type Select = Filter = Extract; declare type T17 = Select; @@ -415,3 +525,39 @@ declare type IsNever = T extends never ? true : false; declare type T50 = IsNever; declare type T51 = IsNever; declare type T52 = IsNever; +declare type Eq = T extends U ? U extends T ? true : false : false; +declare type T60 = Eq; +declare type T61 = Eq; +declare type T62 = Eq; +declare type T63 = Eq; +declare type Eq1 = Eq extends false ? false : true; +declare type T70 = Eq1; +declare type T71 = Eq1; +declare type T72 = Eq1; +declare type T73 = Eq1; +declare type Eq2 = Eq extends true ? true : false; +declare type T80 = Eq2; +declare type T81 = Eq2; +declare type T82 = Eq2; +declare type T83 = Eq2; +declare type Foo = T extends string ? boolean : number; +declare type Bar = T extends string ? boolean : number; +declare const convert: (value: Foo) => Foo; +declare type Baz = Foo; +declare const convert2: (value: Foo) => Foo; +declare function f31(): void; +declare function f32(): void; +declare function f33(): void; +declare type T90 = T extends 0 ? 0 : () => 0; +declare type T91 = T extends 0 ? 0 : () => 0; +declare const f40: (a: T90) => T91; +declare const f41: (a: T91) => T90; +declare type T92 = T extends () => 0 ? () => 1 : () => 2; +declare type T93 = T extends () => 0 ? () => 1 : () => 2; +declare const f42: (a: T92) => T93; +declare const f43: (a: T93) => T92; +declare type T94 = T extends string ? true : 42; +declare type T95 = T extends string ? boolean : number; +declare const f44: (value: T94) => T95; +declare const f45: (value: T95) => T94; +declare function f50(): void; diff --git a/tests/baselines/reference/conditionalTypes1.symbols b/tests/baselines/reference/conditionalTypes1.symbols index 9d3b79d5c30..6c05ee1eeee 100644 --- a/tests/baselines/reference/conditionalTypes1.symbols +++ b/tests/baselines/reference/conditionalTypes1.symbols @@ -1,779 +1,1123 @@ === tests/cases/conformance/types/conditional/conditionalTypes1.ts === -type Diff = T extends U ? never : T; ->Diff : Symbol(Diff, Decl(conditionalTypes1.ts, 0, 0)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 0, 10)) ->U : Symbol(U, Decl(conditionalTypes1.ts, 0, 12)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 0, 10)) ->U : Symbol(U, Decl(conditionalTypes1.ts, 0, 12)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 0, 10)) +type T00 = Exclude<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "b" | "d" +>T00 : Symbol(T00, Decl(conditionalTypes1.ts, 0, 0)) +>Exclude : Symbol(Exclude, Decl(lib.d.ts, --, --)) -type Filter = T extends U ? T : never; ->Filter : Symbol(Filter, Decl(conditionalTypes1.ts, 0, 42)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 1, 12)) ->U : Symbol(U, Decl(conditionalTypes1.ts, 1, 14)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 1, 12)) ->U : Symbol(U, Decl(conditionalTypes1.ts, 1, 14)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 1, 12)) +type T01 = Extract<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "a" | "c" +>T01 : Symbol(T01, Decl(conditionalTypes1.ts, 0, 59)) +>Extract : Symbol(Extract, Decl(lib.d.ts, --, --)) -type NonNullable = Diff; ->NonNullable : Symbol(NonNullable, Decl(conditionalTypes1.ts, 1, 44)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 2, 17)) ->Diff : Symbol(Diff, Decl(conditionalTypes1.ts, 0, 0)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 2, 17)) - -type T00 = Diff<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "b" | "d" ->T00 : Symbol(T00, Decl(conditionalTypes1.ts, 2, 48)) ->Diff : Symbol(Diff, Decl(conditionalTypes1.ts, 0, 0)) - -type T01 = Filter<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "a" | "c" ->T01 : Symbol(T01, Decl(conditionalTypes1.ts, 4, 56)) ->Filter : Symbol(Filter, Decl(conditionalTypes1.ts, 0, 42)) - -type T02 = Diff void), Function>; // string | number ->T02 : Symbol(T02, Decl(conditionalTypes1.ts, 5, 58)) ->Diff : Symbol(Diff, Decl(conditionalTypes1.ts, 0, 0)) +type T02 = Exclude void), Function>; // string | number +>T02 : Symbol(T02, Decl(conditionalTypes1.ts, 1, 59)) +>Exclude : Symbol(Exclude, Decl(lib.d.ts, --, --)) >Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) -type T03 = Filter void), Function>; // () => void ->T03 : Symbol(T03, Decl(conditionalTypes1.ts, 7, 58)) ->Filter : Symbol(Filter, Decl(conditionalTypes1.ts, 0, 42)) +type T03 = Extract void), Function>; // () => void +>T03 : Symbol(T03, Decl(conditionalTypes1.ts, 3, 61)) +>Extract : Symbol(Extract, Decl(lib.d.ts, --, --)) >Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) type T04 = NonNullable; // string | number ->T04 : Symbol(T04, Decl(conditionalTypes1.ts, 8, 60)) ->NonNullable : Symbol(NonNullable, Decl(conditionalTypes1.ts, 1, 44)) +>T04 : Symbol(T04, Decl(conditionalTypes1.ts, 4, 61)) +>NonNullable : Symbol(NonNullable, Decl(lib.d.ts, --, --)) type T05 = NonNullable<(() => string) | string[] | null | undefined>; // (() => string) | string[] ->T05 : Symbol(T05, Decl(conditionalTypes1.ts, 10, 52)) ->NonNullable : Symbol(NonNullable, Decl(conditionalTypes1.ts, 1, 44)) +>T05 : Symbol(T05, Decl(conditionalTypes1.ts, 6, 52)) +>NonNullable : Symbol(NonNullable, Decl(lib.d.ts, --, --)) function f1(x: T, y: NonNullable) { ->f1 : Symbol(f1, Decl(conditionalTypes1.ts, 11, 69)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 13, 12)) ->x : Symbol(x, Decl(conditionalTypes1.ts, 13, 15)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 13, 12)) ->y : Symbol(y, Decl(conditionalTypes1.ts, 13, 20)) ->NonNullable : Symbol(NonNullable, Decl(conditionalTypes1.ts, 1, 44)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 13, 12)) +>f1 : Symbol(f1, Decl(conditionalTypes1.ts, 7, 69)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 9, 12)) +>x : Symbol(x, Decl(conditionalTypes1.ts, 9, 15)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 9, 12)) +>y : Symbol(y, Decl(conditionalTypes1.ts, 9, 20)) +>NonNullable : Symbol(NonNullable, Decl(lib.d.ts, --, --)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 9, 12)) x = y; ->x : Symbol(x, Decl(conditionalTypes1.ts, 13, 15)) ->y : Symbol(y, Decl(conditionalTypes1.ts, 13, 20)) +>x : Symbol(x, Decl(conditionalTypes1.ts, 9, 15)) +>y : Symbol(y, Decl(conditionalTypes1.ts, 9, 20)) y = x; // Error ->y : Symbol(y, Decl(conditionalTypes1.ts, 13, 20)) ->x : Symbol(x, Decl(conditionalTypes1.ts, 13, 15)) +>y : Symbol(y, Decl(conditionalTypes1.ts, 9, 20)) +>x : Symbol(x, Decl(conditionalTypes1.ts, 9, 15)) } function f2(x: T, y: NonNullable) { ->f2 : Symbol(f2, Decl(conditionalTypes1.ts, 16, 1)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 18, 12)) ->x : Symbol(x, Decl(conditionalTypes1.ts, 18, 42)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 18, 12)) ->y : Symbol(y, Decl(conditionalTypes1.ts, 18, 47)) ->NonNullable : Symbol(NonNullable, Decl(conditionalTypes1.ts, 1, 44)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 18, 12)) +>f2 : Symbol(f2, Decl(conditionalTypes1.ts, 12, 1)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 14, 12)) +>x : Symbol(x, Decl(conditionalTypes1.ts, 14, 42)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 14, 12)) +>y : Symbol(y, Decl(conditionalTypes1.ts, 14, 47)) +>NonNullable : Symbol(NonNullable, Decl(lib.d.ts, --, --)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 14, 12)) x = y; ->x : Symbol(x, Decl(conditionalTypes1.ts, 18, 42)) ->y : Symbol(y, Decl(conditionalTypes1.ts, 18, 47)) +>x : Symbol(x, Decl(conditionalTypes1.ts, 14, 42)) +>y : Symbol(y, Decl(conditionalTypes1.ts, 14, 47)) y = x; // Error ->y : Symbol(y, Decl(conditionalTypes1.ts, 18, 47)) ->x : Symbol(x, Decl(conditionalTypes1.ts, 18, 42)) +>y : Symbol(y, Decl(conditionalTypes1.ts, 14, 47)) +>x : Symbol(x, Decl(conditionalTypes1.ts, 14, 42)) let s1: string = x; // Error ->s1 : Symbol(s1, Decl(conditionalTypes1.ts, 21, 7)) ->x : Symbol(x, Decl(conditionalTypes1.ts, 18, 42)) +>s1 : Symbol(s1, Decl(conditionalTypes1.ts, 17, 7)) +>x : Symbol(x, Decl(conditionalTypes1.ts, 14, 42)) let s2: string = y; ->s2 : Symbol(s2, Decl(conditionalTypes1.ts, 22, 7)) ->y : Symbol(y, Decl(conditionalTypes1.ts, 18, 47)) +>s2 : Symbol(s2, Decl(conditionalTypes1.ts, 18, 7)) +>y : Symbol(y, Decl(conditionalTypes1.ts, 14, 47)) } function f3(x: Partial[keyof T], y: NonNullable[keyof T]>) { ->f3 : Symbol(f3, Decl(conditionalTypes1.ts, 23, 1)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 25, 12)) ->x : Symbol(x, Decl(conditionalTypes1.ts, 25, 15)) +>f3 : Symbol(f3, Decl(conditionalTypes1.ts, 19, 1)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 21, 12)) +>x : Symbol(x, Decl(conditionalTypes1.ts, 21, 15)) >Partial : Symbol(Partial, Decl(lib.d.ts, --, --)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 25, 12)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 25, 12)) ->y : Symbol(y, Decl(conditionalTypes1.ts, 25, 38)) ->NonNullable : Symbol(NonNullable, Decl(conditionalTypes1.ts, 1, 44)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 21, 12)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 21, 12)) +>y : Symbol(y, Decl(conditionalTypes1.ts, 21, 38)) +>NonNullable : Symbol(NonNullable, Decl(lib.d.ts, --, --)) >Partial : Symbol(Partial, Decl(lib.d.ts, --, --)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 25, 12)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 25, 12)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 21, 12)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 21, 12)) x = y; ->x : Symbol(x, Decl(conditionalTypes1.ts, 25, 15)) ->y : Symbol(y, Decl(conditionalTypes1.ts, 25, 38)) +>x : Symbol(x, Decl(conditionalTypes1.ts, 21, 15)) +>y : Symbol(y, Decl(conditionalTypes1.ts, 21, 38)) y = x; // Error ->y : Symbol(y, Decl(conditionalTypes1.ts, 25, 38)) ->x : Symbol(x, Decl(conditionalTypes1.ts, 25, 15)) +>y : Symbol(y, Decl(conditionalTypes1.ts, 21, 38)) +>x : Symbol(x, Decl(conditionalTypes1.ts, 21, 15)) +} + +function f4(x: T["x"], y: NonNullable) { +>f4 : Symbol(f4, Decl(conditionalTypes1.ts, 24, 1)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 26, 12)) +>x : Symbol(x, Decl(conditionalTypes1.ts, 26, 23)) +>x : Symbol(x, Decl(conditionalTypes1.ts, 26, 49)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 26, 12)) +>y : Symbol(y, Decl(conditionalTypes1.ts, 26, 59)) +>NonNullable : Symbol(NonNullable, Decl(lib.d.ts, --, --)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 26, 12)) + + x = y; +>x : Symbol(x, Decl(conditionalTypes1.ts, 26, 49)) +>y : Symbol(y, Decl(conditionalTypes1.ts, 26, 59)) + + y = x; // Error +>y : Symbol(y, Decl(conditionalTypes1.ts, 26, 59)) +>x : Symbol(x, Decl(conditionalTypes1.ts, 26, 49)) + + let s1: string = x; // Error +>s1 : Symbol(s1, Decl(conditionalTypes1.ts, 29, 7)) +>x : Symbol(x, Decl(conditionalTypes1.ts, 26, 49)) + + let s2: string = y; +>s2 : Symbol(s2, Decl(conditionalTypes1.ts, 30, 7)) +>y : Symbol(y, Decl(conditionalTypes1.ts, 26, 59)) } type Options = { k: "a", a: number } | { k: "b", b: string } | { k: "c", c: boolean }; ->Options : Symbol(Options, Decl(conditionalTypes1.ts, 28, 1)) ->k : Symbol(k, Decl(conditionalTypes1.ts, 30, 16)) ->a : Symbol(a, Decl(conditionalTypes1.ts, 30, 24)) ->k : Symbol(k, Decl(conditionalTypes1.ts, 30, 40)) ->b : Symbol(b, Decl(conditionalTypes1.ts, 30, 48)) ->k : Symbol(k, Decl(conditionalTypes1.ts, 30, 64)) ->c : Symbol(c, Decl(conditionalTypes1.ts, 30, 72)) +>Options : Symbol(Options, Decl(conditionalTypes1.ts, 31, 1)) +>k : Symbol(k, Decl(conditionalTypes1.ts, 33, 16)) +>a : Symbol(a, Decl(conditionalTypes1.ts, 33, 24)) +>k : Symbol(k, Decl(conditionalTypes1.ts, 33, 40)) +>b : Symbol(b, Decl(conditionalTypes1.ts, 33, 48)) +>k : Symbol(k, Decl(conditionalTypes1.ts, 33, 64)) +>c : Symbol(c, Decl(conditionalTypes1.ts, 33, 72)) -type T10 = Diff; // { k: "c", c: boolean } ->T10 : Symbol(T10, Decl(conditionalTypes1.ts, 30, 86)) ->Diff : Symbol(Diff, Decl(conditionalTypes1.ts, 0, 0)) ->Options : Symbol(Options, Decl(conditionalTypes1.ts, 28, 1)) ->k : Symbol(k, Decl(conditionalTypes1.ts, 32, 26)) +type T10 = Exclude; // { k: "c", c: boolean } +>T10 : Symbol(T10, Decl(conditionalTypes1.ts, 33, 86)) +>Exclude : Symbol(Exclude, Decl(lib.d.ts, --, --)) +>Options : Symbol(Options, Decl(conditionalTypes1.ts, 31, 1)) +>k : Symbol(k, Decl(conditionalTypes1.ts, 35, 29)) -type T11 = Filter; // { k: "a", a: number } | { k: "b", b: string } ->T11 : Symbol(T11, Decl(conditionalTypes1.ts, 32, 43)) ->Filter : Symbol(Filter, Decl(conditionalTypes1.ts, 0, 42)) ->Options : Symbol(Options, Decl(conditionalTypes1.ts, 28, 1)) ->k : Symbol(k, Decl(conditionalTypes1.ts, 33, 28)) +type T11 = Extract; // { k: "a", a: number } | { k: "b", b: string } +>T11 : Symbol(T11, Decl(conditionalTypes1.ts, 35, 46)) +>Extract : Symbol(Extract, Decl(lib.d.ts, --, --)) +>Options : Symbol(Options, Decl(conditionalTypes1.ts, 31, 1)) +>k : Symbol(k, Decl(conditionalTypes1.ts, 36, 29)) -type T12 = Diff; // { k: "c", c: boolean } ->T12 : Symbol(T12, Decl(conditionalTypes1.ts, 33, 45)) ->Diff : Symbol(Diff, Decl(conditionalTypes1.ts, 0, 0)) ->Options : Symbol(Options, Decl(conditionalTypes1.ts, 28, 1)) ->k : Symbol(k, Decl(conditionalTypes1.ts, 35, 26)) ->k : Symbol(k, Decl(conditionalTypes1.ts, 35, 39)) +type T12 = Exclude; // { k: "c", c: boolean } +>T12 : Symbol(T12, Decl(conditionalTypes1.ts, 36, 46)) +>Exclude : Symbol(Exclude, Decl(lib.d.ts, --, --)) +>Options : Symbol(Options, Decl(conditionalTypes1.ts, 31, 1)) +>k : Symbol(k, Decl(conditionalTypes1.ts, 38, 29)) +>k : Symbol(k, Decl(conditionalTypes1.ts, 38, 42)) -type T13 = Filter; // { k: "a", a: number } | { k: "b", b: string } ->T13 : Symbol(T13, Decl(conditionalTypes1.ts, 35, 50)) ->Filter : Symbol(Filter, Decl(conditionalTypes1.ts, 0, 42)) ->Options : Symbol(Options, Decl(conditionalTypes1.ts, 28, 1)) ->k : Symbol(k, Decl(conditionalTypes1.ts, 36, 28)) ->k : Symbol(k, Decl(conditionalTypes1.ts, 36, 41)) +type T13 = Extract; // { k: "a", a: number } | { k: "b", b: string } +>T13 : Symbol(T13, Decl(conditionalTypes1.ts, 38, 53)) +>Extract : Symbol(Extract, Decl(lib.d.ts, --, --)) +>Options : Symbol(Options, Decl(conditionalTypes1.ts, 31, 1)) +>k : Symbol(k, Decl(conditionalTypes1.ts, 39, 29)) +>k : Symbol(k, Decl(conditionalTypes1.ts, 39, 42)) -type T14 = Diff; // Options ->T14 : Symbol(T14, Decl(conditionalTypes1.ts, 36, 52)) ->Diff : Symbol(Diff, Decl(conditionalTypes1.ts, 0, 0)) ->Options : Symbol(Options, Decl(conditionalTypes1.ts, 28, 1)) ->q : Symbol(q, Decl(conditionalTypes1.ts, 38, 26)) +type T14 = Exclude; // Options +>T14 : Symbol(T14, Decl(conditionalTypes1.ts, 39, 53)) +>Exclude : Symbol(Exclude, Decl(lib.d.ts, --, --)) +>Options : Symbol(Options, Decl(conditionalTypes1.ts, 31, 1)) +>q : Symbol(q, Decl(conditionalTypes1.ts, 41, 29)) -type T15 = Filter; // never ->T15 : Symbol(T15, Decl(conditionalTypes1.ts, 38, 37)) ->Filter : Symbol(Filter, Decl(conditionalTypes1.ts, 0, 42)) ->Options : Symbol(Options, Decl(conditionalTypes1.ts, 28, 1)) ->q : Symbol(q, Decl(conditionalTypes1.ts, 39, 28)) +type T15 = Extract; // never +>T15 : Symbol(T15, Decl(conditionalTypes1.ts, 41, 40)) +>Extract : Symbol(Extract, Decl(lib.d.ts, --, --)) +>Options : Symbol(Options, Decl(conditionalTypes1.ts, 31, 1)) +>q : Symbol(q, Decl(conditionalTypes1.ts, 42, 29)) -declare function f4(p: K): Filter; ->f4 : Symbol(f4, Decl(conditionalTypes1.ts, 39, 39)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 41, 20)) ->Options : Symbol(Options, Decl(conditionalTypes1.ts, 28, 1)) ->K : Symbol(K, Decl(conditionalTypes1.ts, 41, 38)) ->p : Symbol(p, Decl(conditionalTypes1.ts, 41, 57)) ->K : Symbol(K, Decl(conditionalTypes1.ts, 41, 38)) ->Filter : Symbol(Filter, Decl(conditionalTypes1.ts, 0, 42)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 41, 20)) ->k : Symbol(k, Decl(conditionalTypes1.ts, 41, 75)) ->K : Symbol(K, Decl(conditionalTypes1.ts, 41, 38)) +declare function f5(p: K): Extract; +>f5 : Symbol(f5, Decl(conditionalTypes1.ts, 42, 40)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 44, 20)) +>Options : Symbol(Options, Decl(conditionalTypes1.ts, 31, 1)) +>K : Symbol(K, Decl(conditionalTypes1.ts, 44, 38)) +>p : Symbol(p, Decl(conditionalTypes1.ts, 44, 57)) +>K : Symbol(K, Decl(conditionalTypes1.ts, 44, 38)) +>Extract : Symbol(Extract, Decl(lib.d.ts, --, --)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 44, 20)) +>k : Symbol(k, Decl(conditionalTypes1.ts, 44, 76)) +>K : Symbol(K, Decl(conditionalTypes1.ts, 44, 38)) -let x0 = f4("a"); // { k: "a", a: number } ->x0 : Symbol(x0, Decl(conditionalTypes1.ts, 42, 3)) ->f4 : Symbol(f4, Decl(conditionalTypes1.ts, 39, 39)) +let x0 = f5("a"); // { k: "a", a: number } +>x0 : Symbol(x0, Decl(conditionalTypes1.ts, 45, 3)) +>f5 : Symbol(f5, Decl(conditionalTypes1.ts, 42, 40)) -type OptionsOfKind = Filter; ->OptionsOfKind : Symbol(OptionsOfKind, Decl(conditionalTypes1.ts, 42, 17)) ->K : Symbol(K, Decl(conditionalTypes1.ts, 44, 19)) ->Options : Symbol(Options, Decl(conditionalTypes1.ts, 28, 1)) ->Filter : Symbol(Filter, Decl(conditionalTypes1.ts, 0, 42)) ->Options : Symbol(Options, Decl(conditionalTypes1.ts, 28, 1)) ->k : Symbol(k, Decl(conditionalTypes1.ts, 44, 62)) ->K : Symbol(K, Decl(conditionalTypes1.ts, 44, 19)) +type OptionsOfKind = Extract; +>OptionsOfKind : Symbol(OptionsOfKind, Decl(conditionalTypes1.ts, 45, 17)) +>K : Symbol(K, Decl(conditionalTypes1.ts, 47, 19)) +>Options : Symbol(Options, Decl(conditionalTypes1.ts, 31, 1)) +>Extract : Symbol(Extract, Decl(lib.d.ts, --, --)) +>Options : Symbol(Options, Decl(conditionalTypes1.ts, 31, 1)) +>k : Symbol(k, Decl(conditionalTypes1.ts, 47, 63)) +>K : Symbol(K, Decl(conditionalTypes1.ts, 47, 19)) type T16 = OptionsOfKind<"a" | "b">; // { k: "a", a: number } | { k: "b", b: string } ->T16 : Symbol(T16, Decl(conditionalTypes1.ts, 44, 71)) ->OptionsOfKind : Symbol(OptionsOfKind, Decl(conditionalTypes1.ts, 42, 17)) +>T16 : Symbol(T16, Decl(conditionalTypes1.ts, 47, 72)) +>OptionsOfKind : Symbol(OptionsOfKind, Decl(conditionalTypes1.ts, 45, 17)) -type Select = Filter; ->Select : Symbol(Select, Decl(conditionalTypes1.ts, 46, 36)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 48, 12)) ->K : Symbol(K, Decl(conditionalTypes1.ts, 48, 14)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 48, 12)) ->V : Symbol(V, Decl(conditionalTypes1.ts, 48, 33)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 48, 12)) ->K : Symbol(K, Decl(conditionalTypes1.ts, 48, 14)) ->Filter : Symbol(Filter, Decl(conditionalTypes1.ts, 0, 42)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 48, 12)) ->P : Symbol(P, Decl(conditionalTypes1.ts, 48, 65)) ->K : Symbol(K, Decl(conditionalTypes1.ts, 48, 14)) ->V : Symbol(V, Decl(conditionalTypes1.ts, 48, 33)) +type Select = Extract; +>Select : Symbol(Select, Decl(conditionalTypes1.ts, 49, 36)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 51, 12)) +>K : Symbol(K, Decl(conditionalTypes1.ts, 51, 14)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 51, 12)) +>V : Symbol(V, Decl(conditionalTypes1.ts, 51, 33)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 51, 12)) +>K : Symbol(K, Decl(conditionalTypes1.ts, 51, 14)) +>Extract : Symbol(Extract, Decl(lib.d.ts, --, --)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 51, 12)) +>P : Symbol(P, Decl(conditionalTypes1.ts, 51, 66)) +>K : Symbol(K, Decl(conditionalTypes1.ts, 51, 14)) +>V : Symbol(V, Decl(conditionalTypes1.ts, 51, 33)) type T17 = Select; // // { k: "a", a: number } | { k: "b", b: string } ->T17 : Symbol(T17, Decl(conditionalTypes1.ts, 48, 79)) ->Select : Symbol(Select, Decl(conditionalTypes1.ts, 46, 36)) ->Options : Symbol(Options, Decl(conditionalTypes1.ts, 28, 1)) +>T17 : Symbol(T17, Decl(conditionalTypes1.ts, 51, 80)) +>Select : Symbol(Select, Decl(conditionalTypes1.ts, 49, 36)) +>Options : Symbol(Options, Decl(conditionalTypes1.ts, 31, 1)) type TypeName = ->TypeName : Symbol(TypeName, Decl(conditionalTypes1.ts, 50, 43)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 52, 14)) +>TypeName : Symbol(TypeName, Decl(conditionalTypes1.ts, 53, 43)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 55, 14)) T extends string ? "string" : ->T : Symbol(T, Decl(conditionalTypes1.ts, 52, 14)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 55, 14)) T extends number ? "number" : ->T : Symbol(T, Decl(conditionalTypes1.ts, 52, 14)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 55, 14)) T extends boolean ? "boolean" : ->T : Symbol(T, Decl(conditionalTypes1.ts, 52, 14)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 55, 14)) T extends undefined ? "undefined" : ->T : Symbol(T, Decl(conditionalTypes1.ts, 52, 14)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 55, 14)) T extends Function ? "function" : ->T : Symbol(T, Decl(conditionalTypes1.ts, 52, 14)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 55, 14)) >Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) "object"; type T20 = TypeName void)>; // "string" | "function" ->T20 : Symbol(T20, Decl(conditionalTypes1.ts, 58, 13)) ->TypeName : Symbol(TypeName, Decl(conditionalTypes1.ts, 50, 43)) +>T20 : Symbol(T20, Decl(conditionalTypes1.ts, 61, 13)) +>TypeName : Symbol(TypeName, Decl(conditionalTypes1.ts, 53, 43)) type T21 = TypeName; // "string" | "number" | "boolean" | "undefined" | "function" | "object" ->T21 : Symbol(T21, Decl(conditionalTypes1.ts, 60, 43)) ->TypeName : Symbol(TypeName, Decl(conditionalTypes1.ts, 50, 43)) +>T21 : Symbol(T21, Decl(conditionalTypes1.ts, 63, 43)) +>TypeName : Symbol(TypeName, Decl(conditionalTypes1.ts, 53, 43)) type T22 = TypeName; // "string" | "number" | "boolean" | "undefined" | "function" | "object" ->T22 : Symbol(T22, Decl(conditionalTypes1.ts, 61, 25)) ->TypeName : Symbol(TypeName, Decl(conditionalTypes1.ts, 50, 43)) +>T22 : Symbol(T22, Decl(conditionalTypes1.ts, 64, 25)) +>TypeName : Symbol(TypeName, Decl(conditionalTypes1.ts, 53, 43)) type T23 = TypeName<{}>; // "object" ->T23 : Symbol(T23, Decl(conditionalTypes1.ts, 62, 27)) ->TypeName : Symbol(TypeName, Decl(conditionalTypes1.ts, 50, 43)) +>T23 : Symbol(T23, Decl(conditionalTypes1.ts, 65, 27)) +>TypeName : Symbol(TypeName, Decl(conditionalTypes1.ts, 53, 43)) type KnockoutObservable = { object: T }; ->KnockoutObservable : Symbol(KnockoutObservable, Decl(conditionalTypes1.ts, 63, 24)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 65, 24)) ->object : Symbol(object, Decl(conditionalTypes1.ts, 65, 30)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 65, 24)) +>KnockoutObservable : Symbol(KnockoutObservable, Decl(conditionalTypes1.ts, 66, 24)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 68, 24)) +>object : Symbol(object, Decl(conditionalTypes1.ts, 68, 30)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 68, 24)) type KnockoutObservableArray = { array: T }; ->KnockoutObservableArray : Symbol(KnockoutObservableArray, Decl(conditionalTypes1.ts, 65, 43)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 66, 29)) ->array : Symbol(array, Decl(conditionalTypes1.ts, 66, 35)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 66, 29)) +>KnockoutObservableArray : Symbol(KnockoutObservableArray, Decl(conditionalTypes1.ts, 68, 43)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 69, 29)) +>array : Symbol(array, Decl(conditionalTypes1.ts, 69, 35)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 69, 29)) type KnockedOut = T extends any[] ? KnockoutObservableArray : KnockoutObservable; ->KnockedOut : Symbol(KnockedOut, Decl(conditionalTypes1.ts, 66, 47)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 68, 16)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 68, 16)) ->KnockoutObservableArray : Symbol(KnockoutObservableArray, Decl(conditionalTypes1.ts, 65, 43)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 68, 16)) ->KnockoutObservable : Symbol(KnockoutObservable, Decl(conditionalTypes1.ts, 63, 24)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 68, 16)) +>KnockedOut : Symbol(KnockedOut, Decl(conditionalTypes1.ts, 69, 47)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 71, 16)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 71, 16)) +>KnockoutObservableArray : Symbol(KnockoutObservableArray, Decl(conditionalTypes1.ts, 68, 43)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 71, 16)) +>KnockoutObservable : Symbol(KnockoutObservable, Decl(conditionalTypes1.ts, 66, 24)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 71, 16)) type KnockedOutObj = { ->KnockedOutObj : Symbol(KnockedOutObj, Decl(conditionalTypes1.ts, 68, 98)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 70, 19)) +>KnockedOutObj : Symbol(KnockedOutObj, Decl(conditionalTypes1.ts, 71, 98)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 73, 19)) [P in keyof T]: KnockedOut; ->P : Symbol(P, Decl(conditionalTypes1.ts, 71, 5)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 70, 19)) ->KnockedOut : Symbol(KnockedOut, Decl(conditionalTypes1.ts, 66, 47)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 70, 19)) ->P : Symbol(P, Decl(conditionalTypes1.ts, 71, 5)) +>P : Symbol(P, Decl(conditionalTypes1.ts, 74, 5)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 73, 19)) +>KnockedOut : Symbol(KnockedOut, Decl(conditionalTypes1.ts, 69, 47)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 73, 19)) +>P : Symbol(P, Decl(conditionalTypes1.ts, 74, 5)) } interface Item { ->Item : Symbol(Item, Decl(conditionalTypes1.ts, 72, 1)) +>Item : Symbol(Item, Decl(conditionalTypes1.ts, 75, 1)) id: number; ->id : Symbol(Item.id, Decl(conditionalTypes1.ts, 74, 16)) +>id : Symbol(Item.id, Decl(conditionalTypes1.ts, 77, 16)) name: string; ->name : Symbol(Item.name, Decl(conditionalTypes1.ts, 75, 15)) +>name : Symbol(Item.name, Decl(conditionalTypes1.ts, 78, 15)) subitems: string[]; ->subitems : Symbol(Item.subitems, Decl(conditionalTypes1.ts, 76, 17)) +>subitems : Symbol(Item.subitems, Decl(conditionalTypes1.ts, 79, 17)) } type KOItem = KnockedOutObj; ->KOItem : Symbol(KOItem, Decl(conditionalTypes1.ts, 78, 1)) ->KnockedOutObj : Symbol(KnockedOutObj, Decl(conditionalTypes1.ts, 68, 98)) ->Item : Symbol(Item, Decl(conditionalTypes1.ts, 72, 1)) +>KOItem : Symbol(KOItem, Decl(conditionalTypes1.ts, 81, 1)) +>KnockedOutObj : Symbol(KnockedOutObj, Decl(conditionalTypes1.ts, 71, 98)) +>Item : Symbol(Item, Decl(conditionalTypes1.ts, 75, 1)) interface Part { ->Part : Symbol(Part, Decl(conditionalTypes1.ts, 80, 34)) +>Part : Symbol(Part, Decl(conditionalTypes1.ts, 83, 34)) id: number; ->id : Symbol(Part.id, Decl(conditionalTypes1.ts, 82, 16)) +>id : Symbol(Part.id, Decl(conditionalTypes1.ts, 85, 16)) name: string; ->name : Symbol(Part.name, Decl(conditionalTypes1.ts, 83, 15)) +>name : Symbol(Part.name, Decl(conditionalTypes1.ts, 86, 15)) subparts: Part[]; ->subparts : Symbol(Part.subparts, Decl(conditionalTypes1.ts, 84, 17)) ->Part : Symbol(Part, Decl(conditionalTypes1.ts, 80, 34)) +>subparts : Symbol(Part.subparts, Decl(conditionalTypes1.ts, 87, 17)) +>Part : Symbol(Part, Decl(conditionalTypes1.ts, 83, 34)) updatePart(newName: string): void; ->updatePart : Symbol(Part.updatePart, Decl(conditionalTypes1.ts, 85, 21)) ->newName : Symbol(newName, Decl(conditionalTypes1.ts, 86, 15)) +>updatePart : Symbol(Part.updatePart, Decl(conditionalTypes1.ts, 88, 21)) +>newName : Symbol(newName, Decl(conditionalTypes1.ts, 89, 15)) } type FunctionPropertyNames = { [K in keyof T]: T[K] extends Function ? K : never }[keyof T]; ->FunctionPropertyNames : Symbol(FunctionPropertyNames, Decl(conditionalTypes1.ts, 87, 1)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 89, 27)) ->K : Symbol(K, Decl(conditionalTypes1.ts, 89, 35)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 89, 27)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 89, 27)) ->K : Symbol(K, Decl(conditionalTypes1.ts, 89, 35)) +>FunctionPropertyNames : Symbol(FunctionPropertyNames, Decl(conditionalTypes1.ts, 90, 1)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 92, 27)) +>K : Symbol(K, Decl(conditionalTypes1.ts, 92, 35)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 92, 27)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 92, 27)) +>K : Symbol(K, Decl(conditionalTypes1.ts, 92, 35)) >Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->K : Symbol(K, Decl(conditionalTypes1.ts, 89, 35)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 89, 27)) +>K : Symbol(K, Decl(conditionalTypes1.ts, 92, 35)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 92, 27)) type FunctionProperties = Pick>; ->FunctionProperties : Symbol(FunctionProperties, Decl(conditionalTypes1.ts, 89, 95)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 90, 24)) +>FunctionProperties : Symbol(FunctionProperties, Decl(conditionalTypes1.ts, 92, 95)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 93, 24)) >Pick : Symbol(Pick, Decl(lib.d.ts, --, --)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 90, 24)) ->FunctionPropertyNames : Symbol(FunctionPropertyNames, Decl(conditionalTypes1.ts, 87, 1)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 90, 24)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 93, 24)) +>FunctionPropertyNames : Symbol(FunctionPropertyNames, Decl(conditionalTypes1.ts, 90, 1)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 93, 24)) type NonFunctionPropertyNames = { [K in keyof T]: T[K] extends Function ? never : K }[keyof T]; ->NonFunctionPropertyNames : Symbol(NonFunctionPropertyNames, Decl(conditionalTypes1.ts, 90, 63)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 92, 30)) ->K : Symbol(K, Decl(conditionalTypes1.ts, 92, 38)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 92, 30)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 92, 30)) ->K : Symbol(K, Decl(conditionalTypes1.ts, 92, 38)) +>NonFunctionPropertyNames : Symbol(NonFunctionPropertyNames, Decl(conditionalTypes1.ts, 93, 63)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 95, 30)) +>K : Symbol(K, Decl(conditionalTypes1.ts, 95, 38)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 95, 30)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 95, 30)) +>K : Symbol(K, Decl(conditionalTypes1.ts, 95, 38)) >Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->K : Symbol(K, Decl(conditionalTypes1.ts, 92, 38)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 92, 30)) +>K : Symbol(K, Decl(conditionalTypes1.ts, 95, 38)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 95, 30)) type NonFunctionProperties = Pick>; ->NonFunctionProperties : Symbol(NonFunctionProperties, Decl(conditionalTypes1.ts, 92, 98)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 93, 27)) +>NonFunctionProperties : Symbol(NonFunctionProperties, Decl(conditionalTypes1.ts, 95, 98)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 96, 27)) >Pick : Symbol(Pick, Decl(lib.d.ts, --, --)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 93, 27)) ->NonFunctionPropertyNames : Symbol(NonFunctionPropertyNames, Decl(conditionalTypes1.ts, 90, 63)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 93, 27)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 96, 27)) +>NonFunctionPropertyNames : Symbol(NonFunctionPropertyNames, Decl(conditionalTypes1.ts, 93, 63)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 96, 27)) type T30 = FunctionProperties; ->T30 : Symbol(T30, Decl(conditionalTypes1.ts, 93, 69)) ->FunctionProperties : Symbol(FunctionProperties, Decl(conditionalTypes1.ts, 89, 95)) ->Part : Symbol(Part, Decl(conditionalTypes1.ts, 80, 34)) +>T30 : Symbol(T30, Decl(conditionalTypes1.ts, 96, 69)) +>FunctionProperties : Symbol(FunctionProperties, Decl(conditionalTypes1.ts, 92, 95)) +>Part : Symbol(Part, Decl(conditionalTypes1.ts, 83, 34)) type T31 = NonFunctionProperties; ->T31 : Symbol(T31, Decl(conditionalTypes1.ts, 95, 36)) ->NonFunctionProperties : Symbol(NonFunctionProperties, Decl(conditionalTypes1.ts, 92, 98)) ->Part : Symbol(Part, Decl(conditionalTypes1.ts, 80, 34)) +>T31 : Symbol(T31, Decl(conditionalTypes1.ts, 98, 36)) +>NonFunctionProperties : Symbol(NonFunctionProperties, Decl(conditionalTypes1.ts, 95, 98)) +>Part : Symbol(Part, Decl(conditionalTypes1.ts, 83, 34)) function f7(x: T, y: FunctionProperties, z: NonFunctionProperties) { ->f7 : Symbol(f7, Decl(conditionalTypes1.ts, 96, 39)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 98, 12)) ->x : Symbol(x, Decl(conditionalTypes1.ts, 98, 15)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 98, 12)) ->y : Symbol(y, Decl(conditionalTypes1.ts, 98, 20)) ->FunctionProperties : Symbol(FunctionProperties, Decl(conditionalTypes1.ts, 89, 95)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 98, 12)) ->z : Symbol(z, Decl(conditionalTypes1.ts, 98, 46)) ->NonFunctionProperties : Symbol(NonFunctionProperties, Decl(conditionalTypes1.ts, 92, 98)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 98, 12)) +>f7 : Symbol(f7, Decl(conditionalTypes1.ts, 99, 39)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 101, 12)) +>x : Symbol(x, Decl(conditionalTypes1.ts, 101, 15)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 101, 12)) +>y : Symbol(y, Decl(conditionalTypes1.ts, 101, 20)) +>FunctionProperties : Symbol(FunctionProperties, Decl(conditionalTypes1.ts, 92, 95)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 101, 12)) +>z : Symbol(z, Decl(conditionalTypes1.ts, 101, 46)) +>NonFunctionProperties : Symbol(NonFunctionProperties, Decl(conditionalTypes1.ts, 95, 98)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 101, 12)) x = y; // Error ->x : Symbol(x, Decl(conditionalTypes1.ts, 98, 15)) ->y : Symbol(y, Decl(conditionalTypes1.ts, 98, 20)) +>x : Symbol(x, Decl(conditionalTypes1.ts, 101, 15)) +>y : Symbol(y, Decl(conditionalTypes1.ts, 101, 20)) x = z; // Error ->x : Symbol(x, Decl(conditionalTypes1.ts, 98, 15)) ->z : Symbol(z, Decl(conditionalTypes1.ts, 98, 46)) +>x : Symbol(x, Decl(conditionalTypes1.ts, 101, 15)) +>z : Symbol(z, Decl(conditionalTypes1.ts, 101, 46)) y = x; ->y : Symbol(y, Decl(conditionalTypes1.ts, 98, 20)) ->x : Symbol(x, Decl(conditionalTypes1.ts, 98, 15)) +>y : Symbol(y, Decl(conditionalTypes1.ts, 101, 20)) +>x : Symbol(x, Decl(conditionalTypes1.ts, 101, 15)) y = z; // Error ->y : Symbol(y, Decl(conditionalTypes1.ts, 98, 20)) ->z : Symbol(z, Decl(conditionalTypes1.ts, 98, 46)) +>y : Symbol(y, Decl(conditionalTypes1.ts, 101, 20)) +>z : Symbol(z, Decl(conditionalTypes1.ts, 101, 46)) z = x; ->z : Symbol(z, Decl(conditionalTypes1.ts, 98, 46)) ->x : Symbol(x, Decl(conditionalTypes1.ts, 98, 15)) +>z : Symbol(z, Decl(conditionalTypes1.ts, 101, 46)) +>x : Symbol(x, Decl(conditionalTypes1.ts, 101, 15)) z = y; // Error ->z : Symbol(z, Decl(conditionalTypes1.ts, 98, 46)) ->y : Symbol(y, Decl(conditionalTypes1.ts, 98, 20)) +>z : Symbol(z, Decl(conditionalTypes1.ts, 101, 46)) +>y : Symbol(y, Decl(conditionalTypes1.ts, 101, 20)) } function f8(x: keyof T, y: FunctionPropertyNames, z: NonFunctionPropertyNames) { ->f8 : Symbol(f8, Decl(conditionalTypes1.ts, 105, 1)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 107, 12)) ->x : Symbol(x, Decl(conditionalTypes1.ts, 107, 15)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 107, 12)) ->y : Symbol(y, Decl(conditionalTypes1.ts, 107, 26)) ->FunctionPropertyNames : Symbol(FunctionPropertyNames, Decl(conditionalTypes1.ts, 87, 1)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 107, 12)) ->z : Symbol(z, Decl(conditionalTypes1.ts, 107, 55)) ->NonFunctionPropertyNames : Symbol(NonFunctionPropertyNames, Decl(conditionalTypes1.ts, 90, 63)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 107, 12)) +>f8 : Symbol(f8, Decl(conditionalTypes1.ts, 108, 1)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 110, 12)) +>x : Symbol(x, Decl(conditionalTypes1.ts, 110, 15)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 110, 12)) +>y : Symbol(y, Decl(conditionalTypes1.ts, 110, 26)) +>FunctionPropertyNames : Symbol(FunctionPropertyNames, Decl(conditionalTypes1.ts, 90, 1)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 110, 12)) +>z : Symbol(z, Decl(conditionalTypes1.ts, 110, 55)) +>NonFunctionPropertyNames : Symbol(NonFunctionPropertyNames, Decl(conditionalTypes1.ts, 93, 63)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 110, 12)) x = y; ->x : Symbol(x, Decl(conditionalTypes1.ts, 107, 15)) ->y : Symbol(y, Decl(conditionalTypes1.ts, 107, 26)) +>x : Symbol(x, Decl(conditionalTypes1.ts, 110, 15)) +>y : Symbol(y, Decl(conditionalTypes1.ts, 110, 26)) x = z; ->x : Symbol(x, Decl(conditionalTypes1.ts, 107, 15)) ->z : Symbol(z, Decl(conditionalTypes1.ts, 107, 55)) +>x : Symbol(x, Decl(conditionalTypes1.ts, 110, 15)) +>z : Symbol(z, Decl(conditionalTypes1.ts, 110, 55)) y = x; // Error ->y : Symbol(y, Decl(conditionalTypes1.ts, 107, 26)) ->x : Symbol(x, Decl(conditionalTypes1.ts, 107, 15)) +>y : Symbol(y, Decl(conditionalTypes1.ts, 110, 26)) +>x : Symbol(x, Decl(conditionalTypes1.ts, 110, 15)) y = z; // Error ->y : Symbol(y, Decl(conditionalTypes1.ts, 107, 26)) ->z : Symbol(z, Decl(conditionalTypes1.ts, 107, 55)) +>y : Symbol(y, Decl(conditionalTypes1.ts, 110, 26)) +>z : Symbol(z, Decl(conditionalTypes1.ts, 110, 55)) z = x; // Error ->z : Symbol(z, Decl(conditionalTypes1.ts, 107, 55)) ->x : Symbol(x, Decl(conditionalTypes1.ts, 107, 15)) +>z : Symbol(z, Decl(conditionalTypes1.ts, 110, 55)) +>x : Symbol(x, Decl(conditionalTypes1.ts, 110, 15)) z = y; // Error ->z : Symbol(z, Decl(conditionalTypes1.ts, 107, 55)) ->y : Symbol(y, Decl(conditionalTypes1.ts, 107, 26)) +>z : Symbol(z, Decl(conditionalTypes1.ts, 110, 55)) +>y : Symbol(y, Decl(conditionalTypes1.ts, 110, 26)) } type DeepReadonly = ->DeepReadonly : Symbol(DeepReadonly, Decl(conditionalTypes1.ts, 114, 1)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 116, 18)) +>DeepReadonly : Symbol(DeepReadonly, Decl(conditionalTypes1.ts, 117, 1)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 119, 18)) T extends any[] ? DeepReadonlyArray : ->T : Symbol(T, Decl(conditionalTypes1.ts, 116, 18)) ->DeepReadonlyArray : Symbol(DeepReadonlyArray, Decl(conditionalTypes1.ts, 119, 6)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 116, 18)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 119, 18)) +>DeepReadonlyArray : Symbol(DeepReadonlyArray, Decl(conditionalTypes1.ts, 122, 6)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 119, 18)) T extends object ? DeepReadonlyObject : ->T : Symbol(T, Decl(conditionalTypes1.ts, 116, 18)) ->DeepReadonlyObject : Symbol(DeepReadonlyObject, Decl(conditionalTypes1.ts, 121, 72)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 116, 18)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 119, 18)) +>DeepReadonlyObject : Symbol(DeepReadonlyObject, Decl(conditionalTypes1.ts, 124, 72)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 119, 18)) T; ->T : Symbol(T, Decl(conditionalTypes1.ts, 116, 18)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 119, 18)) interface DeepReadonlyArray extends ReadonlyArray> {} ->DeepReadonlyArray : Symbol(DeepReadonlyArray, Decl(conditionalTypes1.ts, 119, 6)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 121, 28)) +>DeepReadonlyArray : Symbol(DeepReadonlyArray, Decl(conditionalTypes1.ts, 122, 6)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 124, 28)) >ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.d.ts, --, --)) ->DeepReadonly : Symbol(DeepReadonly, Decl(conditionalTypes1.ts, 114, 1)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 121, 28)) +>DeepReadonly : Symbol(DeepReadonly, Decl(conditionalTypes1.ts, 117, 1)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 124, 28)) type DeepReadonlyObject = { ->DeepReadonlyObject : Symbol(DeepReadonlyObject, Decl(conditionalTypes1.ts, 121, 72)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 123, 24)) +>DeepReadonlyObject : Symbol(DeepReadonlyObject, Decl(conditionalTypes1.ts, 124, 72)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 126, 24)) readonly [P in NonFunctionPropertyNames]: DeepReadonly; ->P : Symbol(P, Decl(conditionalTypes1.ts, 124, 14)) ->NonFunctionPropertyNames : Symbol(NonFunctionPropertyNames, Decl(conditionalTypes1.ts, 90, 63)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 123, 24)) ->DeepReadonly : Symbol(DeepReadonly, Decl(conditionalTypes1.ts, 114, 1)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 123, 24)) ->P : Symbol(P, Decl(conditionalTypes1.ts, 124, 14)) +>P : Symbol(P, Decl(conditionalTypes1.ts, 127, 14)) +>NonFunctionPropertyNames : Symbol(NonFunctionPropertyNames, Decl(conditionalTypes1.ts, 93, 63)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 126, 24)) +>DeepReadonly : Symbol(DeepReadonly, Decl(conditionalTypes1.ts, 117, 1)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 126, 24)) +>P : Symbol(P, Decl(conditionalTypes1.ts, 127, 14)) }; function f10(part: DeepReadonly) { ->f10 : Symbol(f10, Decl(conditionalTypes1.ts, 125, 2)) ->part : Symbol(part, Decl(conditionalTypes1.ts, 127, 13)) ->DeepReadonly : Symbol(DeepReadonly, Decl(conditionalTypes1.ts, 114, 1)) ->Part : Symbol(Part, Decl(conditionalTypes1.ts, 80, 34)) +>f10 : Symbol(f10, Decl(conditionalTypes1.ts, 128, 2)) +>part : Symbol(part, Decl(conditionalTypes1.ts, 130, 13)) +>DeepReadonly : Symbol(DeepReadonly, Decl(conditionalTypes1.ts, 117, 1)) +>Part : Symbol(Part, Decl(conditionalTypes1.ts, 83, 34)) let name: string = part.name; ->name : Symbol(name, Decl(conditionalTypes1.ts, 128, 7)) +>name : Symbol(name, Decl(conditionalTypes1.ts, 131, 7)) >part.name : Symbol(name) ->part : Symbol(part, Decl(conditionalTypes1.ts, 127, 13)) +>part : Symbol(part, Decl(conditionalTypes1.ts, 130, 13)) >name : Symbol(name) let id: number = part.subparts[0].id; ->id : Symbol(id, Decl(conditionalTypes1.ts, 129, 7)) +>id : Symbol(id, Decl(conditionalTypes1.ts, 132, 7)) >part.subparts[0].id : Symbol(id) >part.subparts : Symbol(subparts) ->part : Symbol(part, Decl(conditionalTypes1.ts, 127, 13)) +>part : Symbol(part, Decl(conditionalTypes1.ts, 130, 13)) >subparts : Symbol(subparts) >id : Symbol(id) part.id = part.id; // Error >part.id : Symbol(id) ->part : Symbol(part, Decl(conditionalTypes1.ts, 127, 13)) +>part : Symbol(part, Decl(conditionalTypes1.ts, 130, 13)) >id : Symbol(id) >part.id : Symbol(id) ->part : Symbol(part, Decl(conditionalTypes1.ts, 127, 13)) +>part : Symbol(part, Decl(conditionalTypes1.ts, 130, 13)) >id : Symbol(id) part.subparts[0] = part.subparts[0]; // Error >part.subparts : Symbol(subparts) ->part : Symbol(part, Decl(conditionalTypes1.ts, 127, 13)) +>part : Symbol(part, Decl(conditionalTypes1.ts, 130, 13)) >subparts : Symbol(subparts) >part.subparts : Symbol(subparts) ->part : Symbol(part, Decl(conditionalTypes1.ts, 127, 13)) +>part : Symbol(part, Decl(conditionalTypes1.ts, 130, 13)) >subparts : Symbol(subparts) part.subparts[0].id = part.subparts[0].id; // Error >part.subparts[0].id : Symbol(id) >part.subparts : Symbol(subparts) ->part : Symbol(part, Decl(conditionalTypes1.ts, 127, 13)) +>part : Symbol(part, Decl(conditionalTypes1.ts, 130, 13)) >subparts : Symbol(subparts) >id : Symbol(id) >part.subparts[0].id : Symbol(id) >part.subparts : Symbol(subparts) ->part : Symbol(part, Decl(conditionalTypes1.ts, 127, 13)) +>part : Symbol(part, Decl(conditionalTypes1.ts, 130, 13)) >subparts : Symbol(subparts) >id : Symbol(id) part.updatePart("hello"); // Error ->part : Symbol(part, Decl(conditionalTypes1.ts, 127, 13)) +>part : Symbol(part, Decl(conditionalTypes1.ts, 130, 13)) } type ZeroOf = T extends number ? 0 : T extends string ? "" : false; ->ZeroOf : Symbol(ZeroOf, Decl(conditionalTypes1.ts, 134, 1)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 136, 12)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 136, 12)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 136, 12)) +>ZeroOf : Symbol(ZeroOf, Decl(conditionalTypes1.ts, 137, 1)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 139, 12)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 139, 12)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 139, 12)) function zeroOf(value: T) { ->zeroOf : Symbol(zeroOf, Decl(conditionalTypes1.ts, 136, 104)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 138, 16)) ->value : Symbol(value, Decl(conditionalTypes1.ts, 138, 53)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 138, 16)) +>zeroOf : Symbol(zeroOf, Decl(conditionalTypes1.ts, 139, 104)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 141, 16)) +>value : Symbol(value, Decl(conditionalTypes1.ts, 141, 53)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 141, 16)) return >(typeof value === "number" ? 0 : typeof value === "string" ? "" : false); ->ZeroOf : Symbol(ZeroOf, Decl(conditionalTypes1.ts, 134, 1)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 138, 16)) ->value : Symbol(value, Decl(conditionalTypes1.ts, 138, 53)) ->value : Symbol(value, Decl(conditionalTypes1.ts, 138, 53)) +>ZeroOf : Symbol(ZeroOf, Decl(conditionalTypes1.ts, 137, 1)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 141, 16)) +>value : Symbol(value, Decl(conditionalTypes1.ts, 141, 53)) +>value : Symbol(value, Decl(conditionalTypes1.ts, 141, 53)) } function f20(n: number, b: boolean, x: number | boolean, y: T) { ->f20 : Symbol(f20, Decl(conditionalTypes1.ts, 140, 1)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 142, 13)) ->n : Symbol(n, Decl(conditionalTypes1.ts, 142, 31)) ->b : Symbol(b, Decl(conditionalTypes1.ts, 142, 41)) ->x : Symbol(x, Decl(conditionalTypes1.ts, 142, 53)) ->y : Symbol(y, Decl(conditionalTypes1.ts, 142, 74)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 142, 13)) +>f20 : Symbol(f20, Decl(conditionalTypes1.ts, 143, 1)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 145, 13)) +>n : Symbol(n, Decl(conditionalTypes1.ts, 145, 31)) +>b : Symbol(b, Decl(conditionalTypes1.ts, 145, 41)) +>x : Symbol(x, Decl(conditionalTypes1.ts, 145, 53)) +>y : Symbol(y, Decl(conditionalTypes1.ts, 145, 74)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 145, 13)) zeroOf(5); // 0 ->zeroOf : Symbol(zeroOf, Decl(conditionalTypes1.ts, 136, 104)) +>zeroOf : Symbol(zeroOf, Decl(conditionalTypes1.ts, 139, 104)) zeroOf("hello"); // "" ->zeroOf : Symbol(zeroOf, Decl(conditionalTypes1.ts, 136, 104)) +>zeroOf : Symbol(zeroOf, Decl(conditionalTypes1.ts, 139, 104)) zeroOf(true); // false ->zeroOf : Symbol(zeroOf, Decl(conditionalTypes1.ts, 136, 104)) +>zeroOf : Symbol(zeroOf, Decl(conditionalTypes1.ts, 139, 104)) zeroOf(n); // 0 ->zeroOf : Symbol(zeroOf, Decl(conditionalTypes1.ts, 136, 104)) ->n : Symbol(n, Decl(conditionalTypes1.ts, 142, 31)) +>zeroOf : Symbol(zeroOf, Decl(conditionalTypes1.ts, 139, 104)) +>n : Symbol(n, Decl(conditionalTypes1.ts, 145, 31)) zeroOf(b); // False ->zeroOf : Symbol(zeroOf, Decl(conditionalTypes1.ts, 136, 104)) ->b : Symbol(b, Decl(conditionalTypes1.ts, 142, 41)) +>zeroOf : Symbol(zeroOf, Decl(conditionalTypes1.ts, 139, 104)) +>b : Symbol(b, Decl(conditionalTypes1.ts, 145, 41)) zeroOf(x); // 0 | false ->zeroOf : Symbol(zeroOf, Decl(conditionalTypes1.ts, 136, 104)) ->x : Symbol(x, Decl(conditionalTypes1.ts, 142, 53)) +>zeroOf : Symbol(zeroOf, Decl(conditionalTypes1.ts, 139, 104)) +>x : Symbol(x, Decl(conditionalTypes1.ts, 145, 53)) zeroOf(y); // ZeroOf ->zeroOf : Symbol(zeroOf, Decl(conditionalTypes1.ts, 136, 104)) ->y : Symbol(y, Decl(conditionalTypes1.ts, 142, 74)) +>zeroOf : Symbol(zeroOf, Decl(conditionalTypes1.ts, 139, 104)) +>y : Symbol(y, Decl(conditionalTypes1.ts, 145, 74)) } function f21(x: T, y: ZeroOf) { ->f21 : Symbol(f21, Decl(conditionalTypes1.ts, 150, 1)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 152, 13)) ->x : Symbol(x, Decl(conditionalTypes1.ts, 152, 40)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 152, 13)) ->y : Symbol(y, Decl(conditionalTypes1.ts, 152, 45)) ->ZeroOf : Symbol(ZeroOf, Decl(conditionalTypes1.ts, 134, 1)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 152, 13)) +>f21 : Symbol(f21, Decl(conditionalTypes1.ts, 153, 1)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 155, 13)) +>x : Symbol(x, Decl(conditionalTypes1.ts, 155, 40)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 155, 13)) +>y : Symbol(y, Decl(conditionalTypes1.ts, 155, 45)) +>ZeroOf : Symbol(ZeroOf, Decl(conditionalTypes1.ts, 137, 1)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 155, 13)) let z1: number | string = y; ->z1 : Symbol(z1, Decl(conditionalTypes1.ts, 153, 7)) ->y : Symbol(y, Decl(conditionalTypes1.ts, 152, 45)) +>z1 : Symbol(z1, Decl(conditionalTypes1.ts, 156, 7)) +>y : Symbol(y, Decl(conditionalTypes1.ts, 155, 45)) let z2: 0 | "" = y; ->z2 : Symbol(z2, Decl(conditionalTypes1.ts, 154, 7)) ->y : Symbol(y, Decl(conditionalTypes1.ts, 152, 45)) +>z2 : Symbol(z2, Decl(conditionalTypes1.ts, 157, 7)) +>y : Symbol(y, Decl(conditionalTypes1.ts, 155, 45)) x = y; // Error ->x : Symbol(x, Decl(conditionalTypes1.ts, 152, 40)) ->y : Symbol(y, Decl(conditionalTypes1.ts, 152, 45)) +>x : Symbol(x, Decl(conditionalTypes1.ts, 155, 40)) +>y : Symbol(y, Decl(conditionalTypes1.ts, 155, 45)) y = x; // Error ->y : Symbol(y, Decl(conditionalTypes1.ts, 152, 45)) ->x : Symbol(x, Decl(conditionalTypes1.ts, 152, 40)) +>y : Symbol(y, Decl(conditionalTypes1.ts, 155, 45)) +>x : Symbol(x, Decl(conditionalTypes1.ts, 155, 40)) } type Extends = T extends U ? true : false; ->Extends : Symbol(Extends, Decl(conditionalTypes1.ts, 157, 1)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 159, 13)) ->U : Symbol(U, Decl(conditionalTypes1.ts, 159, 15)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 159, 13)) ->U : Symbol(U, Decl(conditionalTypes1.ts, 159, 15)) +>Extends : Symbol(Extends, Decl(conditionalTypes1.ts, 160, 1)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 162, 13)) +>U : Symbol(U, Decl(conditionalTypes1.ts, 162, 15)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 162, 13)) +>U : Symbol(U, Decl(conditionalTypes1.ts, 162, 15)) type If = C extends true ? T : F; ->If : Symbol(If, Decl(conditionalTypes1.ts, 159, 48)) ->C : Symbol(C, Decl(conditionalTypes1.ts, 160, 8)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 160, 26)) ->F : Symbol(F, Decl(conditionalTypes1.ts, 160, 29)) ->C : Symbol(C, Decl(conditionalTypes1.ts, 160, 8)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 160, 26)) ->F : Symbol(F, Decl(conditionalTypes1.ts, 160, 29)) +>If : Symbol(If, Decl(conditionalTypes1.ts, 162, 48)) +>C : Symbol(C, Decl(conditionalTypes1.ts, 163, 8)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 163, 26)) +>F : Symbol(F, Decl(conditionalTypes1.ts, 163, 29)) +>C : Symbol(C, Decl(conditionalTypes1.ts, 163, 8)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 163, 26)) +>F : Symbol(F, Decl(conditionalTypes1.ts, 163, 29)) type Not = If; ->Not : Symbol(Not, Decl(conditionalTypes1.ts, 160, 58)) ->C : Symbol(C, Decl(conditionalTypes1.ts, 161, 9)) ->If : Symbol(If, Decl(conditionalTypes1.ts, 159, 48)) ->C : Symbol(C, Decl(conditionalTypes1.ts, 161, 9)) +>Not : Symbol(Not, Decl(conditionalTypes1.ts, 163, 58)) +>C : Symbol(C, Decl(conditionalTypes1.ts, 164, 9)) +>If : Symbol(If, Decl(conditionalTypes1.ts, 162, 48)) +>C : Symbol(C, Decl(conditionalTypes1.ts, 164, 9)) type And = If; ->And : Symbol(And, Decl(conditionalTypes1.ts, 161, 49)) ->A : Symbol(A, Decl(conditionalTypes1.ts, 162, 9)) ->B : Symbol(B, Decl(conditionalTypes1.ts, 162, 27)) ->If : Symbol(If, Decl(conditionalTypes1.ts, 159, 48)) ->A : Symbol(A, Decl(conditionalTypes1.ts, 162, 9)) ->B : Symbol(B, Decl(conditionalTypes1.ts, 162, 27)) +>And : Symbol(And, Decl(conditionalTypes1.ts, 164, 49)) +>A : Symbol(A, Decl(conditionalTypes1.ts, 165, 9)) +>B : Symbol(B, Decl(conditionalTypes1.ts, 165, 27)) +>If : Symbol(If, Decl(conditionalTypes1.ts, 162, 48)) +>A : Symbol(A, Decl(conditionalTypes1.ts, 165, 9)) +>B : Symbol(B, Decl(conditionalTypes1.ts, 165, 27)) type Or = If; ->Or : Symbol(Or, Decl(conditionalTypes1.ts, 162, 65)) ->A : Symbol(A, Decl(conditionalTypes1.ts, 163, 8)) ->B : Symbol(B, Decl(conditionalTypes1.ts, 163, 26)) ->If : Symbol(If, Decl(conditionalTypes1.ts, 159, 48)) ->A : Symbol(A, Decl(conditionalTypes1.ts, 163, 8)) ->B : Symbol(B, Decl(conditionalTypes1.ts, 163, 26)) +>Or : Symbol(Or, Decl(conditionalTypes1.ts, 165, 65)) +>A : Symbol(A, Decl(conditionalTypes1.ts, 166, 8)) +>B : Symbol(B, Decl(conditionalTypes1.ts, 166, 26)) +>If : Symbol(If, Decl(conditionalTypes1.ts, 162, 48)) +>A : Symbol(A, Decl(conditionalTypes1.ts, 166, 8)) +>B : Symbol(B, Decl(conditionalTypes1.ts, 166, 26)) type IsString = Extends; ->IsString : Symbol(IsString, Decl(conditionalTypes1.ts, 163, 63)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 165, 14)) ->Extends : Symbol(Extends, Decl(conditionalTypes1.ts, 157, 1)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 165, 14)) +>IsString : Symbol(IsString, Decl(conditionalTypes1.ts, 166, 63)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 168, 14)) +>Extends : Symbol(Extends, Decl(conditionalTypes1.ts, 160, 1)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 168, 14)) type Q1 = IsString; // false ->Q1 : Symbol(Q1, Decl(conditionalTypes1.ts, 165, 38)) ->IsString : Symbol(IsString, Decl(conditionalTypes1.ts, 163, 63)) +>Q1 : Symbol(Q1, Decl(conditionalTypes1.ts, 168, 38)) +>IsString : Symbol(IsString, Decl(conditionalTypes1.ts, 166, 63)) type Q2 = IsString<"abc">; // true ->Q2 : Symbol(Q2, Decl(conditionalTypes1.ts, 167, 27)) ->IsString : Symbol(IsString, Decl(conditionalTypes1.ts, 163, 63)) +>Q2 : Symbol(Q2, Decl(conditionalTypes1.ts, 170, 27)) +>IsString : Symbol(IsString, Decl(conditionalTypes1.ts, 166, 63)) type Q3 = IsString; // boolean ->Q3 : Symbol(Q3, Decl(conditionalTypes1.ts, 168, 26)) ->IsString : Symbol(IsString, Decl(conditionalTypes1.ts, 163, 63)) +>Q3 : Symbol(Q3, Decl(conditionalTypes1.ts, 171, 26)) +>IsString : Symbol(IsString, Decl(conditionalTypes1.ts, 166, 63)) type Q4 = IsString; // boolean ->Q4 : Symbol(Q4, Decl(conditionalTypes1.ts, 169, 24)) ->IsString : Symbol(IsString, Decl(conditionalTypes1.ts, 163, 63)) +>Q4 : Symbol(Q4, Decl(conditionalTypes1.ts, 172, 24)) +>IsString : Symbol(IsString, Decl(conditionalTypes1.ts, 166, 63)) type N1 = Not; // true ->N1 : Symbol(N1, Decl(conditionalTypes1.ts, 170, 26)) ->Not : Symbol(Not, Decl(conditionalTypes1.ts, 160, 58)) +>N1 : Symbol(N1, Decl(conditionalTypes1.ts, 173, 26)) +>Not : Symbol(Not, Decl(conditionalTypes1.ts, 163, 58)) type N2 = Not; // false ->N2 : Symbol(N2, Decl(conditionalTypes1.ts, 172, 21)) ->Not : Symbol(Not, Decl(conditionalTypes1.ts, 160, 58)) +>N2 : Symbol(N2, Decl(conditionalTypes1.ts, 175, 21)) +>Not : Symbol(Not, Decl(conditionalTypes1.ts, 163, 58)) type N3 = Not; // boolean ->N3 : Symbol(N3, Decl(conditionalTypes1.ts, 173, 20)) ->Not : Symbol(Not, Decl(conditionalTypes1.ts, 160, 58)) +>N3 : Symbol(N3, Decl(conditionalTypes1.ts, 176, 20)) +>Not : Symbol(Not, Decl(conditionalTypes1.ts, 163, 58)) type A1 = And; // false ->A1 : Symbol(A1, Decl(conditionalTypes1.ts, 174, 23)) ->And : Symbol(And, Decl(conditionalTypes1.ts, 161, 49)) +>A1 : Symbol(A1, Decl(conditionalTypes1.ts, 177, 23)) +>And : Symbol(And, Decl(conditionalTypes1.ts, 164, 49)) type A2 = And; // false ->A2 : Symbol(A2, Decl(conditionalTypes1.ts, 176, 28)) ->And : Symbol(And, Decl(conditionalTypes1.ts, 161, 49)) +>A2 : Symbol(A2, Decl(conditionalTypes1.ts, 179, 28)) +>And : Symbol(And, Decl(conditionalTypes1.ts, 164, 49)) type A3 = And; // false ->A3 : Symbol(A3, Decl(conditionalTypes1.ts, 177, 27)) ->And : Symbol(And, Decl(conditionalTypes1.ts, 161, 49)) +>A3 : Symbol(A3, Decl(conditionalTypes1.ts, 180, 27)) +>And : Symbol(And, Decl(conditionalTypes1.ts, 164, 49)) type A4 = And; // true ->A4 : Symbol(A4, Decl(conditionalTypes1.ts, 178, 27)) ->And : Symbol(And, Decl(conditionalTypes1.ts, 161, 49)) +>A4 : Symbol(A4, Decl(conditionalTypes1.ts, 181, 27)) +>And : Symbol(And, Decl(conditionalTypes1.ts, 164, 49)) type A5 = And; // false ->A5 : Symbol(A5, Decl(conditionalTypes1.ts, 179, 26)) ->And : Symbol(And, Decl(conditionalTypes1.ts, 161, 49)) +>A5 : Symbol(A5, Decl(conditionalTypes1.ts, 182, 26)) +>And : Symbol(And, Decl(conditionalTypes1.ts, 164, 49)) type A6 = And; // false ->A6 : Symbol(A6, Decl(conditionalTypes1.ts, 180, 30)) ->And : Symbol(And, Decl(conditionalTypes1.ts, 161, 49)) +>A6 : Symbol(A6, Decl(conditionalTypes1.ts, 183, 30)) +>And : Symbol(And, Decl(conditionalTypes1.ts, 164, 49)) type A7 = And; // boolean ->A7 : Symbol(A7, Decl(conditionalTypes1.ts, 181, 30)) ->And : Symbol(And, Decl(conditionalTypes1.ts, 161, 49)) +>A7 : Symbol(A7, Decl(conditionalTypes1.ts, 184, 30)) +>And : Symbol(And, Decl(conditionalTypes1.ts, 164, 49)) type A8 = And; // boolean ->A8 : Symbol(A8, Decl(conditionalTypes1.ts, 182, 29)) ->And : Symbol(And, Decl(conditionalTypes1.ts, 161, 49)) +>A8 : Symbol(A8, Decl(conditionalTypes1.ts, 185, 29)) +>And : Symbol(And, Decl(conditionalTypes1.ts, 164, 49)) type A9 = And; // boolean ->A9 : Symbol(A9, Decl(conditionalTypes1.ts, 183, 29)) ->And : Symbol(And, Decl(conditionalTypes1.ts, 161, 49)) +>A9 : Symbol(A9, Decl(conditionalTypes1.ts, 186, 29)) +>And : Symbol(And, Decl(conditionalTypes1.ts, 164, 49)) type O1 = Or; // false ->O1 : Symbol(O1, Decl(conditionalTypes1.ts, 184, 32)) ->Or : Symbol(Or, Decl(conditionalTypes1.ts, 162, 65)) +>O1 : Symbol(O1, Decl(conditionalTypes1.ts, 187, 32)) +>Or : Symbol(Or, Decl(conditionalTypes1.ts, 165, 65)) type O2 = Or; // true ->O2 : Symbol(O2, Decl(conditionalTypes1.ts, 186, 27)) ->Or : Symbol(Or, Decl(conditionalTypes1.ts, 162, 65)) +>O2 : Symbol(O2, Decl(conditionalTypes1.ts, 189, 27)) +>Or : Symbol(Or, Decl(conditionalTypes1.ts, 165, 65)) type O3 = Or; // true ->O3 : Symbol(O3, Decl(conditionalTypes1.ts, 187, 26)) ->Or : Symbol(Or, Decl(conditionalTypes1.ts, 162, 65)) +>O3 : Symbol(O3, Decl(conditionalTypes1.ts, 190, 26)) +>Or : Symbol(Or, Decl(conditionalTypes1.ts, 165, 65)) type O4 = Or; // true ->O4 : Symbol(O4, Decl(conditionalTypes1.ts, 188, 26)) ->Or : Symbol(Or, Decl(conditionalTypes1.ts, 162, 65)) +>O4 : Symbol(O4, Decl(conditionalTypes1.ts, 191, 26)) +>Or : Symbol(Or, Decl(conditionalTypes1.ts, 165, 65)) type O5 = Or; // boolean ->O5 : Symbol(O5, Decl(conditionalTypes1.ts, 189, 25)) ->Or : Symbol(Or, Decl(conditionalTypes1.ts, 162, 65)) +>O5 : Symbol(O5, Decl(conditionalTypes1.ts, 192, 25)) +>Or : Symbol(Or, Decl(conditionalTypes1.ts, 165, 65)) type O6 = Or; // boolean ->O6 : Symbol(O6, Decl(conditionalTypes1.ts, 190, 29)) ->Or : Symbol(Or, Decl(conditionalTypes1.ts, 162, 65)) +>O6 : Symbol(O6, Decl(conditionalTypes1.ts, 193, 29)) +>Or : Symbol(Or, Decl(conditionalTypes1.ts, 165, 65)) type O7 = Or; // true ->O7 : Symbol(O7, Decl(conditionalTypes1.ts, 191, 29)) ->Or : Symbol(Or, Decl(conditionalTypes1.ts, 162, 65)) +>O7 : Symbol(O7, Decl(conditionalTypes1.ts, 194, 29)) +>Or : Symbol(Or, Decl(conditionalTypes1.ts, 165, 65)) type O8 = Or; // true ->O8 : Symbol(O8, Decl(conditionalTypes1.ts, 192, 28)) ->Or : Symbol(Or, Decl(conditionalTypes1.ts, 162, 65)) +>O8 : Symbol(O8, Decl(conditionalTypes1.ts, 195, 28)) +>Or : Symbol(Or, Decl(conditionalTypes1.ts, 165, 65)) type O9 = Or; // boolean ->O9 : Symbol(O9, Decl(conditionalTypes1.ts, 193, 28)) ->Or : Symbol(Or, Decl(conditionalTypes1.ts, 162, 65)) +>O9 : Symbol(O9, Decl(conditionalTypes1.ts, 196, 28)) +>Or : Symbol(Or, Decl(conditionalTypes1.ts, 165, 65)) type T40 = never extends never ? true : false; // true ->T40 : Symbol(T40, Decl(conditionalTypes1.ts, 194, 31)) +>T40 : Symbol(T40, Decl(conditionalTypes1.ts, 197, 31)) type T41 = number extends never ? true : false; // false ->T41 : Symbol(T41, Decl(conditionalTypes1.ts, 196, 46)) +>T41 : Symbol(T41, Decl(conditionalTypes1.ts, 199, 46)) type T42 = never extends number ? true : false; // boolean ->T42 : Symbol(T42, Decl(conditionalTypes1.ts, 197, 47)) +>T42 : Symbol(T42, Decl(conditionalTypes1.ts, 200, 47)) type IsNever = T extends never ? true : false; ->IsNever : Symbol(IsNever, Decl(conditionalTypes1.ts, 198, 47)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 200, 13)) ->T : Symbol(T, Decl(conditionalTypes1.ts, 200, 13)) +>IsNever : Symbol(IsNever, Decl(conditionalTypes1.ts, 201, 47)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 203, 13)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 203, 13)) type T50 = IsNever; // true ->T50 : Symbol(T50, Decl(conditionalTypes1.ts, 200, 49)) ->IsNever : Symbol(IsNever, Decl(conditionalTypes1.ts, 198, 47)) +>T50 : Symbol(T50, Decl(conditionalTypes1.ts, 203, 49)) +>IsNever : Symbol(IsNever, Decl(conditionalTypes1.ts, 201, 47)) type T51 = IsNever; // false ->T51 : Symbol(T51, Decl(conditionalTypes1.ts, 202, 26)) ->IsNever : Symbol(IsNever, Decl(conditionalTypes1.ts, 198, 47)) +>T51 : Symbol(T51, Decl(conditionalTypes1.ts, 205, 26)) +>IsNever : Symbol(IsNever, Decl(conditionalTypes1.ts, 201, 47)) type T52 = IsNever; // false ->T52 : Symbol(T52, Decl(conditionalTypes1.ts, 203, 27)) ->IsNever : Symbol(IsNever, Decl(conditionalTypes1.ts, 198, 47)) +>T52 : Symbol(T52, Decl(conditionalTypes1.ts, 206, 27)) +>IsNever : Symbol(IsNever, Decl(conditionalTypes1.ts, 201, 47)) + +// Repros from #21664 + +type Eq = T extends U ? U extends T ? true : false : false; +>Eq : Symbol(Eq, Decl(conditionalTypes1.ts, 207, 24)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 211, 8)) +>U : Symbol(U, Decl(conditionalTypes1.ts, 211, 10)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 211, 8)) +>U : Symbol(U, Decl(conditionalTypes1.ts, 211, 10)) +>U : Symbol(U, Decl(conditionalTypes1.ts, 211, 10)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 211, 8)) + +type T60 = Eq; // true +>T60 : Symbol(T60, Decl(conditionalTypes1.ts, 211, 65)) +>Eq : Symbol(Eq, Decl(conditionalTypes1.ts, 207, 24)) + +type T61 = Eq; // false +>T61 : Symbol(T61, Decl(conditionalTypes1.ts, 212, 26)) +>Eq : Symbol(Eq, Decl(conditionalTypes1.ts, 207, 24)) + +type T62 = Eq; // false +>T62 : Symbol(T62, Decl(conditionalTypes1.ts, 213, 27)) +>Eq : Symbol(Eq, Decl(conditionalTypes1.ts, 207, 24)) + +type T63 = Eq; // true +>T63 : Symbol(T63, Decl(conditionalTypes1.ts, 214, 27)) +>Eq : Symbol(Eq, Decl(conditionalTypes1.ts, 207, 24)) + +type Eq1 = Eq extends false ? false : true; +>Eq1 : Symbol(Eq1, Decl(conditionalTypes1.ts, 215, 28)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 217, 9)) +>U : Symbol(U, Decl(conditionalTypes1.ts, 217, 11)) +>Eq : Symbol(Eq, Decl(conditionalTypes1.ts, 207, 24)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 217, 9)) +>U : Symbol(U, Decl(conditionalTypes1.ts, 217, 11)) + +type T70 = Eq1; // true +>T70 : Symbol(T70, Decl(conditionalTypes1.ts, 217, 55)) +>Eq1 : Symbol(Eq1, Decl(conditionalTypes1.ts, 215, 28)) + +type T71 = Eq1; // false +>T71 : Symbol(T71, Decl(conditionalTypes1.ts, 218, 27)) +>Eq1 : Symbol(Eq1, Decl(conditionalTypes1.ts, 215, 28)) + +type T72 = Eq1; // false +>T72 : Symbol(T72, Decl(conditionalTypes1.ts, 219, 28)) +>Eq1 : Symbol(Eq1, Decl(conditionalTypes1.ts, 215, 28)) + +type T73 = Eq1; // true +>T73 : Symbol(T73, Decl(conditionalTypes1.ts, 220, 28)) +>Eq1 : Symbol(Eq1, Decl(conditionalTypes1.ts, 215, 28)) + +type Eq2 = Eq extends true ? true : false; +>Eq2 : Symbol(Eq2, Decl(conditionalTypes1.ts, 221, 29)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 223, 9)) +>U : Symbol(U, Decl(conditionalTypes1.ts, 223, 11)) +>Eq : Symbol(Eq, Decl(conditionalTypes1.ts, 207, 24)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 223, 9)) +>U : Symbol(U, Decl(conditionalTypes1.ts, 223, 11)) + +type T80 = Eq2; // true +>T80 : Symbol(T80, Decl(conditionalTypes1.ts, 223, 54)) +>Eq2 : Symbol(Eq2, Decl(conditionalTypes1.ts, 221, 29)) + +type T81 = Eq2; // false +>T81 : Symbol(T81, Decl(conditionalTypes1.ts, 224, 27)) +>Eq2 : Symbol(Eq2, Decl(conditionalTypes1.ts, 221, 29)) + +type T82 = Eq2; // false +>T82 : Symbol(T82, Decl(conditionalTypes1.ts, 225, 28)) +>Eq2 : Symbol(Eq2, Decl(conditionalTypes1.ts, 221, 29)) + +type T83 = Eq2; // true +>T83 : Symbol(T83, Decl(conditionalTypes1.ts, 226, 28)) +>Eq2 : Symbol(Eq2, Decl(conditionalTypes1.ts, 221, 29)) + +// Repro from #21756 + +type Foo = T extends string ? boolean : number; +>Foo : Symbol(Foo, Decl(conditionalTypes1.ts, 227, 29)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 231, 9)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 231, 9)) + +type Bar = T extends string ? boolean : number; +>Bar : Symbol(Bar, Decl(conditionalTypes1.ts, 231, 50)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 232, 9)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 232, 9)) + +const convert = (value: Foo): Bar => value; +>convert : Symbol(convert, Decl(conditionalTypes1.ts, 233, 5)) +>U : Symbol(U, Decl(conditionalTypes1.ts, 233, 17)) +>value : Symbol(value, Decl(conditionalTypes1.ts, 233, 20)) +>Foo : Symbol(Foo, Decl(conditionalTypes1.ts, 227, 29)) +>U : Symbol(U, Decl(conditionalTypes1.ts, 233, 17)) +>Bar : Symbol(Bar, Decl(conditionalTypes1.ts, 231, 50)) +>U : Symbol(U, Decl(conditionalTypes1.ts, 233, 17)) +>value : Symbol(value, Decl(conditionalTypes1.ts, 233, 20)) + +type Baz = Foo; +>Baz : Symbol(Baz, Decl(conditionalTypes1.ts, 233, 52)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 235, 9)) +>Foo : Symbol(Foo, Decl(conditionalTypes1.ts, 227, 29)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 235, 9)) + +const convert2 = (value: Foo): Baz => value; +>convert2 : Symbol(convert2, Decl(conditionalTypes1.ts, 236, 5)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 236, 18)) +>value : Symbol(value, Decl(conditionalTypes1.ts, 236, 21)) +>Foo : Symbol(Foo, Decl(conditionalTypes1.ts, 227, 29)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 236, 18)) +>Baz : Symbol(Baz, Decl(conditionalTypes1.ts, 233, 52)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 236, 18)) +>value : Symbol(value, Decl(conditionalTypes1.ts, 236, 21)) + +function f31() { +>f31 : Symbol(f31, Decl(conditionalTypes1.ts, 236, 53)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 238, 13)) + + type T1 = T extends string ? boolean : number; +>T1 : Symbol(T1, Decl(conditionalTypes1.ts, 238, 19)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 238, 13)) + + type T2 = T extends string ? boolean : number; +>T2 : Symbol(T2, Decl(conditionalTypes1.ts, 239, 50)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 238, 13)) + + var x: T1; +>x : Symbol(x, Decl(conditionalTypes1.ts, 241, 7), Decl(conditionalTypes1.ts, 242, 7)) +>T1 : Symbol(T1, Decl(conditionalTypes1.ts, 238, 19)) + + var x: T2; +>x : Symbol(x, Decl(conditionalTypes1.ts, 241, 7), Decl(conditionalTypes1.ts, 242, 7)) +>T2 : Symbol(T2, Decl(conditionalTypes1.ts, 239, 50)) +} + +function f32() { +>f32 : Symbol(f32, Decl(conditionalTypes1.ts, 243, 1)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 245, 13)) +>U : Symbol(U, Decl(conditionalTypes1.ts, 245, 15)) + + type T1 = T & U extends string ? boolean : number; +>T1 : Symbol(T1, Decl(conditionalTypes1.ts, 245, 22)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 245, 13)) +>U : Symbol(U, Decl(conditionalTypes1.ts, 245, 15)) + + type T2 = Foo; +>T2 : Symbol(T2, Decl(conditionalTypes1.ts, 246, 54)) +>Foo : Symbol(Foo, Decl(conditionalTypes1.ts, 227, 29)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 245, 13)) +>U : Symbol(U, Decl(conditionalTypes1.ts, 245, 15)) + + var z: T1; +>z : Symbol(z, Decl(conditionalTypes1.ts, 248, 7), Decl(conditionalTypes1.ts, 249, 7)) +>T1 : Symbol(T1, Decl(conditionalTypes1.ts, 245, 22)) + + var z: T2; // Error, T2 is distributive, T1 isn't +>z : Symbol(z, Decl(conditionalTypes1.ts, 248, 7), Decl(conditionalTypes1.ts, 249, 7)) +>T2 : Symbol(T2, Decl(conditionalTypes1.ts, 246, 54)) +} + +function f33() { +>f33 : Symbol(f33, Decl(conditionalTypes1.ts, 250, 1)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 252, 13)) +>U : Symbol(U, Decl(conditionalTypes1.ts, 252, 15)) + + type T1 = Foo; +>T1 : Symbol(T1, Decl(conditionalTypes1.ts, 252, 22)) +>Foo : Symbol(Foo, Decl(conditionalTypes1.ts, 227, 29)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 252, 13)) +>U : Symbol(U, Decl(conditionalTypes1.ts, 252, 15)) + + type T2 = Bar; +>T2 : Symbol(T2, Decl(conditionalTypes1.ts, 253, 25)) +>Bar : Symbol(Bar, Decl(conditionalTypes1.ts, 231, 50)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 252, 13)) +>U : Symbol(U, Decl(conditionalTypes1.ts, 252, 15)) + + var z: T1; +>z : Symbol(z, Decl(conditionalTypes1.ts, 255, 7), Decl(conditionalTypes1.ts, 256, 7)) +>T1 : Symbol(T1, Decl(conditionalTypes1.ts, 252, 22)) + + var z: T2; +>z : Symbol(z, Decl(conditionalTypes1.ts, 255, 7), Decl(conditionalTypes1.ts, 256, 7)) +>T2 : Symbol(T2, Decl(conditionalTypes1.ts, 253, 25)) +} + +// Repro from #21823 + +type T90 = T extends 0 ? 0 : () => 0; +>T90 : Symbol(T90, Decl(conditionalTypes1.ts, 257, 1)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 261, 9)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 261, 9)) + +type T91 = T extends 0 ? 0 : () => 0; +>T91 : Symbol(T91, Decl(conditionalTypes1.ts, 261, 40)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 262, 9)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 262, 9)) + +const f40 = (a: T90): T91 => a; +>f40 : Symbol(f40, Decl(conditionalTypes1.ts, 263, 5)) +>U : Symbol(U, Decl(conditionalTypes1.ts, 263, 13)) +>a : Symbol(a, Decl(conditionalTypes1.ts, 263, 16)) +>T90 : Symbol(T90, Decl(conditionalTypes1.ts, 257, 1)) +>U : Symbol(U, Decl(conditionalTypes1.ts, 263, 13)) +>T91 : Symbol(T91, Decl(conditionalTypes1.ts, 261, 40)) +>U : Symbol(U, Decl(conditionalTypes1.ts, 263, 13)) +>a : Symbol(a, Decl(conditionalTypes1.ts, 263, 16)) + +const f41 = (a: T91): T90 => a; +>f41 : Symbol(f41, Decl(conditionalTypes1.ts, 264, 5)) +>U : Symbol(U, Decl(conditionalTypes1.ts, 264, 13)) +>a : Symbol(a, Decl(conditionalTypes1.ts, 264, 16)) +>T91 : Symbol(T91, Decl(conditionalTypes1.ts, 261, 40)) +>U : Symbol(U, Decl(conditionalTypes1.ts, 264, 13)) +>T90 : Symbol(T90, Decl(conditionalTypes1.ts, 257, 1)) +>U : Symbol(U, Decl(conditionalTypes1.ts, 264, 13)) +>a : Symbol(a, Decl(conditionalTypes1.ts, 264, 16)) + +type T92 = T extends () => 0 ? () => 1 : () => 2; +>T92 : Symbol(T92, Decl(conditionalTypes1.ts, 264, 40)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 266, 9)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 266, 9)) + +type T93 = T extends () => 0 ? () => 1 : () => 2; +>T93 : Symbol(T93, Decl(conditionalTypes1.ts, 266, 52)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 267, 9)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 267, 9)) + +const f42 = (a: T92): T93 => a; +>f42 : Symbol(f42, Decl(conditionalTypes1.ts, 268, 5)) +>U : Symbol(U, Decl(conditionalTypes1.ts, 268, 13)) +>a : Symbol(a, Decl(conditionalTypes1.ts, 268, 16)) +>T92 : Symbol(T92, Decl(conditionalTypes1.ts, 264, 40)) +>U : Symbol(U, Decl(conditionalTypes1.ts, 268, 13)) +>T93 : Symbol(T93, Decl(conditionalTypes1.ts, 266, 52)) +>U : Symbol(U, Decl(conditionalTypes1.ts, 268, 13)) +>a : Symbol(a, Decl(conditionalTypes1.ts, 268, 16)) + +const f43 = (a: T93): T92 => a; +>f43 : Symbol(f43, Decl(conditionalTypes1.ts, 269, 5)) +>U : Symbol(U, Decl(conditionalTypes1.ts, 269, 13)) +>a : Symbol(a, Decl(conditionalTypes1.ts, 269, 16)) +>T93 : Symbol(T93, Decl(conditionalTypes1.ts, 266, 52)) +>U : Symbol(U, Decl(conditionalTypes1.ts, 269, 13)) +>T92 : Symbol(T92, Decl(conditionalTypes1.ts, 264, 40)) +>U : Symbol(U, Decl(conditionalTypes1.ts, 269, 13)) +>a : Symbol(a, Decl(conditionalTypes1.ts, 269, 16)) + +type T94 = T extends string ? true : 42; +>T94 : Symbol(T94, Decl(conditionalTypes1.ts, 269, 40)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 271, 9)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 271, 9)) + +type T95 = T extends string ? boolean : number; +>T95 : Symbol(T95, Decl(conditionalTypes1.ts, 271, 43)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 272, 9)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 272, 9)) + +const f44 = (value: T94): T95 => value; +>f44 : Symbol(f44, Decl(conditionalTypes1.ts, 273, 5)) +>U : Symbol(U, Decl(conditionalTypes1.ts, 273, 13)) +>value : Symbol(value, Decl(conditionalTypes1.ts, 273, 16)) +>T94 : Symbol(T94, Decl(conditionalTypes1.ts, 269, 40)) +>U : Symbol(U, Decl(conditionalTypes1.ts, 273, 13)) +>T95 : Symbol(T95, Decl(conditionalTypes1.ts, 271, 43)) +>U : Symbol(U, Decl(conditionalTypes1.ts, 273, 13)) +>value : Symbol(value, Decl(conditionalTypes1.ts, 273, 16)) + +const f45 = (value: T95): T94 => value; // Error +>f45 : Symbol(f45, Decl(conditionalTypes1.ts, 274, 5)) +>U : Symbol(U, Decl(conditionalTypes1.ts, 274, 13)) +>value : Symbol(value, Decl(conditionalTypes1.ts, 274, 16)) +>T95 : Symbol(T95, Decl(conditionalTypes1.ts, 271, 43)) +>U : Symbol(U, Decl(conditionalTypes1.ts, 274, 13)) +>T94 : Symbol(T94, Decl(conditionalTypes1.ts, 269, 40)) +>U : Symbol(U, Decl(conditionalTypes1.ts, 274, 13)) +>value : Symbol(value, Decl(conditionalTypes1.ts, 274, 16)) + +// Repro from #21863 + +function f50() { +>f50 : Symbol(f50, Decl(conditionalTypes1.ts, 274, 48)) + + type Eq = T extends U ? U extends T ? true : false : false; +>Eq : Symbol(Eq, Decl(conditionalTypes1.ts, 278, 16)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 279, 12)) +>U : Symbol(U, Decl(conditionalTypes1.ts, 279, 14)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 279, 12)) +>U : Symbol(U, Decl(conditionalTypes1.ts, 279, 14)) +>U : Symbol(U, Decl(conditionalTypes1.ts, 279, 14)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 279, 12)) + + type If = S extends false ? U : T; +>If : Symbol(If, Decl(conditionalTypes1.ts, 279, 69)) +>S : Symbol(S, Decl(conditionalTypes1.ts, 280, 12)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 280, 14)) +>U : Symbol(U, Decl(conditionalTypes1.ts, 280, 17)) +>S : Symbol(S, Decl(conditionalTypes1.ts, 280, 12)) +>U : Symbol(U, Decl(conditionalTypes1.ts, 280, 17)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 280, 14)) + + type Omit = { [P in keyof T]: If, never, P>; }[keyof T]; +>Omit : Symbol(Omit, Decl(conditionalTypes1.ts, 280, 47)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 281, 14)) +>P : Symbol(P, Decl(conditionalTypes1.ts, 281, 37)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 281, 14)) +>If : Symbol(If, Decl(conditionalTypes1.ts, 279, 69)) +>Eq : Symbol(Eq, Decl(conditionalTypes1.ts, 278, 16)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 281, 14)) +>P : Symbol(P, Decl(conditionalTypes1.ts, 281, 37)) +>P : Symbol(P, Decl(conditionalTypes1.ts, 281, 37)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 281, 14)) + + type Omit2 = { [P in keyof T]: If, never, P>; }[keyof T]; +>Omit2 : Symbol(Omit2, Decl(conditionalTypes1.ts, 281, 94)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 282, 15)) +>U : Symbol(U, Decl(conditionalTypes1.ts, 282, 32)) +>P : Symbol(P, Decl(conditionalTypes1.ts, 282, 49)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 282, 15)) +>If : Symbol(If, Decl(conditionalTypes1.ts, 279, 69)) +>Eq : Symbol(Eq, Decl(conditionalTypes1.ts, 278, 16)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 282, 15)) +>P : Symbol(P, Decl(conditionalTypes1.ts, 282, 49)) +>U : Symbol(U, Decl(conditionalTypes1.ts, 282, 32)) +>P : Symbol(P, Decl(conditionalTypes1.ts, 282, 49)) +>T : Symbol(T, Decl(conditionalTypes1.ts, 282, 15)) + + type A = Omit<{ a: void; b: never; }>; // 'a' +>A : Symbol(A, Decl(conditionalTypes1.ts, 282, 102)) +>Omit : Symbol(Omit, Decl(conditionalTypes1.ts, 280, 47)) +>a : Symbol(a, Decl(conditionalTypes1.ts, 283, 19)) +>b : Symbol(b, Decl(conditionalTypes1.ts, 283, 28)) + + type B = Omit2<{ a: void; b: never; }>; // 'a' +>B : Symbol(B, Decl(conditionalTypes1.ts, 283, 42)) +>Omit2 : Symbol(Omit2, Decl(conditionalTypes1.ts, 281, 94)) +>a : Symbol(a, Decl(conditionalTypes1.ts, 284, 20)) +>b : Symbol(b, Decl(conditionalTypes1.ts, 284, 29)) +} diff --git a/tests/baselines/reference/conditionalTypes1.types b/tests/baselines/reference/conditionalTypes1.types index df825ecd40b..b544acdf3e2 100644 --- a/tests/baselines/reference/conditionalTypes1.types +++ b/tests/baselines/reference/conditionalTypes1.types @@ -1,91 +1,68 @@ === tests/cases/conformance/types/conditional/conditionalTypes1.ts === -type Diff = T extends U ? never : T; ->Diff : Diff ->T : T ->U : U ->T : T ->U : U ->T : T - -type Filter = T extends U ? T : never; ->Filter : Filter ->T : T ->U : U ->T : T ->U : U ->T : T - -type NonNullable = Diff; ->NonNullable : Diff ->T : T ->Diff : Diff ->T : T ->null : null - -type T00 = Diff<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "b" | "d" +type T00 = Exclude<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "b" | "d" >T00 : "b" | "d" ->Diff : Diff +>Exclude : Exclude -type T01 = Filter<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "a" | "c" +type T01 = Extract<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "a" | "c" >T01 : "a" | "c" ->Filter : Filter +>Extract : Extract -type T02 = Diff void), Function>; // string | number +type T02 = Exclude void), Function>; // string | number >T02 : string | number ->Diff : Diff +>Exclude : Exclude >Function : Function -type T03 = Filter void), Function>; // () => void +type T03 = Extract void), Function>; // () => void >T03 : () => void ->Filter : Filter +>Extract : Extract >Function : Function type T04 = NonNullable; // string | number >T04 : string | number ->NonNullable : Diff +>NonNullable : NonNullable type T05 = NonNullable<(() => string) | string[] | null | undefined>; // (() => string) | string[] >T05 : (() => string) | string[] ->NonNullable : Diff +>NonNullable : NonNullable >null : null function f1(x: T, y: NonNullable) { ->f1 : (x: T, y: Diff) => void +>f1 : (x: T, y: NonNullable) => void >T : T >x : T >T : T ->y : Diff ->NonNullable : Diff +>y : NonNullable +>NonNullable : NonNullable >T : T x = y; ->x = y : Diff +>x = y : NonNullable >x : T ->y : Diff +>y : NonNullable y = x; // Error >y = x : T ->y : Diff +>y : NonNullable >x : T } function f2(x: T, y: NonNullable) { ->f2 : (x: T, y: Diff) => void +>f2 : (x: T, y: NonNullable) => void >T : T >x : T >T : T ->y : Diff ->NonNullable : Diff +>y : NonNullable +>NonNullable : NonNullable >T : T x = y; ->x = y : Diff +>x = y : NonNullable >x : T ->y : Diff +>y : NonNullable y = x; // Error >y = x : T ->y : Diff +>y : NonNullable >x : T let s1: string = x; // Error @@ -94,33 +71,62 @@ function f2(x: T, y: NonNullable) { let s2: string = y; >s2 : string ->y : Diff +>y : NonNullable } function f3(x: Partial[keyof T], y: NonNullable[keyof T]>) { ->f3 : (x: Partial[keyof T], y: Diff[keyof T], null | undefined>) => void +>f3 : (x: Partial[keyof T], y: NonNullable[keyof T]>) => void >T : T >x : Partial[keyof T] >Partial : Partial >T : T >T : T ->y : Diff[keyof T], null | undefined> ->NonNullable : Diff +>y : NonNullable[keyof T]> +>NonNullable : NonNullable >Partial : Partial >T : T >T : T x = y; ->x = y : Diff[keyof T], null | undefined> +>x = y : NonNullable[keyof T]> >x : Partial[keyof T] ->y : Diff[keyof T], null | undefined> +>y : NonNullable[keyof T]> y = x; // Error >y = x : Partial[keyof T] ->y : Diff[keyof T], null | undefined> +>y : NonNullable[keyof T]> >x : Partial[keyof T] } +function f4(x: T["x"], y: NonNullable) { +>f4 : (x: T["x"], y: NonNullable) => void +>T : T +>x : string | undefined +>x : T["x"] +>T : T +>y : NonNullable +>NonNullable : NonNullable +>T : T + + x = y; +>x = y : NonNullable +>x : T["x"] +>y : NonNullable + + y = x; // Error +>y = x : T["x"] +>y : NonNullable +>x : T["x"] + + let s1: string = x; // Error +>s1 : string +>x : T["x"] + + let s2: string = y; +>s2 : string +>y : NonNullable +} + type Options = { k: "a", a: number } | { k: "b", b: string } | { k: "c", c: boolean }; >Options : Options >k : "a" @@ -130,84 +136,84 @@ type Options = { k: "a", a: number } | { k: "b", b: string } | { k: "c", c: bool >k : "c" >c : boolean -type T10 = Diff; // { k: "c", c: boolean } +type T10 = Exclude; // { k: "c", c: boolean } >T10 : { k: "c"; c: boolean; } ->Diff : Diff +>Exclude : Exclude >Options : Options >k : "a" | "b" -type T11 = Filter; // { k: "a", a: number } | { k: "b", b: string } +type T11 = Extract; // { k: "a", a: number } | { k: "b", b: string } >T11 : { k: "a"; a: number; } | { k: "b"; b: string; } ->Filter : Filter +>Extract : Extract >Options : Options >k : "a" | "b" -type T12 = Diff; // { k: "c", c: boolean } +type T12 = Exclude; // { k: "c", c: boolean } >T12 : { k: "c"; c: boolean; } ->Diff : Diff +>Exclude : Exclude >Options : Options >k : "a" >k : "b" -type T13 = Filter; // { k: "a", a: number } | { k: "b", b: string } +type T13 = Extract; // { k: "a", a: number } | { k: "b", b: string } >T13 : { k: "a"; a: number; } | { k: "b"; b: string; } ->Filter : Filter +>Extract : Extract >Options : Options >k : "a" >k : "b" -type T14 = Diff; // Options +type T14 = Exclude; // Options >T14 : Options ->Diff : Diff +>Exclude : Exclude >Options : Options >q : "a" -type T15 = Filter; // never +type T15 = Extract; // never >T15 : never ->Filter : Filter +>Extract : Extract >Options : Options >q : "a" -declare function f4(p: K): Filter; ->f4 : (p: K) => Filter +declare function f5(p: K): Extract; +>f5 : (p: K) => Extract >T : T >Options : Options >K : K >p : K >K : K ->Filter : Filter +>Extract : Extract >T : T >k : K >K : K -let x0 = f4("a"); // { k: "a", a: number } +let x0 = f5("a"); // { k: "a", a: number } >x0 : { k: "a"; a: number; } ->f4("a") : { k: "a"; a: number; } ->f4 : (p: K) => Filter +>f5("a") : { k: "a"; a: number; } +>f5 : (p: K) => Extract >"a" : "a" -type OptionsOfKind = Filter; ->OptionsOfKind : Filter<{ k: "a"; a: number; }, { k: K; }> | Filter<{ k: "b"; b: string; }, { k: K; }> | Filter<{ k: "c"; c: boolean; }, { k: K; }> +type OptionsOfKind = Extract; +>OptionsOfKind : Extract<{ k: "a"; a: number; }, { k: K; }> | Extract<{ k: "b"; b: string; }, { k: K; }> | Extract<{ k: "c"; c: boolean; }, { k: K; }> >K : K >Options : Options ->Filter : Filter +>Extract : Extract >Options : Options >k : K >K : K type T16 = OptionsOfKind<"a" | "b">; // { k: "a", a: number } | { k: "b", b: string } >T16 : { k: "a"; a: number; } | { k: "b"; b: string; } ->OptionsOfKind : Filter<{ k: "a"; a: number; }, { k: K; }> | Filter<{ k: "b"; b: string; }, { k: K; }> | Filter<{ k: "c"; c: boolean; }, { k: K; }> +>OptionsOfKind : Extract<{ k: "a"; a: number; }, { k: K; }> | Extract<{ k: "b"; b: string; }, { k: K; }> | Extract<{ k: "c"; c: boolean; }, { k: K; }> -type Select = Filter; ->Select : Filter +type Select = Extract; +>Select : Extract >T : T >K : K >T : T >V : V >T : T >K : K ->Filter : Filter +>Extract : Extract >T : T >P : P >K : K @@ -215,7 +221,7 @@ type Select = Filter; type T17 = Select; // // { k: "a", a: number } | { k: "b", b: string } >T17 : { k: "a"; a: number; } | { k: "b"; b: string; } ->Select : Filter +>Select : Extract >Options : Options type TypeName = @@ -883,3 +889,388 @@ type T52 = IsNever; // false >T52 : false >IsNever : IsNever +// Repros from #21664 + +type Eq = T extends U ? U extends T ? true : false : false; +>Eq : Eq +>T : T +>U : U +>T : T +>U : U +>U : U +>T : T +>true : true +>false : false +>false : false + +type T60 = Eq; // true +>T60 : true +>Eq : Eq +>true : true +>true : true + +type T61 = Eq; // false +>T61 : false +>Eq : Eq +>true : true +>false : false + +type T62 = Eq; // false +>T62 : false +>Eq : Eq +>false : false +>true : true + +type T63 = Eq; // true +>T63 : true +>Eq : Eq +>false : false +>false : false + +type Eq1 = Eq extends false ? false : true; +>Eq1 : Eq1 +>T : T +>U : U +>Eq : Eq +>T : T +>U : U +>false : false +>false : false +>true : true + +type T70 = Eq1; // true +>T70 : true +>Eq1 : Eq1 +>true : true +>true : true + +type T71 = Eq1; // false +>T71 : false +>Eq1 : Eq1 +>true : true +>false : false + +type T72 = Eq1; // false +>T72 : false +>Eq1 : Eq1 +>false : false +>true : true + +type T73 = Eq1; // true +>T73 : true +>Eq1 : Eq1 +>false : false +>false : false + +type Eq2 = Eq extends true ? true : false; +>Eq2 : Eq2 +>T : T +>U : U +>Eq : Eq +>T : T +>U : U +>true : true +>true : true +>false : false + +type T80 = Eq2; // true +>T80 : true +>Eq2 : Eq2 +>true : true +>true : true + +type T81 = Eq2; // false +>T81 : false +>Eq2 : Eq2 +>true : true +>false : false + +type T82 = Eq2; // false +>T82 : false +>Eq2 : Eq2 +>false : false +>true : true + +type T83 = Eq2; // true +>T83 : true +>Eq2 : Eq2 +>false : false +>false : false + +// Repro from #21756 + +type Foo = T extends string ? boolean : number; +>Foo : Foo +>T : T +>T : T + +type Bar = T extends string ? boolean : number; +>Bar : Bar +>T : T +>T : T + +const convert = (value: Foo): Bar => value; +>convert : (value: Foo) => Foo +>(value: Foo): Bar => value : (value: Foo) => Foo +>U : U +>value : Foo +>Foo : Foo +>U : U +>Bar : Bar +>U : U +>value : Foo + +type Baz = Foo; +>Baz : Foo +>T : T +>Foo : Foo +>T : T + +const convert2 = (value: Foo): Baz => value; +>convert2 : (value: Foo) => Foo +>(value: Foo): Baz => value : (value: Foo) => Foo +>T : T +>value : Foo +>Foo : Foo +>T : T +>Baz : Foo +>T : T +>value : Foo + +function f31() { +>f31 : () => void +>T : T + + type T1 = T extends string ? boolean : number; +>T1 : T extends string ? boolean : number +>T : T + + type T2 = T extends string ? boolean : number; +>T2 : T extends string ? boolean : number +>T : T + + var x: T1; +>x : T extends string ? boolean : number +>T1 : T extends string ? boolean : number + + var x: T2; +>x : T extends string ? boolean : number +>T2 : T extends string ? boolean : number +} + +function f32() { +>f32 : () => void +>T : T +>U : U + + type T1 = T & U extends string ? boolean : number; +>T1 : T & U extends string ? boolean : number +>T : T +>U : U + + type T2 = Foo; +>T2 : Foo +>Foo : Foo +>T : T +>U : U + + var z: T1; +>z : T & U extends string ? boolean : number +>T1 : T & U extends string ? boolean : number + + var z: T2; // Error, T2 is distributive, T1 isn't +>z : T & U extends string ? boolean : number +>T2 : Foo +} + +function f33() { +>f33 : () => void +>T : T +>U : U + + type T1 = Foo; +>T1 : Foo +>Foo : Foo +>T : T +>U : U + + type T2 = Bar; +>T2 : Foo +>Bar : Bar +>T : T +>U : U + + var z: T1; +>z : Foo +>T1 : Foo + + var z: T2; +>z : Foo +>T2 : Foo +} + +// Repro from #21823 + +type T90 = T extends 0 ? 0 : () => 0; +>T90 : T90 +>T : T +>T : T + +type T91 = T extends 0 ? 0 : () => 0; +>T91 : T91 +>T : T +>T : T + +const f40 = (a: T90): T91 => a; +>f40 : (a: T90) => T91 +>(a: T90): T91 => a : (a: T90) => T91 +>U : U +>a : T90 +>T90 : T90 +>U : U +>T91 : T91 +>U : U +>a : T90 + +const f41 = (a: T91): T90 => a; +>f41 : (a: T91) => T90 +>(a: T91): T90 => a : (a: T91) => T90 +>U : U +>a : T91 +>T91 : T91 +>U : U +>T90 : T90 +>U : U +>a : T91 + +type T92 = T extends () => 0 ? () => 1 : () => 2; +>T92 : T92 +>T : T +>T : T + +type T93 = T extends () => 0 ? () => 1 : () => 2; +>T93 : T93 +>T : T +>T : T + +const f42 = (a: T92): T93 => a; +>f42 : (a: T92) => T93 +>(a: T92): T93 => a : (a: T92) => T93 +>U : U +>a : T92 +>T92 : T92 +>U : U +>T93 : T93 +>U : U +>a : T92 + +const f43 = (a: T93): T92 => a; +>f43 : (a: T93) => T92 +>(a: T93): T92 => a : (a: T93) => T92 +>U : U +>a : T93 +>T93 : T93 +>U : U +>T92 : T92 +>U : U +>a : T93 + +type T94 = T extends string ? true : 42; +>T94 : T94 +>T : T +>T : T +>true : true + +type T95 = T extends string ? boolean : number; +>T95 : T95 +>T : T +>T : T + +const f44 = (value: T94): T95 => value; +>f44 : (value: T94) => T95 +>(value: T94): T95 => value : (value: T94) => T95 +>U : U +>value : T94 +>T94 : T94 +>U : U +>T95 : T95 +>U : U +>value : T94 + +const f45 = (value: T95): T94 => value; // Error +>f45 : (value: T95) => T94 +>(value: T95): T94 => value : (value: T95) => T94 +>U : U +>value : T95 +>T95 : T95 +>U : U +>T94 : T94 +>U : U +>value : T95 + +// Repro from #21863 + +function f50() { +>f50 : () => void + + type Eq = T extends U ? U extends T ? true : false : false; +>Eq : T extends U ? U extends T ? true : false : false +>T : T +>U : U +>T : T +>U : U +>U : U +>T : T +>true : true +>false : false +>false : false + + type If = S extends false ? U : T; +>If : S extends false ? U : T +>S : S +>T : T +>U : U +>S : S +>false : false +>U : U +>T : T + + type Omit = { [P in keyof T]: If, never, P>; }[keyof T]; +>Omit : { [P in keyof T]: (T[P] extends never ? boolean : false) extends false ? P : never; }[keyof T] +>T : T +>P : P +>T : T +>If : S extends false ? U : T +>Eq : T extends U ? U extends T ? true : false : false +>T : T +>P : P +>P : P +>T : T + + type Omit2 = { [P in keyof T]: If, never, P>; }[keyof T]; +>Omit2 : { [P in keyof T]: (T[P] extends U ? U extends T[P] ? true : false : false) extends false ? P : never; }[keyof T] +>T : T +>U : U +>P : P +>T : T +>If : S extends false ? U : T +>Eq : T extends U ? U extends T ? true : false : false +>T : T +>P : P +>U : U +>P : P +>T : T + + type A = Omit<{ a: void; b: never; }>; // 'a' +>A : "a" +>Omit : { [P in keyof T]: (T[P] extends never ? boolean : false) extends false ? P : never; }[keyof T] +>a : void +>b : never + + type B = Omit2<{ a: void; b: never; }>; // 'a' +>B : "a" +>Omit2 : { [P in keyof T]: (T[P] extends U ? U extends T[P] ? true : false : false) extends false ? P : never; }[keyof T] +>a : void +>b : never +} + diff --git a/tests/baselines/reference/conflictMarkerTrivia3.symbols b/tests/baselines/reference/conflictMarkerTrivia3.symbols index 3b9fd368bd5..a952f35f932 100644 --- a/tests/baselines/reference/conflictMarkerTrivia3.symbols +++ b/tests/baselines/reference/conflictMarkerTrivia3.symbols @@ -1,6 +1,5 @@ === tests/cases/compiler/conflictMarkerTrivia3.tsx === const x =
>x : Symbol(x, Decl(conflictMarkerTrivia3.tsx, 0, 5)) ->div : Symbol(unknown) <<<<<<< HEAD diff --git a/tests/baselines/reference/constEnumErrors.errors.txt b/tests/baselines/reference/constEnumErrors.errors.txt index c2642c9b1ac..3763a218336 100644 --- a/tests/baselines/reference/constEnumErrors.errors.txt +++ b/tests/baselines/reference/constEnumErrors.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/constEnumErrors.ts(1,12): error TS2300: Duplicate identifier 'E'. -tests/cases/compiler/constEnumErrors.ts(5,8): error TS2300: Duplicate identifier 'E'. +tests/cases/compiler/constEnumErrors.ts(1,12): error TS2567: Enum declarations can only merge with namespace or other enum declarations. +tests/cases/compiler/constEnumErrors.ts(5,8): error TS2567: Enum declarations can only merge with namespace or other enum declarations. tests/cases/compiler/constEnumErrors.ts(12,9): error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums. tests/cases/compiler/constEnumErrors.ts(14,9): error TS2474: In 'const' enum declarations member initializer must be constant expression. tests/cases/compiler/constEnumErrors.ts(15,10): error TS2474: In 'const' enum declarations member initializer must be constant expression. @@ -16,13 +16,13 @@ tests/cases/compiler/constEnumErrors.ts(42,9): error TS2478: 'const' enum member ==== tests/cases/compiler/constEnumErrors.ts (13 errors) ==== const enum E { ~ -!!! error TS2300: Duplicate identifier 'E'. +!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. A } module E { ~ -!!! error TS2300: Duplicate identifier 'E'. +!!! error TS2567: Enum declarations can only merge with namespace or other enum declarations. var x = 1; } diff --git a/tests/baselines/reference/constEnumPropertyAccess1.symbols b/tests/baselines/reference/constEnumPropertyAccess1.symbols index 63861a94ae1..a2b4ed6a9a1 100644 --- a/tests/baselines/reference/constEnumPropertyAccess1.symbols +++ b/tests/baselines/reference/constEnumPropertyAccess1.symbols @@ -30,6 +30,8 @@ var o: { } = { 1: true +>1 : Symbol(1, Decl(constEnumPropertyAccess1.ts, 13, 5)) + }; var a = G.A; diff --git a/tests/baselines/reference/constEnumPropertyAccess1.types b/tests/baselines/reference/constEnumPropertyAccess1.types index af9aacd279c..9a210c646c7 100644 --- a/tests/baselines/reference/constEnumPropertyAccess1.types +++ b/tests/baselines/reference/constEnumPropertyAccess1.types @@ -37,6 +37,7 @@ var o: { >{ 1: true } : { 1: true; } 1: true +>1 : true >true : true }; diff --git a/tests/baselines/reference/constIndexedAccess.symbols b/tests/baselines/reference/constIndexedAccess.symbols index ef2be6368e3..658a30c99a6 100644 --- a/tests/baselines/reference/constIndexedAccess.symbols +++ b/tests/baselines/reference/constIndexedAccess.symbols @@ -13,7 +13,10 @@ interface indexAccess { >indexAccess : Symbol(indexAccess, Decl(constIndexedAccess.ts, 3, 1)) 0: string; +>0 : Symbol(indexAccess[0], Decl(constIndexedAccess.ts, 5, 23)) + 1: number; +>1 : Symbol(indexAccess[1], Decl(constIndexedAccess.ts, 6, 14)) } let test: indexAccess; diff --git a/tests/baselines/reference/constIndexedAccess.types b/tests/baselines/reference/constIndexedAccess.types index e63852c1ab1..2a753814d40 100644 --- a/tests/baselines/reference/constIndexedAccess.types +++ b/tests/baselines/reference/constIndexedAccess.types @@ -13,7 +13,10 @@ interface indexAccess { >indexAccess : indexAccess 0: string; +>0 : string + 1: number; +>1 : number } let test: indexAccess; diff --git a/tests/baselines/reference/constWithNonNull.errors.txt b/tests/baselines/reference/constWithNonNull.errors.txt new file mode 100644 index 00000000000..58667c417da --- /dev/null +++ b/tests/baselines/reference/constWithNonNull.errors.txt @@ -0,0 +1,11 @@ +tests/cases/compiler/constWithNonNull.ts(4,1): error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. + + +==== tests/cases/compiler/constWithNonNull.ts (1 errors) ==== + // Fixes #21848 + + declare const x: number | undefined; + x!++; + ~ +!!! error TS2540: Cannot assign to 'x' because it is a constant or a read-only property. + \ No newline at end of file diff --git a/tests/baselines/reference/constWithNonNull.js b/tests/baselines/reference/constWithNonNull.js new file mode 100644 index 00000000000..66aeb426489 --- /dev/null +++ b/tests/baselines/reference/constWithNonNull.js @@ -0,0 +1,10 @@ +//// [constWithNonNull.ts] +// Fixes #21848 + +declare const x: number | undefined; +x!++; + + +//// [constWithNonNull.js] +// Fixes #21848 +x++; diff --git a/tests/baselines/reference/constWithNonNull.symbols b/tests/baselines/reference/constWithNonNull.symbols new file mode 100644 index 00000000000..4f5ddcbb454 --- /dev/null +++ b/tests/baselines/reference/constWithNonNull.symbols @@ -0,0 +1,9 @@ +=== tests/cases/compiler/constWithNonNull.ts === +// Fixes #21848 + +declare const x: number | undefined; +>x : Symbol(x, Decl(constWithNonNull.ts, 2, 13)) + +x!++; +>x : Symbol(x, Decl(constWithNonNull.ts, 2, 13)) + diff --git a/tests/baselines/reference/constWithNonNull.types b/tests/baselines/reference/constWithNonNull.types new file mode 100644 index 00000000000..b58fb7a62d5 --- /dev/null +++ b/tests/baselines/reference/constWithNonNull.types @@ -0,0 +1,11 @@ +=== tests/cases/compiler/constWithNonNull.ts === +// Fixes #21848 + +declare const x: number | undefined; +>x : number + +x!++; +>x!++ : number +>x! : any +>x : any + diff --git a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.symbols b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.symbols index 45a894d8895..56b4bb3c7fa 100644 --- a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.symbols +++ b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.symbols @@ -1,5 +1,7 @@ === tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts === declare module "fs" { +>"fs" : Symbol("fs", Decl(constructorWithIncompleteTypeAnnotation.ts, 0, 0)) + export class File { >File : Symbol(File, Decl(constructorWithIncompleteTypeAnnotation.ts, 0, 21)) @@ -171,6 +173,7 @@ module TypeScriptAllInOne { var objLit = { "var": number = 42, equals: function (x) { return x["var"] === 42; }, instanceof : () => 'objLit{42}' }; >objLit : Symbol(objLit, Decl(constructorWithIncompleteTypeAnnotation.ts, 82, 15)) +>"var" : Symbol("var", Decl(constructorWithIncompleteTypeAnnotation.ts, 82, 26)) >number : Symbol(number, Decl(constructorWithIncompleteTypeAnnotation.ts, 97, 15)) >equals : Symbol(equals, Decl(constructorWithIncompleteTypeAnnotation.ts, 82, 46)) >x : Symbol(x, Decl(constructorWithIncompleteTypeAnnotation.ts, 82, 65)) diff --git a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.types b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.types index d1b7c98087f..f0044067db8 100644 --- a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.types +++ b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.types @@ -1,5 +1,7 @@ === tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts === declare module "fs" { +>"fs" : typeof "fs" + export class File { >File : File @@ -19,7 +21,7 @@ declare module "fs" { import fs = module("fs"); >fs : any ->module : No type information available! +>module : any >("fs") : "fs" >"fs" : "fs" @@ -249,6 +251,7 @@ module TypeScriptAllInOne { var objLit = { "var": number = 42, equals: function (x) { return x["var"] === 42; }, instanceof : () => 'objLit{42}' }; >objLit : { "var": number; equals: (x: any) => boolean; instanceof: () => string; } >{ "var": number = 42, equals: function (x) { return x["var"] === 42; }, instanceof : () => 'objLit{42}' } : { "var": number; equals: (x: any) => boolean; instanceof: () => string; } +>"var" : number >number = 42 : 42 >number : number >42 : 42 diff --git a/tests/baselines/reference/contextualTypeArrayReturnType.symbols b/tests/baselines/reference/contextualTypeArrayReturnType.symbols index 2982a1ce893..0688e810c08 100644 --- a/tests/baselines/reference/contextualTypeArrayReturnType.symbols +++ b/tests/baselines/reference/contextualTypeArrayReturnType.symbols @@ -33,6 +33,8 @@ var style: IBookStyle = { return [ {'ry': null } +>'ry' : Symbol('ry', Decl(contextualTypeArrayReturnType.ts, 15, 13)) + ]; } } diff --git a/tests/baselines/reference/contextualTypeArrayReturnType.types b/tests/baselines/reference/contextualTypeArrayReturnType.types index 6c91fd7b8b9..aee8eae59f5 100644 --- a/tests/baselines/reference/contextualTypeArrayReturnType.types +++ b/tests/baselines/reference/contextualTypeArrayReturnType.types @@ -38,6 +38,7 @@ var style: IBookStyle = { {'ry': null } >{'ry': null } : { 'ry': null; } +>'ry' : null >null : null ]; diff --git a/tests/baselines/reference/contextualTypeWithUnionTypeIndexSignatures.symbols b/tests/baselines/reference/contextualTypeWithUnionTypeIndexSignatures.symbols index 985bb52f243..207b4dab689 100644 --- a/tests/baselines/reference/contextualTypeWithUnionTypeIndexSignatures.symbols +++ b/tests/baselines/reference/contextualTypeWithUnionTypeIndexSignatures.symbols @@ -24,6 +24,7 @@ interface IWithNoNumberIndexSignature { >IWithNoNumberIndexSignature : Symbol(IWithNoNumberIndexSignature, Decl(contextualTypeWithUnionTypeIndexSignatures.ts, 11, 1)) 0: string; +>0 : Symbol(IWithNoNumberIndexSignature[0], Decl(contextualTypeWithUnionTypeIndexSignatures.ts, 12, 39)) } interface IWithStringIndexSignature1 { >IWithStringIndexSignature1 : Symbol(IWithStringIndexSignature1, Decl(contextualTypeWithUnionTypeIndexSignatures.ts, 14, 1)) @@ -113,6 +114,7 @@ var x3: IWithNoNumberIndexSignature | IWithNumberIndexSignature1 = { 1: a => a } >x3 : Symbol(x3, Decl(contextualTypeWithUnionTypeIndexSignatures.ts, 49, 3), Decl(contextualTypeWithUnionTypeIndexSignatures.ts, 50, 3), Decl(contextualTypeWithUnionTypeIndexSignatures.ts, 51, 3)) >IWithNoNumberIndexSignature : Symbol(IWithNoNumberIndexSignature, Decl(contextualTypeWithUnionTypeIndexSignatures.ts, 11, 1)) >IWithNumberIndexSignature1 : Symbol(IWithNumberIndexSignature1, Decl(contextualTypeWithUnionTypeIndexSignatures.ts, 20, 1)) +>1 : Symbol(1, Decl(contextualTypeWithUnionTypeIndexSignatures.ts, 49, 68)) >a : Symbol(a, Decl(contextualTypeWithUnionTypeIndexSignatures.ts, 49, 71)) >a : Symbol(a, Decl(contextualTypeWithUnionTypeIndexSignatures.ts, 49, 71)) @@ -120,6 +122,7 @@ var x3: IWithNoNumberIndexSignature | IWithNumberIndexSignature1 = { 0: a => a } >x3 : Symbol(x3, Decl(contextualTypeWithUnionTypeIndexSignatures.ts, 49, 3), Decl(contextualTypeWithUnionTypeIndexSignatures.ts, 50, 3), Decl(contextualTypeWithUnionTypeIndexSignatures.ts, 51, 3)) >IWithNoNumberIndexSignature : Symbol(IWithNoNumberIndexSignature, Decl(contextualTypeWithUnionTypeIndexSignatures.ts, 11, 1)) >IWithNumberIndexSignature1 : Symbol(IWithNumberIndexSignature1, Decl(contextualTypeWithUnionTypeIndexSignatures.ts, 20, 1)) +>0 : Symbol(0, Decl(contextualTypeWithUnionTypeIndexSignatures.ts, 50, 68)) >a : Symbol(a, Decl(contextualTypeWithUnionTypeIndexSignatures.ts, 50, 71)) >a : Symbol(a, Decl(contextualTypeWithUnionTypeIndexSignatures.ts, 50, 71)) @@ -127,11 +130,13 @@ var x3: IWithNoNumberIndexSignature | IWithNumberIndexSignature1 = { 0: "hello" >x3 : Symbol(x3, Decl(contextualTypeWithUnionTypeIndexSignatures.ts, 49, 3), Decl(contextualTypeWithUnionTypeIndexSignatures.ts, 50, 3), Decl(contextualTypeWithUnionTypeIndexSignatures.ts, 51, 3)) >IWithNoNumberIndexSignature : Symbol(IWithNoNumberIndexSignature, Decl(contextualTypeWithUnionTypeIndexSignatures.ts, 11, 1)) >IWithNumberIndexSignature1 : Symbol(IWithNumberIndexSignature1, Decl(contextualTypeWithUnionTypeIndexSignatures.ts, 20, 1)) +>0 : Symbol(0, Decl(contextualTypeWithUnionTypeIndexSignatures.ts, 51, 68)) var x4: IWithNumberIndexSignature1 | IWithNumberIndexSignature2 = { 1: a => a.toString() }; // a should be number >x4 : Symbol(x4, Decl(contextualTypeWithUnionTypeIndexSignatures.ts, 52, 3), Decl(contextualTypeWithUnionTypeIndexSignatures.ts, 53, 3)) >IWithNumberIndexSignature1 : Symbol(IWithNumberIndexSignature1, Decl(contextualTypeWithUnionTypeIndexSignatures.ts, 20, 1)) >IWithNumberIndexSignature2 : Symbol(IWithNumberIndexSignature2, Decl(contextualTypeWithUnionTypeIndexSignatures.ts, 23, 1)) +>1 : Symbol(1, Decl(contextualTypeWithUnionTypeIndexSignatures.ts, 52, 67)) >a : Symbol(a, Decl(contextualTypeWithUnionTypeIndexSignatures.ts, 52, 70)) >a.toString : Symbol(Number.toString, Decl(lib.d.ts, --, --)) >a : Symbol(a, Decl(contextualTypeWithUnionTypeIndexSignatures.ts, 52, 70)) @@ -141,6 +146,7 @@ var x4: IWithNumberIndexSignature1 | IWithNumberIndexSignature2 = { 1: a => a }; >x4 : Symbol(x4, Decl(contextualTypeWithUnionTypeIndexSignatures.ts, 52, 3), Decl(contextualTypeWithUnionTypeIndexSignatures.ts, 53, 3)) >IWithNumberIndexSignature1 : Symbol(IWithNumberIndexSignature1, Decl(contextualTypeWithUnionTypeIndexSignatures.ts, 20, 1)) >IWithNumberIndexSignature2 : Symbol(IWithNumberIndexSignature2, Decl(contextualTypeWithUnionTypeIndexSignatures.ts, 23, 1)) +>1 : Symbol(1, Decl(contextualTypeWithUnionTypeIndexSignatures.ts, 53, 67)) >a : Symbol(a, Decl(contextualTypeWithUnionTypeIndexSignatures.ts, 53, 70)) >a : Symbol(a, Decl(contextualTypeWithUnionTypeIndexSignatures.ts, 53, 70)) diff --git a/tests/baselines/reference/contextualTypeWithUnionTypeIndexSignatures.types b/tests/baselines/reference/contextualTypeWithUnionTypeIndexSignatures.types index 97c5f0fdf90..c44afae7cd5 100644 --- a/tests/baselines/reference/contextualTypeWithUnionTypeIndexSignatures.types +++ b/tests/baselines/reference/contextualTypeWithUnionTypeIndexSignatures.types @@ -24,6 +24,7 @@ interface IWithNoNumberIndexSignature { >IWithNoNumberIndexSignature : IWithNoNumberIndexSignature 0: string; +>0 : string } interface IWithStringIndexSignature1 { >IWithStringIndexSignature1 : IWithStringIndexSignature1 @@ -125,6 +126,7 @@ var x3: IWithNoNumberIndexSignature | IWithNumberIndexSignature1 = { 1: a => a } >IWithNoNumberIndexSignature : IWithNoNumberIndexSignature >IWithNumberIndexSignature1 : IWithNumberIndexSignature1 >{ 1: a => a } : { 1: (a: number) => number; } +>1 : (a: number) => number >a => a : (a: number) => number >a : number >a : number @@ -134,6 +136,7 @@ var x3: IWithNoNumberIndexSignature | IWithNumberIndexSignature1 = { 0: a => a } >IWithNoNumberIndexSignature : IWithNoNumberIndexSignature >IWithNumberIndexSignature1 : IWithNumberIndexSignature1 >{ 0: a => a } : { 0: (a: any) => any; } +>0 : (a: any) => any >a => a : (a: any) => any >a : any >a : any @@ -143,6 +146,7 @@ var x3: IWithNoNumberIndexSignature | IWithNumberIndexSignature1 = { 0: "hello" >IWithNoNumberIndexSignature : IWithNoNumberIndexSignature >IWithNumberIndexSignature1 : IWithNumberIndexSignature1 >{ 0: "hello" } : { 0: string; } +>0 : string >"hello" : "hello" var x4: IWithNumberIndexSignature1 | IWithNumberIndexSignature2 = { 1: a => a.toString() }; // a should be number @@ -150,6 +154,7 @@ var x4: IWithNumberIndexSignature1 | IWithNumberIndexSignature2 = { 1: a => a.to >IWithNumberIndexSignature1 : IWithNumberIndexSignature1 >IWithNumberIndexSignature2 : IWithNumberIndexSignature2 >{ 1: a => a.toString() } : { 1: (a: number) => string; } +>1 : (a: number) => string >a => a.toString() : (a: number) => string >a : number >a.toString() : string @@ -162,6 +167,7 @@ var x4: IWithNumberIndexSignature1 | IWithNumberIndexSignature2 = { 1: a => a }; >IWithNumberIndexSignature1 : IWithNumberIndexSignature1 >IWithNumberIndexSignature2 : IWithNumberIndexSignature2 >{ 1: a => a } : { 1: (a: number) => number; } +>1 : (a: number) => number >a => a : (a: number) => number >a : number >a : number diff --git a/tests/baselines/reference/convertKeywordsYes.symbols b/tests/baselines/reference/convertKeywordsYes.symbols index 8049c747efb..27e5774b1f7 100644 --- a/tests/baselines/reference/convertKeywordsYes.symbols +++ b/tests/baselines/reference/convertKeywordsYes.symbols @@ -505,6 +505,8 @@ class bigClass { >bigClass : Symbol(bigClass, Decl(convertKeywordsYes.ts, 171, 1)) public "constructor" = 0; +>"constructor" : Symbol(bigClass["constructor"], Decl(convertKeywordsYes.ts, 173, 16)) + public any = 0; >any : Symbol(bigClass.any, Decl(convertKeywordsYes.ts, 174, 29)) diff --git a/tests/baselines/reference/convertKeywordsYes.types b/tests/baselines/reference/convertKeywordsYes.types index 3ed4f9ae903..b7b3989df4e 100644 --- a/tests/baselines/reference/convertKeywordsYes.types +++ b/tests/baselines/reference/convertKeywordsYes.types @@ -578,6 +578,7 @@ class bigClass { >bigClass : bigClass public "constructor" = 0; +>"constructor" : number >0 : 0 public any = 0; diff --git a/tests/baselines/reference/correctlyMarkAliasAsReferences1.symbols b/tests/baselines/reference/correctlyMarkAliasAsReferences1.symbols index b0338f1c803..f8a1dfe2ef4 100644 --- a/tests/baselines/reference/correctlyMarkAliasAsReferences1.symbols +++ b/tests/baselines/reference/correctlyMarkAliasAsReferences1.symbols @@ -25,5 +25,5 @@ let k = ; ->button : Symbol(unknown) ->button : Symbol(unknown) } } diff --git a/tests/baselines/reference/tsxExternalModuleEmit1.types b/tests/baselines/reference/tsxExternalModuleEmit1.types index 7045cd739c1..fa22a5ec49f 100644 --- a/tests/baselines/reference/tsxExternalModuleEmit1.types +++ b/tests/baselines/reference/tsxExternalModuleEmit1.types @@ -1,5 +1,7 @@ === tests/cases/conformance/jsx/react.d.ts === declare module 'react' { +>'react' : typeof 'react' + class Component { } >Component : Component >T : T diff --git a/tests/baselines/reference/tsxExternalModuleEmit2.symbols b/tests/baselines/reference/tsxExternalModuleEmit2.symbols index 20ae94fb668..5d3a586ee42 100644 --- a/tests/baselines/reference/tsxExternalModuleEmit2.symbols +++ b/tests/baselines/reference/tsxExternalModuleEmit2.symbols @@ -1,5 +1,7 @@ === tests/cases/conformance/jsx/modules.d.ts === declare module 'mod' { +>'mod' : Symbol('mod', Decl(modules.d.ts, 0, 0)) + var y: any; >y : Symbol(y, Decl(modules.d.ts, 1, 5)) diff --git a/tests/baselines/reference/tsxExternalModuleEmit2.types b/tests/baselines/reference/tsxExternalModuleEmit2.types index bb858cdf0c1..5d397b517af 100644 --- a/tests/baselines/reference/tsxExternalModuleEmit2.types +++ b/tests/baselines/reference/tsxExternalModuleEmit2.types @@ -1,5 +1,7 @@ === tests/cases/conformance/jsx/modules.d.ts === declare module 'mod' { +>'mod' : typeof 'mod' + var y: any; >y : any diff --git a/tests/baselines/reference/tsxInferenceShouldNotYieldAnyOnUnions.symbols b/tests/baselines/reference/tsxInferenceShouldNotYieldAnyOnUnions.symbols index b6163a36df6..37580994a15 100644 --- a/tests/baselines/reference/tsxInferenceShouldNotYieldAnyOnUnions.symbols +++ b/tests/baselines/reference/tsxInferenceShouldNotYieldAnyOnUnions.symbols @@ -44,7 +44,6 @@ function ShouldInferFromData(props: Props): JSX.Element { >Element : Symbol(JSX.Element, Decl(index.tsx, 0, 15)) return
; ->div : Symbol(unknown) } // Sanity check: function call equivalent versions work fine diff --git a/tests/baselines/reference/tsxNoJsx.symbols b/tests/baselines/reference/tsxNoJsx.symbols index 2bf187c99cd..65a397961e7 100644 --- a/tests/baselines/reference/tsxNoJsx.symbols +++ b/tests/baselines/reference/tsxNoJsx.symbols @@ -1,4 +1,4 @@ === tests/cases/conformance/jsx/tsxNoJsx.tsx === ; ->nope : Symbol(unknown) - +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/tsxPreserveEmit1.symbols b/tests/baselines/reference/tsxPreserveEmit1.symbols index d477dcc3d3c..98ffd3282d5 100644 --- a/tests/baselines/reference/tsxPreserveEmit1.symbols +++ b/tests/baselines/reference/tsxPreserveEmit1.symbols @@ -33,6 +33,8 @@ module M { === tests/cases/conformance/jsx/react.d.ts === declare module 'react' { +>'react' : Symbol('react', Decl(react.d.ts, 0, 0)) + var x: any; >x : Symbol(x, Decl(react.d.ts, 1, 4)) @@ -50,6 +52,8 @@ declare module ReactRouter { >Thing : Symbol(Thing, Decl(react.d.ts, 6, 16)) } declare module 'react-router' { +>'react-router' : Symbol('react-router', Decl(react.d.ts, 8, 1)) + export = ReactRouter; >ReactRouter : Symbol(ReactRouter, Decl(react.d.ts, 3, 1)) } diff --git a/tests/baselines/reference/tsxPreserveEmit1.types b/tests/baselines/reference/tsxPreserveEmit1.types index 099a184b322..a5a7a0efaca 100644 --- a/tests/baselines/reference/tsxPreserveEmit1.types +++ b/tests/baselines/reference/tsxPreserveEmit1.types @@ -35,6 +35,8 @@ module M { === tests/cases/conformance/jsx/react.d.ts === declare module 'react' { +>'react' : typeof 'react' + var x: any; >x : any @@ -52,6 +54,8 @@ declare module ReactRouter { >Thing : Thing } declare module 'react-router' { +>'react-router' : typeof 'react-router' + export = ReactRouter; >ReactRouter : typeof ReactRouter } diff --git a/tests/baselines/reference/tsxReactEmitNesting.symbols b/tests/baselines/reference/tsxReactEmitNesting.symbols index 9972436ac73..e6d19f3ea62 100644 --- a/tests/baselines/reference/tsxReactEmitNesting.symbols +++ b/tests/baselines/reference/tsxReactEmitNesting.symbols @@ -15,19 +15,13 @@ let render = (ctrl, model) => >model : Symbol(model, Decl(file.tsx, 5, 19))
->section : Symbol(unknown) >class : Symbol(class, Decl(file.tsx, 6, 12))
->header : Symbol(unknown) >class : Symbol(class, Decl(file.tsx, 7, 15))

todos <x>

->h1 : Symbol(unknown) ->h1 : Symbol(unknown) - ->input : Symbol(unknown) >class : Symbol(class, Decl(file.tsx, 9, 18)) >autofocus : Symbol(autofocus, Decl(file.tsx, 9, 35)) >autocomplete : Symbol(autocomplete, Decl(file.tsx, 9, 45)) @@ -40,10 +34,7 @@ let render = (ctrl, model) => >model : Symbol(model, Decl(file.tsx, 5, 19))
->header : Symbol(unknown) -
->section : Symbol(unknown) >class : Symbol(class, Decl(file.tsx, 11, 16)) >style : Symbol(style, Decl(file.tsx, 11, 29)) >display : Symbol(display, Decl(file.tsx, 11, 38)) @@ -51,7 +42,6 @@ let render = (ctrl, model) => >model : Symbol(model, Decl(file.tsx, 5, 19)) ->input : Symbol(unknown) >class : Symbol(class, Decl(file.tsx, 12, 18)) >type : Symbol(type, Decl(file.tsx, 12, 37)) >onChange : Symbol(onChange, Decl(file.tsx, 12, 53)) @@ -59,7 +49,6 @@ let render = (ctrl, model) => >ctrl : Symbol(ctrl, Decl(file.tsx, 5, 14))
    ->ul : Symbol(unknown) >class : Symbol(class, Decl(file.tsx, 13, 15)) {model.filteredTodos.map((todo) => @@ -67,7 +56,6 @@ let render = (ctrl, model) => >todo : Symbol(todo, Decl(file.tsx, 14, 42))
  • ->li : Symbol(unknown) >class : Symbol(class, Decl(file.tsx, 15, 23)) >todo : Symbol(todo, Decl(file.tsx, 15, 32)) >completed : Symbol(completed, Decl(file.tsx, 15, 43)) @@ -77,62 +65,42 @@ let render = (ctrl, model) => >model : Symbol(model, Decl(file.tsx, 5, 19))
    ->div : Symbol(unknown) >class : Symbol(class, Decl(file.tsx, 16, 28)) {(!todo.editable) ? >todo : Symbol(todo, Decl(file.tsx, 14, 42)) ->input : Symbol(unknown) >class : Symbol(class, Decl(file.tsx, 18, 38)) >type : Symbol(type, Decl(file.tsx, 18, 53)) ->input : Symbol(unknown) : null } ->label : Symbol(unknown) >onDoubleClick : Symbol(onDoubleClick, Decl(file.tsx, 21, 34)) >ctrl : Symbol(ctrl, Decl(file.tsx, 5, 14)) >todo : Symbol(todo, Decl(file.tsx, 14, 42)) >todo : Symbol(todo, Decl(file.tsx, 14, 42)) ->label : Symbol(unknown) ->button : Symbol(unknown) >class : Symbol(class, Decl(file.tsx, 22, 35)) >onClick : Symbol(onClick, Decl(file.tsx, 22, 51)) >ctrl : Symbol(ctrl, Decl(file.tsx, 5, 14)) >ctrl : Symbol(ctrl, Decl(file.tsx, 5, 14)) >todo : Symbol(todo, Decl(file.tsx, 14, 42)) ->button : Symbol(unknown)
    ->div : Symbol(unknown) >class : Symbol(class, Decl(file.tsx, 23, 32))
    ->div : Symbol(unknown) >class : Symbol(class, Decl(file.tsx, 24, 36))
    ->div : Symbol(unknown) -
    ->div : Symbol(unknown) -
  • ->li : Symbol(unknown) - )}
->ul : Symbol(unknown) -
->section : Symbol(unknown) -
->section : Symbol(unknown) diff --git a/tests/baselines/reference/tsxSpreadAttributesResolution17.symbols b/tests/baselines/reference/tsxSpreadAttributesResolution17.symbols index 6f346ccdcb1..96dfe32abb0 100644 --- a/tests/baselines/reference/tsxSpreadAttributesResolution17.symbols +++ b/tests/baselines/reference/tsxSpreadAttributesResolution17.symbols @@ -24,8 +24,6 @@ export class Empty extends React.Component<{}, {}> { >render : Symbol(Empty.render, Decl(file.tsx, 8, 52)) return
Hello
; ->div : Symbol(unknown) ->div : Symbol(unknown) } } diff --git a/tests/baselines/reference/tsxSpreadAttributesResolution4.symbols b/tests/baselines/reference/tsxSpreadAttributesResolution4.symbols index ccf2e68d4f1..e599665b156 100644 --- a/tests/baselines/reference/tsxSpreadAttributesResolution4.symbols +++ b/tests/baselines/reference/tsxSpreadAttributesResolution4.symbols @@ -89,4 +89,5 @@ let e4 = let e5 = >e5 : Symbol(e5, Decl(file.tsx, 33, 3)) >EmptyProp : Symbol(EmptyProp, Decl(file.tsx, 19, 30)) +>"data-prop" : Symbol("data-prop", Decl(file.tsx, 33, 25)) diff --git a/tests/baselines/reference/tsxSpreadAttributesResolution4.types b/tests/baselines/reference/tsxSpreadAttributesResolution4.types index 532e7828df9..ee5dd48aed2 100644 --- a/tests/baselines/reference/tsxSpreadAttributesResolution4.types +++ b/tests/baselines/reference/tsxSpreadAttributesResolution4.types @@ -108,5 +108,6 @@ let e5 = > : JSX.Element >EmptyProp : typeof EmptyProp >{ "data-prop": true} : { "data-prop": boolean; } +>"data-prop" : boolean >true : true diff --git a/tests/baselines/reference/tsxStatelessFunctionComponentOverload1.symbols b/tests/baselines/reference/tsxStatelessFunctionComponentOverload1.symbols index 6946c2b3279..ca25cba4f49 100644 --- a/tests/baselines/reference/tsxStatelessFunctionComponentOverload1.symbols +++ b/tests/baselines/reference/tsxStatelessFunctionComponentOverload1.symbols @@ -38,6 +38,7 @@ declare function OneThing(l1: {data: string, "data-prop": boolean}): JSX.Element >OneThing : Symbol(OneThing, Decl(file.tsx, 0, 31), Decl(file.tsx, 2, 57), Decl(file.tsx, 3, 76), Decl(file.tsx, 4, 69), Decl(file.tsx, 5, 83)) >l1 : Symbol(l1, Decl(file.tsx, 6, 26)) >data : Symbol(data, Decl(file.tsx, 6, 31)) +>"data-prop" : Symbol("data-prop", Decl(file.tsx, 6, 44)) >JSX : Symbol(JSX, Decl(react.d.ts, 2353, 1)) >Element : Symbol(JSX.Element, Decl(react.d.ts, 2356, 27)) @@ -82,6 +83,7 @@ declare function TestingOneThing({y1: string}): JSX.Element; declare function TestingOneThing(j: {"extra-data": string, yy?: string}): JSX.Element; >TestingOneThing : Symbol(TestingOneThing, Decl(file.tsx, 13, 47), Decl(file.tsx, 16, 60), Decl(file.tsx, 17, 86), Decl(file.tsx, 18, 83)) >j : Symbol(j, Decl(file.tsx, 17, 33)) +>"extra-data" : Symbol("extra-data", Decl(file.tsx, 17, 37)) >yy : Symbol(yy, Decl(file.tsx, 17, 58)) >JSX : Symbol(JSX, Decl(react.d.ts, 2353, 1)) >Element : Symbol(JSX.Element, Decl(react.d.ts, 2356, 27)) diff --git a/tests/baselines/reference/tsxStatelessFunctionComponentOverload1.types b/tests/baselines/reference/tsxStatelessFunctionComponentOverload1.types index cb1908845dd..ec16b6134ee 100644 --- a/tests/baselines/reference/tsxStatelessFunctionComponentOverload1.types +++ b/tests/baselines/reference/tsxStatelessFunctionComponentOverload1.types @@ -38,6 +38,7 @@ declare function OneThing(l1: {data: string, "data-prop": boolean}): JSX.Element >OneThing : { (k: { yxx: string; }): JSX.Element; (k: { yxx1: string; children: string; }): JSX.Element; (l: { yy: number; yy1: string; }): JSX.Element; (l: { yy: number; yy1: string; yy2: boolean; }): JSX.Element; (l1: { data: string; "data-prop": boolean; }): JSX.Element; } >l1 : { data: string; "data-prop": boolean; } >data : string +>"data-prop" : boolean >JSX : any >Element : JSX.Element @@ -88,6 +89,7 @@ declare function TestingOneThing({y1: string}): JSX.Element; declare function TestingOneThing(j: {"extra-data": string, yy?: string}): JSX.Element; >TestingOneThing : { ({ y1: string }: { y1: any; }): JSX.Element; (j: { "extra-data": string; yy?: string; }): JSX.Element; (n: { yy: number; direction?: number; }): JSX.Element; (n: { yy: string; name: string; }): JSX.Element; } >j : { "extra-data": string; yy?: string; } +>"extra-data" : string >yy : string >JSX : any >Element : JSX.Element diff --git a/tests/baselines/reference/tsxStatelessFunctionComponentOverload2.symbols b/tests/baselines/reference/tsxStatelessFunctionComponentOverload2.symbols index ed613618411..68dff707c9f 100644 --- a/tests/baselines/reference/tsxStatelessFunctionComponentOverload2.symbols +++ b/tests/baselines/reference/tsxStatelessFunctionComponentOverload2.symbols @@ -39,6 +39,7 @@ let obj2 = { >yy : Symbol(yy, Decl(file.tsx, 13, 12)) "ignore-prop": "hello" +>"ignore-prop" : Symbol("ignore-prop", Decl(file.tsx, 14, 12)) } let defaultObj: any; @@ -93,6 +94,7 @@ const c8 = const c9 = ; >c9 : Symbol(c9, Decl(file.tsx, 29, 5)) >OneThing : Symbol(OneThing, Decl(file.tsx, 0, 31), Decl(file.tsx, 1, 41)) +>"ignore-prop" : Symbol("ignore-prop", Decl(file.tsx, 29, 26)) const c10 = ; >c10 : Symbol(c10, Decl(file.tsx, 30, 5)) diff --git a/tests/baselines/reference/tsxStatelessFunctionComponentOverload2.types b/tests/baselines/reference/tsxStatelessFunctionComponentOverload2.types index d1cc5774447..5374e8c8e5b 100644 --- a/tests/baselines/reference/tsxStatelessFunctionComponentOverload2.types +++ b/tests/baselines/reference/tsxStatelessFunctionComponentOverload2.types @@ -46,6 +46,7 @@ let obj2 = { >500 : 500 "ignore-prop": "hello" +>"ignore-prop" : string >"hello" : "hello" } @@ -119,6 +120,7 @@ const c9 = ; > : JSX.Element >OneThing : { (): JSX.Element; (l: { yy: number; yy1: string; }): JSX.Element; } >{ "ignore-prop":200 } : { "ignore-prop": number; } +>"ignore-prop" : number >200 : 200 const c10 = ; diff --git a/tests/baselines/reference/tsxStatelessFunctionComponentOverload4.symbols b/tests/baselines/reference/tsxStatelessFunctionComponentOverload4.symbols index 7316de2dcc9..950ff21be00 100644 --- a/tests/baselines/reference/tsxStatelessFunctionComponentOverload4.symbols +++ b/tests/baselines/reference/tsxStatelessFunctionComponentOverload4.symbols @@ -77,6 +77,7 @@ const c7 = ; // Should error as there is extra attribu declare function TestingOneThing(j: {"extra-data": string}): JSX.Element; >TestingOneThing : Symbol(TestingOneThing, Decl(file.tsx, 18, 37), Decl(file.tsx, 20, 73)) >j : Symbol(j, Decl(file.tsx, 20, 33)) +>"extra-data" : Symbol("extra-data", Decl(file.tsx, 20, 37)) >JSX : Symbol(JSX, Decl(react.d.ts, 2353, 1)) >Element : Symbol(JSX.Element, Decl(react.d.ts, 2356, 27)) diff --git a/tests/baselines/reference/tsxStatelessFunctionComponentOverload4.types b/tests/baselines/reference/tsxStatelessFunctionComponentOverload4.types index fe265c5c4d0..b1d5b59323e 100644 --- a/tests/baselines/reference/tsxStatelessFunctionComponentOverload4.types +++ b/tests/baselines/reference/tsxStatelessFunctionComponentOverload4.types @@ -96,6 +96,7 @@ const c7 = ; // Should error as there is extra attribu declare function TestingOneThing(j: {"extra-data": string}): JSX.Element; >TestingOneThing : { (j: { "extra-data": string; }): JSX.Element; (n: { yy: string; direction?: number; }): JSX.Element; } >j : { "extra-data": string; } +>"extra-data" : string >JSX : any >Element : JSX.Element diff --git a/tests/baselines/reference/tsxStatelessFunctionComponentOverload5.symbols b/tests/baselines/reference/tsxStatelessFunctionComponentOverload5.symbols index df26fe0bea6..acec753b783 100644 --- a/tests/baselines/reference/tsxStatelessFunctionComponentOverload5.symbols +++ b/tests/baselines/reference/tsxStatelessFunctionComponentOverload5.symbols @@ -35,6 +35,7 @@ export interface HyphenProps extends ClickableProps { >ClickableProps : Symbol(ClickableProps, Decl(file.tsx, 0, 31)) "data-format": string; +>"data-format" : Symbol(HyphenProps["data-format"], Decl(file.tsx, 15, 53)) } let obj0 = { diff --git a/tests/baselines/reference/tsxStatelessFunctionComponentOverload5.types b/tests/baselines/reference/tsxStatelessFunctionComponentOverload5.types index b60a5a2d3f0..2e14ff745cb 100644 --- a/tests/baselines/reference/tsxStatelessFunctionComponentOverload5.types +++ b/tests/baselines/reference/tsxStatelessFunctionComponentOverload5.types @@ -35,6 +35,7 @@ export interface HyphenProps extends ClickableProps { >ClickableProps : ClickableProps "data-format": string; +>"data-format" : string } let obj0 = { diff --git a/tests/baselines/reference/tsxStatelessFunctionComponentOverload6.symbols b/tests/baselines/reference/tsxStatelessFunctionComponentOverload6.symbols index cc3cb199309..fa961797460 100644 --- a/tests/baselines/reference/tsxStatelessFunctionComponentOverload6.symbols +++ b/tests/baselines/reference/tsxStatelessFunctionComponentOverload6.symbols @@ -35,6 +35,7 @@ export interface HyphenProps extends ClickableProps { >ClickableProps : Symbol(ClickableProps, Decl(file.tsx, 0, 31)) "data-format": string; +>"data-format" : Symbol(HyphenProps["data-format"], Decl(file.tsx, 15, 53)) } let obj = { diff --git a/tests/baselines/reference/tsxStatelessFunctionComponentOverload6.types b/tests/baselines/reference/tsxStatelessFunctionComponentOverload6.types index 6f7f04e3cf3..df77ce5558e 100644 --- a/tests/baselines/reference/tsxStatelessFunctionComponentOverload6.types +++ b/tests/baselines/reference/tsxStatelessFunctionComponentOverload6.types @@ -35,6 +35,7 @@ export interface HyphenProps extends ClickableProps { >ClickableProps : ClickableProps "data-format": string; +>"data-format" : string } let obj = { diff --git a/tests/baselines/reference/tsxStatelessFunctionComponents1.symbols b/tests/baselines/reference/tsxStatelessFunctionComponents1.symbols index 7350fda3e76..28105943860 100644 --- a/tests/baselines/reference/tsxStatelessFunctionComponents1.symbols +++ b/tests/baselines/reference/tsxStatelessFunctionComponents1.symbols @@ -29,6 +29,7 @@ function Meet({name = 'world'}) { function MeetAndGreet(k: {"prop-name": string}) { >MeetAndGreet : Symbol(MeetAndGreet, Decl(file.tsx, 9, 1)) >k : Symbol(k, Decl(file.tsx, 10, 22)) +>"prop-name" : Symbol("prop-name", Decl(file.tsx, 10, 26)) return
Hi Hi
; >div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) @@ -144,5 +145,6 @@ let j3 = let j4 = >j4 : Symbol(j4, Decl(file.tsx, 52, 3)) >EmptyPropSFC : Symbol(EmptyPropSFC, Decl(file.tsx, 0, 0)) +>"data-info" : Symbol("data-info", Decl(file.tsx, 52, 28)) diff --git a/tests/baselines/reference/tsxStatelessFunctionComponents1.types b/tests/baselines/reference/tsxStatelessFunctionComponents1.types index ffd52cb4978..08e29302480 100644 --- a/tests/baselines/reference/tsxStatelessFunctionComponents1.types +++ b/tests/baselines/reference/tsxStatelessFunctionComponents1.types @@ -33,6 +33,7 @@ function Meet({name = 'world'}) { function MeetAndGreet(k: {"prop-name": string}) { >MeetAndGreet : (k: { "prop-name": string; }) => JSX.Element >k : { "prop-name": string; } +>"prop-name" : string return
Hi Hi
; >
Hi Hi
: JSX.Element @@ -179,6 +180,7 @@ let j4 = > : JSX.Element >EmptyPropSFC : () => JSX.Element >{ "data-info": "hi"} : { "data-info": string; } +>"data-info" : string >"hi" : "hi" diff --git a/tests/baselines/reference/tsxStatelessFunctionComponentsWithTypeArguments2.symbols b/tests/baselines/reference/tsxStatelessFunctionComponentsWithTypeArguments2.symbols index 66660e4d205..72aebfd2e4c 100644 --- a/tests/baselines/reference/tsxStatelessFunctionComponentsWithTypeArguments2.symbols +++ b/tests/baselines/reference/tsxStatelessFunctionComponentsWithTypeArguments2.symbols @@ -8,6 +8,7 @@ declare function ComponentSpecific1(l: {prop: U, "ignore-prop": string}): JSX >l : Symbol(l, Decl(file.tsx, 2, 39)) >prop : Symbol(prop, Decl(file.tsx, 2, 43)) >U : Symbol(U, Decl(file.tsx, 2, 36)) +>"ignore-prop" : Symbol("ignore-prop", Decl(file.tsx, 2, 51)) >JSX : Symbol(JSX, Decl(react.d.ts, 2353, 1)) >Element : Symbol(JSX.Element, Decl(react.d.ts, 2356, 27)) diff --git a/tests/baselines/reference/tsxStatelessFunctionComponentsWithTypeArguments2.types b/tests/baselines/reference/tsxStatelessFunctionComponentsWithTypeArguments2.types index 851839ea921..2c2b4d3bd5f 100644 --- a/tests/baselines/reference/tsxStatelessFunctionComponentsWithTypeArguments2.types +++ b/tests/baselines/reference/tsxStatelessFunctionComponentsWithTypeArguments2.types @@ -8,6 +8,7 @@ declare function ComponentSpecific1(l: {prop: U, "ignore-prop": string}): JSX >l : { prop: U; "ignore-prop": string; } >prop : U >U : U +>"ignore-prop" : string >JSX : any >Element : JSX.Element diff --git a/tests/baselines/reference/tsxStatelessFunctionComponentsWithTypeArguments3.symbols b/tests/baselines/reference/tsxStatelessFunctionComponentsWithTypeArguments3.symbols index b0823c19d67..42f2ce9792e 100644 --- a/tests/baselines/reference/tsxStatelessFunctionComponentsWithTypeArguments3.symbols +++ b/tests/baselines/reference/tsxStatelessFunctionComponentsWithTypeArguments3.symbols @@ -15,6 +15,7 @@ declare function OverloadComponent(attr: {b: U, a?: string, "ignore-prop": bo >b : Symbol(b, Decl(file.tsx, 3, 45)) >U : Symbol(U, Decl(file.tsx, 3, 35)) >a : Symbol(a, Decl(file.tsx, 3, 50)) +>"ignore-prop" : Symbol("ignore-prop", Decl(file.tsx, 3, 62)) >JSX : Symbol(JSX, Decl(react.d.ts, 2353, 1)) >Element : Symbol(JSX.Element, Decl(react.d.ts, 2356, 27)) diff --git a/tests/baselines/reference/tsxStatelessFunctionComponentsWithTypeArguments3.types b/tests/baselines/reference/tsxStatelessFunctionComponentsWithTypeArguments3.types index 32f483227d3..7d767208772 100644 --- a/tests/baselines/reference/tsxStatelessFunctionComponentsWithTypeArguments3.types +++ b/tests/baselines/reference/tsxStatelessFunctionComponentsWithTypeArguments3.types @@ -15,6 +15,7 @@ declare function OverloadComponent(attr: {b: U, a?: string, "ignore-prop": bo >b : U >U : U >a : string +>"ignore-prop" : boolean >JSX : any >Element : JSX.Element diff --git a/tests/baselines/reference/tsxStatelessFunctionComponentsWithTypeArguments4.symbols b/tests/baselines/reference/tsxStatelessFunctionComponentsWithTypeArguments4.symbols index 6011e091c52..5dc9a40fd6c 100644 --- a/tests/baselines/reference/tsxStatelessFunctionComponentsWithTypeArguments4.symbols +++ b/tests/baselines/reference/tsxStatelessFunctionComponentsWithTypeArguments4.symbols @@ -15,6 +15,7 @@ declare function OverloadComponent(attr: {b: U, a: string, "ignore-prop": boo >b : Symbol(b, Decl(file.tsx, 3, 45)) >U : Symbol(U, Decl(file.tsx, 3, 35)) >a : Symbol(a, Decl(file.tsx, 3, 50)) +>"ignore-prop" : Symbol("ignore-prop", Decl(file.tsx, 3, 61)) >JSX : Symbol(JSX, Decl(react.d.ts, 2353, 1)) >Element : Symbol(JSX.Element, Decl(react.d.ts, 2356, 27)) diff --git a/tests/baselines/reference/tsxStatelessFunctionComponentsWithTypeArguments4.types b/tests/baselines/reference/tsxStatelessFunctionComponentsWithTypeArguments4.types index 310450045db..2c31f2afde2 100644 --- a/tests/baselines/reference/tsxStatelessFunctionComponentsWithTypeArguments4.types +++ b/tests/baselines/reference/tsxStatelessFunctionComponentsWithTypeArguments4.types @@ -15,6 +15,7 @@ declare function OverloadComponent(attr: {b: U, a: string, "ignore-prop": boo >b : U >U : U >a : string +>"ignore-prop" : boolean >JSX : any >Element : JSX.Element diff --git a/tests/baselines/reference/tsxStatelessFunctionComponentsWithTypeArguments5.symbols b/tests/baselines/reference/tsxStatelessFunctionComponentsWithTypeArguments5.symbols index d6aa17e5109..20ca8dc4e03 100644 --- a/tests/baselines/reference/tsxStatelessFunctionComponentsWithTypeArguments5.symbols +++ b/tests/baselines/reference/tsxStatelessFunctionComponentsWithTypeArguments5.symbols @@ -44,6 +44,7 @@ declare function ComponentSpecific1(l: { prop: U, "ignore-prop": number }): J >l : Symbol(l, Decl(file.tsx, 9, 39)) >prop : Symbol(prop, Decl(file.tsx, 9, 43)) >U : Symbol(U, Decl(file.tsx, 9, 36)) +>"ignore-prop" : Symbol("ignore-prop", Decl(file.tsx, 9, 52)) >JSX : Symbol(JSX, Decl(react.d.ts, 2353, 1)) >Element : Symbol(JSX.Element, Decl(react.d.ts, 2356, 27)) diff --git a/tests/baselines/reference/tsxStatelessFunctionComponentsWithTypeArguments5.types b/tests/baselines/reference/tsxStatelessFunctionComponentsWithTypeArguments5.types index 98a9c621797..99d760bb7a5 100644 --- a/tests/baselines/reference/tsxStatelessFunctionComponentsWithTypeArguments5.types +++ b/tests/baselines/reference/tsxStatelessFunctionComponentsWithTypeArguments5.types @@ -46,6 +46,7 @@ declare function ComponentSpecific1(l: { prop: U, "ignore-prop": number }): J >l : { prop: U; "ignore-prop": number; } >prop : U >U : U +>"ignore-prop" : number >JSX : any >Element : JSX.Element diff --git a/tests/baselines/reference/tsxTypeErrors.symbols b/tests/baselines/reference/tsxTypeErrors.symbols index f40faf52b19..a58529c5258 100644 --- a/tests/baselines/reference/tsxTypeErrors.symbols +++ b/tests/baselines/reference/tsxTypeErrors.symbols @@ -2,13 +2,11 @@ // A built-in element (OK) var a1 =
; >a1 : Symbol(a1, Decl(tsxTypeErrors.tsx, 1, 3)) ->div : Symbol(unknown) >id : Symbol(id, Decl(tsxTypeErrors.tsx, 1, 13)) // A built-in element with a mistyped property (error) var a2 = >a2 : Symbol(a2, Decl(tsxTypeErrors.tsx, 4, 3)) ->img : Symbol(unknown) >srce : Symbol(srce, Decl(tsxTypeErrors.tsx, 4, 13)) // A built-in element with a badly-typed attribute value (error) @@ -18,14 +16,12 @@ var thing = { oops: 100 }; var a3 =
>a3 : Symbol(a3, Decl(tsxTypeErrors.tsx, 8, 3)) ->div : Symbol(unknown) >id : Symbol(id, Decl(tsxTypeErrors.tsx, 8, 13)) >thing : Symbol(thing, Decl(tsxTypeErrors.tsx, 7, 3)) // Mistyped html name (error) var e1 = >e1 : Symbol(e1, Decl(tsxTypeErrors.tsx, 11, 3)) ->imag : Symbol(unknown) >src : Symbol(src, Decl(tsxTypeErrors.tsx, 11, 14)) // A custom type diff --git a/tests/baselines/reference/typeAliasExport.symbols b/tests/baselines/reference/typeAliasExport.symbols index 5ffe181ca70..7b880e41b72 100644 --- a/tests/baselines/reference/typeAliasExport.symbols +++ b/tests/baselines/reference/typeAliasExport.symbols @@ -1,5 +1,7 @@ === tests/cases/compiler/typeAliasExport.ts === declare module "a" { +>"a" : Symbol("a", Decl(typeAliasExport.ts, 0, 0)) + export default undefined >undefined : Symbol(undefined) diff --git a/tests/baselines/reference/typeAliasExport.types b/tests/baselines/reference/typeAliasExport.types index e9a7b92c3e7..5cbea867ad3 100644 --- a/tests/baselines/reference/typeAliasExport.types +++ b/tests/baselines/reference/typeAliasExport.types @@ -1,5 +1,7 @@ === tests/cases/compiler/typeAliasExport.ts === declare module "a" { +>"a" : typeof "a" + export default undefined >undefined : undefined diff --git a/tests/baselines/reference/typeAnnotationBestCommonTypeInArrayLiteral.symbols b/tests/baselines/reference/typeAnnotationBestCommonTypeInArrayLiteral.symbols index 1e7604b44e7..0edef5db04b 100644 --- a/tests/baselines/reference/typeAnnotationBestCommonTypeInArrayLiteral.symbols +++ b/tests/baselines/reference/typeAnnotationBestCommonTypeInArrayLiteral.symbols @@ -25,14 +25,29 @@ var menuData: IMenuItem[] = [ >IMenuItem : Symbol(IMenuItem, Decl(typeAnnotationBestCommonTypeInArrayLiteral.ts, 0, 0)) { "id": "ourLogo", +>"id" : Symbol("id", Decl(typeAnnotationBestCommonTypeInArrayLiteral.ts, 9, 5)) + "type": "image", +>"type" : Symbol("type", Decl(typeAnnotationBestCommonTypeInArrayLiteral.ts, 10, 24)) + "link": "", +>"link" : Symbol("link", Decl(typeAnnotationBestCommonTypeInArrayLiteral.ts, 11, 24)) + "icon": "modules/menu/logo.svg" +>"icon" : Symbol("icon", Decl(typeAnnotationBestCommonTypeInArrayLiteral.ts, 12, 19)) + }, { "id": "productName", +>"id" : Symbol("id", Decl(typeAnnotationBestCommonTypeInArrayLiteral.ts, 14, 8)) + "type": "default", +>"type" : Symbol("type", Decl(typeAnnotationBestCommonTypeInArrayLiteral.ts, 15, 28)) + "link": "", +>"link" : Symbol("link", Decl(typeAnnotationBestCommonTypeInArrayLiteral.ts, 16, 26)) + "text": "Product Name" +>"text" : Symbol("text", Decl(typeAnnotationBestCommonTypeInArrayLiteral.ts, 17, 19)) } ]; diff --git a/tests/baselines/reference/typeAnnotationBestCommonTypeInArrayLiteral.types b/tests/baselines/reference/typeAnnotationBestCommonTypeInArrayLiteral.types index 66e35a5a535..8e6fc0e315a 100644 --- a/tests/baselines/reference/typeAnnotationBestCommonTypeInArrayLiteral.types +++ b/tests/baselines/reference/typeAnnotationBestCommonTypeInArrayLiteral.types @@ -28,30 +28,38 @@ var menuData: IMenuItem[] = [ >{ "id": "ourLogo", "type": "image", "link": "", "icon": "modules/menu/logo.svg" } : { "id": string; "type": string; "link": string; "icon": string; } "id": "ourLogo", +>"id" : string >"ourLogo" : "ourLogo" "type": "image", +>"type" : string >"image" : "image" "link": "", +>"link" : string >"" : "" "icon": "modules/menu/logo.svg" +>"icon" : string >"modules/menu/logo.svg" : "modules/menu/logo.svg" }, { >{ "id": "productName", "type": "default", "link": "", "text": "Product Name" } : { "id": string; "type": string; "link": string; "text": string; } "id": "productName", +>"id" : string >"productName" : "productName" "type": "default", +>"type" : string >"default" : "default" "link": "", +>"link" : string >"" : "" "text": "Product Name" +>"text" : string >"Product Name" : "Product Name" } ]; diff --git a/tests/baselines/reference/typeFromPropertyAssignmentWithExport.js b/tests/baselines/reference/typeFromPropertyAssignmentWithExport.js new file mode 100644 index 00000000000..34fbd5fd53e --- /dev/null +++ b/tests/baselines/reference/typeFromPropertyAssignmentWithExport.js @@ -0,0 +1,18 @@ +//// [a.js] +// this is a javascript file... + +export const Adapter = {}; + +Adapter.prop = {}; + +// comment this out, and it works +Adapter.asyncMethod = function() {} + +//// [a.js] +"use strict"; +// this is a javascript file... +exports.__esModule = true; +exports.Adapter = {}; +exports.Adapter.prop = {}; +// comment this out, and it works +exports.Adapter.asyncMethod = function () { }; diff --git a/tests/baselines/reference/typeFromPropertyAssignmentWithExport.symbols b/tests/baselines/reference/typeFromPropertyAssignmentWithExport.symbols new file mode 100644 index 00000000000..060018acdeb --- /dev/null +++ b/tests/baselines/reference/typeFromPropertyAssignmentWithExport.symbols @@ -0,0 +1,13 @@ +=== tests/cases/conformance/salsa/a.js === +// this is a javascript file... + +export const Adapter = {}; +>Adapter : Symbol(Adapter, Decl(a.js, 2, 12), Decl(a.js, 4, 18)) + +Adapter.prop = {}; +>Adapter : Symbol(Adapter, Decl(a.js, 2, 12), Decl(a.js, 4, 18)) + +// comment this out, and it works +Adapter.asyncMethod = function() {} +>Adapter : Symbol(Adapter, Decl(a.js, 2, 12), Decl(a.js, 4, 18)) + diff --git a/tests/baselines/reference/typeFromPropertyAssignmentWithExport.types b/tests/baselines/reference/typeFromPropertyAssignmentWithExport.types new file mode 100644 index 00000000000..82b0e0b48f9 --- /dev/null +++ b/tests/baselines/reference/typeFromPropertyAssignmentWithExport.types @@ -0,0 +1,22 @@ +=== tests/cases/conformance/salsa/a.js === +// this is a javascript file... + +export const Adapter = {}; +>Adapter : { [x: string]: any; } +>{} : { [x: string]: any; } + +Adapter.prop = {}; +>Adapter.prop = {} : {} +>Adapter.prop : any +>Adapter : { [x: string]: any; } +>prop : any +>{} : {} + +// comment this out, and it works +Adapter.asyncMethod = function() {} +>Adapter.asyncMethod = function() {} : () => void +>Adapter.asyncMethod : any +>Adapter : { [x: string]: any; } +>asyncMethod : any +>function() {} : () => void + diff --git a/tests/baselines/reference/typeGuardFunctionErrors.symbols b/tests/baselines/reference/typeGuardFunctionErrors.symbols index 59f30533674..841e986a95d 100644 --- a/tests/baselines/reference/typeGuardFunctionErrors.symbols +++ b/tests/baselines/reference/typeGuardFunctionErrors.symbols @@ -382,9 +382,11 @@ declare function hasKey(x: KeySet): x is KeySet; type Foo = { 'a': string; } >Foo : Symbol(Foo, Decl(typeGuardFunctionErrors.ts, 151, 74)) +>'a' : Symbol('a', Decl(typeGuardFunctionErrors.ts, 153, 12)) type Bar = { 'a': number; } >Bar : Symbol(Bar, Decl(typeGuardFunctionErrors.ts, 153, 27)) +>'a' : Symbol('a', Decl(typeGuardFunctionErrors.ts, 154, 12)) interface NeedsFoo { >NeedsFoo : Symbol(NeedsFoo, Decl(typeGuardFunctionErrors.ts, 154, 27)) diff --git a/tests/baselines/reference/typeGuardFunctionErrors.types b/tests/baselines/reference/typeGuardFunctionErrors.types index d8add236887..96d441d8b8d 100644 --- a/tests/baselines/reference/typeGuardFunctionErrors.types +++ b/tests/baselines/reference/typeGuardFunctionErrors.types @@ -434,9 +434,11 @@ declare function hasKey(x: KeySet): x is KeySet; type Foo = { 'a': string; } >Foo : Foo +>'a' : string type Bar = { 'a': number; } >Bar : Bar +>'a' : number interface NeedsFoo { >NeedsFoo : NeedsFoo diff --git a/tests/baselines/reference/typeOfOnTypeArg.symbols b/tests/baselines/reference/typeOfOnTypeArg.symbols index 13d2d75b47f..254fba1107b 100644 --- a/tests/baselines/reference/typeOfOnTypeArg.symbols +++ b/tests/baselines/reference/typeOfOnTypeArg.symbols @@ -1,6 +1,7 @@ === tests/cases/compiler/typeOfOnTypeArg.ts === var A = { '': 3 }; >A : Symbol(A, Decl(typeOfOnTypeArg.ts, 0, 3)) +>'' : Symbol('', Decl(typeOfOnTypeArg.ts, 0, 9)) function fill(f: B) { >fill : Symbol(fill, Decl(typeOfOnTypeArg.ts, 0, 18)) diff --git a/tests/baselines/reference/typeOfOnTypeArg.types b/tests/baselines/reference/typeOfOnTypeArg.types index 9c76b6fa906..fef88255d05 100644 --- a/tests/baselines/reference/typeOfOnTypeArg.types +++ b/tests/baselines/reference/typeOfOnTypeArg.types @@ -2,6 +2,7 @@ var A = { '': 3 }; >A : { '': number; } >{ '': 3 } : { '': number; } +>'' : number >3 : 3 function fill(f: B) { diff --git a/tests/baselines/reference/typeReferenceDirectives12.symbols b/tests/baselines/reference/typeReferenceDirectives12.symbols index b3c6cc1b8d7..fc37a10f43d 100644 --- a/tests/baselines/reference/typeReferenceDirectives12.symbols +++ b/tests/baselines/reference/typeReferenceDirectives12.symbols @@ -48,6 +48,8 @@ Cls.prototype.foo = function() { return undefined; } >undefined : Symbol(undefined) declare module "./main" { +>"./main" : Symbol("/main", Decl(main.ts, 0, 0), Decl(mod1.ts, 3, 52)) + interface Cls { >Cls : Symbol(Cls, Decl(main.ts, 0, 0), Decl(mod1.ts, 5, 25), Decl(mod1.ts, 8, 5)) diff --git a/tests/baselines/reference/typeReferenceDirectives12.types b/tests/baselines/reference/typeReferenceDirectives12.types index cb6f3239bea..3503de37ad3 100644 --- a/tests/baselines/reference/typeReferenceDirectives12.types +++ b/tests/baselines/reference/typeReferenceDirectives12.types @@ -53,6 +53,8 @@ Cls.prototype.foo = function() { return undefined; } >undefined : undefined declare module "./main" { +>"./main" : typeof "/main" + interface Cls { >Cls : Cls diff --git a/tests/baselines/reference/typeReferenceDirectives9.symbols b/tests/baselines/reference/typeReferenceDirectives9.symbols index b3c6cc1b8d7..fc37a10f43d 100644 --- a/tests/baselines/reference/typeReferenceDirectives9.symbols +++ b/tests/baselines/reference/typeReferenceDirectives9.symbols @@ -48,6 +48,8 @@ Cls.prototype.foo = function() { return undefined; } >undefined : Symbol(undefined) declare module "./main" { +>"./main" : Symbol("/main", Decl(main.ts, 0, 0), Decl(mod1.ts, 3, 52)) + interface Cls { >Cls : Symbol(Cls, Decl(main.ts, 0, 0), Decl(mod1.ts, 5, 25), Decl(mod1.ts, 8, 5)) diff --git a/tests/baselines/reference/typeReferenceDirectives9.types b/tests/baselines/reference/typeReferenceDirectives9.types index cb6f3239bea..3503de37ad3 100644 --- a/tests/baselines/reference/typeReferenceDirectives9.types +++ b/tests/baselines/reference/typeReferenceDirectives9.types @@ -53,6 +53,8 @@ Cls.prototype.foo = function() { return undefined; } >undefined : undefined declare module "./main" { +>"./main" : typeof "/main" + interface Cls { >Cls : Cls diff --git a/tests/baselines/reference/typeRootsFromMultipleNodeModulesDirectories.symbols b/tests/baselines/reference/typeRootsFromMultipleNodeModulesDirectories.symbols index 11b00906cec..79fb6799a89 100644 --- a/tests/baselines/reference/typeRootsFromMultipleNodeModulesDirectories.symbols +++ b/tests/baselines/reference/typeRootsFromMultipleNodeModulesDirectories.symbols @@ -15,18 +15,24 @@ x + y + z; === /node_modules/@types/dopey/index.d.ts === declare module "xyz" { +>"xyz" : Symbol("xyz", Decl(index.d.ts, 0, 0)) + export const x: number; >x : Symbol(x, Decl(index.d.ts, 1, 16)) } === /foo/node_modules/@types/grumpy/index.d.ts === declare module "pdq" { +>"pdq" : Symbol("pdq", Decl(index.d.ts, 0, 0)) + export const y: number; >y : Symbol(y, Decl(index.d.ts, 1, 16)) } === /foo/node_modules/@types/sneezy/index.d.ts === declare module "abc" { +>"abc" : Symbol("abc", Decl(index.d.ts, 0, 0)) + export const z: number; >z : Symbol(z, Decl(index.d.ts, 1, 16)) } diff --git a/tests/baselines/reference/typeRootsFromMultipleNodeModulesDirectories.types b/tests/baselines/reference/typeRootsFromMultipleNodeModulesDirectories.types index f99c3c08991..94411e4cfda 100644 --- a/tests/baselines/reference/typeRootsFromMultipleNodeModulesDirectories.types +++ b/tests/baselines/reference/typeRootsFromMultipleNodeModulesDirectories.types @@ -17,18 +17,24 @@ x + y + z; === /node_modules/@types/dopey/index.d.ts === declare module "xyz" { +>"xyz" : typeof "xyz" + export const x: number; >x : number } === /foo/node_modules/@types/grumpy/index.d.ts === declare module "pdq" { +>"pdq" : typeof "pdq" + export const y: number; >y : number } === /foo/node_modules/@types/sneezy/index.d.ts === declare module "abc" { +>"abc" : typeof "abc" + export const z: number; >z : number } diff --git a/tests/baselines/reference/typeRootsFromNodeModulesInParentDirectory.symbols b/tests/baselines/reference/typeRootsFromNodeModulesInParentDirectory.symbols index 453f5a542b7..1e3fe12b121 100644 --- a/tests/baselines/reference/typeRootsFromNodeModulesInParentDirectory.symbols +++ b/tests/baselines/reference/typeRootsFromNodeModulesInParentDirectory.symbols @@ -7,6 +7,8 @@ x; === /node_modules/@types/foo/index.d.ts === declare module "xyz" { +>"xyz" : Symbol("xyz", Decl(index.d.ts, 0, 0)) + export const x: number; >x : Symbol(x, Decl(index.d.ts, 1, 16)) } diff --git a/tests/baselines/reference/typeRootsFromNodeModulesInParentDirectory.types b/tests/baselines/reference/typeRootsFromNodeModulesInParentDirectory.types index ebc801015ff..9288256420d 100644 --- a/tests/baselines/reference/typeRootsFromNodeModulesInParentDirectory.types +++ b/tests/baselines/reference/typeRootsFromNodeModulesInParentDirectory.types @@ -7,6 +7,8 @@ x; === /node_modules/@types/foo/index.d.ts === declare module "xyz" { +>"xyz" : typeof "xyz" + export const x: number; >x : number } diff --git a/tests/baselines/reference/typeofOperatorWithEnumType.symbols b/tests/baselines/reference/typeofOperatorWithEnumType.symbols index 3ae150ece03..8374b556732 100644 --- a/tests/baselines/reference/typeofOperatorWithEnumType.symbols +++ b/tests/baselines/reference/typeofOperatorWithEnumType.symbols @@ -8,6 +8,7 @@ enum ENUM1 { A, B, "" }; >ENUM1 : Symbol(ENUM1, Decl(typeofOperatorWithEnumType.ts, 2, 14)) >A : Symbol(ENUM1.A, Decl(typeofOperatorWithEnumType.ts, 3, 12)) >B : Symbol(ENUM1.B, Decl(typeofOperatorWithEnumType.ts, 3, 15)) +>"" : Symbol(ENUM1[""], Decl(typeofOperatorWithEnumType.ts, 3, 18)) // enum type var var ResultIsString1 = typeof ENUM; diff --git a/tests/baselines/reference/typeofOperatorWithEnumType.types b/tests/baselines/reference/typeofOperatorWithEnumType.types index 5537a4edff2..ccbb7bef2c5 100644 --- a/tests/baselines/reference/typeofOperatorWithEnumType.types +++ b/tests/baselines/reference/typeofOperatorWithEnumType.types @@ -8,6 +8,7 @@ enum ENUM1 { A, B, "" }; >ENUM1 : ENUM1 >A : ENUM1.A >B : ENUM1.B +>"" : ENUM1. // enum type var var ResultIsString1 = typeof ENUM; diff --git a/tests/baselines/reference/umd-augmentation-1.symbols b/tests/baselines/reference/umd-augmentation-1.symbols index bf5023f0e39..cd072fd6d20 100644 --- a/tests/baselines/reference/umd-augmentation-1.symbols +++ b/tests/baselines/reference/umd-augmentation-1.symbols @@ -82,6 +82,8 @@ import * as Math2d from 'math2d'; // Augment the module declare module 'math2d' { +>'math2d' : Symbol(Math2d, Decl(index.d.ts, 0, 0), Decl(math2d-augment.d.ts, 0, 33)) + // Add a method to the class interface Vector { >Vector : Symbol(Vector, Decl(index.d.ts, 5, 1), Decl(math2d-augment.d.ts, 2, 25)) diff --git a/tests/baselines/reference/umd-augmentation-1.types b/tests/baselines/reference/umd-augmentation-1.types index 9d89e0c4537..0df11a2009a 100644 --- a/tests/baselines/reference/umd-augmentation-1.types +++ b/tests/baselines/reference/umd-augmentation-1.types @@ -91,6 +91,8 @@ import * as Math2d from 'math2d'; // Augment the module declare module 'math2d' { +>'math2d' : typeof Math2d + // Add a method to the class interface Vector { >Vector : Vector diff --git a/tests/baselines/reference/umd-augmentation-2.symbols b/tests/baselines/reference/umd-augmentation-2.symbols index 18f79b6090e..c083dc35bf8 100644 --- a/tests/baselines/reference/umd-augmentation-2.symbols +++ b/tests/baselines/reference/umd-augmentation-2.symbols @@ -80,6 +80,8 @@ import * as Math2d from 'math2d'; // Augment the module declare module 'math2d' { +>'math2d' : Symbol(Math2d, Decl(index.d.ts, 0, 0), Decl(math2d-augment.d.ts, 0, 33)) + // Add a method to the class interface Vector { >Vector : Symbol(Vector, Decl(index.d.ts, 5, 1), Decl(math2d-augment.d.ts, 2, 25)) diff --git a/tests/baselines/reference/umd-augmentation-2.types b/tests/baselines/reference/umd-augmentation-2.types index b8d04ecd643..2effb43fb76 100644 --- a/tests/baselines/reference/umd-augmentation-2.types +++ b/tests/baselines/reference/umd-augmentation-2.types @@ -89,6 +89,8 @@ import * as Math2d from 'math2d'; // Augment the module declare module 'math2d' { +>'math2d' : typeof Math2d + // Add a method to the class interface Vector { >Vector : Vector diff --git a/tests/baselines/reference/umd-augmentation-3.symbols b/tests/baselines/reference/umd-augmentation-3.symbols index 7cbe3ac803b..606c7cd2398 100644 --- a/tests/baselines/reference/umd-augmentation-3.symbols +++ b/tests/baselines/reference/umd-augmentation-3.symbols @@ -91,6 +91,8 @@ import * as Math2d from 'math2d'; // Augment the module declare module 'math2d' { +>'math2d' : Symbol(Math2d, Decl(index.d.ts, 2, 13), Decl(math2d-augment.d.ts, 0, 33)) + // Add a method to the class interface Vector { >Vector : Symbol(Vector, Decl(index.d.ts, 8, 2), Decl(math2d-augment.d.ts, 2, 25)) diff --git a/tests/baselines/reference/umd-augmentation-3.types b/tests/baselines/reference/umd-augmentation-3.types index 5efafd780a0..8c329eaf6d4 100644 --- a/tests/baselines/reference/umd-augmentation-3.types +++ b/tests/baselines/reference/umd-augmentation-3.types @@ -100,6 +100,8 @@ import * as Math2d from 'math2d'; // Augment the module declare module 'math2d' { +>'math2d' : typeof Math2d + // Add a method to the class interface Vector { >Vector : Vector diff --git a/tests/baselines/reference/umd-augmentation-4.symbols b/tests/baselines/reference/umd-augmentation-4.symbols index eabb2e15898..90341d679f0 100644 --- a/tests/baselines/reference/umd-augmentation-4.symbols +++ b/tests/baselines/reference/umd-augmentation-4.symbols @@ -89,6 +89,8 @@ import * as Math2d from 'math2d'; // Augment the module declare module 'math2d' { +>'math2d' : Symbol(Math2d, Decl(index.d.ts, 2, 13), Decl(math2d-augment.d.ts, 0, 33)) + // Add a method to the class interface Vector { >Vector : Symbol(Vector, Decl(index.d.ts, 8, 2), Decl(math2d-augment.d.ts, 2, 25)) diff --git a/tests/baselines/reference/umd-augmentation-4.types b/tests/baselines/reference/umd-augmentation-4.types index f71928f5afc..901ae2f6374 100644 --- a/tests/baselines/reference/umd-augmentation-4.types +++ b/tests/baselines/reference/umd-augmentation-4.types @@ -98,6 +98,8 @@ import * as Math2d from 'math2d'; // Augment the module declare module 'math2d' { +>'math2d' : typeof Math2d + // Add a method to the class interface Vector { >Vector : Vector diff --git a/tests/baselines/reference/umd-errors.symbols b/tests/baselines/reference/umd-errors.symbols index f7cbb705c10..be2566003fb 100644 --- a/tests/baselines/reference/umd-errors.symbols +++ b/tests/baselines/reference/umd-errors.symbols @@ -4,11 +4,13 @@ No type information for this code.export as namespace Foo; No type information for this code. No type information for this code.=== tests/cases/conformance/externalModules/err2.d.ts === // Illegal, can't be in external ambient module -No type information for this code.declare module "Foo" { -No type information for this code. export as namespace Bar; -No type information for this code.} -No type information for this code. -No type information for this code.=== tests/cases/conformance/externalModules/err3.d.ts === +declare module "Foo" { +>"Foo" : Symbol("Foo", Decl(err2.d.ts, 0, 0)) + + export as namespace Bar; +} + +=== tests/cases/conformance/externalModules/err3.d.ts === // Illegal, can't have modifiers export var p; >p : Symbol(p, Decl(err3.d.ts, 1, 10)) diff --git a/tests/baselines/reference/umd-errors.types b/tests/baselines/reference/umd-errors.types index 56d2f7d470e..5464613dc14 100644 --- a/tests/baselines/reference/umd-errors.types +++ b/tests/baselines/reference/umd-errors.types @@ -6,6 +6,8 @@ export as namespace Foo; === tests/cases/conformance/externalModules/err2.d.ts === // Illegal, can't be in external ambient module declare module "Foo" { +>"Foo" : typeof "Foo" + export as namespace Bar; >Bar : No type information available! } diff --git a/tests/baselines/reference/underscoreEscapedNameInEnum.symbols b/tests/baselines/reference/underscoreEscapedNameInEnum.symbols index 98e2a931cf8..e7c3f454169 100644 --- a/tests/baselines/reference/underscoreEscapedNameInEnum.symbols +++ b/tests/baselines/reference/underscoreEscapedNameInEnum.symbols @@ -3,6 +3,8 @@ enum E { >E : Symbol(E, Decl(underscoreEscapedNameInEnum.ts, 0, 0)) "__foo" = 1, +>"__foo" : Symbol(E["__foo"], Decl(underscoreEscapedNameInEnum.ts, 0, 8)) + bar = E["__foo"] + 1 >bar : Symbol(E.bar, Decl(underscoreEscapedNameInEnum.ts, 1, 16)) >E : Symbol(E, Decl(underscoreEscapedNameInEnum.ts, 0, 0)) diff --git a/tests/baselines/reference/underscoreEscapedNameInEnum.types b/tests/baselines/reference/underscoreEscapedNameInEnum.types index 02fc9a5493c..7dae091e9bb 100644 --- a/tests/baselines/reference/underscoreEscapedNameInEnum.types +++ b/tests/baselines/reference/underscoreEscapedNameInEnum.types @@ -3,6 +3,7 @@ enum E { >E : E "__foo" = 1, +>"__foo" : E >1 : 1 bar = E["__foo"] + 1 diff --git a/tests/baselines/reference/underscoreTest1.symbols b/tests/baselines/reference/underscoreTest1.symbols index 41b0c811027..a2819531d20 100644 --- a/tests/baselines/reference/underscoreTest1.symbols +++ b/tests/baselines/reference/underscoreTest1.symbols @@ -1011,9 +1011,11 @@ interface Tuple2 extends Array { >Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) 0: T0; +>0 : Symbol(Tuple2[0], Decl(underscoreTest1_underscore.ts, 12, 45)) >T0 : Symbol(T0, Decl(underscoreTest1_underscore.ts, 12, 17)) 1: T1; +>1 : Symbol(Tuple2[1], Decl(underscoreTest1_underscore.ts, 13, 10)) >T1 : Symbol(T1, Decl(underscoreTest1_underscore.ts, 12, 20)) } @@ -1025,12 +1027,15 @@ interface Tuple3 extends Array { >Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) 0: T0; +>0 : Symbol(Tuple3[0], Decl(underscoreTest1_underscore.ts, 17, 49)) >T0 : Symbol(T0, Decl(underscoreTest1_underscore.ts, 17, 17)) 1: T1; +>1 : Symbol(Tuple3[1], Decl(underscoreTest1_underscore.ts, 18, 10)) >T1 : Symbol(T1, Decl(underscoreTest1_underscore.ts, 17, 20)) 2: T2; +>2 : Symbol(Tuple3[2], Decl(underscoreTest1_underscore.ts, 19, 10)) >T2 : Symbol(T2, Decl(underscoreTest1_underscore.ts, 17, 24)) } @@ -1043,15 +1048,19 @@ interface Tuple4 extends Array { >Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) 0: T0; +>0 : Symbol(Tuple4[0], Decl(underscoreTest1_underscore.ts, 23, 53)) >T0 : Symbol(T0, Decl(underscoreTest1_underscore.ts, 23, 17)) 1: T1; +>1 : Symbol(Tuple4[1], Decl(underscoreTest1_underscore.ts, 24, 10)) >T1 : Symbol(T1, Decl(underscoreTest1_underscore.ts, 23, 20)) 2: T2; +>2 : Symbol(Tuple4[2], Decl(underscoreTest1_underscore.ts, 25, 10)) >T2 : Symbol(T2, Decl(underscoreTest1_underscore.ts, 23, 24)) 3: T3; +>3 : Symbol(Tuple4[3], Decl(underscoreTest1_underscore.ts, 26, 10)) >T3 : Symbol(T3, Decl(underscoreTest1_underscore.ts, 23, 28)) } diff --git a/tests/baselines/reference/underscoreTest1.types b/tests/baselines/reference/underscoreTest1.types index 101d7319553..29792110552 100644 --- a/tests/baselines/reference/underscoreTest1.types +++ b/tests/baselines/reference/underscoreTest1.types @@ -1772,9 +1772,11 @@ interface Tuple2 extends Array { >Array : T[] 0: T0; +>0 : T0 >T0 : T0 1: T1; +>1 : T1 >T1 : T1 } @@ -1786,12 +1788,15 @@ interface Tuple3 extends Array { >Array : T[] 0: T0; +>0 : T0 >T0 : T0 1: T1; +>1 : T1 >T1 : T1 2: T2; +>2 : T2 >T2 : T2 } @@ -1804,15 +1809,19 @@ interface Tuple4 extends Array { >Array : T[] 0: T0; +>0 : T0 >T0 : T0 1: T1; +>1 : T1 >T1 : T1 2: T2; +>2 : T2 >T2 : T2 3: T3; +>3 : T3 >T3 : T3 } diff --git a/tests/baselines/reference/unionAndIntersectionInference1.symbols b/tests/baselines/reference/unionAndIntersectionInference1.symbols index 685b21dd215..174a9a7cbba 100644 --- a/tests/baselines/reference/unionAndIntersectionInference1.symbols +++ b/tests/baselines/reference/unionAndIntersectionInference1.symbols @@ -3,6 +3,7 @@ interface Y { 'i am a very certain type': Y } >Y : Symbol(Y, Decl(unionAndIntersectionInference1.ts, 0, 0)) +>'i am a very certain type' : Symbol(Y['i am a very certain type'], Decl(unionAndIntersectionInference1.ts, 2, 13)) >Y : Symbol(Y, Decl(unionAndIntersectionInference1.ts, 0, 0)) var y: Y = undefined; diff --git a/tests/baselines/reference/unionAndIntersectionInference1.types b/tests/baselines/reference/unionAndIntersectionInference1.types index 6d24bffb56d..2746c9dac92 100644 --- a/tests/baselines/reference/unionAndIntersectionInference1.types +++ b/tests/baselines/reference/unionAndIntersectionInference1.types @@ -3,6 +3,7 @@ interface Y { 'i am a very certain type': Y } >Y : Y +>'i am a very certain type' : Y >Y : Y var y: Y = undefined; diff --git a/tests/baselines/reference/unionTypeFromArrayLiteral.symbols b/tests/baselines/reference/unionTypeFromArrayLiteral.symbols index 7699e89dedd..b6d2a0d548f 100644 --- a/tests/baselines/reference/unionTypeFromArrayLiteral.symbols +++ b/tests/baselines/reference/unionTypeFromArrayLiteral.symbols @@ -23,7 +23,11 @@ var arr5Tuple: { >arr5Tuple : Symbol(arr5Tuple, Decl(unionTypeFromArrayLiteral.ts, 10, 3)) 0: string; +>0 : Symbol(0, Decl(unionTypeFromArrayLiteral.ts, 10, 16)) + 5: number; +>5 : Symbol(5, Decl(unionTypeFromArrayLiteral.ts, 11, 14)) + } = ["hello", true, false, " hello", true, 10, "any"]; // Tuple class C { foo() { } } >C : Symbol(C, Decl(unionTypeFromArrayLiteral.ts, 13, 54)) diff --git a/tests/baselines/reference/unionTypeFromArrayLiteral.types b/tests/baselines/reference/unionTypeFromArrayLiteral.types index efff5e5e219..a2563e7b04c 100644 --- a/tests/baselines/reference/unionTypeFromArrayLiteral.types +++ b/tests/baselines/reference/unionTypeFromArrayLiteral.types @@ -37,7 +37,11 @@ var arr5Tuple: { >arr5Tuple : { 0: string; 5: number; } 0: string; +>0 : string + 5: number; +>5 : number + } = ["hello", true, false, " hello", true, 10, "any"]; // Tuple >["hello", true, false, " hello", true, 10, "any"] : [string, boolean, boolean, string, boolean, number, string] >"hello" : "hello" diff --git a/tests/baselines/reference/unknownSymbols2.types b/tests/baselines/reference/unknownSymbols2.types index fe0c6c1b46a..c87484d8215 100644 --- a/tests/baselines/reference/unknownSymbols2.types +++ b/tests/baselines/reference/unknownSymbols2.types @@ -66,5 +66,5 @@ module M { import d = asdf; >d : any ->asdf : No type information available! +>asdf : any } diff --git a/tests/baselines/reference/untypedModuleImport_vsAmbient.symbols b/tests/baselines/reference/untypedModuleImport_vsAmbient.symbols index 8def3c6a09b..11cae5ef356 100644 --- a/tests/baselines/reference/untypedModuleImport_vsAmbient.symbols +++ b/tests/baselines/reference/untypedModuleImport_vsAmbient.symbols @@ -8,6 +8,8 @@ x; === /declarations.d.ts === declare module "foo" { +>"foo" : Symbol("foo", Decl(declarations.d.ts, 0, 0)) + export const x: number; >x : Symbol(x, Decl(declarations.d.ts, 1, 16)) } diff --git a/tests/baselines/reference/untypedModuleImport_vsAmbient.types b/tests/baselines/reference/untypedModuleImport_vsAmbient.types index 58b0eabefdf..f1991818ad1 100644 --- a/tests/baselines/reference/untypedModuleImport_vsAmbient.types +++ b/tests/baselines/reference/untypedModuleImport_vsAmbient.types @@ -8,6 +8,8 @@ x; === /declarations.d.ts === declare module "foo" { +>"foo" : typeof "foo" + export const x: number; >x : number } diff --git a/tests/baselines/reference/untypedModuleImport_withAugmentation.symbols b/tests/baselines/reference/untypedModuleImport_withAugmentation.symbols index e8575071c9f..ed07d73e21b 100644 --- a/tests/baselines/reference/untypedModuleImport_withAugmentation.symbols +++ b/tests/baselines/reference/untypedModuleImport_withAugmentation.symbols @@ -1,5 +1,7 @@ === /a.ts === declare module "foo" { +>"foo" : Symbol("foo", Decl(a.ts, 0, 0)) + export const x: number; >x : Symbol(x, Decl(a.ts, 1, 16)) } diff --git a/tests/baselines/reference/untypedModuleImport_withAugmentation.types b/tests/baselines/reference/untypedModuleImport_withAugmentation.types index ada8fd7db5d..8bd23ca6aa5 100644 --- a/tests/baselines/reference/untypedModuleImport_withAugmentation.types +++ b/tests/baselines/reference/untypedModuleImport_withAugmentation.types @@ -1,5 +1,7 @@ === /a.ts === declare module "foo" { +>"foo" : typeof "foo" + export const x: number; >x : number } diff --git a/tests/baselines/reference/untypedModuleImport_withAugmentation2.symbols b/tests/baselines/reference/untypedModuleImport_withAugmentation2.symbols index 8671b37b06f..b401b3bb21f 100644 --- a/tests/baselines/reference/untypedModuleImport_withAugmentation2.symbols +++ b/tests/baselines/reference/untypedModuleImport_withAugmentation2.symbols @@ -5,6 +5,8 @@ No type information for this code.=== /node_modules/augmenter/index.d.ts === // This tests that augmenting an untyped module is forbidden even in an ambient context. Contrast with `moduleAugmentationInDependency.ts`. declare module "js" { +>"js" : Symbol("js", Decl(index.d.ts, 0, 0)) + export const j: number; >j : Symbol(j, Decl(index.d.ts, 3, 16)) } diff --git a/tests/baselines/reference/untypedModuleImport_withAugmentation2.types b/tests/baselines/reference/untypedModuleImport_withAugmentation2.types index 89bb2dd2805..89637715584 100644 --- a/tests/baselines/reference/untypedModuleImport_withAugmentation2.types +++ b/tests/baselines/reference/untypedModuleImport_withAugmentation2.types @@ -5,6 +5,8 @@ No type information for this code.=== /node_modules/augmenter/index.d.ts === // This tests that augmenting an untyped module is forbidden even in an ambient context. Contrast with `moduleAugmentationInDependency.ts`. declare module "js" { +>"js" : typeof "js" + export const j: number; >j : number } diff --git a/tests/baselines/reference/unusedImports13.symbols b/tests/baselines/reference/unusedImports13.symbols index 2b9da078e44..46949555e73 100644 --- a/tests/baselines/reference/unusedImports13.symbols +++ b/tests/baselines/reference/unusedImports13.symbols @@ -4,8 +4,6 @@ import React = require("react"); export const FooComponent =
>FooComponent : Symbol(FooComponent, Decl(foo.tsx, 2, 12)) ->div : Symbol(unknown) ->div : Symbol(unknown) === tests/cases/compiler/node_modules/@types/react/index.d.ts === export = React; diff --git a/tests/baselines/reference/unusedImports14.symbols b/tests/baselines/reference/unusedImports14.symbols index 2b9da078e44..46949555e73 100644 --- a/tests/baselines/reference/unusedImports14.symbols +++ b/tests/baselines/reference/unusedImports14.symbols @@ -4,8 +4,6 @@ import React = require("react"); export const FooComponent =
>FooComponent : Symbol(FooComponent, Decl(foo.tsx, 2, 12)) ->div : Symbol(unknown) ->div : Symbol(unknown) === tests/cases/compiler/node_modules/@types/react/index.d.ts === export = React; diff --git a/tests/baselines/reference/unusedImports15.symbols b/tests/baselines/reference/unusedImports15.symbols index e163b1ad459..2aa41146738 100644 --- a/tests/baselines/reference/unusedImports15.symbols +++ b/tests/baselines/reference/unusedImports15.symbols @@ -4,8 +4,6 @@ import Element = require("react"); export const FooComponent =
>FooComponent : Symbol(FooComponent, Decl(foo.tsx, 2, 12)) ->div : Symbol(unknown) ->div : Symbol(unknown) === tests/cases/compiler/node_modules/@types/react/index.d.ts === export = React; diff --git a/tests/baselines/reference/unusedImports16.symbols b/tests/baselines/reference/unusedImports16.symbols index e163b1ad459..2aa41146738 100644 --- a/tests/baselines/reference/unusedImports16.symbols +++ b/tests/baselines/reference/unusedImports16.symbols @@ -4,8 +4,6 @@ import Element = require("react"); export const FooComponent =
>FooComponent : Symbol(FooComponent, Decl(foo.tsx, 2, 12)) ->div : Symbol(unknown) ->div : Symbol(unknown) === tests/cases/compiler/node_modules/@types/react/index.d.ts === export = React; diff --git a/tests/baselines/reference/voidOperatorWithEnumType.symbols b/tests/baselines/reference/voidOperatorWithEnumType.symbols index 26e2ca70959..36a7960ffb3 100644 --- a/tests/baselines/reference/voidOperatorWithEnumType.symbols +++ b/tests/baselines/reference/voidOperatorWithEnumType.symbols @@ -8,6 +8,7 @@ enum ENUM1 { A, B, "" }; >ENUM1 : Symbol(ENUM1, Decl(voidOperatorWithEnumType.ts, 2, 14)) >A : Symbol(ENUM1.A, Decl(voidOperatorWithEnumType.ts, 3, 12)) >B : Symbol(ENUM1.B, Decl(voidOperatorWithEnumType.ts, 3, 15)) +>"" : Symbol(ENUM1[""], Decl(voidOperatorWithEnumType.ts, 3, 18)) // enum type var var ResultIsAny1 = void ENUM; diff --git a/tests/baselines/reference/voidOperatorWithEnumType.types b/tests/baselines/reference/voidOperatorWithEnumType.types index 21332786390..2646cb6ca48 100644 --- a/tests/baselines/reference/voidOperatorWithEnumType.types +++ b/tests/baselines/reference/voidOperatorWithEnumType.types @@ -8,6 +8,7 @@ enum ENUM1 { A, B, "" }; >ENUM1 : ENUM1 >A : ENUM1.A >B : ENUM1.B +>"" : ENUM1. // enum type var var ResultIsAny1 = void ENUM; diff --git a/tests/cases/compiler/constWithNonNull.ts b/tests/cases/compiler/constWithNonNull.ts new file mode 100644 index 00000000000..3a5718f31a7 --- /dev/null +++ b/tests/cases/compiler/constWithNonNull.ts @@ -0,0 +1,4 @@ +// Fixes #21848 + +declare const x: number | undefined; +x!++; diff --git a/tests/cases/compiler/duplicateIdentifierEnum.ts b/tests/cases/compiler/duplicateIdentifierEnum.ts new file mode 100644 index 00000000000..c4f13b24602 --- /dev/null +++ b/tests/cases/compiler/duplicateIdentifierEnum.ts @@ -0,0 +1,37 @@ +// Test the error message when attempting to merge an enum with a class, an interface, or a function. +// @Filename: duplicateIdentifierEnum_A.ts +enum A { + bar +} +class A { + foo: number; +} + +interface B { + foo: number; +} +const enum B { + bar +} + +const enum C { + +} +function C() { + return 0; +} + +enum D { + bar +} +class E { + foo: number; +} +// also make sure the error appears when trying to merge an enum in a separate file. +// @Filename: duplicateIdentifierEnum_B.ts +function D() { + return 0; +} +enum E { + bar +} \ No newline at end of file diff --git a/tests/cases/compiler/jsdocParamTagOnPropertyInitializer.ts b/tests/cases/compiler/jsdocParamTagOnPropertyInitializer.ts new file mode 100644 index 00000000000..831b7252a3b --- /dev/null +++ b/tests/cases/compiler/jsdocParamTagOnPropertyInitializer.ts @@ -0,0 +1,10 @@ +// @allowJs: true +// @checkJs: true +// @noEmit: true +// @noImplicitAny: true + +// @Filename: /a.js +class Foo { + /**@param {string} x */ + m = x => x.toLowerCase(); +} diff --git a/tests/cases/compiler/jsxFactoryMissingErrorInsideAClass.ts b/tests/cases/compiler/jsxFactoryMissingErrorInsideAClass.ts new file mode 100644 index 00000000000..73b25974f5e --- /dev/null +++ b/tests/cases/compiler/jsxFactoryMissingErrorInsideAClass.ts @@ -0,0 +1,11 @@ +//@jsx: react +//@target: es6 +//@module: commonjs +//@reactNamespace: factory + +//@filename: test.tsx +export class C { + factory() { + return
; + } +} diff --git a/tests/cases/compiler/noUnusedLocals_selfReference.ts b/tests/cases/compiler/noUnusedLocals_selfReference.ts index 10ec9ebf782..9ae8244d0f8 100644 --- a/tests/cases/compiler/noUnusedLocals_selfReference.ts +++ b/tests/cases/compiler/noUnusedLocals_selfReference.ts @@ -1,4 +1,5 @@ // @noUnusedLocals: true +// @noUnusedParameters: true export {}; // Make this a module scope, so these are local variables. @@ -12,6 +13,14 @@ class C { m() { C; } } enum E { A = 0, B = E.A } +interface I { x: I }; +type T = { x: T }; +namespace N { N; } + +// Avoid a false positive. +// Previously `T` was considered unused due to merging with the property, +// back when all non-blocks were checked for recursion. +export interface A { T: T } class P { private m() { this.m; } } P; diff --git a/tests/cases/compiler/nounusedTypeParameterConstraint.ts b/tests/cases/compiler/nounusedTypeParameterConstraint.ts index d2c3a1677ee..8108d01d68f 100644 --- a/tests/cases/compiler/nounusedTypeParameterConstraint.ts +++ b/tests/cases/compiler/nounusedTypeParameterConstraint.ts @@ -1,4 +1,5 @@ -//@noUnusedLocals:true +// @noUnusedLocals: true +// @noUnusedParameters:true //@filename: bar.ts export interface IEventSourcedEntity { } diff --git a/tests/cases/compiler/objectLiteralPropertyImplicitlyAny.ts b/tests/cases/compiler/objectLiteralPropertyImplicitlyAny.ts new file mode 100644 index 00000000000..e87d279c401 --- /dev/null +++ b/tests/cases/compiler/objectLiteralPropertyImplicitlyAny.ts @@ -0,0 +1,5 @@ +// @target: esnext +// @noImplicitAny: true + +const foo = Symbol.for("foo"); +const o = { [foo]: undefined }; diff --git a/tests/cases/compiler/pathMappingBasedModuleResolution8_classic.ts b/tests/cases/compiler/pathMappingBasedModuleResolution8_classic.ts new file mode 100644 index 00000000000..dbbf84ab91b --- /dev/null +++ b/tests/cases/compiler/pathMappingBasedModuleResolution8_classic.ts @@ -0,0 +1,21 @@ +// @moduleResolution: classic +// @module: amd +// @traceResolution: true + +// @filename: c:/root/tsconfig.json +{ + "compilerOptions": { + "baseUrl": ".", + "paths": { + "@speedy/*/testing": [ + "*/dist/index.ts" + ] + } + } +} + +// @filename: c:/root/index.ts +import {x} from "@speedy/folder1/testing" + +// @filename: c:/root/folder1/dist/index.ts +export const x = 1 + 2; diff --git a/tests/cases/compiler/pathMappingBasedModuleResolution8_node.ts b/tests/cases/compiler/pathMappingBasedModuleResolution8_node.ts new file mode 100644 index 00000000000..64cf26881d8 --- /dev/null +++ b/tests/cases/compiler/pathMappingBasedModuleResolution8_node.ts @@ -0,0 +1,21 @@ +// @moduleResolution: node +// @module: commonjs +// @traceResolution: true + +// @filename: c:/root/tsconfig.json +{ + "compilerOptions": { + "baseUrl": ".", + "paths": { + "@speedy/*/testing": [ + "*/dist/index.ts" + ] + } + } +} + +// @filename: c:/root/index.ts +import {x} from "@speedy/folder1/testing" + +// @filename: c:/root/folder1/dist/index.ts +export const x = 1 + 2; diff --git a/tests/cases/conformance/async/es2017/asyncAwait_es2017.ts b/tests/cases/conformance/async/es2017/asyncAwait_es2017.ts index a255cb7cb71..7256762788b 100644 --- a/tests/cases/conformance/async/es2017/asyncAwait_es2017.ts +++ b/tests/cases/conformance/async/es2017/asyncAwait_es2017.ts @@ -14,7 +14,7 @@ let f6 = async function(): MyPromise { } let f7 = async () => { }; let f8 = async (): Promise => { }; -let f9 = async (): MyPromise => { }; +let f9 = async (): MyPromise => { }; let f10 = async () => p; let f11 = async () => mp; let f12 = async (): Promise => mp; @@ -37,4 +37,11 @@ class C { module M { export async function f1() { } +} + +async function f14() { + block: { + await 1; + break block; + } } \ No newline at end of file diff --git a/tests/cases/conformance/async/es5/asyncAwait_es5.ts b/tests/cases/conformance/async/es5/asyncAwait_es5.ts index 88cda3201dc..5c33a42ab74 100644 --- a/tests/cases/conformance/async/es5/asyncAwait_es5.ts +++ b/tests/cases/conformance/async/es5/asyncAwait_es5.ts @@ -38,4 +38,11 @@ class C { module M { export async function f1() { } +} + +async function f14() { + block: { + await 1; + break block; + } } \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncAwait_es6.ts b/tests/cases/conformance/async/es6/asyncAwait_es6.ts index 8e72197a98d..203d748e114 100644 --- a/tests/cases/conformance/async/es6/asyncAwait_es6.ts +++ b/tests/cases/conformance/async/es6/asyncAwait_es6.ts @@ -14,7 +14,7 @@ let f6 = async function(): MyPromise { } let f7 = async () => { }; let f8 = async (): Promise => { }; -let f9 = async (): MyPromise => { }; +let f9 = async (): MyPromise => { }; let f10 = async () => p; let f11 = async () => mp; let f12 = async (): Promise => mp; @@ -37,4 +37,11 @@ class C { module M { export async function f1() { } +} + +async function f14() { + block: { + await 1; + break block; + } } \ No newline at end of file diff --git a/tests/cases/conformance/salsa/typeFromPropertyAssignmentWithExport.ts b/tests/cases/conformance/salsa/typeFromPropertyAssignmentWithExport.ts new file mode 100644 index 00000000000..ed4ca168bf7 --- /dev/null +++ b/tests/cases/conformance/salsa/typeFromPropertyAssignmentWithExport.ts @@ -0,0 +1,12 @@ +// @allowJs: true +// @checkJs: true +// @Filename: a.js +// @outDir: dist +// this is a javascript file... + +export const Adapter = {}; + +Adapter.prop = {}; + +// comment this out, and it works +Adapter.asyncMethod = function() {} \ No newline at end of file diff --git a/tests/cases/conformance/types/conditional/conditionalTypes1.ts b/tests/cases/conformance/types/conditional/conditionalTypes1.ts index a6169d428ff..94a802a0ffc 100644 --- a/tests/cases/conformance/types/conditional/conditionalTypes1.ts +++ b/tests/cases/conformance/types/conditional/conditionalTypes1.ts @@ -1,15 +1,11 @@ // @strict: true // @declaration: true -type Diff = T extends U ? never : T; -type Filter = T extends U ? T : never; -type NonNullable = Diff; +type T00 = Exclude<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "b" | "d" +type T01 = Extract<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "a" | "c" -type T00 = Diff<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "b" | "d" -type T01 = Filter<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "a" | "c" - -type T02 = Diff void), Function>; // string | number -type T03 = Filter void), Function>; // () => void +type T02 = Exclude void), Function>; // string | number +type T03 = Extract void), Function>; // () => void type T04 = NonNullable; // string | number type T05 = NonNullable<(() => string) | string[] | null | undefined>; // (() => string) | string[] @@ -31,25 +27,32 @@ function f3(x: Partial[keyof T], y: NonNullable[keyof T]>) { y = x; // Error } +function f4(x: T["x"], y: NonNullable) { + x = y; + y = x; // Error + let s1: string = x; // Error + let s2: string = y; +} + type Options = { k: "a", a: number } | { k: "b", b: string } | { k: "c", c: boolean }; -type T10 = Diff; // { k: "c", c: boolean } -type T11 = Filter; // { k: "a", a: number } | { k: "b", b: string } +type T10 = Exclude; // { k: "c", c: boolean } +type T11 = Extract; // { k: "a", a: number } | { k: "b", b: string } -type T12 = Diff; // { k: "c", c: boolean } -type T13 = Filter; // { k: "a", a: number } | { k: "b", b: string } +type T12 = Exclude; // { k: "c", c: boolean } +type T13 = Extract; // { k: "a", a: number } | { k: "b", b: string } -type T14 = Diff; // Options -type T15 = Filter; // never +type T14 = Exclude; // Options +type T15 = Extract; // never -declare function f4(p: K): Filter; -let x0 = f4("a"); // { k: "a", a: number } +declare function f5(p: K): Extract; +let x0 = f5("a"); // { k: "a", a: number } -type OptionsOfKind = Filter; +type OptionsOfKind = Extract; type T16 = OptionsOfKind<"a" | "b">; // { k: "a", a: number } | { k: "b", b: string } -type Select = Filter; +type Select = Extract; type T17 = Select; // // { k: "a", a: number } | { k: "b", b: string } @@ -206,3 +209,81 @@ type IsNever = T extends never ? true : false; type T50 = IsNever; // true type T51 = IsNever; // false type T52 = IsNever; // false + +// Repros from #21664 + +type Eq = T extends U ? U extends T ? true : false : false; +type T60 = Eq; // true +type T61 = Eq; // false +type T62 = Eq; // false +type T63 = Eq; // true + +type Eq1 = Eq extends false ? false : true; +type T70 = Eq1; // true +type T71 = Eq1; // false +type T72 = Eq1; // false +type T73 = Eq1; // true + +type Eq2 = Eq extends true ? true : false; +type T80 = Eq2; // true +type T81 = Eq2; // false +type T82 = Eq2; // false +type T83 = Eq2; // true + +// Repro from #21756 + +type Foo = T extends string ? boolean : number; +type Bar = T extends string ? boolean : number; +const convert = (value: Foo): Bar => value; + +type Baz = Foo; +const convert2 = (value: Foo): Baz => value; + +function f31() { + type T1 = T extends string ? boolean : number; + type T2 = T extends string ? boolean : number; + var x: T1; + var x: T2; +} + +function f32() { + type T1 = T & U extends string ? boolean : number; + type T2 = Foo; + var z: T1; + var z: T2; // Error, T2 is distributive, T1 isn't +} + +function f33() { + type T1 = Foo; + type T2 = Bar; + var z: T1; + var z: T2; +} + +// Repro from #21823 + +type T90 = T extends 0 ? 0 : () => 0; +type T91 = T extends 0 ? 0 : () => 0; +const f40 = (a: T90): T91 => a; +const f41 = (a: T91): T90 => a; + +type T92 = T extends () => 0 ? () => 1 : () => 2; +type T93 = T extends () => 0 ? () => 1 : () => 2; +const f42 = (a: T92): T93 => a; +const f43 = (a: T93): T92 => a; + +type T94 = T extends string ? true : 42; +type T95 = T extends string ? boolean : number; +const f44 = (value: T94): T95 => value; +const f45 = (value: T95): T94 => value; // Error + +// Repro from #21863 + +function f50() { + type Eq = T extends U ? U extends T ? true : false : false; + type If = S extends false ? U : T; + type Omit = { [P in keyof T]: If, never, P>; }[keyof T]; + type Omit2 = { [P in keyof T]: If, never, P>; }[keyof T]; + type A = Omit<{ a: void; b: never; }>; // 'a' + type B = Omit2<{ a: void; b: never; }>; // 'a' +} diff --git a/tests/cases/conformance/types/conditional/inferTypes1.ts b/tests/cases/conformance/types/conditional/inferTypes1.ts index 6ff7ae67c89..cb803103bae 100644 --- a/tests/cases/conformance/types/conditional/inferTypes1.ts +++ b/tests/cases/conformance/types/conditional/inferTypes1.ts @@ -15,8 +15,6 @@ type T04 = Unpacked[]>>; // string type T05 = Unpacked; // any type T06 = Unpacked; // never -type ReturnType = T extends ((...args: any[]) => infer R) | (new (...args: any[]) => infer R) ? R : any; - function f1(s: string) { return { a: 1, b: s }; } @@ -31,11 +29,16 @@ type T11 = ReturnType<(s: string) => void>; // void type T12 = ReturnType<(() => T)>; // {} type T13 = ReturnType<(() => T)>; // number[] type T14 = ReturnType; // { a: number, b: string } -type T15 = ReturnType; // C -type T16 = ReturnType; // any -type T17 = ReturnType; // any -type T18 = ReturnType; // Error -type T19 = ReturnType; // any +type T15 = ReturnType; // any +type T16 = ReturnType; // any +type T17 = ReturnType; // Error +type T18 = ReturnType; // Error + +type U10 = InstanceType; // C +type U11 = InstanceType; // any +type U12 = InstanceType; // any +type U13 = InstanceType; // Error +type U14 = InstanceType; // Error type ArgumentType any> = T extends (a: infer A) => any ? A : any; @@ -74,6 +77,19 @@ type T60 = infer U; // Error type T61 = infer A extends infer B ? infer C : infer D; // Error type T62 = U extends (infer U)[] ? U : U; // Error +type T70 = { x: T }; +type T71 = T extends T70 ? T70 : never; + +type T72 = { y: T }; +type T73 = T extends T72 ? T70 : never; // Error + +type T74 = { x: T, y: U }; +type T75 = T extends T74 ? T70 | T72 | T74 : never; + +type T76 = { x: T }; +type T77 = T extends T76 ? T76 : never; +type T78 = T extends T76 ? T76 : never; + // Example from #21496 type JsonifiedObject = { [K in keyof T]: Jsonified }; @@ -105,3 +121,17 @@ type JsonifiedExample = Jsonified; declare let ex: JsonifiedExample; const z1: "correct" = ex.customClass; const z2: string = ex.obj.nested.attr; + +// Repros from #21631 + +type A1> = [T, U]; +type B1 = S extends A1 ? [T, U] : never; + +type A2 = [T, U]; +type B2 = S extends A2 ? [T, U] : never; +type C2 = S extends A2 ? [T, U] : never; + +// Repro from #21735 + +type A = T extends string ? { [P in T]: void; } : T; +type B = string extends T ? { [P in T]: void; } : T; // Error diff --git a/tests/cases/conformance/types/mapped/mappedTypes6.ts b/tests/cases/conformance/types/mapped/mappedTypes6.ts new file mode 100644 index 00000000000..b3beef76846 --- /dev/null +++ b/tests/cases/conformance/types/mapped/mappedTypes6.ts @@ -0,0 +1,127 @@ +// @strict: true +// @declaration: true + +type T00 = { [P in keyof T]: T[P] }; +type T01 = { [P in keyof T]?: T[P] }; +type T02 = { [P in keyof T]+?: T[P] }; +type T03 = { [P in keyof T]-?: T[P] }; + +type T04 = { readonly [P in keyof T]: T[P] }; +type T05 = { readonly [P in keyof T]?: T[P] }; +type T06 = { readonly [P in keyof T]+?: T[P] }; +type T07 = { readonly [P in keyof T]-?: T[P] }; + +type T08 = { +readonly [P in keyof T]: T[P] }; +type T09 = { +readonly [P in keyof T]?: T[P] }; +type T10 = { +readonly [P in keyof T]+?: T[P] }; +type T11 = { +readonly [P in keyof T]-?: T[P] }; + +type T12 = { -readonly [P in keyof T]: T[P] }; +type T13 = { -readonly [P in keyof T]?: T[P] }; +type T14 = { -readonly [P in keyof T]+?: T[P] }; +type T15 = { -readonly [P in keyof T]-?: T[P] }; + +function f1(x: Required, y: T, z: Partial) { + x = x; + x = y; // Error + x = z; // Error + y = x; + y = y; + y = z; // Error + z = x; + z = y; + z = z; +} + +type Denullified = { [P in keyof T]-?: NonNullable }; + +function f2(w: Denullified, x: Required, y: T, z: Partial) { + w = w; + w = x; // Error + w = y; // Error + w = z; // Error + x = w; + x = x; + x = y; // Error + x = z; // Error + y = w; + y = x; + y = y; + y = z; // Error + z = w; + z = x; + z = y; + z = z; +} + + +function f3(w: Denullified, x: Required, y: T, z: Partial) { + w = {}; // Error + x = {}; // Error + y = {}; // Error + z = {}; +} + +type Readwrite = { + -readonly [P in keyof T]: T[P]; +} + +function f10(x: Readonly, y: T, z: Readwrite) { + x = x; + x = y; + x = z; + y = x; + y = y; + y = z; + z = x; + z = y; + z = z; +} + +type Foo = { + a: number; + b: number | undefined; + c?: number; + d?: number | undefined; +} + +declare let x1: Foo; + +x1.a; // number +x1.b; // number | undefined +x1.c; // number | undefined +x1.d; // number | undefined + +x1 = { a: 1 }; // Error +x1 = { a: 1, b: 1 }; +x1 = { a: 1, b: 1, c: 1 }; +x1 = { a: 1, b: 1, c: 1, d: 1 }; + +declare let x2: Required; + +x1.a; // number +x1.b; // number | undefined +x1.c; // number +x1.d; // number + +x2 = { a: 1 }; // Error +x2 = { a: 1, b: 1 }; // Error +x2 = { a: 1, b: 1, c: 1 }; // Error +x2 = { a: 1, b: 1, c: 1, d: 1 }; + +type Bar = { + a: number; + readonly b: number; +} + +declare let x3: Bar; +x3.a = 1; +x3.b = 1; // Error + +declare let x4: Readonly; +x4.a = 1; // Error +x4.b = 1; // Error + +declare let x5: Readwrite; +x5.a = 1; +x5.b = 1; diff --git a/tests/cases/fourslash/codeFixAddMissingMember8.ts b/tests/cases/fourslash/codeFixAddMissingMember8.ts new file mode 100644 index 00000000000..6a3b67ca9f7 --- /dev/null +++ b/tests/cases/fourslash/codeFixAddMissingMember8.ts @@ -0,0 +1,7 @@ +/// + +// @Filename: a.ts +////declare var x: [1, 2]; +////x.b; + +verify.not.codeFixAvailable(); diff --git a/tests/cases/fourslash/codeFixForgottenThisPropertyAccess04.ts b/tests/cases/fourslash/codeFixForgottenThisPropertyAccess04.ts new file mode 100644 index 00000000000..884bad4d21a --- /dev/null +++ b/tests/cases/fourslash/codeFixForgottenThisPropertyAccess04.ts @@ -0,0 +1,14 @@ +/// + +// @jsx: react +// @jsxFactory: factory + +// @Filename: /a.tsx +////export class C { +//// foo() { +//// return ; +//// } +////} + + +verify.not.codeFixAvailable(); diff --git a/tests/cases/fourslash/commentsInheritance.ts b/tests/cases/fourslash/commentsInheritance.ts index 985c55c7947..a965bf213c8 100644 --- a/tests/cases/fourslash/commentsInheritance.ts +++ b/tests/cases/fourslash/commentsInheritance.ts @@ -271,10 +271,10 @@ verify.completionListContains("i1_nc_f1", "(method) c1.i1_nc_f1(): void", ""); verify.completionListContains("i1_nc_l1", "(property) c1.i1_nc_l1: () => void", ""); verify.completionListContains("p1", "(property) c1.p1: number", "c1_p1"); verify.completionListContains("f1", "(method) c1.f1(): void", "c1_f1"); -verify.completionListContains("l1", "(property) c1.l1: () => void", ""); +verify.completionListContains("l1", "(property) c1.l1: () => void", "c1_l1"); verify.completionListContains("nc_p1", "(property) c1.nc_p1: number", "c1_nc_p1"); verify.completionListContains("nc_f1", "(method) c1.nc_f1(): void", "c1_nc_f1"); -verify.completionListContains("nc_l1", "(property) c1.nc_l1: () => void", ""); +verify.completionListContains("nc_l1", "(property) c1.nc_l1: () => void", "c1_nc_l1"); goTo.marker('7'); verify.currentSignatureHelpDocCommentIs("i1_f1"); goTo.marker('8'); @@ -288,9 +288,9 @@ verify.currentSignatureHelpDocCommentIs(""); goTo.marker('l8'); verify.currentSignatureHelpDocCommentIs(""); goTo.marker('l9'); -verify.currentSignatureHelpDocCommentIs(""); +verify.currentSignatureHelpDocCommentIs("c1_l1"); goTo.marker('l10'); -verify.currentSignatureHelpDocCommentIs(""); +verify.currentSignatureHelpDocCommentIs("c1_nc_l1"); verify.quickInfos({ "6iq": "var c1_i: c1", @@ -300,8 +300,8 @@ verify.quickInfos({ "10q": ["(method) c1.nc_f1(): void", "c1_nc_f1"], l7q: "(property) c1.i1_l1: () => void", l8q: "(property) c1.i1_nc_l1: () => void", - l9q: "(property) c1.l1: () => void", - l10q: "(property) c1.nc_l1: () => void" + l9q: ["(property) c1.l1: () => void", "c1_l1"], + l10q: ["(property) c1.nc_l1: () => void", "c1_nc_l1"], }); goTo.marker('11'); diff --git a/tests/cases/fourslash/completionsInJsxTag.ts b/tests/cases/fourslash/completionsInJsxTag.ts new file mode 100644 index 00000000000..a38f64e8fed --- /dev/null +++ b/tests/cases/fourslash/completionsInJsxTag.ts @@ -0,0 +1,27 @@ +/// + +// @jsx: preserve + +// @Filename: /a.tsx +////declare namespace JSX { +//// interface Element {} +//// interface IntrinsicElements { +//// div: { +//// /** Doc */ +//// foo: string +//// } +//// } +////} +////class Foo { +//// render() { +////
; +////
+//// } +////} + +goTo.marker("1"); +verify.completionListCount(1); +verify.completionListContains("foo", "(JSX attribute) foo: string", "Doc ", "JSX attribute"); +goTo.marker("2"); +verify.completionListCount(1); +verify.completionListContains("foo", "(JSX attribute) foo: string", "Doc ", "JSX attribute"); diff --git a/tests/cases/fourslash/completionsRecommended_nonAccessibleSymbol.ts b/tests/cases/fourslash/completionsRecommended_nonAccessibleSymbol.ts new file mode 100644 index 00000000000..0f27e824d2b --- /dev/null +++ b/tests/cases/fourslash/completionsRecommended_nonAccessibleSymbol.ts @@ -0,0 +1,10 @@ +/// + +////function f() { +//// class C {} +//// return (c: C) => void; +////} +////f()(new /**/); + +goTo.marker(""); +verify.not.completionListContains("C"); // Not accessible diff --git a/tests/cases/fourslash/completionsStringLiteral_fromTypeConstraint.ts b/tests/cases/fourslash/completionsStringLiteral_fromTypeConstraint.ts new file mode 100644 index 00000000000..cb3f1a31fe2 --- /dev/null +++ b/tests/cases/fourslash/completionsStringLiteral_fromTypeConstraint.ts @@ -0,0 +1,6 @@ +/// + +////interface Foo { foo: string; bar: string; } +////type T = Pick; + +verify.completionsAt("", ["foo", "bar"]); diff --git a/tests/cases/fourslash/documentHighlightsInvalidModifierLocations.ts b/tests/cases/fourslash/documentHighlightsInvalidModifierLocations.ts new file mode 100644 index 00000000000..f008e632464 --- /dev/null +++ b/tests/cases/fourslash/documentHighlightsInvalidModifierLocations.ts @@ -0,0 +1,10 @@ +/// + +////class C { +//// m([|readonly|] p) {} +////} +////function f([|readonly|] p) {} + +for (const r of test.ranges()) { + verify.documentHighlightsOf(r, [r]); +} diff --git a/tests/cases/fourslash/esModuleInteropFindAllReferences.ts b/tests/cases/fourslash/esModuleInteropFindAllReferences.ts new file mode 100644 index 00000000000..9ead793a867 --- /dev/null +++ b/tests/cases/fourslash/esModuleInteropFindAllReferences.ts @@ -0,0 +1,12 @@ +// @esModuleInterop: true + +// @Filename: /abc.d.ts +////declare module "a" { +//// export const [|x|]: number; +////} + +// @Filename: /b.ts +////import * as a from "a"; +////a.[|x|]; + +verify.rangesReferenceEachOther(); \ No newline at end of file diff --git a/tests/cases/fourslash/extract-method_jsxIntrinsicTagSymbol.ts b/tests/cases/fourslash/extract-method_jsxIntrinsicTagSymbol.ts new file mode 100644 index 00000000000..55fd74d4243 --- /dev/null +++ b/tests/cases/fourslash/extract-method_jsxIntrinsicTagSymbol.ts @@ -0,0 +1,10 @@ +/// + +// @Filename: /a.tsx + +// Test that we don't get `unknownSymbol`, which causes a crash when we try getting its declarations. + +/////*a*/
/*b*/ + +goTo.select("a", "b"); +verify.refactorAvailable("Extract Symbol", "constant_scope_0"); diff --git a/tests/cases/fourslash/findAllRefsExportNotAtTopLevel.ts b/tests/cases/fourslash/findAllRefsExportNotAtTopLevel.ts new file mode 100644 index 00000000000..7f9c258bbe2 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsExportNotAtTopLevel.ts @@ -0,0 +1,8 @@ +/// + +////{ +//// export const [|{| "isWriteAccess": true, "isDefinition": true |}x|] = 0; +//// [|x|]; +////} + +verify.singleReferenceGroup("const x: 0"); diff --git a/tests/cases/fourslash/findAllRefsReExport_broken.ts b/tests/cases/fourslash/findAllRefsReExport_broken.ts new file mode 100644 index 00000000000..7c42d9e2b6c --- /dev/null +++ b/tests/cases/fourslash/findAllRefsReExport_broken.ts @@ -0,0 +1,6 @@ +/// + +// @Filename: /a.ts +////export { [|{| "isWriteAccess": true, "isDefinition": true |}x|] }; + +verify.singleReferenceGroup("import x"); diff --git a/tests/cases/fourslash/findAllRefsReExport_broken2.ts b/tests/cases/fourslash/findAllRefsReExport_broken2.ts new file mode 100644 index 00000000000..4f8a3ea5f45 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsReExport_broken2.ts @@ -0,0 +1,6 @@ +/// + +// @Filename: /a.ts +////export { [|{| "isWriteAccess": true, "isDefinition": true |}x|] } from "nonsense"; + +verify.singleReferenceGroup("import x"); diff --git a/tests/cases/fourslash/formattingConditionalOperator.ts b/tests/cases/fourslash/formattingConditionalOperator.ts index 545adb572b1..308f39315a3 100644 --- a/tests/cases/fourslash/formattingConditionalOperator.ts +++ b/tests/cases/fourslash/formattingConditionalOperator.ts @@ -3,4 +3,4 @@ ////var x=true?1:2 format.document(); goTo.bof(); -verify.currentLineContentIs("var x = true ? 1 : 2");; \ No newline at end of file +verify.currentLineContentIs("var x = true ? 1 : 2"); \ No newline at end of file diff --git a/tests/cases/fourslash/formattingConditionalTypes.ts b/tests/cases/fourslash/formattingConditionalTypes.ts new file mode 100644 index 00000000000..1d9526ef7bc --- /dev/null +++ b/tests/cases/fourslash/formattingConditionalTypes.ts @@ -0,0 +1,12 @@ +/// + +/////*L1*/type Diff1 = T extends U?never:T; +/////*L2*/type Diff2 = T extends U ? never : T; + +format.document(); + +goTo.marker("L1"); +verify.currentLineContentIs("type Diff1 = T extends U ? never : T;"); + +goTo.marker("L2"); +verify.currentLineContentIs("type Diff2 = T extends U ? never : T;"); \ No newline at end of file diff --git a/tests/cases/fourslash/formattingInDestructuring5.ts b/tests/cases/fourslash/formattingInDestructuring5.ts new file mode 100644 index 00000000000..3141f3ee3e6 --- /dev/null +++ b/tests/cases/fourslash/formattingInDestructuring5.ts @@ -0,0 +1,15 @@ +/// + +//// let a, b; +//// /*1*/if (false)[a, b] = [1, 2]; +//// /*2*/if (true) [a, b] = [1, 2]; +//// /*3*/var a = [1, 2, 3].map(num => num) [0]; + +format.document(); + +goTo.marker("1"); +verify.currentLineContentIs("if (false) [a, b] = [1, 2];"); +goTo.marker("2"); +verify.currentLineContentIs("if (true) [a, b] = [1, 2];"); +goTo.marker("3"); +verify.currentLineContentIs("var a = [1, 2, 3].map(num => num)[0];"); \ No newline at end of file diff --git a/tests/cases/fourslash/formattingMultipleMappedType.ts b/tests/cases/fourslash/formattingMultipleMappedType.ts new file mode 100644 index 00000000000..1ebfd3144d7 --- /dev/null +++ b/tests/cases/fourslash/formattingMultipleMappedType.ts @@ -0,0 +1,36 @@ +/// + +/////*x1*/type x1 = {[K in keyof T]: number} +/////*x2*/type x2 = { [K in keyof T]: number } +/////*x3*/type x3 = { [K in keyof T]: number} +/////*x4*/type x4 = {[K in keyof T]: number } +/////*x5*/type x5 = { [K in keyof T]: number} +/////*x6*/type x6 = {[K in keyof T]: number } +/////*x7*/type x7 = { [K in keyof T]: number } +/////*x8*/type x8 = { [K in keyof T]: number }; +//// +/////*y1*/type y1 = {foo: number} +/////*y2*/type y2 = { foo: number } +/////*y3*/type y3 = { foo: number} +/////*y4*/type y4 = {foo: number } +/////*y5*/type y5 = { foo: number} +/////*y6*/type y6 = {foo: number } +/////*y7*/type y7 = { foo: number } +/////*y8*/type y8 = { foo: number }; + +format.document(); +for (let index = 1; index < 8; index++) { + goTo.marker(`x${index}`); + verify.currentLineContentIs(`type x${index} = { [K in keyof T]: number }`); +} + +goTo.marker(`x8`); +verify.currentLineContentIs(`type x8 = { [K in keyof T]: number };`); + +for (let index = 1; index < 8; index++) { + goTo.marker(`y${index}`); + verify.currentLineContentIs(`type y${index} = { foo: number }`); +} + +goTo.marker(`y8`); +verify.currentLineContentIs(`type y8 = { foo: number };`); \ No newline at end of file diff --git a/tests/cases/fourslash/formattingTypeInfer.ts b/tests/cases/fourslash/formattingTypeInfer.ts new file mode 100644 index 00000000000..f41a4ef19a8 --- /dev/null +++ b/tests/cases/fourslash/formattingTypeInfer.ts @@ -0,0 +1,45 @@ +/// + +//// +/////*L1*/type C = T extends Array ? U : never; +//// +/////*L2*/ type C < T > = T extends Array < infer U > ? U : never ; +//// +/////*L3*/type C = T extends Array ? U : T; +//// +/////*L4*/ type C < T > = T extends Array < infer U > ? U : T ; +//// +/////*L5*/type Foo = T extends { a: infer U, b: infer U } ? U : never; +//// +/////*L6*/ type Foo < T > = T extends { a : infer U , b : infer U } ? U : never ; +//// +/////*L7*/type Bar = T extends { a: (x: infer U) => void, b: (x: infer U) => void } ? U : never; +//// +/////*L8*/ type Bar < T > = T extends { a : (x : infer U ) => void , b : (x : infer U ) => void } ? U : never ; +//// + +format.document(); + +goTo.marker("L1"); +verify.currentLineContentIs("type C = T extends Array ? U : never;"); + +goTo.marker("L2"); +verify.currentLineContentIs("type C = T extends Array ? U : never;"); + +goTo.marker("L3"); +verify.currentLineContentIs("type C = T extends Array ? U : T;"); + +goTo.marker("L4"); +verify.currentLineContentIs("type C = T extends Array ? U : T;"); + +goTo.marker("L5"); +verify.currentLineContentIs("type Foo = T extends { a: infer U, b: infer U } ? U : never;"); + +goTo.marker("L6"); +verify.currentLineContentIs("type Foo = T extends { a: infer U, b: infer U } ? U : never;"); + +goTo.marker("L7"); +verify.currentLineContentIs("type Bar = T extends { a: (x: infer U) => void, b: (x: infer U) => void } ? U : never;"); + +goTo.marker("L8"); +verify.currentLineContentIs("type Bar = T extends { a: (x: infer U) => void, b: (x: infer U) => void } ? U : never;"); \ No newline at end of file diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 3079736ea11..987af1d6a3a 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -102,7 +102,7 @@ declare namespace FourSlashInterface { } interface Range { fileName: string; - start: number; + pos: number; end: number; marker?: Marker; } @@ -181,7 +181,7 @@ declare namespace FourSlashInterface { errorCode?: number, index?: number, }); - codeFixAvailable(options: Array<{ description: string, actions?: Array<{ type: string, data: {} }>, commands?: {}[] }>): void; + codeFixAvailable(options?: Array<{ description: string, actions?: Array<{ type: string, data: {} }>, commands?: {}[] }>): void; applicableRefactorAvailableAtMarker(markerName: string): void; codeFixDiagnosticsAvailableAtMarkers(markerNames: string[], diagnosticCode?: number): void; applicableRefactorAvailableForRange(): void; @@ -289,7 +289,7 @@ declare namespace FourSlashInterface { baselineGetEmitOutput(): void; baselineQuickInfo(): void; nameOrDottedNameSpanTextIs(text: string): void; - outliningSpansInCurrentFile(spans: TextSpan[]): void; + outliningSpansInCurrentFile(spans: Range[]): void; todoCommentsInCurrentFile(descriptors: string[]): void; matchingBracePositionInCurrentFile(bracePosition: number, expectedMatchPosition: number): void; noMatchingBracePositionInCurrentFile(bracePosition: number): void; diff --git a/tests/cases/fourslash/getMatchingBraces.ts b/tests/cases/fourslash/getMatchingBraces.ts index cea9c8c84eb..3c3016bc994 100644 --- a/tests/cases/fourslash/getMatchingBraces.ts +++ b/tests/cases/fourslash/getMatchingBraces.ts @@ -38,7 +38,7 @@ ////} ////const x: Array[|<() => void>|] = []; -test.ranges().forEach((range) => { - verify.matchingBracePositionInCurrentFile(range.start, range.end - 1); - verify.matchingBracePositionInCurrentFile(range.end - 1, range.start); -}); \ No newline at end of file +for (const range of test.ranges()) { + verify.matchingBracePositionInCurrentFile(range.pos, range.end - 1); + verify.matchingBracePositionInCurrentFile(range.end - 1, range.pos); +} diff --git a/tests/cases/fourslash/getMatchingBracesAdjacentBraces.ts b/tests/cases/fourslash/getMatchingBracesAdjacentBraces.ts index 0dbd5630a5f..9c88179a3d8 100644 --- a/tests/cases/fourslash/getMatchingBracesAdjacentBraces.ts +++ b/tests/cases/fourslash/getMatchingBracesAdjacentBraces.ts @@ -4,6 +4,6 @@ // If there is an adjacent opening and closing brace, // then only the opening brace should get highlighted. -test.ranges().forEach(range => { - verify.matchingBracePositionInCurrentFile(range.start, range.end - 1); -}); \ No newline at end of file +for (const range of test.ranges()) { + verify.matchingBracePositionInCurrentFile(range.pos, range.end - 1); +} diff --git a/tests/cases/fourslash/getOccurrencesConst01.ts b/tests/cases/fourslash/getOccurrencesConst01.ts index 107ad4a5c24..c6b6114f464 100644 --- a/tests/cases/fourslash/getOccurrencesConst01.ts +++ b/tests/cases/fourslash/getOccurrencesConst01.ts @@ -1,14 +1,13 @@ /// -/////*1*/const enum E1 { +////[|const|] enum E1 { //// v1, //// v2 ////} //// /////*2*/const c = 0; -goTo.marker("1"); -verify.occurrencesAtPositionCount(0); +verify.rangesAreOccurrences(); goTo.marker("2"); verify.occurrencesAtPositionCount(0); diff --git a/tests/cases/fourslash/getOccurrencesConst02.ts b/tests/cases/fourslash/getOccurrencesConst02.ts index 57d75f88e22..f96c520b4e5 100644 --- a/tests/cases/fourslash/getOccurrencesConst02.ts +++ b/tests/cases/fourslash/getOccurrencesConst02.ts @@ -1,13 +1,14 @@ /// ////module m { -//// declare [|const|] x; +//// declare /*1*/const x; //// declare [|const|] enum E { //// } ////} //// -////declare [|const|] x; +////declare /*2*/const x; ////declare [|const|] enum E { ////} -goTo.eachRange(() => verify.occurrencesAtPositionCount(0)); +goTo.eachRange(() => verify.occurrencesAtPositionCount(1)); // They are in different scopes, so not counted together. +goTo.eachMarker(() => verify.occurrencesAtPositionCount(0)); diff --git a/tests/cases/fourslash/getOccurrencesConst03.ts b/tests/cases/fourslash/getOccurrencesConst03.ts index a86481ed72a..511a9fa9afb 100644 --- a/tests/cases/fourslash/getOccurrencesConst03.ts +++ b/tests/cases/fourslash/getOccurrencesConst03.ts @@ -1,13 +1,14 @@ /// ////module m { -//// export [|const|] x; +//// export /*1*/const x; //// export [|const|] enum E { //// } ////} //// -////export [|const|] x; +////export /*2*/const x; ////export [|const|] enum E { ////} -goTo.eachRange(() => verify.occurrencesAtPositionCount(0)); \ No newline at end of file +goTo.eachRange(() => verify.occurrencesAtPositionCount(1)); // They are in different scopes, so not counted together. +goTo.eachMarker(() => verify.occurrencesAtPositionCount(0)); \ No newline at end of file diff --git a/tests/cases/fourslash/getOccurrencesConst04.ts b/tests/cases/fourslash/getOccurrencesConst04.ts index 2a8ee4c9e2c..dca2d70957d 100644 --- a/tests/cases/fourslash/getOccurrencesConst04.ts +++ b/tests/cases/fourslash/getOccurrencesConst04.ts @@ -7,8 +7,8 @@ ////} goTo.marker("1"); -verify.occurrencesAtPositionCount(0); +verify.occurrencesAtPositionCount(1); goTo.marker("2"); verify.occurrencesAtPositionCount(1); goTo.marker("3"); -verify.occurrencesAtPositionCount(0); \ No newline at end of file +verify.occurrencesAtPositionCount(1); \ No newline at end of file diff --git a/tests/cases/fourslash/getOccurrencesModifiersNegatives1.ts b/tests/cases/fourslash/getOccurrencesModifiersNegatives1.ts index 836d87fa9be..ab3adeb4776 100644 --- a/tests/cases/fourslash/getOccurrencesModifiersNegatives1.ts +++ b/tests/cases/fourslash/getOccurrencesModifiersNegatives1.ts @@ -1,37 +1,40 @@ /// ////class C { -//// [|export|] foo; -//// [|declare|] bar; -//// [|export|] [|declare|] foobar; -//// [|declare|] [|export|] barfoo; +//// [|{| "count": 3 |}export|] foo; +//// [|{| "count": 3 |}declare|] bar; +//// [|{| "count": 3 |}export|] [|{| "count": 3 |}declare|] foobar; +//// [|{| "count": 3 |}declare|] [|{| "count": 3 |}export|] barfoo; //// -//// constructor([|export|] conFoo, -//// [|declare|] conBar, -//// [|export|] [|declare|] conFooBar, -//// [|declare|] [|export|] conBarFoo, -//// [|static|] sue, -//// [|static|] [|export|] [|declare|] sueFooBar, -//// [|static|] [|declare|] [|export|] sueBarFoo, -//// [|declare|] [|static|] [|export|] barSueFoo) { +//// constructor([|{| "count": 9 |}export|] conFoo, +//// [|{| "count": 9 |}declare|] conBar, +//// [|{| "count": 9 |}export|] [|{| "count": 9 |}declare|] conFooBar, +//// [|{| "count": 9 |}declare|] [|{| "count": 9 |}export|] conBarFoo, +//// [|{| "count": 4 |}static|] sue, +//// [|{| "count": 4 |}static|] [|{| "count": 9 |}export|] [|{| "count": 9 |}declare|] sueFooBar, +//// [|{| "count": 4 |}static|] [|{| "count": 9 |}declare|] [|{| "count": 9 |}export|] sueBarFoo, +//// [|{| "count": 9 |}declare|] [|{| "count": 4 |}static|] [|{| "count": 9 |}export|] barSueFoo) { //// } ////} //// ////module m { -//// [|static|] a; -//// [|public|] b; -//// [|private|] c; -//// [|protected|] d; -//// [|static|] [|public|] [|private|] [|protected|] e; -//// [|public|] [|static|] [|protected|] [|private|] f; -//// [|protected|] [|static|] [|public|] g; +//// [|{| "count": 0 |}static|] a; +//// [|{| "count": 0 |}public|] b; +//// [|{| "count": 0 |}private|] c; +//// [|{| "count": 0 |}protected|] d; +//// [|{| "count": 0 |}static|] [|{| "count": 0 |}public|] [|{| "count": 0 |}private|] [|{| "count": 0 |}protected|] e; +//// [|{| "count": 0 |}public|] [|{| "count": 0 |}static|] [|{| "count": 0 |}protected|] [|{| "count": 0 |}private|] f; +//// [|{| "count": 0 |}protected|] [|{| "count": 0 |}static|] [|{| "count": 0 |}public|] g; ////} -////[|static|] a; -////[|public|] b; -////[|private|] c; -////[|protected|] d; -////[|static|] [|public|] [|private|] [|protected|] e; -////[|public|] [|static|] [|protected|] [|private|] f; -////[|protected|] [|static|] [|public|] g; +////[|{| "count": 0 |}static|] a; +////[|{| "count": 0 |}public|] b; +////[|{| "count": 0 |}private|] c; +////[|{| "count": 0 |}protected|] d; +////[|{| "count": 0 |}static|] [|{| "count": 0 |}public|] [|{| "count": 0 |}private|] [|{| "count": 0 |}protected|] e; +////[|{| "count": 0 |}public|] [|{| "count": 0 |}static|] [|{| "count": 0 |}protected|] [|{| "count": 0 |}private|] f; +////[|{| "count": 0 |}protected|] [|{| "count": 0 |}static|] [|{| "count": 0 |}public|] g; -goTo.eachRange(() => verify.occurrencesAtPositionCount(0)); +for (const range of test.ranges()) { + goTo.rangeStart(range); + verify.occurrencesAtPositionCount(range.marker.data.count); +} diff --git a/tests/cases/fourslash/goToDefinitionNewExpressionTargetNotClass.ts b/tests/cases/fourslash/goToDefinitionNewExpressionTargetNotClass.ts new file mode 100644 index 00000000000..02a6dca9d52 --- /dev/null +++ b/tests/cases/fourslash/goToDefinitionNewExpressionTargetNotClass.ts @@ -0,0 +1,16 @@ +/// + +////class C2 { +////} +////let I: { +//// /*constructSignature*/new(): C2; +////}; +////new [|/*invokeExpression1*/I|](); +////let /*symbolDeclaration*/I2: { +////}; +////new [|/*invokeExpression2*/I2|](); + +verify.goToDefinition({ + invokeExpression1: "constructSignature", + invokeExpression2: "symbolDeclaration" +}); diff --git a/tests/cases/fourslash/importNameCodeFixIndentedIdentifier.ts b/tests/cases/fourslash/importNameCodeFixIndentedIdentifier.ts new file mode 100644 index 00000000000..49bb3df022b --- /dev/null +++ b/tests/cases/fourslash/importNameCodeFixIndentedIdentifier.ts @@ -0,0 +1,22 @@ +/// + +// @Filename: /a.ts +////[|import * as b from "./b"; +////{ +//// x/**/ +////}|] + +// @Filename: /b.ts +////export const x = 0; + +verify.importFixAtPosition([ +`import * as b from "./b"; +{ + b.x +}`, +`import * as b from "./b"; +import { x } from "./b"; +{ + x +}`, +]); diff --git a/tests/cases/fourslash/importNameCodeFixUMDGlobalReact0.ts b/tests/cases/fourslash/importNameCodeFixUMDGlobalReact0.ts index cd3d25030fa..6fc3ce54988 100644 --- a/tests/cases/fourslash/importNameCodeFixUMDGlobalReact0.ts +++ b/tests/cases/fourslash/importNameCodeFixUMDGlobalReact0.ts @@ -22,10 +22,22 @@ ////export class MyMap extends Component { } ////;|] +// @Filename: /b.tsx +////[|import { Component } from "react"; +////<>;|] + goTo.file("/a.tsx"); +verify.importFixAtPosition([ + `import { Component } from "react"; +import * as React from "react"; +export class MyMap extends Component { } +;`]); + + +goTo.file("/b.tsx"); + verify.importFixAtPosition([ `import { Component } from "react"; import * as React from "react"; -export class MyMap extends Component { } -;`]); +<>;`]); diff --git a/tests/cases/fourslash/importNameCodeFixUMDGlobalReact2.ts b/tests/cases/fourslash/importNameCodeFixUMDGlobalReact2.ts index a3c8253fbd1..0a152e9f2d4 100644 --- a/tests/cases/fourslash/importNameCodeFixUMDGlobalReact2.ts +++ b/tests/cases/fourslash/importNameCodeFixUMDGlobalReact2.ts @@ -17,5 +17,8 @@ ////[|
|] goTo.file("/a.tsx"); -verify.not -verify.importFixAtPosition([]); +verify.importFixAtPosition([ +`import { factory } from "./factory"; + +
` +]); diff --git a/tests/cases/fourslash/importNameCodeFix_jsx.ts b/tests/cases/fourslash/importNameCodeFix_jsx.ts new file mode 100644 index 00000000000..c2c437ff6b4 --- /dev/null +++ b/tests/cases/fourslash/importNameCodeFix_jsx.ts @@ -0,0 +1,10 @@ +/// + +// @jsx: react + +// @Filename: /a.tsx +////[||] + +// Tests that we don't crash at non-identifier location. + +verify.importFixAtPosition([]); diff --git a/tests/cases/fourslash/memberCompletionOnRightSideOfImport.ts b/tests/cases/fourslash/memberCompletionOnRightSideOfImport.ts new file mode 100644 index 00000000000..223995ebb0c --- /dev/null +++ b/tests/cases/fourslash/memberCompletionOnRightSideOfImport.ts @@ -0,0 +1,6 @@ +/// + +////import x = M./**/ + +goTo.marker(""); +verify.completionListIsEmpty(); \ No newline at end of file diff --git a/tests/cases/fourslash/quickInfoMappedTypeRecursiveInference.ts b/tests/cases/fourslash/quickInfoMappedTypeRecursiveInference.ts index 1b46eba1f6b..ced12951813 100644 --- a/tests/cases/fourslash/quickInfoMappedTypeRecursiveInference.ts +++ b/tests/cases/fourslash/quickInfoMappedTypeRecursiveInference.ts @@ -17,23 +17,37 @@ //// oub.b.a.n.a.n.a/*10*/ verify.quickInfoAt('1', `const out: { - a: any; + a: { + a: any; + }; }`); verify.quickInfoAt('2', `function foo<{ - a: any; + a: { + a: any; + }; }>(deep: Deep<{ - a: any; + a: { + a: any; + }; }>): { - a: any; + a: { + a: any; + }; }`); verify.quickInfoAt('3', `(property) a: { - a: any; + a: { + a: any; + }; }`); verify.quickInfoAt('4', `(property) a: { - a: any; + a: { + a: any; + }; }`); verify.quickInfoAt('5', `(property) a: { - a: any; + a: { + a: any; + }; }`); verify.quickInfoAt('6', `const oub: { [x: string]: any; diff --git a/tests/cases/fourslash/refactorConvertToEs6Module_export_namedFunctionExpression.ts b/tests/cases/fourslash/refactorConvertToEs6Module_export_namedFunctionExpression.ts new file mode 100644 index 00000000000..a4b0ba24109 --- /dev/null +++ b/tests/cases/fourslash/refactorConvertToEs6Module_export_namedFunctionExpression.ts @@ -0,0 +1,17 @@ +/// + +// @allowJs: true + +// @Filename: /a.js +/////*a*/exports/*b*/.f = function g() { g(); } +////exports.h = function h() { h(); } + +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Convert to ES6 module", + actionName: "Convert to ES6 module", + actionDescription: "Convert to ES6 module", + newContent: +`export const f = function g() { g(); }; +export function h() { h(); }` +}); diff --git a/tests/cases/fourslash/refactorConvertToEs6Module_triggers_declarationList.ts b/tests/cases/fourslash/refactorConvertToEs6Module_triggers_declarationList.ts new file mode 100644 index 00000000000..36ec32b0561 --- /dev/null +++ b/tests/cases/fourslash/refactorConvertToEs6Module_triggers_declarationList.ts @@ -0,0 +1,9 @@ +/// + +// @allowJs: true + +// @Filename: /a.js +////c[|o|]nst; +////require("x"); + +goTo.eachRange(() => verify.not.refactorAvailable("Convert to ES6 module")); diff --git a/tests/cases/fourslash/refactorConvertToEs6Module_triggers_noInitializer.ts b/tests/cases/fourslash/refactorConvertToEs6Module_triggers_noInitializer.ts new file mode 100644 index 00000000000..23cbdd12aee --- /dev/null +++ b/tests/cases/fourslash/refactorConvertToEs6Module_triggers_noInitializer.ts @@ -0,0 +1,11 @@ +/// + +// @allowJs: true + +// @Filename: /a.js +/////*a*/const/*b*/ alias; +////require("x"); + +goTo.select("a", "b"); +verify.not.refactorAvailable("Convert to ES6 module"); + diff --git a/tests/cases/fourslash/refactorUseDefaultImport.ts b/tests/cases/fourslash/refactorUseDefaultImport.ts index 8834b70f85e..3846c1d5c1e 100644 --- a/tests/cases/fourslash/refactorUseDefaultImport.ts +++ b/tests/cases/fourslash/refactorUseDefaultImport.ts @@ -12,6 +12,12 @@ // @Filename: /c.ts /////*c0*/import a = require("./a");/*c1*/ +// @Filename: /d.ts +/////*d0*/import "./a";/*d1*/ + +// @Filename: /e.ts +/////*e0*/import * as n from "./non-existant";/*e1*/ + goTo.select("b0", "b1"); edit.applyRefactor({ refactorName: "Convert to default import", @@ -27,3 +33,9 @@ edit.applyRefactor({ actionDescription: "Convert to default import", newContent: 'import a from "./a";', }); + +goTo.select("d0", "d1"); +verify.not.applicableRefactorAvailableAtMarker("d0"); + +goTo.select("e0", "e1"); +verify.not.applicableRefactorAvailableAtMarker("e0"); \ No newline at end of file diff --git a/tests/cases/fourslash/server/brace01.ts b/tests/cases/fourslash/server/brace01.ts index 916a2e0b33f..845f96ac9a3 100644 --- a/tests/cases/fourslash/server/brace01.ts +++ b/tests/cases/fourslash/server/brace01.ts @@ -37,7 +37,7 @@ //// } ////} -test.ranges().forEach((range) => { - verify.matchingBracePositionInCurrentFile(range.start, range.end - 1); - verify.matchingBracePositionInCurrentFile(range.end - 1, range.start); -}); \ No newline at end of file +for (const range of test.ranges()) { + verify.matchingBracePositionInCurrentFile(range.pos, range.end - 1); + verify.matchingBracePositionInCurrentFile(range.end - 1, range.pos); +} diff --git a/tests/cases/fourslash/shims-pp/getBraceMatchingAtPosition.ts b/tests/cases/fourslash/shims-pp/getBraceMatchingAtPosition.ts index fc8a71197db..a41f6e2e31a 100644 --- a/tests/cases/fourslash/shims-pp/getBraceMatchingAtPosition.ts +++ b/tests/cases/fourslash/shims-pp/getBraceMatchingAtPosition.ts @@ -37,7 +37,7 @@ //// } ////} -test.ranges().forEach((range) => { - verify.matchingBracePositionInCurrentFile(range.start, range.end - 1); - verify.matchingBracePositionInCurrentFile(range.end - 1, range.start); -}); \ No newline at end of file +for (const range of test.ranges()) { + verify.matchingBracePositionInCurrentFile(range.pos, range.end - 1); + verify.matchingBracePositionInCurrentFile(range.end - 1, range.pos); +} diff --git a/tests/cases/fourslash/shims/getBraceMatchingAtPosition.ts b/tests/cases/fourslash/shims/getBraceMatchingAtPosition.ts index fc8a71197db..a41f6e2e31a 100644 --- a/tests/cases/fourslash/shims/getBraceMatchingAtPosition.ts +++ b/tests/cases/fourslash/shims/getBraceMatchingAtPosition.ts @@ -37,7 +37,7 @@ //// } ////} -test.ranges().forEach((range) => { - verify.matchingBracePositionInCurrentFile(range.start, range.end - 1); - verify.matchingBracePositionInCurrentFile(range.end - 1, range.start); -}); \ No newline at end of file +for (const range of test.ranges()) { + verify.matchingBracePositionInCurrentFile(range.pos, range.end - 1); + verify.matchingBracePositionInCurrentFile(range.end - 1, range.pos); +} diff --git a/tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter b/tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter index 40bdb4eadab..ed149eb0c78 160000 --- a/tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter +++ b/tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter @@ -1 +1 @@ -Subproject commit 40bdb4eadabc9fbed7d83e3f26817a931c0763b6 +Subproject commit ed149eb0c787b1195a95b44105822c64bb6eb636