Merge branch 'master' into release-2.3

This commit is contained in:
Mohamed Hegazy
2017-04-18 17:59:47 -07:00
98 changed files with 1900 additions and 440 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
[![Build Status](https://travis-ci.org/Microsoft/TypeScript.svg?branch=master)](https://travis-ci.org/Microsoft/TypeScript)
[![npm version](https://badge.fury.io/js/typescript.svg)](https://www.npmjs.com/package/typescript)
[![Downloads](https://img.shields.io/npm/dm/TypeScript.svg)](https://www.npmjs.com/package/typescript)
[![Downloads](https://img.shields.io/npm/dm/typescript.svg)](https://www.npmjs.com/package/typescript)
# TypeScript
+5 -3
View File
@@ -1414,6 +1414,7 @@ namespace ts {
if (isObjectLiteralOrClassExpressionMethod(node)) {
return ContainerFlags.IsContainer | ContainerFlags.IsControlFlowContainer | ContainerFlags.HasLocals | ContainerFlags.IsFunctionLike | ContainerFlags.IsObjectLiteralOrClassExpressionMethod;
}
// falls through
case SyntaxKind.Constructor:
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.MethodSignature:
@@ -1715,7 +1716,7 @@ namespace ts {
declareModuleMember(node, symbolFlags, symbolExcludes);
break;
}
// fall through.
// falls through
default:
if (!blockScopeContainer.locals) {
blockScopeContainer.locals = createMap<Symbol>();
@@ -2009,6 +2010,7 @@ namespace ts {
bindBlockScopedDeclaration(<Declaration>parentNode, SymbolFlags.TypeAlias, SymbolFlags.TypeAliasExcludes);
break;
}
// falls through
case SyntaxKind.ThisKeyword:
if (currentFlow && (isExpression(node) || parent.kind === SyntaxKind.ShorthandPropertyAssignment)) {
node.flowNode = currentFlow;
@@ -2184,7 +2186,7 @@ namespace ts {
if (!isFunctionLike(node.parent)) {
return;
}
// Fall through
// falls through
case SyntaxKind.ModuleBlock:
return updateStrictModeStatementList((<Block | ModuleBlock>node).statements);
}
@@ -2401,7 +2403,7 @@ namespace ts {
}
function lookupSymbolForName(name: string) {
return (container.symbol && container.symbol.exports && container.symbol.exports.get(name)) || container.locals.get(name);
return (container.symbol && container.symbol.exports && container.symbol.exports.get(name)) || (container.locals && container.locals.get(name));
}
function bindPropertyAssignment(functionName: string, propertyAccessExpression: PropertyAccessExpression, isPrototypeProperty: boolean) {
+143 -189
View File
@@ -349,7 +349,7 @@ namespace ts {
TypeofNEHostObject = 1 << 13, // typeof x !== "xxx"
EQUndefined = 1 << 14, // x === undefined
EQNull = 1 << 15, // x === null
EQUndefinedOrNull = 1 << 16, // x == undefined / x == null
EQUndefinedOrNull = 1 << 16, // x === undefined / x === null
NEUndefined = 1 << 17, // x !== undefined
NENull = 1 << 18, // x !== null
NEUndefinedOrNull = 1 << 19, // x != undefined / x != null
@@ -727,7 +727,7 @@ namespace ts {
if (declarationFile !== useFile) {
if ((modulekind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) ||
(!compilerOptions.outFile && !compilerOptions.out)) {
// nodes are in different files and order cannot be determines
// nodes are in different files and order cannot be determined
return true;
}
// declaration is after usage
@@ -745,7 +745,7 @@ namespace ts {
// still might be illegal if declaration and usage are both binding elements (eg var [a = b, b = b] = [1, 2])
const errorBindingElement = getAncestor(usage, SyntaxKind.BindingElement) as BindingElement;
if (errorBindingElement) {
return getAncestorBindingPattern(errorBindingElement) !== getAncestorBindingPattern(declaration) ||
return findAncestor(errorBindingElement, isBindingElement) !== findAncestor(declaration, isBindingElement) ||
declaration.pos < errorBindingElement.pos;
}
// or it might be illegal if usage happens before parent variable is declared (eg var [a] = a)
@@ -760,11 +760,19 @@ namespace ts {
// declaration is after usage, but it can still be legal if usage is deferred:
// 1. inside a function
// 2. inside an instance property initializer, a reference to a non-instance property
// 3. inside a static property initializer, a reference to a static method in the same class
// 1. inside an export specifier
// 2. inside a function
// 3. inside an instance property initializer, a reference to a non-instance property
// 4. inside a static property initializer, a reference to a static method in the same class
// or if usage is in a type context:
// 1. inside a type query (typeof in type position)
if (usage.parent.kind === SyntaxKind.ExportSpecifier) {
// export specifiers do not use the variable, they only make it available for use
return true;
}
const container = getEnclosingBlockScopeContainer(declaration);
return isUsedInFunctionOrInstanceProperty(usage, declaration, container);
return isInTypeQuery(usage) || isUsedInFunctionOrInstanceProperty(usage, declaration, container);
function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration: VariableDeclaration, usage: Node): boolean {
const container = getEnclosingBlockScopeContainer(declaration);
@@ -794,12 +802,10 @@ namespace ts {
}
function isUsedInFunctionOrInstanceProperty(usage: Node, declaration: Node, container?: Node): boolean {
let current = usage;
while (current) {
return !!findAncestor(usage, current => {
if (current === container) {
return false;
return "quit";
}
if (isFunctionLike(current)) {
return true;
}
@@ -821,20 +827,7 @@ namespace ts {
}
}
}
current = current.parent;
}
return false;
}
function getAncestorBindingPattern(node: Node): BindingPattern {
while (node) {
if (isBindingPattern(node)) {
return node;
}
node = node.parent;
}
return undefined;
});
}
}
@@ -896,6 +889,7 @@ namespace ts {
case SyntaxKind.SourceFile:
if (!isExternalOrCommonJsModule(<SourceFile>location)) break;
isInExternalModule = true;
// falls through
case SyntaxKind.ModuleDeclaration:
const moduleExports = getSymbolOfNode(location).exports;
if (location.kind === SyntaxKind.SourceFile || isAmbientModule(location)) {
@@ -1256,15 +1250,7 @@ namespace ts {
* Return false if 'stopAt' node is reached or isFunctionLike(current) === true.
*/
function isSameScopeDescendentOf(initial: Node, parent: Node, stopAt: Node): boolean {
if (!parent) {
return false;
}
for (let current = initial; current && current !== stopAt && !isFunctionLike(current); current = current.parent) {
if (current === parent) {
return true;
}
}
return false;
return parent && !!findAncestor(initial, n => n === stopAt || isFunctionLike(n) ? "quit" : n === parent);
}
function getAnyImportSyntax(node: Node): AnyImportSyntax {
@@ -1273,10 +1259,7 @@ namespace ts {
return <ImportEqualsDeclaration>node;
}
while (node && node.kind !== SyntaxKind.ImportDeclaration) {
node = node.parent;
}
return <ImportDeclaration>node;
return findAncestor(node, n => n.kind === SyntaxKind.ImportDeclaration) as ImportDeclaration;
}
}
@@ -1932,6 +1915,7 @@ namespace ts {
if (!isExternalOrCommonJsModule(<SourceFile>location)) {
break;
}
// falls through
case SyntaxKind.ModuleDeclaration:
if (result = callback(getSymbolOfNode(location).exports)) {
return result;
@@ -2137,11 +2121,8 @@ namespace ts {
return { accessibility: SymbolAccessibility.Accessible };
function getExternalModuleContainer(declaration: Node) {
for (; declaration; declaration = declaration.parent) {
if (hasExternalModuleSymbol(declaration)) {
return getSymbolOfNode(declaration);
}
}
const node = findAncestor(declaration, hasExternalModuleSymbol);
return node && getSymbolOfNode(node);
}
}
@@ -2885,10 +2866,7 @@ namespace ts {
function getTypeAliasForTypeLiteral(type: Type): Symbol {
if (type.symbol && type.symbol.flags & SymbolFlags.TypeLiteral) {
let node = type.symbol.declarations[0].parent;
while (node.kind === SyntaxKind.ParenthesizedType) {
node = node.parent;
}
const node = findAncestor(type.symbol.declarations[0].parent, n => n.kind !== SyntaxKind.ParenthesizedType);
if (node.kind === SyntaxKind.TypeAliasDeclaration) {
return getSymbolOfNode(node);
}
@@ -3652,7 +3630,7 @@ namespace ts {
// If the binding pattern is empty, this variable declaration is not visible
return false;
}
// Otherwise fall through
// falls through
case SyntaxKind.ModuleDeclaration:
case SyntaxKind.ClassDeclaration:
case SyntaxKind.InterfaceDeclaration:
@@ -3683,7 +3661,8 @@ namespace ts {
// Private/protected properties/methods are not visible
return false;
}
// Public properties/methods are visible if its parents are visible, so const it fall into next case statement
// Public properties/methods are visible if its parents are visible, so:
// falls through
case SyntaxKind.Constructor:
case SyntaxKind.ConstructSignature:
@@ -3831,8 +3810,7 @@ namespace ts {
}
function getDeclarationContainer(node: Node): Node {
node = getRootDeclaration(node);
while (node) {
node = findAncestor(getRootDeclaration(node), node => {
switch (node.kind) {
case SyntaxKind.VariableDeclaration:
case SyntaxKind.VariableDeclarationList:
@@ -3840,13 +3818,12 @@ namespace ts {
case SyntaxKind.NamedImports:
case SyntaxKind.NamespaceImport:
case SyntaxKind.ImportClause:
node = node.parent;
break;
return false;
default:
return node.parent;
return true;
}
}
});
return node && node.parent;
}
function getTypeOfPrototypeProperty(prototype: Symbol): Type {
@@ -7918,8 +7895,10 @@ namespace ts {
// Starting with the parent of the symbol's declaration, check if the mapper maps any of
// the type parameters introduced by enclosing declarations. We just pick the first
// declaration since multiple declarations will all have the same parent anyway.
let node: Node = symbol.declarations[0];
while (node) {
return !!findAncestor(symbol.declarations[0], node => {
if (node.kind === SyntaxKind.ModuleDeclaration || node.kind === SyntaxKind.SourceFile) {
return "quit";
}
switch (node.kind) {
case SyntaxKind.FunctionType:
case SyntaxKind.ConstructorType:
@@ -7966,13 +7945,8 @@ namespace ts {
}
}
break;
case SyntaxKind.ModuleDeclaration:
case SyntaxKind.SourceFile:
return false;
}
node = node.parent;
}
return false;
});
}
function isTopLevelTypeAlias(symbol: Symbol) {
@@ -8197,7 +8171,8 @@ namespace ts {
function isSignatureAssignableTo(source: Signature,
target: Signature,
ignoreReturnTypes: boolean): boolean {
return compareSignaturesRelated(source, target, ignoreReturnTypes, /*reportErrors*/ false, /*errorReporter*/ undefined, compareTypesAssignable) !== Ternary.False;
return compareSignaturesRelated(source, target, /*checkAsCallback*/ false, ignoreReturnTypes, /*reportErrors*/ false,
/*errorReporter*/ undefined, compareTypesAssignable) !== Ternary.False;
}
type ErrorReporter = (message: DiagnosticMessage, arg0?: string, arg1?: string) => void;
@@ -8207,6 +8182,7 @@ namespace ts {
*/
function compareSignaturesRelated(source: Signature,
target: Signature,
checkAsCallback: boolean,
ignoreReturnTypes: boolean,
reportErrors: boolean,
errorReporter: ErrorReporter,
@@ -8249,9 +8225,23 @@ namespace ts {
const sourceParams = source.parameters;
const targetParams = target.parameters;
for (let i = 0; i < checkCount; i++) {
const s = i < sourceMax ? getTypeOfParameter(sourceParams[i]) : getRestTypeOfSignature(source);
const t = i < targetMax ? getTypeOfParameter(targetParams[i]) : getRestTypeOfSignature(target);
const related = compareTypes(s, t, /*reportErrors*/ false) || compareTypes(t, s, reportErrors);
const sourceType = i < sourceMax ? getTypeOfParameter(sourceParams[i]) : getRestTypeOfSignature(source);
const targetType = i < targetMax ? getTypeOfParameter(targetParams[i]) : getRestTypeOfSignature(target);
const sourceSig = getSingleCallSignature(getNonNullableType(sourceType));
const targetSig = getSingleCallSignature(getNonNullableType(targetType));
// In order to ensure that any generic type Foo<T> is at least co-variant with respect to T no matter
// how Foo uses T, we need to relate parameters bi-variantly (given that parameters are input positions,
// they naturally relate only contra-variantly). However, if the source and target parameters both have
// function types with a single call signature, we known we are relating two callback parameters. In
// that case it is sufficient to only relate the parameters of the signatures co-variantly because,
// similar to return values, callback parameters are output positions. This means that a Promise<T>,
// where T is used only in callback parameter positions, will be co-variant (as opposed to bi-variant)
// with respect to T.
const callbacks = sourceSig && targetSig && !sourceSig.typePredicate && !targetSig.typePredicate &&
(getFalsyFlags(sourceType) & TypeFlags.Nullable) === (getFalsyFlags(targetType) & TypeFlags.Nullable);
const related = callbacks ?
compareSignaturesRelated(targetSig, sourceSig, /*checkAsCallback*/ true, /*ignoreReturnTypes*/ false, reportErrors, errorReporter, compareTypes) :
!checkAsCallback && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors);
if (!related) {
if (reportErrors) {
errorReporter(Diagnostics.Types_of_parameters_0_and_1_are_incompatible,
@@ -8283,7 +8273,11 @@ namespace ts {
}
}
else {
result &= compareTypes(sourceReturnType, targetReturnType, reportErrors);
// When relating callback signatures, we still need to relate return types bi-variantly as otherwise
// the containing type wouldn't be co-variant. For example, interface Foo<T> { add(cb: () => T): void }
// wouldn't be co-variant for T without this rule.
result &= checkAsCallback && compareTypes(targetReturnType, sourceReturnType, /*reportErrors*/ false) ||
compareTypes(sourceReturnType, targetReturnType, reportErrors);
}
}
@@ -8714,7 +8708,7 @@ namespace ts {
if (maybeTypeOfKind(target, TypeFlags.Object) && !(getObjectFlags(target) & ObjectFlags.ObjectLiteralPatternWithComputedProperties)) {
const isComparingJsxAttributes = !!(source.flags & TypeFlags.JsxAttributes);
if ((relation === assignableRelation || relation === comparableRelation) &&
(target === globalObjectType || (!isComparingJsxAttributes && isEmptyObjectType(target)))) {
(isTypeSubsetOf(globalObjectType, target) || (!isComparingJsxAttributes && isEmptyObjectType(target)))) {
return false;
}
for (const prop of getPropertiesOfObjectType(source)) {
@@ -9251,7 +9245,7 @@ namespace ts {
* See signatureAssignableTo, compareSignaturesIdentical
*/
function signatureRelatedTo(source: Signature, target: Signature, reportErrors: boolean): Ternary {
return compareSignaturesRelated(source, target, /*ignoreReturnTypes*/ false, reportErrors, reportError, isRelatedTo);
return compareSignaturesRelated(source, target, /*checkAsCallback*/ false, /*ignoreReturnTypes*/ false, reportErrors, reportError, isRelatedTo);
}
function signaturesIdenticalTo(source: Type, target: Type, kind: SignatureKind): Ternary {
@@ -10416,19 +10410,9 @@ namespace ts {
// TypeScript 1.0 spec (April 2014): 3.6.3
// A type query consists of the keyword typeof followed by an expression.
// The expression is restricted to a single identifier or a sequence of identifiers separated by periods
while (node) {
switch (node.kind) {
case SyntaxKind.TypeQuery:
return true;
case SyntaxKind.Identifier:
case SyntaxKind.QualifiedName:
node = node.parent;
continue;
default:
return false;
}
}
Debug.fail("should not get here");
return !!findAncestor(
node,
n => n.kind === SyntaxKind.TypeQuery ? true : n.kind === SyntaxKind.Identifier || n.kind === SyntaxKind.QualifiedName ? false : "quit");
}
// Return the flow cache key for a "dotted name" (i.e. a sequence of identifiers
@@ -10934,7 +10918,7 @@ namespace ts {
// we defer subtype reduction until the evolving array type is finalized into a manifest
// array type.
function addEvolvingArrayElementType(evolvingArrayType: EvolvingArrayType, node: Expression): EvolvingArrayType {
const elementType = getBaseTypeOfLiteralType(getTypeOfExpression(node));
const elementType = getBaseTypeOfLiteralType(getContextFreeTypeOfExpression(node));
return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType]));
}
@@ -11651,15 +11635,11 @@ namespace ts {
}
function getControlFlowContainer(node: Node): Node {
while (true) {
node = node.parent;
if (isFunctionLike(node) && !getImmediatelyInvokedFunctionExpression(node) ||
node.kind === SyntaxKind.ModuleBlock ||
node.kind === SyntaxKind.SourceFile ||
node.kind === SyntaxKind.PropertyDeclaration) {
return node;
}
}
return findAncestor(node.parent, node =>
isFunctionLike(node) && !getImmediatelyInvokedFunctionExpression(node) ||
node.kind === SyntaxKind.ModuleBlock ||
node.kind === SyntaxKind.SourceFile ||
node.kind === SyntaxKind.PropertyDeclaration);
}
// Check if a parameter is assigned anywhere within its declaring function.
@@ -11676,15 +11656,7 @@ namespace ts {
}
function hasParentWithAssignmentsMarked(node: Node) {
while (true) {
node = node.parent;
if (!node) {
return false;
}
if (isFunctionLike(node) && getNodeLinks(node).flags & NodeCheckFlags.AssignmentsMarked) {
return true;
}
}
return !!findAncestor(node.parent, node => isFunctionLike(node) && !!(getNodeLinks(node).flags & NodeCheckFlags.AssignmentsMarked));
}
function markParameterAssignments(node: Node) {
@@ -11856,15 +11828,7 @@ namespace ts {
}
function isInsideFunction(node: Node, threshold: Node): boolean {
let current = node;
while (current && current !== threshold) {
if (isFunctionLike(current)) {
return true;
}
current = current.parent;
}
return false;
return !!findAncestor(node, n => n === threshold ? "quit" : isFunctionLike(n));
}
function checkNestedBlockScopedBinding(node: Identifier, symbol: Symbol): void {
@@ -11916,8 +11880,8 @@ namespace ts {
}
function isAssignedInBodyOfForStatement(node: Identifier, container: ForStatement): boolean {
let current: Node = node;
// skip parenthesized nodes
let current: Node = node;
while (current.parent.kind === SyntaxKind.ParenthesizedExpression) {
current = current.parent;
}
@@ -11938,15 +11902,7 @@ namespace ts {
// at this point we know that node is the target of assignment
// now check that modification happens inside the statement part of the ForStatement
while (current !== container) {
if (current === container.statement) {
return true;
}
else {
current = current.parent;
}
}
return false;
return !!findAncestor(current, n => n === container ? "quit" : n === container.statement);
}
function captureLexicalThis(node: Node, container: Node): void {
@@ -12128,12 +12084,7 @@ namespace ts {
}
function isInConstructorArgumentInitializer(node: Node, constructorDecl: Node): boolean {
for (let n = node; n && n !== constructorDecl; n = n.parent) {
if (n.kind === SyntaxKind.Parameter) {
return true;
}
}
return false;
return !!findAncestor(node, n => n === constructorDecl ? "quit" : n.kind === SyntaxKind.Parameter);
}
function checkSuperExpression(node: Node): Type {
@@ -12159,10 +12110,7 @@ namespace ts {
// class B {
// [super.foo()]() {}
// }
let current = node;
while (current && current !== container && current.kind !== SyntaxKind.ComputedPropertyName) {
current = current.parent;
}
const current = findAncestor(node, n => n === container ? "quit" : n.kind === SyntaxKind.ComputedPropertyName);
if (current && current.kind === SyntaxKind.ComputedPropertyName) {
error(node, Diagnostics.super_cannot_be_referenced_in_a_computed_property_name);
}
@@ -12766,13 +12714,8 @@ namespace ts {
}
function getContextualMapper(node: Node) {
while (node) {
if (node.contextualMapper) {
return node.contextualMapper;
}
node = node.parent;
}
return identityMapper;
node = findAncestor(node, n => !!n.contextualMapper);
return node ? node.contextualMapper : identityMapper;
}
// If the given type is an object or union type, if that type has a single signature, and if
@@ -17122,10 +17065,12 @@ namespace ts {
return type;
}
// Returns the type of an expression. Unlike checkExpression, this function is simply concerned
// with computing the type and may not fully check all contained sub-expressions for errors.
// A cache argument of true indicates that if the function performs a full type check, it is ok
// to cache the result.
/**
* Returns the type of an expression. Unlike checkExpression, this function is simply concerned
* with computing the type and may not fully check all contained sub-expressions for errors.
* A cache argument of true indicates that if the function performs a full type check, it is ok
* to cache the result.
*/
function getTypeOfExpression(node: Expression, cache?: boolean) {
// Optimize for the common case of a call to a function with a single non-generic call
// signature where we can just fetch the return type without checking the arguments.
@@ -17142,6 +17087,21 @@ namespace ts {
return cache ? checkExpressionCached(node) : checkExpression(node);
}
/**
* Returns the type of an expression. Unlike checkExpression, this function is simply concerned
* with computing the type and may not fully check all contained sub-expressions for errors.
* It is intended for uses where you know there is no contextual type,
* and requesting the contextual type might cause a circularity or other bad behaviour.
* It sets the contextual type of the node to any before calling getTypeOfExpression.
*/
function getContextFreeTypeOfExpression(node: Expression) {
const saveContextualType = node.contextualType;
node.contextualType = anyType;
const type = getTypeOfExpression(node);
node.contextualType = saveContextualType;
return type;
}
// Checks an expression and returns its type. The contextualMapper parameter serves two purposes: When
// contextualMapper is not undefined and not equal to the identityMapper function object it indicates that the
// expression is being inferentially typed (section 4.15.2 in spec) and provides the type mapper to use in
@@ -17610,7 +17570,7 @@ namespace ts {
function checkObjectTypeForDuplicateDeclarations(node: TypeLiteralNode | InterfaceDeclaration) {
const names = createMap<boolean>();
for (const member of node.members) {
if (member.kind == SyntaxKind.PropertySignature) {
if (member.kind === SyntaxKind.PropertySignature) {
let memberName: string;
switch (member.name.kind) {
case SyntaxKind.StringLiteral:
@@ -19011,8 +18971,7 @@ namespace ts {
// this function will run after checking the source file so 'CaptureThis' is correct for all nodes
function checkIfThisIsCapturedInEnclosingScope(node: Node): void {
let current = node;
while (current) {
findAncestor(node, current => {
if (getNodeCheckFlags(current) & NodeCheckFlags.CaptureThis) {
const isDeclaration = node.kind !== SyntaxKind.Identifier;
if (isDeclaration) {
@@ -19021,15 +18980,13 @@ namespace ts {
else {
error(node, Diagnostics.Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference);
}
return;
return true;
}
current = current.parent;
}
});
}
function checkIfNewTargetIsCapturedInEnclosingScope(node: Node): void {
let current = node;
while (current) {
findAncestor(node, current => {
if (getNodeCheckFlags(current) & NodeCheckFlags.CaptureNewTarget) {
const isDeclaration = node.kind !== SyntaxKind.Identifier;
if (isDeclaration) {
@@ -19038,10 +18995,9 @@ namespace ts {
else {
error(node, Diagnostics.Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference);
}
return;
return true;
}
current = current.parent;
}
});
}
function checkCollisionWithCapturedSuperVariable(node: Node, name: Identifier) {
@@ -19225,19 +19181,20 @@ namespace ts {
return;
}
// - parameter is wrapped in function-like entity
let current = n;
while (current !== node.initializer) {
if (isFunctionLike(current.parent)) {
return;
}
// computed property names/initializers in instance property declaration of class like entities
// are executed in constructor and thus deferred
if (current.parent.kind === SyntaxKind.PropertyDeclaration &&
!(hasModifier(current.parent, ModifierFlags.Static)) &&
isClassLike(current.parent.parent)) {
return;
}
current = current.parent;
if (findAncestor(
n,
current => {
if (current === node.initializer) {
return "quit";
}
return isFunctionLike(current.parent) ||
// computed property names/initializers in instance property declaration of class like entities
// are executed in constructor and thus deferred
(current.parent.kind === SyntaxKind.PropertyDeclaration &&
!(hasModifier(current.parent, ModifierFlags.Static)) &&
isClassLike(current.parent.parent));
})) {
return;
}
// fall through to report error
}
@@ -20035,18 +19992,17 @@ namespace ts {
function checkLabeledStatement(node: LabeledStatement) {
// Grammar checking
if (!checkGrammarStatementInAmbientContext(node)) {
let current = node.parent;
while (current) {
if (isFunctionLike(current)) {
break;
}
if (current.kind === SyntaxKind.LabeledStatement && (<LabeledStatement>current).label.text === node.label.text) {
const sourceFile = getSourceFileOfNode(node);
grammarErrorOnNode(node.label, Diagnostics.Duplicate_label_0, getTextOfNodeFromSourceText(sourceFile.text, node.label));
break;
}
current = current.parent;
}
findAncestor(node.parent,
current => {
if (isFunctionLike(current)) {
return "quit";
}
if (current.kind === SyntaxKind.LabeledStatement && (<LabeledStatement>current).label.text === node.label.text) {
const sourceFile = getSourceFileOfNode(node);
grammarErrorOnNode(node.label, Diagnostics.Duplicate_label_0, getTextOfNodeFromSourceText(sourceFile.text, node.label));
return true;
}
});
}
// ensure that label is unique
@@ -20531,7 +20487,7 @@ namespace ts {
errorMessage = Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function;
}
error(derived.valueDeclaration.name, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type));
error(derived.valueDeclaration.name || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type));
}
}
}
@@ -21045,7 +21001,7 @@ namespace ts {
}
break;
}
// fallthrough
// falls through
case SyntaxKind.ClassDeclaration:
case SyntaxKind.EnumDeclaration:
case SyntaxKind.FunctionDeclaration:
@@ -21680,6 +21636,7 @@ namespace ts {
if (!isExternalOrCommonJsModule(<SourceFile>location)) {
break;
}
// falls through
case SyntaxKind.ModuleDeclaration:
copySymbols(getSymbolOfNode(location).exports, meaning & SymbolFlags.ModuleMember);
break;
@@ -21691,7 +21648,8 @@ namespace ts {
if (className) {
copySymbol(location.symbol, meaning);
}
// fall through; this fall-through is necessary because we would like to handle
// falls through
// this fall-through is necessary because we would like to handle
// type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration
case SyntaxKind.ClassDeclaration:
case SyntaxKind.InterfaceDeclaration:
@@ -21980,7 +21938,7 @@ namespace ts {
return sig.thisParameter;
}
}
// fallthrough
// falls through
case SyntaxKind.SuperKeyword:
const type = isPartOfExpression(node) ? getTypeOfExpression(<Expression>node) : getTypeFromTypeNode(<TypeNode>node);
@@ -22008,7 +21966,7 @@ namespace ts {
if (isInJavaScriptFile(node) && isRequireCall(node.parent, /*checkArgumentIsStringLiteral*/ false)) {
return resolveExternalModuleName(node, <LiteralExpression>node);
}
// Fall through
// falls through
case SyntaxKind.NumericLiteral:
// index access
@@ -22299,11 +22257,7 @@ namespace ts {
const symbolIsUmdExport = symbolFile !== referenceFile;
return symbolIsUmdExport ? undefined : symbolFile;
}
for (let n = node.parent; n; n = n.parent) {
if (isModuleOrEnumDeclaration(n) && getSymbolOfNode(n) === parentSymbol) {
return <ModuleDeclaration | EnumDeclaration>n;
}
}
return findAncestor(node.parent, n => isModuleOrEnumDeclaration(n) && getSymbolOfNode(n) === parentSymbol) as ModuleDeclaration | EnumDeclaration;
}
}
}
+19
View File
@@ -224,6 +224,25 @@ namespace ts {
}
return undefined;
}
/**
* Iterates through the parent chain of a node and performs the callback on each parent until the callback
* returns a truthy value, then returns that value.
* If no such value is found, it applies the callback until the parent pointer is undefined or the callback returns "quit"
* At that point findAncestor returns undefined.
*/
export function findAncestor(node: Node, callback: (element: Node) => boolean | "quit"): Node {
while (node) {
const result = callback(node);
if (result === "quit") {
return undefined;
}
else if (result) {
return node;
}
node = node.parent;
}
return undefined;
}
export function zipWith<T, U>(arrayA: T[], arrayB: U[], callback: (a: T, b: U, index: number) => void): void {
Debug.assert(arrayA.length === arrayB.length);
+4
View File
@@ -3197,6 +3197,10 @@
"category": "Message",
"code": 6181
},
"Scoped package detected, looking in '{0}'": {
"category": "Message",
"code": "6182"
},
"Variable '{0}' implicitly has an '{1}' type.": {
"category": "Error",
+17 -2
View File
@@ -378,7 +378,7 @@ namespace ts {
directoryPathMap.set(parent, result);
current = parent;
if (current == commonPrefix) {
if (current === commonPrefix) {
break;
}
}
@@ -954,10 +954,25 @@ namespace ts {
}
nodeModulesAtTypesExists = false;
}
return loadModuleFromNodeModulesFolder(Extensions.DtsOnly, moduleName, nodeModulesAtTypes, nodeModulesAtTypesExists, failedLookupLocations, state);
return loadModuleFromNodeModulesFolder(Extensions.DtsOnly, mangleScopedPackage(moduleName, state), nodeModulesAtTypes, nodeModulesAtTypesExists, failedLookupLocations, state);
}
}
/** For a scoped package, we must look in `@types/foo__bar` instead of `@types/@foo/bar`. */
function mangleScopedPackage(moduleName: string, state: ModuleResolutionState): string {
if (startsWith(moduleName, "@")) {
const replaceSlash = moduleName.replace(ts.directorySeparator, "__");
if (replaceSlash !== moduleName) {
const mangled = replaceSlash.slice(1); // Take off the "@"
if (state.traceEnabled) {
trace(state.host, Diagnostics.Scoped_package_detected_looking_in_0, mangled);
}
return mangled;
}
}
return moduleName;
}
function tryFindNonRelativeModuleNameInCache(cache: PerModuleNameCache | undefined, moduleName: string, containingDirectory: string, traceEnabled: boolean, host: ModuleResolutionHost): SearchResult<Resolved> {
const result = cache && cache.get(containingDirectory);
if (result) {
+7 -4
View File
@@ -57,7 +57,7 @@ namespace ts {
// The visitXXX functions could be written as local functions that close over the cbNode and cbNodeArray
// callback parameters, but that causes a closure allocation for each invocation with noticeable effects
// on performance.
const visitNodes: (cb: (node: Node | Node[]) => T, nodes: Node[]) => T = cbNodeArray ? visitNodeArray : visitEachNode;
const visitNodes: (cb: ((node: Node) => T) | ((node: Node[]) => T), nodes: Node[]) => T = cbNodeArray ? visitNodeArray : visitEachNode;
const cbNodes = cbNodeArray || cbNode;
switch (node.kind) {
case SyntaxKind.QualifiedName:
@@ -3573,6 +3573,7 @@ namespace ts {
if (isAwaitExpression()) {
return parseAwaitExpression();
}
// falls through
default:
return parseIncrementExpression();
}
@@ -3606,8 +3607,8 @@ namespace ts {
if (sourceFile.languageVariant !== LanguageVariant.JSX) {
return false;
}
// We are in JSX context and the token is part of JSXElement.
// Fall through
// We are in JSX context and the token is part of JSXElement.
// falls through
default:
return true;
}
@@ -6571,7 +6572,8 @@ namespace ts {
indent += scanner.getTokenText().length;
break;
}
// FALLTHROUGH otherwise to record the * as a comment
// record the * as a comment
// falls through
default:
state = JSDocState.SavingComments; // leading identifiers start recording as well
pushComment(scanner.getTokenText());
@@ -6797,6 +6799,7 @@ namespace ts {
break;
case SyntaxKind.Identifier:
canParseTag = false;
break;
case SyntaxKind.EndOfFileToken:
break;
}
+21 -19
View File
@@ -557,7 +557,7 @@ namespace ts {
// combine results of resolutions and predicted results
let j = 0;
for (let i = 0; i < result.length; i++) {
if (result[i] == predictedToResolveToAmbientModuleMarker) {
if (result[i] === predictedToResolveToAmbientModuleMarker) {
result[i] = undefined;
}
else {
@@ -930,20 +930,22 @@ namespace ts {
*/
function shouldReportDiagnostic(diagnostic: Diagnostic) {
const { file, start } = diagnostic;
const lineStarts = getLineStarts(file);
let { line } = computeLineAndCharacterOfPosition(lineStarts, start);
while (line > 0) {
const previousLineText = file.text.slice(lineStarts[line - 1], lineStarts[line]);
const result = ignoreDiagnosticCommentRegEx.exec(previousLineText);
if (!result) {
// non-empty line
return true;
if (file) {
const lineStarts = getLineStarts(file);
let { line } = computeLineAndCharacterOfPosition(lineStarts, start);
while (line > 0) {
const previousLineText = file.text.slice(lineStarts[line - 1], lineStarts[line]);
const result = ignoreDiagnosticCommentRegEx.exec(previousLineText);
if (!result) {
// non-empty line
return true;
}
if (result[3]) {
// @ts-ignore
return false;
}
line--;
}
if (result[3]) {
// @ts-ignore
return false;
}
line--;
}
return true;
}
@@ -967,8 +969,7 @@ namespace ts {
diagnostics.push(createDiagnosticForNode(node, Diagnostics._0_can_only_be_used_in_a_ts_file, "?"));
return;
}
// Pass through
// falls through
case SyntaxKind.MethodDeclaration:
case SyntaxKind.MethodSignature:
case SyntaxKind.Constructor:
@@ -1048,7 +1049,7 @@ namespace ts {
diagnostics.push(createDiagnosticForNodeArray(nodes, Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file));
return;
}
// pass through
// falls through
case SyntaxKind.VariableStatement:
// Check modifiers
if (nodes === (<ClassDeclaration | FunctionLikeDeclaration | VariableStatement>parent).modifiers) {
@@ -1096,7 +1097,8 @@ namespace ts {
if (isConstValid) {
continue;
}
// Fallthrough to report error
// to report error,
// falls through
case SyntaxKind.PublicKeyword:
case SyntaxKind.PrivateKeyword:
case SyntaxKind.ProtectedKeyword:
@@ -1364,7 +1366,7 @@ namespace ts {
// If the file was previously found via a node_modules search, but is now being processed as a root file,
// then everything it sucks in may also be marked incorrectly, and needs to be checked again.
if (file && sourceFilesFoundSearchingNodeModules.get(file.path) && currentNodeModulesDepth == 0) {
if (file && sourceFilesFoundSearchingNodeModules.get(file.path) && currentNodeModulesDepth === 0) {
sourceFilesFoundSearchingNodeModules.set(file.path, false);
if (!options.noResolve) {
processReferencedFiles(file, isDefaultLib);
+5 -1
View File
@@ -308,6 +308,7 @@ namespace ts {
if (text.charCodeAt(pos) === CharacterCodes.lineFeed) {
pos++;
}
// falls through
case CharacterCodes.lineFeed:
result.push(lineStart);
lineStart = pos;
@@ -454,6 +455,7 @@ namespace ts {
if (text.charCodeAt(pos + 1) === CharacterCodes.lineFeed) {
pos++;
}
// falls through
case CharacterCodes.lineFeed:
pos++;
if (stopAfterLineBreak) {
@@ -625,6 +627,7 @@ namespace ts {
if (text.charCodeAt(pos + 1) === CharacterCodes.lineFeed) {
pos++;
}
// falls through
case CharacterCodes.lineFeed:
pos++;
if (trailing) {
@@ -1072,7 +1075,7 @@ namespace ts {
if (pos < end && text.charCodeAt(pos) === CharacterCodes.lineFeed) {
pos++;
}
// fall through
// falls through
case CharacterCodes.lineFeed:
case CharacterCodes.lineSeparator:
case CharacterCodes.paragraphSeparator:
@@ -1459,6 +1462,7 @@ namespace ts {
// This fall-through is a deviation from the EcmaScript grammar. The grammar says that a leading zero
// can only be followed by an octal digit, a dot, or the end of the number literal. However, we are being
// permissive and allowing decimal digits of the form 08* and 09* (which many browsers also do).
// falls through
case CharacterCodes._1:
case CharacterCodes._2:
case CharacterCodes._3:
+1 -1
View File
@@ -479,8 +479,8 @@ namespace ts {
// module is imported only for side-effects, no emit required
break;
}
// falls through
// fall-through
case SyntaxKind.ImportEqualsDeclaration:
Debug.assert(importVariableName !== undefined);
// save import into the local
+3 -3
View File
@@ -30,7 +30,7 @@ namespace ts {
}
function reportEmittedFiles(files: string[]): void {
if (!files || files.length == 0) {
if (!files || files.length === 0) {
return;
}
@@ -282,7 +282,7 @@ namespace ts {
// When the configFileName is just "tsconfig.json", the watched directory should be
// the current directory; if there is a given "project" parameter, then the configFileName
// is an absolute file name.
directory == "" ? "." : directory,
directory === "" ? "." : directory,
watchedDirectoryChanged, /*recursive*/ true);
}
}
@@ -334,7 +334,7 @@ namespace ts {
// When the configFileName is just "tsconfig.json", the watched directory should be
// the current directory; if there is a given "project" parameter, then the configFileName
// is an absolute file name.
directory == "" ? "." : directory,
directory === "" ? "." : directory,
watchedDirectoryChanged, /*recursive*/ true);
}
}
+8 -5
View File
@@ -674,6 +674,7 @@ namespace ts {
// At this point, node is either a qualified name or an identifier
Debug.assert(node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.QualifiedName || node.kind === SyntaxKind.PropertyAccessExpression,
"'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'.");
// falls through
case SyntaxKind.QualifiedName:
case SyntaxKind.PropertyAccessExpression:
case SyntaxKind.ThisKeyword:
@@ -783,6 +784,7 @@ namespace ts {
if (operand) {
traverse(operand);
}
return;
case SyntaxKind.EnumDeclaration:
case SyntaxKind.InterfaceDeclaration:
case SyntaxKind.ModuleDeclaration:
@@ -1000,7 +1002,7 @@ namespace ts {
if (!includeArrowFunctions) {
continue;
}
// Fall through
// falls through
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.FunctionExpression:
case SyntaxKind.ModuleDeclaration:
@@ -1059,6 +1061,7 @@ namespace ts {
if (!stopOnFunctions) {
continue;
}
// falls through
case SyntaxKind.PropertyDeclaration:
case SyntaxKind.PropertySignature:
case SyntaxKind.MethodDeclaration:
@@ -1258,7 +1261,7 @@ namespace ts {
if (node.parent.kind === SyntaxKind.TypeQuery || isJSXTagName(node)) {
return true;
}
// fall through
// falls through
case SyntaxKind.NumericLiteral:
case SyntaxKind.StringLiteral:
case SyntaxKind.ThisKeyword:
@@ -1940,7 +1943,7 @@ namespace ts {
if (node.asteriskToken) {
flags |= FunctionFlags.Generator;
}
// fall through
// falls through
case SyntaxKind.ArrowFunction:
if (hasModifier(node, ModifierFlags.Async)) {
flags |= FunctionFlags.Async;
@@ -4428,7 +4431,7 @@ namespace ts {
newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2));
}
return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), /*newLength:*/ newEndN - oldStartN);
return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), /*newLength*/ newEndN - oldStartN);
}
export function getTypeParameterOwner(d: Declaration): Declaration {
@@ -4604,7 +4607,7 @@ namespace ts {
*/
export function getParseTreeNode<T extends Node>(node: Node, nodeTest?: (node: Node) => node is T): T;
export function getParseTreeNode(node: Node, nodeTest?: (node: Node) => boolean): Node {
if (node == undefined || isParseTreeNode(node)) {
if (node === undefined || isParseTreeNode(node)) {
return node;
}
+5 -3
View File
@@ -322,7 +322,7 @@ namespace ts {
nodesVisitor((<UnionOrIntersectionTypeNode>node).types, visitor, isTypeNode));
case SyntaxKind.ParenthesizedType:
Debug.fail("not implemented.");
throw Debug.fail("not implemented.");
case SyntaxKind.TypeOperator:
return updateTypeOperatorNode(<TypeOperatorNode>node, visitNode((<TypeOperatorNode>node).type, visitor, isTypeNode));
@@ -885,7 +885,7 @@ namespace ts {
return initial;
}
const reduceNodes: (nodes: NodeArray<Node>, f: (memo: T, node: Node | NodeArray<Node>) => T, initial: T) => T = cbNodeArray ? reduceNodeArray : reduceLeft;
const reduceNodes: (nodes: NodeArray<Node>, f: ((memo: T, node: Node) => T) | ((memo: T, node: NodeArray<Node>) => T), initial: T) => T = cbNodeArray ? reduceNodeArray : reduceLeft;
const cbNodes = cbNodeArray || cbNode;
const kind = node.kind;
@@ -1289,6 +1289,7 @@ namespace ts {
case SyntaxKind.JsxAttributes:
result = reduceNodes((<JsxAttributes>node).properties, cbNodes, result);
break;
case SyntaxKind.JsxClosingElement:
result = reduceNode((<JsxClosingElement>node).tagName, cbNode, result);
@@ -1310,7 +1311,7 @@ namespace ts {
// Clauses
case SyntaxKind.CaseClause:
result = reduceNode((<CaseClause>node).expression, cbNode, result);
// fall-through
// falls through
case SyntaxKind.DefaultClause:
result = reduceNodes((<CaseClause | DefaultClause>node).statements, cbNodes, result);
@@ -1344,6 +1345,7 @@ namespace ts {
case SyntaxKind.EnumMember:
result = reduceNode((<EnumMember>node).name, cbNode, result);
result = reduceNode((<EnumMember>node).initializer, cbNode, result);
break;
// Top-level nodes
case SyntaxKind.SourceFile:
+4 -5
View File
@@ -2367,13 +2367,13 @@ namespace FourSlash {
public verifyImportFixAtPosition(expectedTextArray: string[], errorCode?: number) {
const ranges = this.getRanges();
if (ranges.length == 0) {
if (ranges.length === 0) {
this.raiseError("At least one range should be specified in the testfile.");
}
const codeFixes = this.getCodeFixActions(this.activeFile.fileName, errorCode);
if (!codeFixes || codeFixes.length == 0) {
if (!codeFixes || codeFixes.length === 0) {
this.raiseError("No codefixes returned.");
}
@@ -2738,7 +2738,7 @@ namespace FourSlash {
private assertItemInCompletionList(items: ts.CompletionEntry[], name: string, text?: string, documentation?: string, kind?: string, spanIndex?: number) {
for (const item of items) {
if (item.name === name) {
if (documentation != undefined || text !== undefined) {
if (documentation !== undefined || text !== undefined) {
const details = this.getCompletionEntryDetails(item.name);
if (documentation !== undefined) {
@@ -2989,9 +2989,8 @@ ${code}
}
}
}
// TODO: should be '==='?
}
else if (line == "" || lineLength === 0) {
else if (line === "" || lineLength === 0) {
// Previously blank lines between fourslash content caused it to be considered as 2 files,
// Remove this behavior since it just causes errors now
}
+1 -1
View File
@@ -1933,7 +1933,7 @@ namespace Harness {
}
const parentDirectory = IO.directoryName(dirName);
if (parentDirectory != "") {
if (parentDirectory !== "") {
createDirectoryStructure(parentDirectory);
}
IO.createDirectory(dirName);
+1 -2
View File
@@ -111,8 +111,7 @@ class ProjectRunner extends RunnerBase {
else if (url.indexOf(diskProjectPath) === 0) {
// Replace the disk specific path into the project root path
url = url.substr(diskProjectPath.length);
// TODO: should be '!=='?
if (url.charCodeAt(0) != ts.CharacterCodes.slash) {
if (url.charCodeAt(0) !== ts.CharacterCodes.slash) {
url = "/" + url;
}
}
+4 -4
View File
@@ -50,11 +50,11 @@ namespace Harness.SourceMapRecorder {
return true;
}
if (sourceMapMappings.charAt(decodingIndex) == ",") {
if (sourceMapMappings.charAt(decodingIndex) === ",") {
return true;
}
if (sourceMapMappings.charAt(decodingIndex) == ";") {
if (sourceMapMappings.charAt(decodingIndex) === ";") {
return true;
}
@@ -117,7 +117,7 @@ namespace Harness.SourceMapRecorder {
}
while (decodingIndex < sourceMapMappings.length) {
if (sourceMapMappings.charAt(decodingIndex) == ";") {
if (sourceMapMappings.charAt(decodingIndex) === ";") {
// New line
decodeOfEncodedMapping.emittedLine++;
decodeOfEncodedMapping.emittedColumn = 1;
@@ -125,7 +125,7 @@ namespace Harness.SourceMapRecorder {
continue;
}
if (sourceMapMappings.charAt(decodingIndex) == ",") {
if (sourceMapMappings.charAt(decodingIndex) === ",") {
// Next entry is on same line - no action needed
decodingIndex++;
continue;
@@ -3228,7 +3228,7 @@ namespace ts.projectSystem {
checkNumberOfInferredProjects(projectService, 1);
const configuredProject = projectService.configuredProjects[0];
assert.isTrue(configuredProject.getFileNames().length == 0);
assert.isTrue(configuredProject.getFileNames().length === 0);
const inferredProject = projectService.inferredProjects[0];
assert.isTrue(inferredProject.containsFile(<server.NormalizedPath>file1.path));
+1 -1
View File
@@ -278,7 +278,7 @@ and grew 1cm per day`;
const insertString = testContent.substring(rsa[i], rsa[i] + las[i]);
svc.edit(ersa[i], elas[i], insertString);
checkText = editFlat(ersa[i], elas[i], insertString, checkText);
if (0 == (i % 4)) {
if (0 === (i % 4)) {
const snap = svc.getSnapshot();
const snapText = snap.getText(0, checkText.length);
assert.equal(checkText, snapText);
+3 -3
View File
@@ -257,7 +257,7 @@ namespace ts.server {
startWatchingContainingDirectoriesForFile(fileName: string, project: InferredProject, callback: (fileName: string) => void) {
let currentPath = getDirectoryPath(fileName);
let parentPath = getDirectoryPath(currentPath);
while (currentPath != parentPath) {
while (currentPath !== parentPath) {
if (!this.directoryWatchersForTsconfig.has(currentPath)) {
this.projectService.logger.info(`Add watcher for: ${currentPath}`);
this.directoryWatchersForTsconfig.set(currentPath, this.projectService.host.watchDirectory(currentPath, callback));
@@ -618,7 +618,7 @@ namespace ts.server {
*/
private onConfigFileAddedForInferredProject(fileName: string) {
// TODO: check directory separators
if (getBaseFileName(fileName) != "tsconfig.json") {
if (getBaseFileName(fileName) !== "tsconfig.json") {
this.logger.info(`${fileName} is not tsconfig.json`);
return;
}
@@ -1033,7 +1033,7 @@ namespace ts.server {
const scriptKind = propertyReader.getScriptKind(f);
const hasMixedContent = propertyReader.hasMixedContent(f, this.hostConfiguration.extraFileExtensions);
if (this.host.fileExists(rootFilename)) {
const info = this.getOrCreateScriptInfoForNormalizedPath(toNormalizedPath(rootFilename), /*openedByClient*/ clientFileName == rootFilename, /*fileContent*/ undefined, scriptKind, hasMixedContent);
const info = this.getOrCreateScriptInfoForNormalizedPath(toNormalizedPath(rootFilename), /*openedByClient*/ clientFileName === rootFilename, /*fileContent*/ undefined, scriptKind, hasMixedContent);
project.addRoot(info);
}
else {
+1 -1
View File
@@ -643,7 +643,7 @@ namespace ts.server {
// check if requested version is the same that we have reported last time
if (this.lastReportedFileNames && lastKnownVersion === this.lastReportedVersion) {
// if current structure version is the same - return info without any changes
if (this.projectStructureVersion == this.lastReportedVersion && !updatedFileNames) {
if (this.projectStructureVersion === this.lastReportedVersion && !updatedFileNames) {
return { info, projectErrors: this.projectErrors };
}
// compute and return the difference
+2 -2
View File
@@ -79,7 +79,7 @@ namespace ts.server {
const lm = LineIndex.linesFromText(insertedText);
const lines = lm.lines;
if (lines.length > 1) {
if (lines[lines.length - 1] == "") {
if (lines[lines.length - 1] === "") {
lines.length--;
}
}
@@ -570,7 +570,7 @@ namespace ts.server {
}
if (this.checkEdits) {
const updatedText = this.getText(0, this.root.charCount());
Debug.assert(checkText == updatedText, "buffer edit mismatch");
Debug.assert(checkText === updatedText, "buffer edit mismatch");
}
return walker.lineIndex;
}
+4 -2
View File
@@ -380,7 +380,7 @@ namespace ts.server {
}
this.projectService.updateTypingsForProject(response);
if (response.kind == ActionSet && this.socket) {
if (response.kind === ActionSet && this.socket) {
this.sendEvent(0, "setTypings", response);
}
}
@@ -401,7 +401,9 @@ namespace ts.server {
byteLength: Buffer.byteLength,
hrtime: process.hrtime,
logger,
canUseEvents});
canUseEvents,
globalPlugins: options.globalPlugins,
pluginProbeLocations: options.pluginProbeLocations});
if (telemetryEnabled && typingsInstaller) {
typingsInstaller.setTelemetrySender(this);
+6 -6
View File
@@ -49,7 +49,7 @@ namespace ts.server {
if (a.file < b.file) {
return -1;
}
else if (a.file == b.file) {
else if (a.file === b.file) {
const n = compareNumber(a.start.line, b.start.line);
if (n === 0) {
return compareNumber(a.start.offset, b.start.offset);
@@ -1128,7 +1128,7 @@ namespace ts.server {
// getFormattingEditsAfterKeystroke either empty or pertaining
// only to the previous line. If all this is true, then
// add edits necessary to properly indent the current line.
if ((args.key == "\n") && ((!edits) || (edits.length === 0) || allEditsBeforePos(edits, position))) {
if ((args.key === "\n") && ((!edits) || (edits.length === 0) || allEditsBeforePos(edits, position))) {
const lineInfo = scriptInfo.getLineInfo(args.line);
if (lineInfo && (lineInfo.leaf) && (lineInfo.leaf.text)) {
const lineText = lineInfo.leaf.text;
@@ -1137,10 +1137,10 @@ namespace ts.server {
let hasIndent = 0;
let i: number, len: number;
for (i = 0, len = lineText.length; i < len; i++) {
if (lineText.charAt(i) == " ") {
if (lineText.charAt(i) === " ") {
hasIndent++;
}
else if (lineText.charAt(i) == "\t") {
else if (lineText.charAt(i) === "\t") {
hasIndent += formatOptions.tabSize;
}
else {
@@ -1543,7 +1543,7 @@ namespace ts.server {
const normalizedFileName = toNormalizedPath(fileName);
const project = this.projectService.getDefaultProjectForFile(normalizedFileName, /*refreshInferredProjects*/ true);
for (const fileNameInProject of fileNamesInProject) {
if (this.getCanonicalFileName(fileNameInProject) == this.getCanonicalFileName(fileName))
if (this.getCanonicalFileName(fileNameInProject) === this.getCanonicalFileName(fileName))
highPriorityFiles.push(fileNameInProject);
else {
const info = this.projectService.getScriptInfo(fileNameInProject);
@@ -1564,7 +1564,7 @@ namespace ts.server {
const checkList = fileNamesInProject.map(fileName => ({ fileName, project }));
// Project level error analysis runs on background files too, therefore
// doesn't require the file to be opened
this.updateErrorCheck(next, checkList, this.changeSeq, (n) => n == this.changeSeq, delay, 200, /*requireOpen*/ false);
this.updateErrorCheck(next, checkList, this.changeSeq, (n) => n === this.changeSeq, delay, 200, /*requireOpen*/ false);
}
}
+1 -1
View File
@@ -61,7 +61,7 @@ namespace ts.server {
function compilerOptionsChanged(opt1: CompilerOptions, opt2: CompilerOptions): boolean {
// TODO: add more relevant properties
return opt1.allowJs != opt2.allowJs;
return opt1.allowJs !== opt2.allowJs;
}
function unresolvedImportsChanged(imports1: SortedReadonlyArray<string>, imports2: SortedReadonlyArray<string>): boolean {
@@ -31,7 +31,7 @@ namespace ts.server.typingsInstaller {
}
function getNPMLocation(processName: string) {
if (path.basename(processName).indexOf("node") == 0) {
if (path.basename(processName).indexOf("node") === 0) {
return `"${path.join(path.dirname(process.argv[0]), "npm")}"`;
}
else {
+1 -1
View File
@@ -219,7 +219,7 @@ namespace ts.server {
}
public scheduleCollect() {
if (!this.host.gc || this.timerId != undefined) {
if (!this.host.gc || this.timerId !== undefined) {
// no global.gc or collection was already scheduled - skip this request
return;
}
+6 -3
View File
@@ -97,7 +97,7 @@ namespace ts.BreakpointResolver {
if (isFunctionBlock(node)) {
return spanInFunctionBlock(<Block>node);
}
// Fall through
// falls through
case SyntaxKind.ModuleBlock:
return spanInBlock(<Block>node);
@@ -186,6 +186,7 @@ namespace ts.BreakpointResolver {
if (getModuleInstanceState(node) !== ModuleInstanceState.Instantiated) {
return undefined;
}
// falls through
case SyntaxKind.ClassDeclaration:
case SyntaxKind.EnumDeclaration:
@@ -264,7 +265,7 @@ namespace ts.BreakpointResolver {
// a or ...c or d: x from
// [a, b, ...c] or { a, b } or { d: x } from destructuring pattern
if ((node.kind === SyntaxKind.Identifier ||
node.kind == SyntaxKind.SpreadElement ||
node.kind === SyntaxKind.SpreadElement ||
node.kind === SyntaxKind.PropertyAssignment ||
node.kind === SyntaxKind.ShorthandPropertyAssignment) &&
isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) {
@@ -473,6 +474,7 @@ namespace ts.BreakpointResolver {
if (getModuleInstanceState(block.parent) !== ModuleInstanceState.Instantiated) {
return undefined;
}
// falls through
// Set on parent if on same line otherwise on first statement
case SyntaxKind.WhileStatement:
@@ -582,6 +584,7 @@ namespace ts.BreakpointResolver {
if (getModuleInstanceState(node.parent.parent) !== ModuleInstanceState.Instantiated) {
return undefined;
}
// falls through
case SyntaxKind.EnumDeclaration:
case SyntaxKind.ClassDeclaration:
@@ -593,7 +596,7 @@ namespace ts.BreakpointResolver {
// Span on close brace token
return textSpan(node);
}
// fall through
// falls through
case SyntaxKind.CatchClause:
return spanInNode(lastOrUndefined((<Block>node.parent).statements));
+1 -1
View File
@@ -160,7 +160,7 @@ namespace ts {
case EndOfLineState.InTemplateMiddleOrTail:
text = "}\n" + text;
offset = 2;
// fallthrough
// falls through
case EndOfLineState.InTemplateSubstitutionPosition:
templateStack.push(SyntaxKind.TemplateHead);
break;
@@ -14,7 +14,7 @@ namespace ts.codefix {
// ^^^^^^^
const token = getTokenAtPosition(sourceFile, start);
if (token.kind != SyntaxKind.Identifier) {
if (token.kind !== SyntaxKind.Identifier) {
return undefined;
}
@@ -18,7 +18,7 @@ namespace ts.codefix {
// figure out if the `this` access is actually inside the supercall
// i.e. super(this.a), since in that case we won't suggest a fix
if (superCall.expression && superCall.expression.kind == SyntaxKind.CallExpression) {
if (superCall.expression && superCall.expression.kind === SyntaxKind.CallExpression) {
const arguments = (<CallExpression>superCall.expression).arguments;
for (let i = 0; i < arguments.length; i++) {
if ((<PropertyAccessExpression>arguments[i]).expression === token) {
+2 -1
View File
@@ -42,12 +42,13 @@ namespace ts.codefix {
switch (this.compareModuleSpecifiers(existingAction.moduleSpecifier, newAction.moduleSpecifier)) {
case ModuleSpecifierComparison.Better:
// the new one is not worth considering if it is a new improt.
// the new one is not worth considering if it is a new import.
// However if it is instead a insertion into existing import, the user might want to use
// the module specifier even it is worse by our standards. So keep it.
if (newAction.kind === "NewImport") {
return;
}
// falls through
case ModuleSpecifierComparison.Equal:
// the current one is safe. But it is still possible that the new one is worse
// than another existing one. For example, you may have new imports from "./foo/bar"
@@ -58,6 +58,8 @@ namespace ts.codefix {
return deleteNodeInList(token.parent);
}
}
// TODO: #14885
// falls through
case SyntaxKind.TypeParameter:
const typeParameters = (<DeclarationWithTypeParameters>token.parent.parent).typeParameters;
@@ -125,7 +127,7 @@ namespace ts.codefix {
case SyntaxKind.NamespaceImport:
const namespaceImport = <NamespaceImport>token.parent;
if (namespaceImport.name == token && !(<ImportClause>namespaceImport.parent).name) {
if (namespaceImport.name === token && !(<ImportClause>namespaceImport.parent).name) {
const importDecl = getAncestor(namespaceImport, SyntaxKind.ImportDeclaration);
return deleteNode(importDecl);
}
+2 -2
View File
@@ -487,7 +487,7 @@ namespace ts.Completions {
// It has a left-hand side, so we're not in an opening JSX tag.
break;
}
// fall through
// falls through
case SyntaxKind.JsxSelfClosingElement:
case SyntaxKind.JsxElement:
@@ -1311,7 +1311,7 @@ namespace ts.Completions {
}
function isEqualityOperatorKind(kind: SyntaxKind) {
return kind == SyntaxKind.EqualsEqualsToken ||
return kind === SyntaxKind.EqualsEqualsToken ||
kind === SyntaxKind.ExclamationEqualsToken ||
kind === SyntaxKind.EqualsEqualsEqualsToken ||
kind === SyntaxKind.ExclamationEqualsEqualsToken;
+1 -1
View File
@@ -233,7 +233,7 @@ namespace ts.DocumentHighlights {
if (statement.kind === SyntaxKind.ContinueStatement) {
continue;
}
// Fall through.
// falls through
case SyntaxKind.ForStatement:
case SyntaxKind.ForInStatement:
case SyntaxKind.ForOfStatement:
+4 -4
View File
@@ -7,7 +7,7 @@ namespace ts.FindAllReferences {
references: Entry[];
}
type Definition =
export type Definition =
| { type: "symbol"; symbol: Symbol; node: Node }
| { type: "label"; node: Identifier }
| { type: "keyword"; node: ts.Node }
@@ -20,7 +20,7 @@ namespace ts.FindAllReferences {
node: Node;
isInString?: true;
}
interface SpanEntry {
export interface SpanEntry {
type: "span";
fileName: string;
textSpan: TextSpan;
@@ -1234,7 +1234,7 @@ namespace ts.FindAllReferences.Core {
if (isObjectLiteralMethod(searchSpaceNode)) {
break;
}
// fall through
// falls through
case SyntaxKind.PropertyDeclaration:
case SyntaxKind.PropertySignature:
case SyntaxKind.Constructor:
@@ -1247,7 +1247,7 @@ namespace ts.FindAllReferences.Core {
if (isExternalModule(<SourceFile>searchSpaceNode)) {
return undefined;
}
// Fall through
// falls through
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.FunctionExpression:
break;
+2 -3
View File
@@ -483,9 +483,8 @@ namespace ts.formatting {
case SyntaxKind.MethodDeclaration:
if ((<MethodDeclaration>node).asteriskToken) {
return SyntaxKind.AsteriskToken;
}/*
fall-through
*/
}
// falls through
case SyntaxKind.PropertyDeclaration:
case SyntaxKind.Parameter:
return (<Declaration>node).name.kind;
+1 -1
View File
@@ -146,7 +146,7 @@ namespace ts.OutliningElementsCollector {
});
break;
}
// Fallthrough.
// falls through
case SyntaxKind.ModuleBlock: {
const openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile);
+3 -2
View File
@@ -659,7 +659,7 @@ namespace ts {
if (!hasModifier(node, ModifierFlags.ParameterPropertyModifier)) {
break;
}
// fall through
// falls through
case SyntaxKind.VariableDeclaration:
case SyntaxKind.BindingElement: {
const decl = <VariableDeclaration>node;
@@ -670,6 +670,7 @@ namespace ts {
if (decl.initializer)
visit(decl.initializer);
}
// falls through
case SyntaxKind.EnumMember:
case SyntaxKind.PropertyDeclaration:
case SyntaxKind.PropertySignature:
@@ -2079,7 +2080,7 @@ namespace ts {
if (node.parent.kind === SyntaxKind.ComputedPropertyName) {
return isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined;
}
// intentionally fall through
// falls through
case SyntaxKind.Identifier:
return isObjectLiteralElement(node.parent) &&
(node.parent.parent.kind === SyntaxKind.ObjectLiteralExpression || node.parent.parent.kind === SyntaxKind.JsxAttributes) &&
+4 -6
View File
@@ -37,7 +37,7 @@ namespace ts {
*
* Or undefined value if there was no change.
*/
getChangeRange(oldSnapshot: ScriptSnapshotShim): string;
getChangeRange(oldSnapshot: ScriptSnapshotShim): string | undefined;
/** Releases all resources held by this script snapshot */
dispose?(): void;
@@ -292,8 +292,7 @@ namespace ts {
public getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange {
const oldSnapshotShim = <ScriptSnapshotShimAdapter>oldSnapshot;
const encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim);
// TODO: should this be '==='?
if (encoded == null) {
if (encoded === null) {
return null;
}
@@ -381,8 +380,7 @@ namespace ts {
public getCompilationSettings(): CompilerOptions {
const settingsJson = this.shimHost.getCompilationSettings();
// TODO: should this be '==='?
if (settingsJson == null || settingsJson == "") {
if (settingsJson === null || settingsJson === "") {
throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings");
}
const compilerOptions = <CompilerOptions>JSON.parse(settingsJson);
@@ -416,7 +414,7 @@ namespace ts {
public getLocalizedDiagnosticMessages(): any {
const diagnosticMessagesJson = this.shimHost.getLocalizedDiagnosticMessages();
if (diagnosticMessagesJson == null || diagnosticMessagesJson == "") {
if (diagnosticMessagesJson === null || diagnosticMessagesJson === "") {
return null;
}
+1 -1
View File
@@ -56,7 +56,7 @@ namespace ts.SignatureHelp {
// break;
// case TypeScript.SyntaxKind.CommaToken:
// if (stack == 0) {
// if (stack === 0) {
// argumentIndex++;
// }
+1 -1
View File
@@ -465,7 +465,7 @@ namespace ts.textChanges {
change.options.indentation !== undefined
? change.options.indentation
: change.useIndentationFromFile
? formatting.SmartIndenter.getIndentation(change.range.pos, sourceFile, formatOptions, posStartsLine || (change.options.prefix == this.newLineCharacter))
? formatting.SmartIndenter.getIndentation(change.range.pos, sourceFile, formatOptions, posStartsLine || (change.options.prefix === this.newLineCharacter))
: 0;
const delta =
change.options.delta !== undefined
+3 -3
View File
@@ -441,7 +441,7 @@ namespace ts {
if (!(<NewExpression>n).arguments) {
return true;
}
// fall through
// falls through
case SyntaxKind.CallExpression:
case SyntaxKind.ParenthesizedExpression:
case SyntaxKind.ParenthesizedType:
@@ -902,10 +902,10 @@ namespace ts {
// Internally, we represent the end of the comment at the newline and closing '/', respectively.
return predicate ?
forEach(commentRanges, c => c.pos < position &&
(c.kind == SyntaxKind.SingleLineCommentTrivia ? position <= c.end : position < c.end) &&
(c.kind === SyntaxKind.SingleLineCommentTrivia ? position <= c.end : position < c.end) &&
predicate(c)) :
forEach(commentRanges, c => c.pos < position &&
(c.kind == SyntaxKind.SingleLineCommentTrivia ? position <= c.end : position < c.end));
(c.kind === SyntaxKind.SingleLineCommentTrivia ? position <= c.end : position < c.end));
}
return false;
@@ -0,0 +1,113 @@
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures3.ts(71,1): error TS2322: Type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type '<T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U'.
Types of parameters 'y' and 'y' are incompatible.
Types of parameters 'arg2' and 'arg2' are incompatible.
Type 'Base' is not assignable to type '{ foo: string; bing: number; }'.
Property 'bing' is missing in type 'Base'.
==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures3.ts (1 errors) ====
// these are all permitted with the current rules, since we do not do contextual signature instantiation
class Base { foo: string; }
class Derived extends Base { bar: string; }
class Derived2 extends Derived { baz: string; }
class OtherDerived extends Base { bing: string; }
var a: (x: number) => number[];
var a2: (x: number) => string[];
var a3: (x: number) => void;
var a4: (x: string, y: number) => string;
var a5: (x: (arg: string) => number) => string;
var a6: (x: (arg: Base) => Derived) => Base;
var a7: (x: (arg: Base) => Derived) => (r: Base) => Derived;
var a8: (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived;
var a9: (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived;
var a10: (...x: Derived[]) => Derived;
var a11: (x: { foo: string }, y: { foo: string; bar: string }) => Base;
var a12: (x: Array<Base>, y: Array<Derived2>) => Array<Derived>;
var a13: (x: Array<Base>, y: Array<Derived>) => Array<Derived>;
var a14: (x: { a: string; b: number }) => Object;
var a15: {
(x: number): number[];
(x: string): string[];
}
var a16: {
<T extends Derived>(x: T): number[];
<U extends Base>(x: U): number[];
}
var a17: {
(x: (a: number) => number): number[];
(x: (a: string) => string): string[];
};
var a18: {
(x: {
(a: number): number;
(a: string): string;
}): any[];
(x: {
(a: boolean): boolean;
(a: Date): Date;
}): any[];
}
var b: <T>(x: T) => T[];
a = b; // ok
b = a; // ok
var b2: <T>(x: T) => string[];
a2 = b2; // ok
b2 = a2; // ok
var b3: <T>(x: T) => T;
a3 = b3; // ok
b3 = a3; // ok
var b4: <T, U>(x: T, y: U) => T;
a4 = b4; // ok
b4 = a4; // ok
var b5: <T, U>(x: (arg: T) => U) => T;
a5 = b5; // ok
b5 = a5; // ok
var b6: <T extends Base, U extends Derived>(x: (arg: T) => U) => T;
a6 = b6; // ok
b6 = a6; // ok
var b7: <T extends Base, U extends Derived>(x: (arg: T) => U) => (r: T) => U;
a7 = b7; // ok
b7 = a7; // ok
var b8: <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U;
a8 = b8; // ok
b8 = a8; // ok
var b9: <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: string; bing: number }) => U) => (r: T) => U;
a9 = b9; // ok
b9 = a9; // ok
~~
!!! error TS2322: Type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type '<T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U'.
!!! error TS2322: Types of parameters 'y' and 'y' are incompatible.
!!! error TS2322: Types of parameters 'arg2' and 'arg2' are incompatible.
!!! error TS2322: Type 'Base' is not assignable to type '{ foo: string; bing: number; }'.
!!! error TS2322: Property 'bing' is missing in type 'Base'.
var b10: <T extends Derived>(...x: T[]) => T;
a10 = b10; // ok
b10 = a10; // ok
var b11: <T extends Base>(x: T, y: T) => T;
a11 = b11; // ok
b11 = a11; // ok
var b12: <T extends Array<Base>>(x: Array<Base>, y: T) => Array<Derived>;
a12 = b12; // ok
b12 = a12; // ok
var b13: <T extends Array<Derived>>(x: Array<Base>, y: T) => T;
a13 = b13; // ok
b13 = a13; // ok
var b14: <T>(x: { a: T; b: T }) => T;
a14 = b14; // ok
b14 = a14; // ok
var b15: <T>(x: T) => T[];
a15 = b15; // ok
b15 = a15; // ok
var b16: <T extends Base>(x: T) => number[];
a16 = b16; // ok
b16 = a16; // ok
var b17: <T>(x: (a: T) => T) => T[]; // ok
a17 = b17; // ok
b17 = a17; // ok
var b18: <T>(x: (a: T) => T) => T[];
a18 = b18; // ok
b18 = a18; // ok
@@ -1,17 +1,15 @@
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts(52,9): error TS2322: Type '<T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U' is not assignable to type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived'.
Types of parameters 'y' and 'y' are incompatible.
Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'.
Types of parameters 'arg2' and 'arg2' are incompatible.
Type '{ foo: number; }' is not assignable to type 'Base'.
Types of property 'foo' are incompatible.
Type 'number' is not assignable to type 'string'.
Types of parameters 'arg2' and 'arg2' are incompatible.
Type '{ foo: number; }' is not assignable to type 'Base'.
Types of property 'foo' are incompatible.
Type 'number' is not assignable to type 'string'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts(53,9): error TS2322: Type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type '<T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U'.
Types of parameters 'y' and 'y' are incompatible.
Type '(arg2: { foo: number; }) => any' is not assignable to type '(arg2: Base) => Derived'.
Types of parameters 'arg2' and 'arg2' are incompatible.
Type 'Base' is not assignable to type '{ foo: number; }'.
Types of property 'foo' are incompatible.
Type 'string' is not assignable to type 'number'.
Types of parameters 'arg2' and 'arg2' are incompatible.
Type 'Base' is not assignable to type '{ foo: number; }'.
Types of property 'foo' are incompatible.
Type 'string' is not assignable to type 'number'.
==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts (2 errors) ====
@@ -70,20 +68,18 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
~~
!!! error TS2322: Type '<T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U' is not assignable to type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived'.
!!! error TS2322: Types of parameters 'y' and 'y' are incompatible.
!!! error TS2322: Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'.
!!! error TS2322: Types of parameters 'arg2' and 'arg2' are incompatible.
!!! error TS2322: Type '{ foo: number; }' is not assignable to type 'Base'.
!!! error TS2322: Types of property 'foo' are incompatible.
!!! error TS2322: Type 'number' is not assignable to type 'string'.
!!! error TS2322: Types of parameters 'arg2' and 'arg2' are incompatible.
!!! error TS2322: Type '{ foo: number; }' is not assignable to type 'Base'.
!!! error TS2322: Types of property 'foo' are incompatible.
!!! error TS2322: Type 'number' is not assignable to type 'string'.
b8 = a8; // error, { foo: number } and Base are incompatible
~~
!!! error TS2322: Type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type '<T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U'.
!!! error TS2322: Types of parameters 'y' and 'y' are incompatible.
!!! error TS2322: Type '(arg2: { foo: number; }) => any' is not assignable to type '(arg2: Base) => Derived'.
!!! error TS2322: Types of parameters 'arg2' and 'arg2' are incompatible.
!!! error TS2322: Type 'Base' is not assignable to type '{ foo: number; }'.
!!! error TS2322: Types of property 'foo' are incompatible.
!!! error TS2322: Type 'string' is not assignable to type 'number'.
!!! error TS2322: Types of parameters 'arg2' and 'arg2' are incompatible.
!!! error TS2322: Type 'Base' is not assignable to type '{ foo: number; }'.
!!! error TS2322: Types of property 'foo' are incompatible.
!!! error TS2322: Type 'string' is not assignable to type 'number'.
var b10: <T extends Derived>(...x: T[]) => T;
@@ -0,0 +1,113 @@
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures3.ts(71,1): error TS2322: Type 'new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type 'new <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U'.
Types of parameters 'y' and 'y' are incompatible.
Types of parameters 'arg2' and 'arg2' are incompatible.
Type 'Base' is not assignable to type '{ foo: string; bing: number; }'.
Property 'bing' is missing in type 'Base'.
==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures3.ts (1 errors) ====
// checking assignment compatibility relations for function types. All of these are valid.
class Base { foo: string; }
class Derived extends Base { bar: string; }
class Derived2 extends Derived { baz: string; }
class OtherDerived extends Base { bing: string; }
var a: new (x: number) => number[];
var a2: new (x: number) => string[];
var a3: new (x: number) => void;
var a4: new (x: string, y: number) => string;
var a5: new (x: (arg: string) => number) => string;
var a6: new (x: (arg: Base) => Derived) => Base;
var a7: new (x: (arg: Base) => Derived) => (r: Base) => Derived;
var a8: new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived;
var a9: new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived;
var a10: new (...x: Derived[]) => Derived;
var a11: new (x: { foo: string }, y: { foo: string; bar: string }) => Base;
var a12: new (x: Array<Base>, y: Array<Derived2>) => Array<Derived>;
var a13: new (x: Array<Base>, y: Array<Derived>) => Array<Derived>;
var a14: new (x: { a: string; b: number }) => Object;
var a15: {
new (x: number): number[];
new (x: string): string[];
}
var a16: {
new <T extends Derived>(x: T): number[];
new <U extends Base>(x: U): number[];
}
var a17: {
new (x: new (a: number) => number): number[];
new (x: new (a: string) => string): string[];
};
var a18: {
new (x: {
new (a: number): number;
new (a: string): string;
}): any[];
new (x: {
new (a: boolean): boolean;
new (a: Date): Date;
}): any[];
}
var b: new <T>(x: T) => T[];
a = b; // ok
b = a; // ok
var b2: new <T>(x: T) => string[];
a2 = b2; // ok
b2 = a2; // ok
var b3: new <T>(x: T) => T;
a3 = b3; // ok
b3 = a3; // ok
var b4: new <T, U>(x: T, y: U) => T;
a4 = b4; // ok
b4 = a4; // ok
var b5: new <T, U>(x: (arg: T) => U) => T;
a5 = b5; // ok
b5 = a5; // ok
var b6: new <T extends Base, U extends Derived>(x: (arg: T) => U) => T;
a6 = b6; // ok
b6 = a6; // ok
var b7: new <T extends Base, U extends Derived>(x: (arg: T) => U) => (r: T) => U;
a7 = b7; // ok
b7 = a7; // ok
var b8: new <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U;
a8 = b8; // ok
b8 = a8; // ok
var b9: new <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: string; bing: number }) => U) => (r: T) => U;
a9 = b9; // ok
b9 = a9; // ok
~~
!!! error TS2322: Type 'new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type 'new <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U'.
!!! error TS2322: Types of parameters 'y' and 'y' are incompatible.
!!! error TS2322: Types of parameters 'arg2' and 'arg2' are incompatible.
!!! error TS2322: Type 'Base' is not assignable to type '{ foo: string; bing: number; }'.
!!! error TS2322: Property 'bing' is missing in type 'Base'.
var b10: new <T extends Derived>(...x: T[]) => T;
a10 = b10; // ok
b10 = a10; // ok
var b11: new <T extends Base>(x: T, y: T) => T;
a11 = b11; // ok
b11 = a11; // ok
var b12: new <T extends Array<Base>>(x: Array<Base>, y: T) => Array<Derived>;
a12 = b12; // ok
b12 = a12; // ok
var b13: new <T extends Array<Derived>>(x: Array<Base>, y: T) => T;
a13 = b13; // ok
b13 = a13; // ok
var b14: new <T>(x: { a: T; b: T }) => T;
a14 = b14; // ok
b14 = a14; // ok
var b15: new <T>(x: T) => T[];
a15 = b15; // ok
b15 = a15; // ok
var b16: new <T extends Base>(x: T) => number[];
a16 = b16; // ok
b16 = a16; // ok
var b17: new <T>(x: new (a: T) => T) => T[]; // ok
a17 = b17; // ok
b17 = a17; // ok
var b18: new <T>(x: new (a: T) => T) => T[];
a18 = b18; // ok
b18 = a18; // ok
@@ -1,17 +1,15 @@
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(52,9): error TS2322: Type 'new <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U' is not assignable to type 'new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived'.
Types of parameters 'y' and 'y' are incompatible.
Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'.
Types of parameters 'arg2' and 'arg2' are incompatible.
Type '{ foo: number; }' is not assignable to type 'Base'.
Types of property 'foo' are incompatible.
Type 'number' is not assignable to type 'string'.
Types of parameters 'arg2' and 'arg2' are incompatible.
Type '{ foo: number; }' is not assignable to type 'Base'.
Types of property 'foo' are incompatible.
Type 'number' is not assignable to type 'string'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(53,9): error TS2322: Type 'new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type 'new <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U'.
Types of parameters 'y' and 'y' are incompatible.
Type '(arg2: { foo: number; }) => any' is not assignable to type '(arg2: Base) => Derived'.
Types of parameters 'arg2' and 'arg2' are incompatible.
Type 'Base' is not assignable to type '{ foo: number; }'.
Types of property 'foo' are incompatible.
Type 'string' is not assignable to type 'number'.
Types of parameters 'arg2' and 'arg2' are incompatible.
Type 'Base' is not assignable to type '{ foo: number; }'.
Types of property 'foo' are incompatible.
Type 'string' is not assignable to type 'number'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(77,9): error TS2322: Type 'new <T>(x: (a: T) => T) => T[]' is not assignable to type '{ new (x: { new (a: number): number; new (a?: number): number; }): number[]; new (x: { new (a: boolean): boolean; new (a?: boolean): boolean; }): boolean[]; }'.
Types of parameters 'x' and 'x' are incompatible.
Type '{ new (a: number): number; new (a?: number): number; }' is not assignable to type '(a: any) => any'.
@@ -86,20 +84,18 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
~~
!!! error TS2322: Type 'new <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U' is not assignable to type 'new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived'.
!!! error TS2322: Types of parameters 'y' and 'y' are incompatible.
!!! error TS2322: Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'.
!!! error TS2322: Types of parameters 'arg2' and 'arg2' are incompatible.
!!! error TS2322: Type '{ foo: number; }' is not assignable to type 'Base'.
!!! error TS2322: Types of property 'foo' are incompatible.
!!! error TS2322: Type 'number' is not assignable to type 'string'.
!!! error TS2322: Types of parameters 'arg2' and 'arg2' are incompatible.
!!! error TS2322: Type '{ foo: number; }' is not assignable to type 'Base'.
!!! error TS2322: Types of property 'foo' are incompatible.
!!! error TS2322: Type 'number' is not assignable to type 'string'.
b8 = a8; // error
~~
!!! error TS2322: Type 'new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type 'new <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U'.
!!! error TS2322: Types of parameters 'y' and 'y' are incompatible.
!!! error TS2322: Type '(arg2: { foo: number; }) => any' is not assignable to type '(arg2: Base) => Derived'.
!!! error TS2322: Types of parameters 'arg2' and 'arg2' are incompatible.
!!! error TS2322: Type 'Base' is not assignable to type '{ foo: number; }'.
!!! error TS2322: Types of property 'foo' are incompatible.
!!! error TS2322: Type 'string' is not assignable to type 'number'.
!!! error TS2322: Types of parameters 'arg2' and 'arg2' are incompatible.
!!! error TS2322: Type 'Base' is not assignable to type '{ foo: number; }'.
!!! error TS2322: Types of property 'foo' are incompatible.
!!! error TS2322: Type 'string' is not assignable to type 'number'.
var b10: new <T extends Derived>(...x: T[]) => T;
@@ -0,0 +1,56 @@
//// [assignmentToExpandingArrayType.ts]
// Fixes exponential time/space in #14628
let x = []
x[0] = { foo: 'hi' }
x[0] = { foo: 'hi' }
x[0] = { foo: 'hi' }
x[0] = { foo: 'hi' }
x[0] = { foo: 'hi' }
x[0] = { foo: 'hi' }
x[0] = { foo: 'hi' }
x[0] = { foo: 'hi' }
x[0] = { foo: 'hi' }
x[0] = { foo: 'hi' }
x[0] = { foo: 'hi' }
x[0] = { foo: 'hi' }
x[0] = { foo: 'hi' } // previously ran out of memory here
x[0] = { foo: 'hi' }
x[0] = { foo: 'hi' }
x[0] = { foo: 'hi' }
x[0] = { foo: 'hi' }
x[0] = { foo: 'hi' }
x[0] = { foo: 'hi' }
x[0] = { foo: 'hi' }
x[0] = { foo: 'hi' }
x[0] = { foo: 'hi' }
x[0] = { foo: 'hi' }
x[0] = { foo: 'hi' }
//// [assignmentToExpandingArrayType.js]
// Fixes exponential time/space in #14628
var x = [];
x[0] = { foo: 'hi' };
x[0] = { foo: 'hi' };
x[0] = { foo: 'hi' };
x[0] = { foo: 'hi' };
x[0] = { foo: 'hi' };
x[0] = { foo: 'hi' };
x[0] = { foo: 'hi' };
x[0] = { foo: 'hi' };
x[0] = { foo: 'hi' };
x[0] = { foo: 'hi' };
x[0] = { foo: 'hi' };
x[0] = { foo: 'hi' };
x[0] = { foo: 'hi' }; // previously ran out of memory here
x[0] = { foo: 'hi' };
x[0] = { foo: 'hi' };
x[0] = { foo: 'hi' };
x[0] = { foo: 'hi' };
x[0] = { foo: 'hi' };
x[0] = { foo: 'hi' };
x[0] = { foo: 'hi' };
x[0] = { foo: 'hi' };
x[0] = { foo: 'hi' };
x[0] = { foo: 'hi' };
x[0] = { foo: 'hi' };
@@ -0,0 +1,101 @@
=== tests/cases/compiler/assignmentToExpandingArrayType.ts ===
// Fixes exponential time/space in #14628
let x = []
>x : Symbol(x, Decl(assignmentToExpandingArrayType.ts, 1, 3))
x[0] = { foo: 'hi' }
>x : Symbol(x, Decl(assignmentToExpandingArrayType.ts, 1, 3))
>foo : Symbol(foo, Decl(assignmentToExpandingArrayType.ts, 2, 8))
x[0] = { foo: 'hi' }
>x : Symbol(x, Decl(assignmentToExpandingArrayType.ts, 1, 3))
>foo : Symbol(foo, Decl(assignmentToExpandingArrayType.ts, 3, 8))
x[0] = { foo: 'hi' }
>x : Symbol(x, Decl(assignmentToExpandingArrayType.ts, 1, 3))
>foo : Symbol(foo, Decl(assignmentToExpandingArrayType.ts, 4, 8))
x[0] = { foo: 'hi' }
>x : Symbol(x, Decl(assignmentToExpandingArrayType.ts, 1, 3))
>foo : Symbol(foo, Decl(assignmentToExpandingArrayType.ts, 5, 8))
x[0] = { foo: 'hi' }
>x : Symbol(x, Decl(assignmentToExpandingArrayType.ts, 1, 3))
>foo : Symbol(foo, Decl(assignmentToExpandingArrayType.ts, 6, 8))
x[0] = { foo: 'hi' }
>x : Symbol(x, Decl(assignmentToExpandingArrayType.ts, 1, 3))
>foo : Symbol(foo, Decl(assignmentToExpandingArrayType.ts, 7, 8))
x[0] = { foo: 'hi' }
>x : Symbol(x, Decl(assignmentToExpandingArrayType.ts, 1, 3))
>foo : Symbol(foo, Decl(assignmentToExpandingArrayType.ts, 8, 8))
x[0] = { foo: 'hi' }
>x : Symbol(x, Decl(assignmentToExpandingArrayType.ts, 1, 3))
>foo : Symbol(foo, Decl(assignmentToExpandingArrayType.ts, 9, 8))
x[0] = { foo: 'hi' }
>x : Symbol(x, Decl(assignmentToExpandingArrayType.ts, 1, 3))
>foo : Symbol(foo, Decl(assignmentToExpandingArrayType.ts, 10, 8))
x[0] = { foo: 'hi' }
>x : Symbol(x, Decl(assignmentToExpandingArrayType.ts, 1, 3))
>foo : Symbol(foo, Decl(assignmentToExpandingArrayType.ts, 11, 8))
x[0] = { foo: 'hi' }
>x : Symbol(x, Decl(assignmentToExpandingArrayType.ts, 1, 3))
>foo : Symbol(foo, Decl(assignmentToExpandingArrayType.ts, 12, 8))
x[0] = { foo: 'hi' }
>x : Symbol(x, Decl(assignmentToExpandingArrayType.ts, 1, 3))
>foo : Symbol(foo, Decl(assignmentToExpandingArrayType.ts, 13, 8))
x[0] = { foo: 'hi' } // previously ran out of memory here
>x : Symbol(x, Decl(assignmentToExpandingArrayType.ts, 1, 3))
>foo : Symbol(foo, Decl(assignmentToExpandingArrayType.ts, 14, 8))
x[0] = { foo: 'hi' }
>x : Symbol(x, Decl(assignmentToExpandingArrayType.ts, 1, 3))
>foo : Symbol(foo, Decl(assignmentToExpandingArrayType.ts, 15, 8))
x[0] = { foo: 'hi' }
>x : Symbol(x, Decl(assignmentToExpandingArrayType.ts, 1, 3))
>foo : Symbol(foo, Decl(assignmentToExpandingArrayType.ts, 16, 8))
x[0] = { foo: 'hi' }
>x : Symbol(x, Decl(assignmentToExpandingArrayType.ts, 1, 3))
>foo : Symbol(foo, Decl(assignmentToExpandingArrayType.ts, 17, 8))
x[0] = { foo: 'hi' }
>x : Symbol(x, Decl(assignmentToExpandingArrayType.ts, 1, 3))
>foo : Symbol(foo, Decl(assignmentToExpandingArrayType.ts, 18, 8))
x[0] = { foo: 'hi' }
>x : Symbol(x, Decl(assignmentToExpandingArrayType.ts, 1, 3))
>foo : Symbol(foo, Decl(assignmentToExpandingArrayType.ts, 19, 8))
x[0] = { foo: 'hi' }
>x : Symbol(x, Decl(assignmentToExpandingArrayType.ts, 1, 3))
>foo : Symbol(foo, Decl(assignmentToExpandingArrayType.ts, 20, 8))
x[0] = { foo: 'hi' }
>x : Symbol(x, Decl(assignmentToExpandingArrayType.ts, 1, 3))
>foo : Symbol(foo, Decl(assignmentToExpandingArrayType.ts, 21, 8))
x[0] = { foo: 'hi' }
>x : Symbol(x, Decl(assignmentToExpandingArrayType.ts, 1, 3))
>foo : Symbol(foo, Decl(assignmentToExpandingArrayType.ts, 22, 8))
x[0] = { foo: 'hi' }
>x : Symbol(x, Decl(assignmentToExpandingArrayType.ts, 1, 3))
>foo : Symbol(foo, Decl(assignmentToExpandingArrayType.ts, 23, 8))
x[0] = { foo: 'hi' }
>x : Symbol(x, Decl(assignmentToExpandingArrayType.ts, 1, 3))
>foo : Symbol(foo, Decl(assignmentToExpandingArrayType.ts, 24, 8))
x[0] = { foo: 'hi' }
>x : Symbol(x, Decl(assignmentToExpandingArrayType.ts, 1, 3))
>foo : Symbol(foo, Decl(assignmentToExpandingArrayType.ts, 25, 8))
@@ -0,0 +1,222 @@
=== tests/cases/compiler/assignmentToExpandingArrayType.ts ===
// Fixes exponential time/space in #14628
let x = []
>x : any[]
>[] : undefined[]
x[0] = { foo: 'hi' }
>x[0] = { foo: 'hi' } : { foo: string; }
>x[0] : any
>x : any[]
>0 : 0
>{ foo: 'hi' } : { foo: string; }
>foo : string
>'hi' : "hi"
x[0] = { foo: 'hi' }
>x[0] = { foo: 'hi' } : { foo: string; }
>x[0] : any
>x : any[]
>0 : 0
>{ foo: 'hi' } : { foo: string; }
>foo : string
>'hi' : "hi"
x[0] = { foo: 'hi' }
>x[0] = { foo: 'hi' } : { foo: string; }
>x[0] : any
>x : any[]
>0 : 0
>{ foo: 'hi' } : { foo: string; }
>foo : string
>'hi' : "hi"
x[0] = { foo: 'hi' }
>x[0] = { foo: 'hi' } : { foo: string; }
>x[0] : any
>x : any[]
>0 : 0
>{ foo: 'hi' } : { foo: string; }
>foo : string
>'hi' : "hi"
x[0] = { foo: 'hi' }
>x[0] = { foo: 'hi' } : { foo: string; }
>x[0] : any
>x : any[]
>0 : 0
>{ foo: 'hi' } : { foo: string; }
>foo : string
>'hi' : "hi"
x[0] = { foo: 'hi' }
>x[0] = { foo: 'hi' } : { foo: string; }
>x[0] : any
>x : any[]
>0 : 0
>{ foo: 'hi' } : { foo: string; }
>foo : string
>'hi' : "hi"
x[0] = { foo: 'hi' }
>x[0] = { foo: 'hi' } : { foo: string; }
>x[0] : any
>x : any[]
>0 : 0
>{ foo: 'hi' } : { foo: string; }
>foo : string
>'hi' : "hi"
x[0] = { foo: 'hi' }
>x[0] = { foo: 'hi' } : { foo: string; }
>x[0] : any
>x : any[]
>0 : 0
>{ foo: 'hi' } : { foo: string; }
>foo : string
>'hi' : "hi"
x[0] = { foo: 'hi' }
>x[0] = { foo: 'hi' } : { foo: string; }
>x[0] : any
>x : any[]
>0 : 0
>{ foo: 'hi' } : { foo: string; }
>foo : string
>'hi' : "hi"
x[0] = { foo: 'hi' }
>x[0] = { foo: 'hi' } : { foo: string; }
>x[0] : any
>x : any[]
>0 : 0
>{ foo: 'hi' } : { foo: string; }
>foo : string
>'hi' : "hi"
x[0] = { foo: 'hi' }
>x[0] = { foo: 'hi' } : { foo: string; }
>x[0] : any
>x : any[]
>0 : 0
>{ foo: 'hi' } : { foo: string; }
>foo : string
>'hi' : "hi"
x[0] = { foo: 'hi' }
>x[0] = { foo: 'hi' } : { foo: string; }
>x[0] : any
>x : any[]
>0 : 0
>{ foo: 'hi' } : { foo: string; }
>foo : string
>'hi' : "hi"
x[0] = { foo: 'hi' } // previously ran out of memory here
>x[0] = { foo: 'hi' } : { foo: string; }
>x[0] : any
>x : any[]
>0 : 0
>{ foo: 'hi' } : { foo: string; }
>foo : string
>'hi' : "hi"
x[0] = { foo: 'hi' }
>x[0] = { foo: 'hi' } : { foo: string; }
>x[0] : any
>x : any[]
>0 : 0
>{ foo: 'hi' } : { foo: string; }
>foo : string
>'hi' : "hi"
x[0] = { foo: 'hi' }
>x[0] = { foo: 'hi' } : { foo: string; }
>x[0] : any
>x : any[]
>0 : 0
>{ foo: 'hi' } : { foo: string; }
>foo : string
>'hi' : "hi"
x[0] = { foo: 'hi' }
>x[0] = { foo: 'hi' } : { foo: string; }
>x[0] : any
>x : any[]
>0 : 0
>{ foo: 'hi' } : { foo: string; }
>foo : string
>'hi' : "hi"
x[0] = { foo: 'hi' }
>x[0] = { foo: 'hi' } : { foo: string; }
>x[0] : any
>x : any[]
>0 : 0
>{ foo: 'hi' } : { foo: string; }
>foo : string
>'hi' : "hi"
x[0] = { foo: 'hi' }
>x[0] = { foo: 'hi' } : { foo: string; }
>x[0] : any
>x : any[]
>0 : 0
>{ foo: 'hi' } : { foo: string; }
>foo : string
>'hi' : "hi"
x[0] = { foo: 'hi' }
>x[0] = { foo: 'hi' } : { foo: string; }
>x[0] : any
>x : any[]
>0 : 0
>{ foo: 'hi' } : { foo: string; }
>foo : string
>'hi' : "hi"
x[0] = { foo: 'hi' }
>x[0] = { foo: 'hi' } : { foo: string; }
>x[0] : any
>x : any[]
>0 : 0
>{ foo: 'hi' } : { foo: string; }
>foo : string
>'hi' : "hi"
x[0] = { foo: 'hi' }
>x[0] = { foo: 'hi' } : { foo: string; }
>x[0] : any
>x : any[]
>0 : 0
>{ foo: 'hi' } : { foo: string; }
>foo : string
>'hi' : "hi"
x[0] = { foo: 'hi' }
>x[0] = { foo: 'hi' } : { foo: string; }
>x[0] : any
>x : any[]
>0 : 0
>{ foo: 'hi' } : { foo: string; }
>foo : string
>'hi' : "hi"
x[0] = { foo: 'hi' }
>x[0] = { foo: 'hi' } : { foo: string; }
>x[0] : any
>x : any[]
>0 : 0
>{ foo: 'hi' } : { foo: string; }
>foo : string
>'hi' : "hi"
x[0] = { foo: 'hi' }
>x[0] = { foo: 'hi' } : { foo: string; }
>x[0] : any
>x : any[]
>0 : 0
>{ foo: 'hi' } : { foo: string; }
>foo : string
>'hi' : "hi"
@@ -7,11 +7,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign
Types of property 'a8' are incompatible.
Type '<T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U' is not assignable to type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived'.
Types of parameters 'y' and 'y' are incompatible.
Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'.
Types of parameters 'arg2' and 'arg2' are incompatible.
Type '{ foo: number; }' is not assignable to type 'Base'.
Types of property 'foo' are incompatible.
Type 'number' is not assignable to type 'string'.
Types of parameters 'arg2' and 'arg2' are incompatible.
Type '{ foo: number; }' is not assignable to type 'Base'.
Types of property 'foo' are incompatible.
Type 'number' is not assignable to type 'string'.
==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance3.ts (2 errors) ====
@@ -86,11 +85,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign
!!! error TS2430: Types of property 'a8' are incompatible.
!!! error TS2430: Type '<T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U' is not assignable to type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived'.
!!! error TS2430: Types of parameters 'y' and 'y' are incompatible.
!!! error TS2430: Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'.
!!! error TS2430: Types of parameters 'arg2' and 'arg2' are incompatible.
!!! error TS2430: Type '{ foo: number; }' is not assignable to type 'Base'.
!!! error TS2430: Types of property 'foo' are incompatible.
!!! error TS2430: Type 'number' is not assignable to type 'string'.
!!! error TS2430: Types of parameters 'arg2' and 'arg2' are incompatible.
!!! error TS2430: Type '{ foo: number; }' is not assignable to type 'Base'.
!!! error TS2430: Types of property 'foo' are incompatible.
!!! error TS2430: Type 'number' is not assignable to type 'string'.
a8: <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U; // error, type mismatch
}
@@ -0,0 +1,25 @@
tests/cases/compiler/a.js(14,5): error TS2424: Class 'A' defines instance member function 'foo', but extended class 'B' defines it as instance member property.
==== tests/cases/compiler/a.js (1 errors) ====
// @ts-check
class A {
constructor() {
}
foo() {
return 4;
}
}
class B extends A {
constructor() {
super();
this.foo = () => 3;
~~~~~~~~~~~~~~~~~~
!!! error TS2424: Class 'A' defines instance member function 'foo', but extended class 'B' defines it as instance member property.
}
}
const i = new B();
i.foo();
@@ -7,11 +7,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc
Types of property 'a8' are incompatible.
Type 'new <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U' is not assignable to type 'new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived'.
Types of parameters 'y' and 'y' are incompatible.
Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'.
Types of parameters 'arg2' and 'arg2' are incompatible.
Type '{ foo: number; }' is not assignable to type 'Base'.
Types of property 'foo' are incompatible.
Type 'number' is not assignable to type 'string'.
Types of parameters 'arg2' and 'arg2' are incompatible.
Type '{ foo: number; }' is not assignable to type 'Base'.
Types of property 'foo' are incompatible.
Type 'number' is not assignable to type 'string'.
==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance3.ts (2 errors) ====
@@ -76,11 +75,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc
!!! error TS2430: Types of property 'a8' are incompatible.
!!! error TS2430: Type 'new <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U' is not assignable to type 'new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived'.
!!! error TS2430: Types of parameters 'y' and 'y' are incompatible.
!!! error TS2430: Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'.
!!! error TS2430: Types of parameters 'arg2' and 'arg2' are incompatible.
!!! error TS2430: Type '{ foo: number; }' is not assignable to type 'Base'.
!!! error TS2430: Types of property 'foo' are incompatible.
!!! error TS2430: Type 'number' is not assignable to type 'string'.
!!! error TS2430: Types of parameters 'arg2' and 'arg2' are incompatible.
!!! error TS2430: Type '{ foo: number; }' is not assignable to type 'Base'.
!!! error TS2430: Types of property 'foo' are incompatible.
!!! error TS2430: Type 'number' is not assignable to type 'string'.
a8: new <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U; // error, type mismatch
}
@@ -0,0 +1,132 @@
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/covariantCallbacks.ts(12,5): error TS2322: Type 'P<A>' is not assignable to type 'P<B>'.
Type 'A' is not assignable to type 'B'.
Property 'b' is missing in type 'A'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/covariantCallbacks.ts(17,5): error TS2322: Type 'Promise<A>' is not assignable to type 'Promise<B>'.
Type 'A' is not assignable to type 'B'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/covariantCallbacks.ts(30,5): error TS2322: Type 'AList1' is not assignable to type 'BList1'.
Types of property 'forEach' are incompatible.
Type '(cb: (item: A) => void) => void' is not assignable to type '(cb: (item: B) => void) => void'.
Types of parameters 'cb' and 'cb' are incompatible.
Types of parameters 'item' and 'item' are incompatible.
Type 'A' is not assignable to type 'B'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/covariantCallbacks.ts(43,5): error TS2322: Type 'AList2' is not assignable to type 'BList2'.
Types of property 'forEach' are incompatible.
Type '(cb: (item: A) => boolean) => void' is not assignable to type '(cb: (item: A) => void) => void'.
Types of parameters 'cb' and 'cb' are incompatible.
Type 'void' is not assignable to type 'boolean'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/covariantCallbacks.ts(56,5): error TS2322: Type 'AList3' is not assignable to type 'BList3'.
Types of property 'forEach' are incompatible.
Type '(cb: (item: A) => void) => void' is not assignable to type '(cb: (item: A, context: any) => void) => void'.
Types of parameters 'cb' and 'cb' are incompatible.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/covariantCallbacks.ts(69,5): error TS2322: Type 'AList4' is not assignable to type 'BList4'.
Types of property 'forEach' are incompatible.
Type '(cb: (item: A) => A) => void' is not assignable to type '(cb: (item: B) => B) => void'.
Types of parameters 'cb' and 'cb' are incompatible.
Types of parameters 'item' and 'item' are incompatible.
Type 'A' is not assignable to type 'B'.
==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/covariantCallbacks.ts (6 errors) ====
// Test that callback parameters are related covariantly
interface P<T> {
then(cb: (value: T) => void): void;
};
interface A { a: string }
interface B extends A { b: string }
function f1(a: P<A>, b: P<B>) {
a = b;
b = a; // Error
~
!!! error TS2322: Type 'P<A>' is not assignable to type 'P<B>'.
!!! error TS2322: Type 'A' is not assignable to type 'B'.
!!! error TS2322: Property 'b' is missing in type 'A'.
}
function f2(a: Promise<A>, b: Promise<B>) {
a = b;
b = a; // Error
~
!!! error TS2322: Type 'Promise<A>' is not assignable to type 'Promise<B>'.
!!! error TS2322: Type 'A' is not assignable to type 'B'.
}
interface AList1 {
forEach(cb: (item: A) => void): void;
}
interface BList1 {
forEach(cb: (item: B) => void): void;
}
function f11(a: AList1, b: BList1) {
a = b;
b = a; // Error
~
!!! error TS2322: Type 'AList1' is not assignable to type 'BList1'.
!!! error TS2322: Types of property 'forEach' are incompatible.
!!! error TS2322: Type '(cb: (item: A) => void) => void' is not assignable to type '(cb: (item: B) => void) => void'.
!!! error TS2322: Types of parameters 'cb' and 'cb' are incompatible.
!!! error TS2322: Types of parameters 'item' and 'item' are incompatible.
!!! error TS2322: Type 'A' is not assignable to type 'B'.
}
interface AList2 {
forEach(cb: (item: A) => boolean): void;
}
interface BList2 {
forEach(cb: (item: A) => void): void;
}
function f12(a: AList2, b: BList2) {
a = b;
b = a; // Error
~
!!! error TS2322: Type 'AList2' is not assignable to type 'BList2'.
!!! error TS2322: Types of property 'forEach' are incompatible.
!!! error TS2322: Type '(cb: (item: A) => boolean) => void' is not assignable to type '(cb: (item: A) => void) => void'.
!!! error TS2322: Types of parameters 'cb' and 'cb' are incompatible.
!!! error TS2322: Type 'void' is not assignable to type 'boolean'.
}
interface AList3 {
forEach(cb: (item: A) => void): void;
}
interface BList3 {
forEach(cb: (item: A, context: any) => void): void;
}
function f13(a: AList3, b: BList3) {
a = b;
b = a; // Error
~
!!! error TS2322: Type 'AList3' is not assignable to type 'BList3'.
!!! error TS2322: Types of property 'forEach' are incompatible.
!!! error TS2322: Type '(cb: (item: A) => void) => void' is not assignable to type '(cb: (item: A, context: any) => void) => void'.
!!! error TS2322: Types of parameters 'cb' and 'cb' are incompatible.
}
interface AList4 {
forEach(cb: (item: A) => A): void;
}
interface BList4 {
forEach(cb: (item: B) => B): void;
}
function f14(a: AList4, b: BList4) {
a = b;
b = a; // Error
~
!!! error TS2322: Type 'AList4' is not assignable to type 'BList4'.
!!! error TS2322: Types of property 'forEach' are incompatible.
!!! error TS2322: Type '(cb: (item: A) => A) => void' is not assignable to type '(cb: (item: B) => B) => void'.
!!! error TS2322: Types of parameters 'cb' and 'cb' are incompatible.
!!! error TS2322: Types of parameters 'item' and 'item' are incompatible.
!!! error TS2322: Type 'A' is not assignable to type 'B'.
}
@@ -0,0 +1,101 @@
//// [covariantCallbacks.ts]
// Test that callback parameters are related covariantly
interface P<T> {
then(cb: (value: T) => void): void;
};
interface A { a: string }
interface B extends A { b: string }
function f1(a: P<A>, b: P<B>) {
a = b;
b = a; // Error
}
function f2(a: Promise<A>, b: Promise<B>) {
a = b;
b = a; // Error
}
interface AList1 {
forEach(cb: (item: A) => void): void;
}
interface BList1 {
forEach(cb: (item: B) => void): void;
}
function f11(a: AList1, b: BList1) {
a = b;
b = a; // Error
}
interface AList2 {
forEach(cb: (item: A) => boolean): void;
}
interface BList2 {
forEach(cb: (item: A) => void): void;
}
function f12(a: AList2, b: BList2) {
a = b;
b = a; // Error
}
interface AList3 {
forEach(cb: (item: A) => void): void;
}
interface BList3 {
forEach(cb: (item: A, context: any) => void): void;
}
function f13(a: AList3, b: BList3) {
a = b;
b = a; // Error
}
interface AList4 {
forEach(cb: (item: A) => A): void;
}
interface BList4 {
forEach(cb: (item: B) => B): void;
}
function f14(a: AList4, b: BList4) {
a = b;
b = a; // Error
}
//// [covariantCallbacks.js]
"use strict";
// Test that callback parameters are related covariantly
;
function f1(a, b) {
a = b;
b = a; // Error
}
function f2(a, b) {
a = b;
b = a; // Error
}
function f11(a, b) {
a = b;
b = a; // Error
}
function f12(a, b) {
a = b;
b = a; // Error
}
function f13(a, b) {
a = b;
b = a; // Error
}
function f14(a, b) {
a = b;
b = a; // Error
}
@@ -0,0 +1,19 @@
//// [exportBinding.ts]
export { x }
const x = 'x'
export { Y as Z }
class Y {}
//// [exportBinding.js]
"use strict";
exports.__esModule = true;
var x = 'x';
exports.x = x;
var Y = (function () {
function Y() {
}
return Y;
}());
exports.Z = Y;
@@ -0,0 +1,14 @@
=== tests/cases/conformance/es6/modules/exportBinding.ts ===
export { x }
>x : Symbol(x, Decl(exportBinding.ts, 0, 8))
const x = 'x'
>x : Symbol(x, Decl(exportBinding.ts, 1, 5))
export { Y as Z }
>Y : Symbol(Z, Decl(exportBinding.ts, 3, 8))
>Z : Symbol(Z, Decl(exportBinding.ts, 3, 8))
class Y {}
>Y : Symbol(Y, Decl(exportBinding.ts, 3, 17))
@@ -0,0 +1,15 @@
=== tests/cases/conformance/es6/modules/exportBinding.ts ===
export { x }
>x : "x"
const x = 'x'
>x : "x"
>'x' : "x"
export { Y as Z }
>Y : typeof Y
>Z : typeof Y
class Y {}
>Y : Y
@@ -0,0 +1,15 @@
=== tests/cases/compiler/foo.js ===
module.exports = function () {
>module : Symbol(export=, Decl(foo.js, 0, 0))
>exports : Symbol(export=, Decl(foo.js, 0, 0))
class A { }
>A : Symbol(A, Decl(foo.js, 0, 30))
return {
c: A.b = 1,
>c : Symbol(c, Decl(foo.js, 2, 10))
>A : Symbol(A, Decl(foo.js, 0, 30))
}
};
@@ -0,0 +1,24 @@
=== tests/cases/compiler/foo.js ===
module.exports = function () {
>module.exports = function () { class A { } return { c: A.b = 1, }} : () => { [x: string]: any; c: number; }
>module.exports : any
>module : any
>exports : any
>function () { class A { } return { c: A.b = 1, }} : () => { [x: string]: any; c: number; }
class A { }
>A : A
return {
>{ c: A.b = 1, } : { [x: string]: any; c: number; }
c: A.b = 1,
>c : number
>A.b = 1 : 1
>A.b : any
>A : typeof A
>b : any
>1 : 1
}
};
@@ -0,0 +1,11 @@
//// [tests/cases/conformance/references/library-reference-scoped-packages.ts] ////
//// [index.d.ts]
export const y = 0;
//// [a.ts]
/// <reference types="@beep/boop" />
//// [a.js]
/// <reference types="@beep/boop" />
@@ -0,0 +1,7 @@
=== /a.ts ===
/// <reference types="@beep/boop" />
No type information for this code.
No type information for this code.=== /node_modules/@types/beep__boop/index.d.ts ===
export const y = 0;
>y : Symbol(y, Decl(index.d.ts, 0, 12))
@@ -0,0 +1,12 @@
[
"======== Resolving type reference directive '@beep/boop', containing file '/a.ts', root directory 'types'. ========",
"Resolving with primary search path 'types'.",
"Directory 'types/@beep' does not exist, skipping all lookups in it.",
"Looking up in 'node_modules' folder, initial location '/'.",
"Scoped package detected, looking in 'beep__boop'",
"File '/node_modules/@types/beep__boop.d.ts' does not exist.",
"File '/node_modules/@types/beep__boop/package.json' does not exist.",
"File '/node_modules/@types/beep__boop/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/node_modules/@types/beep__boop/index.d.ts', result '/node_modules/@types/beep__boop/index.d.ts'.",
"======== Type reference directive '@beep/boop' was successfully resolved to '/node_modules/@types/beep__boop/index.d.ts', primary: false. ========"
]
@@ -0,0 +1,8 @@
=== /a.ts ===
/// <reference types="@beep/boop" />
No type information for this code.
No type information for this code.=== /node_modules/@types/beep__boop/index.d.ts ===
export const y = 0;
>y : 0
>0 : 0
@@ -1,8 +1,7 @@
tests/cases/compiler/optionalFunctionArgAssignability.ts(7,1): error TS2322: Type '<U>(onFulFill?: (value: number) => U, onReject?: (reason: any) => U) => Promise<U>' is not assignable to type '<U>(onFulfill?: (value: string) => U, onReject?: (reason: any) => U) => Promise<U>'.
Types of parameters 'onFulFill' and 'onFulfill' are incompatible.
Type '(value: string) => any' is not assignable to type '(value: number) => any'.
Types of parameters 'value' and 'value' are incompatible.
Type 'number' is not assignable to type 'string'.
Types of parameters 'value' and 'value' are incompatible.
Type 'number' is not assignable to type 'string'.
==== tests/cases/compiler/optionalFunctionArgAssignability.ts (1 errors) ====
@@ -16,7 +15,6 @@ tests/cases/compiler/optionalFunctionArgAssignability.ts(7,1): error TS2322: Typ
~
!!! error TS2322: Type '<U>(onFulFill?: (value: number) => U, onReject?: (reason: any) => U) => Promise<U>' is not assignable to type '<U>(onFulfill?: (value: string) => U, onReject?: (reason: any) => U) => Promise<U>'.
!!! error TS2322: Types of parameters 'onFulFill' and 'onFulfill' are incompatible.
!!! error TS2322: Type '(value: string) => any' is not assignable to type '(value: number) => any'.
!!! error TS2322: Types of parameters 'value' and 'value' are incompatible.
!!! error TS2322: Type 'number' is not assignable to type 'string'.
!!! error TS2322: Types of parameters 'value' and 'value' are incompatible.
!!! error TS2322: Type 'number' is not assignable to type 'string'.
@@ -1,8 +1,11 @@
tests/cases/compiler/overloadOnConstNoAnyImplementation.ts(1,10): error TS2394: Overload signature is not compatible with function implementation.
tests/cases/compiler/overloadOnConstNoAnyImplementation.ts(9,8): error TS2345: Argument of type '1' is not assignable to parameter of type 'string'.
==== tests/cases/compiler/overloadOnConstNoAnyImplementation.ts (1 errors) ====
==== tests/cases/compiler/overloadOnConstNoAnyImplementation.ts (2 errors) ====
function x1(a: number, cb: (x: 'hi') => number);
~~
!!! error TS2394: Overload signature is not compatible with function implementation.
function x1(a: number, cb: (x: 'bye') => number);
function x1(a: number, cb: (x: string) => number) {
cb('hi');
@@ -1,3 +1,4 @@
tests/cases/compiler/overloadOnConstNoAnyImplementation2.ts(6,5): error TS2394: Overload signature is not compatible with function implementation.
tests/cases/compiler/overloadOnConstNoAnyImplementation2.ts(12,18): error TS2345: Argument of type '1' is not assignable to parameter of type 'string'.
tests/cases/compiler/overloadOnConstNoAnyImplementation2.ts(18,9): error TS2345: Argument of type '(x: "bye") => number' is not assignable to parameter of type '(x: "hi") => number'.
Types of parameters 'x' and 'x' are incompatible.
@@ -7,13 +8,15 @@ tests/cases/compiler/overloadOnConstNoAnyImplementation2.ts(21,9): error TS2345:
Type '"hi"' is not assignable to type 'number'.
==== tests/cases/compiler/overloadOnConstNoAnyImplementation2.ts (3 errors) ====
==== tests/cases/compiler/overloadOnConstNoAnyImplementation2.ts (4 errors) ====
interface I {
x1(a: number, callback: (x: 'hi') => number);
}
class C {
x1(a: number, callback: (x: 'hi') => number);
~~
!!! error TS2394: Overload signature is not compatible with function implementation.
x1(a: number, callback: (x: string) => number) {
callback('hi');
callback('bye');
@@ -31,16 +31,16 @@ tests/cases/compiler/promisePermutations.ts(110,19): error TS2345: Argument of t
tests/cases/compiler/promisePermutations.ts(111,19): error TS2345: Argument of type '(cb: <T>(a: T) => T) => Promise<string>' is not assignable to parameter of type '(value: string) => IPromise<string>'.
Types of parameters 'cb' and 'value' are incompatible.
Type 'string' is not assignable to type '<T>(a: T) => T'.
tests/cases/compiler/promisePermutations.ts(117,19): error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<number>'.
tests/cases/compiler/promisePermutations.ts(120,19): error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<number>'.
tests/cases/compiler/promisePermutations.ts(121,19): error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => Promise<T>' is not assignable to parameter of type '(value: number) => Promise<number>'.
tests/cases/compiler/promisePermutations.ts(117,19): error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
tests/cases/compiler/promisePermutations.ts(120,19): error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
tests/cases/compiler/promisePermutations.ts(121,19): error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => Promise<T>' is not assignable to parameter of type '(value: number) => Promise<any>'.
tests/cases/compiler/promisePermutations.ts(122,19): error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => Promise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
tests/cases/compiler/promisePermutations.ts(126,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<number>'.
tests/cases/compiler/promisePermutations.ts(126,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
tests/cases/compiler/promisePermutations.ts(129,11): error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate 'IPromise<number>' is not a valid type argument because it is not a supertype of candidate 'IPromise<string>'.
Type 'string' is not assignable to type 'number'.
tests/cases/compiler/promisePermutations.ts(132,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<number>'.
tests/cases/compiler/promisePermutations.ts(133,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => Promise<T>' is not assignable to parameter of type '(value: number) => Promise<number>'.
tests/cases/compiler/promisePermutations.ts(132,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
tests/cases/compiler/promisePermutations.ts(133,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => Promise<T>' is not assignable to parameter of type '(value: number) => Promise<any>'.
tests/cases/compiler/promisePermutations.ts(134,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => Promise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
tests/cases/compiler/promisePermutations.ts(137,11): error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate 'IPromise<number>' is not a valid type argument because it is not a supertype of candidate 'IPromise<string>'.
@@ -51,9 +51,8 @@ tests/cases/compiler/promisePermutations.ts(152,12): error TS2453: The type argu
Types of property 'then' are incompatible.
Type '{ <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; }' is not assignable to type '{ <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }'.
Types of parameters 'success' and 'onfulfilled' are incompatible.
Type '(value: number) => any' is not assignable to type '(value: string) => IPromise<any>'.
Types of parameters 'value' and 'value' are incompatible.
Type 'string' is not assignable to type 'number'.
Types of parameters 'value' and 'value' are incompatible.
Type 'string' is not assignable to type 'number'.
tests/cases/compiler/promisePermutations.ts(156,21): error TS2345: Argument of type '{ (x: number): IPromise<number>; (x: string): IPromise<string>; }' is not assignable to parameter of type '(value: number) => IPromise<string>'.
Type 'IPromise<number>' is not assignable to type 'IPromise<string>'.
Type 'number' is not assignable to type 'string'.
@@ -67,9 +66,8 @@ tests/cases/compiler/promisePermutations.ts(160,21): error TS2345: Argument of t
Types of property 'then' are incompatible.
Type '{ <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }' is not assignable to type '{ <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; }'.
Types of parameters 'onfulfilled' and 'success' are incompatible.
Type '(value: string) => IPromise<any>' is not assignable to type '(value: number) => any'.
Types of parameters 'value' and 'value' are incompatible.
Type 'number' is not assignable to type 'string'.
Types of parameters 'value' and 'value' are incompatible.
Type 'number' is not assignable to type 'string'.
==== tests/cases/compiler/promisePermutations.ts (33 errors) ====
@@ -241,15 +239,15 @@ tests/cases/compiler/promisePermutations.ts(160,21): error TS2345: Argument of t
var nPromise: (x: any) => Promise<number>;
var r8a = r8.then(testFunction8, testFunction8, testFunction8); // error
~~~~~~~~~~~~~
!!! error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<number>'.
!!! error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
var r8b = r8.then(nIPromise, nIPromise, nIPromise).then(nIPromise, nIPromise, nIPromise); // ok
var s8: Promise<number>;
var s8a = s8.then(testFunction8, testFunction8, testFunction8); // error
~~~~~~~~~~~~~
!!! error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<number>'.
!!! error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
var s8b = s8.then(testFunction8P, testFunction8P, testFunction8P); // error
~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => Promise<T>' is not assignable to parameter of type '(value: number) => Promise<number>'.
!!! error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => Promise<T>' is not assignable to parameter of type '(value: number) => Promise<any>'.
var s8c = s8.then(testFunction8P, testFunction8, testFunction8); // error
~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => Promise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
@@ -258,7 +256,7 @@ tests/cases/compiler/promisePermutations.ts(160,21): error TS2345: Argument of t
var r9: IPromise<number>;
var r9a = r9.then(testFunction9, testFunction9, testFunction9); // error
~~~~~~~~~~~~~
!!! error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<number>'.
!!! error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
var r9b = r9.then(sIPromise, sIPromise, sIPromise); // ok
var r9c = r9.then(nIPromise, nIPromise, nIPromise); // ok
var r9d = r9.then(testFunction, sIPromise, nIPromise); // ok
@@ -270,10 +268,10 @@ tests/cases/compiler/promisePermutations.ts(160,21): error TS2345: Argument of t
var s9: Promise<number>;
var s9a = s9.then(testFunction9, testFunction9, testFunction9); // error
~~~~~~~~~~~~~
!!! error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<number>'.
!!! error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
var s9b = s9.then(testFunction9P, testFunction9P, testFunction9P); // error
~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => Promise<T>' is not assignable to parameter of type '(value: number) => Promise<number>'.
!!! error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => Promise<T>' is not assignable to parameter of type '(value: number) => Promise<any>'.
var s9c = s9.then(testFunction9P, testFunction9, testFunction9); // error
~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => Promise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
@@ -307,9 +305,8 @@ tests/cases/compiler/promisePermutations.ts(160,21): error TS2345: Argument of t
!!! error TS2453: Types of property 'then' are incompatible.
!!! error TS2453: Type '{ <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; }' is not assignable to type '{ <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }'.
!!! error TS2453: Types of parameters 'success' and 'onfulfilled' are incompatible.
!!! error TS2453: Type '(value: number) => any' is not assignable to type '(value: string) => IPromise<any>'.
!!! error TS2453: Types of parameters 'value' and 'value' are incompatible.
!!! error TS2453: Type 'string' is not assignable to type 'number'.
!!! error TS2453: Types of parameters 'value' and 'value' are incompatible.
!!! error TS2453: Type 'string' is not assignable to type 'number'.
var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok
var r11: IPromise<number>;
@@ -335,9 +332,8 @@ tests/cases/compiler/promisePermutations.ts(160,21): error TS2345: Argument of t
!!! error TS2345: Types of property 'then' are incompatible.
!!! error TS2345: Type '{ <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }' is not assignable to type '{ <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; }'.
!!! error TS2345: Types of parameters 'onfulfilled' and 'success' are incompatible.
!!! error TS2345: Type '(value: string) => IPromise<any>' is not assignable to type '(value: number) => any'.
!!! error TS2345: Types of parameters 'value' and 'value' are incompatible.
!!! error TS2345: Type 'number' is not assignable to type 'string'.
!!! error TS2345: Types of parameters 'value' and 'value' are incompatible.
!!! error TS2345: Type 'number' is not assignable to type 'string'.
var r12 = testFunction12(x => x);
var r12a = r12.then(testFunction12, testFunction12, testFunction12); // ok
@@ -31,16 +31,16 @@ tests/cases/compiler/promisePermutations2.ts(109,19): error TS2345: Argument of
tests/cases/compiler/promisePermutations2.ts(110,19): error TS2345: Argument of type '(cb: <T>(a: T) => T) => Promise<string>' is not assignable to parameter of type '(value: string) => IPromise<string>'.
Types of parameters 'cb' and 'value' are incompatible.
Type 'string' is not assignable to type '<T>(a: T) => T'.
tests/cases/compiler/promisePermutations2.ts(116,19): error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<number>'.
tests/cases/compiler/promisePermutations2.ts(119,19): error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<number>'.
tests/cases/compiler/promisePermutations2.ts(120,19): error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => Promise<T>' is not assignable to parameter of type '(value: number) => Promise<number>'.
tests/cases/compiler/promisePermutations2.ts(116,19): error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
tests/cases/compiler/promisePermutations2.ts(119,19): error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
tests/cases/compiler/promisePermutations2.ts(120,19): error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => Promise<T>' is not assignable to parameter of type '(value: number) => Promise<any>'.
tests/cases/compiler/promisePermutations2.ts(121,19): error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => Promise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
tests/cases/compiler/promisePermutations2.ts(125,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<number>'.
tests/cases/compiler/promisePermutations2.ts(125,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
tests/cases/compiler/promisePermutations2.ts(128,11): error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate 'IPromise<number>' is not a valid type argument because it is not a supertype of candidate 'IPromise<string>'.
Type 'string' is not assignable to type 'number'.
tests/cases/compiler/promisePermutations2.ts(131,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<number>'.
tests/cases/compiler/promisePermutations2.ts(132,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => Promise<T>' is not assignable to parameter of type '(value: number) => Promise<number>'.
tests/cases/compiler/promisePermutations2.ts(131,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
tests/cases/compiler/promisePermutations2.ts(132,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => Promise<T>' is not assignable to parameter of type '(value: number) => Promise<any>'.
tests/cases/compiler/promisePermutations2.ts(133,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => Promise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
tests/cases/compiler/promisePermutations2.ts(136,11): error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate 'IPromise<number>' is not a valid type argument because it is not a supertype of candidate 'IPromise<string>'.
@@ -51,9 +51,8 @@ tests/cases/compiler/promisePermutations2.ts(151,12): error TS2453: The type arg
Types of property 'then' are incompatible.
Type '{ <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; }' is not assignable to type '{ <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <U>(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }'.
Types of parameters 'success' and 'onfulfilled' are incompatible.
Type '(value: number) => any' is not assignable to type '(value: string) => IPromise<any>'.
Types of parameters 'value' and 'value' are incompatible.
Type 'string' is not assignable to type 'number'.
Types of parameters 'value' and 'value' are incompatible.
Type 'string' is not assignable to type 'number'.
tests/cases/compiler/promisePermutations2.ts(155,21): error TS2345: Argument of type '{ (x: number): IPromise<number>; (x: string): IPromise<string>; }' is not assignable to parameter of type '(value: number) => IPromise<string>'.
Type 'IPromise<number>' is not assignable to type 'IPromise<string>'.
Type 'number' is not assignable to type 'string'.
@@ -67,9 +66,8 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of
Types of property 'then' are incompatible.
Type '{ <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <U>(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }' is not assignable to type '{ <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; }'.
Types of parameters 'onfulfilled' and 'success' are incompatible.
Type '(value: string) => IPromise<any>' is not assignable to type '(value: number) => any'.
Types of parameters 'value' and 'value' are incompatible.
Type 'number' is not assignable to type 'string'.
Types of parameters 'value' and 'value' are incompatible.
Type 'number' is not assignable to type 'string'.
==== tests/cases/compiler/promisePermutations2.ts (33 errors) ====
@@ -240,15 +238,15 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of
var nPromise: (x: any) => Promise<number>;
var r8a = r8.then(testFunction8, testFunction8, testFunction8); // error
~~~~~~~~~~~~~
!!! error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<number>'.
!!! error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
var r8b = r8.then(nIPromise, nIPromise, nIPromise).then(nIPromise, nIPromise, nIPromise); // ok
var s8: Promise<number>;
var s8a = s8.then(testFunction8, testFunction8, testFunction8); // error
~~~~~~~~~~~~~
!!! error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<number>'.
!!! error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
var s8b = s8.then(testFunction8P, testFunction8P, testFunction8P); // error
~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => Promise<T>' is not assignable to parameter of type '(value: number) => Promise<number>'.
!!! error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => Promise<T>' is not assignable to parameter of type '(value: number) => Promise<any>'.
var s8c = s8.then(testFunction8P, testFunction8, testFunction8); // error
~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => Promise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
@@ -257,7 +255,7 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of
var r9: IPromise<number>;
var r9a = r9.then(testFunction9, testFunction9, testFunction9); // error
~~~~~~~~~~~~~
!!! error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<number>'.
!!! error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
var r9b = r9.then(sIPromise, sIPromise, sIPromise); // ok
var r9c = r9.then(nIPromise, nIPromise, nIPromise); // ok
var r9d = r9.then(testFunction, sIPromise, nIPromise); // error
@@ -269,10 +267,10 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of
var s9: Promise<number>;
var s9a = s9.then(testFunction9, testFunction9, testFunction9); // error
~~~~~~~~~~~~~
!!! error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<number>'.
!!! error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
var s9b = s9.then(testFunction9P, testFunction9P, testFunction9P); // error
~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => Promise<T>' is not assignable to parameter of type '(value: number) => Promise<number>'.
!!! error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => Promise<T>' is not assignable to parameter of type '(value: number) => Promise<any>'.
var s9c = s9.then(testFunction9P, testFunction9, testFunction9); // error
~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => Promise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
@@ -306,9 +304,8 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of
!!! error TS2453: Types of property 'then' are incompatible.
!!! error TS2453: Type '{ <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; }' is not assignable to type '{ <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <U>(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }'.
!!! error TS2453: Types of parameters 'success' and 'onfulfilled' are incompatible.
!!! error TS2453: Type '(value: number) => any' is not assignable to type '(value: string) => IPromise<any>'.
!!! error TS2453: Types of parameters 'value' and 'value' are incompatible.
!!! error TS2453: Type 'string' is not assignable to type 'number'.
!!! error TS2453: Types of parameters 'value' and 'value' are incompatible.
!!! error TS2453: Type 'string' is not assignable to type 'number'.
var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok
var r11: IPromise<number>;
@@ -334,9 +331,8 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of
!!! error TS2345: Types of property 'then' are incompatible.
!!! error TS2345: Type '{ <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <U>(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }' is not assignable to type '{ <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => IPromise<U>, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => IPromise<U>, progress?: (progress: any) => void): IPromise<U>; <U>(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise<U>; }'.
!!! error TS2345: Types of parameters 'onfulfilled' and 'success' are incompatible.
!!! error TS2345: Type '(value: string) => IPromise<any>' is not assignable to type '(value: number) => any'.
!!! error TS2345: Types of parameters 'value' and 'value' are incompatible.
!!! error TS2345: Type 'number' is not assignable to type 'string'.
!!! error TS2345: Types of parameters 'value' and 'value' are incompatible.
!!! error TS2345: Type 'number' is not assignable to type 'string'.
var r12 = testFunction12(x => x);
var r12a = r12.then(testFunction12, testFunction12, testFunction12); // ok
@@ -34,16 +34,16 @@ tests/cases/compiler/promisePermutations3.ts(109,19): error TS2345: Argument of
tests/cases/compiler/promisePermutations3.ts(110,19): error TS2345: Argument of type '(cb: <T>(a: T) => T) => Promise<string>' is not assignable to parameter of type '(value: string) => IPromise<string>'.
Types of parameters 'cb' and 'value' are incompatible.
Type 'string' is not assignable to type '<T>(a: T) => T'.
tests/cases/compiler/promisePermutations3.ts(116,19): error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<number>'.
tests/cases/compiler/promisePermutations3.ts(119,19): error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<number>'.
tests/cases/compiler/promisePermutations3.ts(120,19): error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => Promise<T>' is not assignable to parameter of type '(value: number) => Promise<number>'.
tests/cases/compiler/promisePermutations3.ts(116,19): error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
tests/cases/compiler/promisePermutations3.ts(119,19): error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
tests/cases/compiler/promisePermutations3.ts(120,19): error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => Promise<T>' is not assignable to parameter of type '(value: number) => Promise<any>'.
tests/cases/compiler/promisePermutations3.ts(121,19): error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => Promise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
tests/cases/compiler/promisePermutations3.ts(125,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<number>'.
tests/cases/compiler/promisePermutations3.ts(125,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
tests/cases/compiler/promisePermutations3.ts(128,11): error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate 'IPromise<number>' is not a valid type argument because it is not a supertype of candidate 'IPromise<string>'.
Type 'string' is not assignable to type 'number'.
tests/cases/compiler/promisePermutations3.ts(131,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<number>'.
tests/cases/compiler/promisePermutations3.ts(132,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => Promise<T>' is not assignable to parameter of type '(value: number) => Promise<number>'.
tests/cases/compiler/promisePermutations3.ts(131,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
tests/cases/compiler/promisePermutations3.ts(132,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => Promise<T>' is not assignable to parameter of type '(value: number) => Promise<any>'.
tests/cases/compiler/promisePermutations3.ts(133,19): error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => Promise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
tests/cases/compiler/promisePermutations3.ts(136,11): error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate 'IPromise<number>' is not a valid type argument because it is not a supertype of candidate 'IPromise<string>'.
@@ -54,9 +54,8 @@ tests/cases/compiler/promisePermutations3.ts(151,12): error TS2453: The type arg
Types of property 'then' are incompatible.
Type '<U>(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise<U>' is not assignable to type '{ <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }'.
Types of parameters 'success' and 'onfulfilled' are incompatible.
Type '(value: number) => any' is not assignable to type '(value: string) => any'.
Types of parameters 'value' and 'value' are incompatible.
Type 'string' is not assignable to type 'number'.
Types of parameters 'value' and 'value' are incompatible.
Type 'string' is not assignable to type 'number'.
tests/cases/compiler/promisePermutations3.ts(155,21): error TS2345: Argument of type '{ (x: number): IPromise<number>; (x: string): IPromise<string>; }' is not assignable to parameter of type '(value: number) => IPromise<string>'.
Type 'IPromise<number>' is not assignable to type 'IPromise<string>'.
Type 'number' is not assignable to type 'string'.
@@ -70,9 +69,8 @@ tests/cases/compiler/promisePermutations3.ts(159,21): error TS2345: Argument of
Types of property 'then' are incompatible.
Type '{ <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }' is not assignable to type '<U>(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise<U>'.
Types of parameters 'onfulfilled' and 'success' are incompatible.
Type '(value: string) => any' is not assignable to type '(value: number) => any'.
Types of parameters 'value' and 'value' are incompatible.
Type 'number' is not assignable to type 'string'.
Types of parameters 'value' and 'value' are incompatible.
Type 'number' is not assignable to type 'string'.
tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of type '{ <T>(x: T): IPromise<T>; <T>(x: T, y: T): Promise<T>; }' is not assignable to parameter of type '(value: (x: any) => any) => Promise<any>'.
Type 'IPromise<any>' is not assignable to type 'Promise<any>'.
Types of property 'then' are incompatible.
@@ -252,15 +250,15 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of
var nPromise: (x: any) => Promise<number>;
var r8a = r8.then(testFunction8, testFunction8, testFunction8); // error
~~~~~~~~~~~~~
!!! error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<number>'.
!!! error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
var r8b = r8.then(nIPromise, nIPromise, nIPromise).then(nIPromise, nIPromise, nIPromise); // ok
var s8: Promise<number>;
var s8a = s8.then(testFunction8, testFunction8, testFunction8); // error
~~~~~~~~~~~~~
!!! error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<number>'.
!!! error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
var s8b = s8.then(testFunction8P, testFunction8P, testFunction8P); // error
~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => Promise<T>' is not assignable to parameter of type '(value: number) => Promise<number>'.
!!! error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => Promise<T>' is not assignable to parameter of type '(value: number) => Promise<any>'.
var s8c = s8.then(testFunction8P, testFunction8, testFunction8); // error
~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '<T>(x: T, cb: (a: T) => T) => Promise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
@@ -269,7 +267,7 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of
var r9: IPromise<number>;
var r9a = r9.then(testFunction9, testFunction9, testFunction9); // error
~~~~~~~~~~~~~
!!! error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<number>'.
!!! error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
var r9b = r9.then(sIPromise, sIPromise, sIPromise); // ok
var r9c = r9.then(nIPromise, nIPromise, nIPromise); // ok
var r9d = r9.then(testFunction, sIPromise, nIPromise); // error
@@ -281,10 +279,10 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of
var s9: Promise<number>;
var s9a = s9.then(testFunction9, testFunction9, testFunction9); // error
~~~~~~~~~~~~~
!!! error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<number>'.
!!! error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => IPromise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
var s9b = s9.then(testFunction9P, testFunction9P, testFunction9P); // error
~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => Promise<T>' is not assignable to parameter of type '(value: number) => Promise<number>'.
!!! error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => Promise<T>' is not assignable to parameter of type '(value: number) => Promise<any>'.
var s9c = s9.then(testFunction9P, testFunction9, testFunction9); // error
~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '<T>(x: T, cb: <U>(a: U) => U) => Promise<T>' is not assignable to parameter of type '(value: number) => IPromise<any>'.
@@ -318,9 +316,8 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of
!!! error TS2453: Types of property 'then' are incompatible.
!!! error TS2453: Type '<U>(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise<U>' is not assignable to type '{ <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }'.
!!! error TS2453: Types of parameters 'success' and 'onfulfilled' are incompatible.
!!! error TS2453: Type '(value: number) => any' is not assignable to type '(value: string) => any'.
!!! error TS2453: Types of parameters 'value' and 'value' are incompatible.
!!! error TS2453: Type 'string' is not assignable to type 'number'.
!!! error TS2453: Types of parameters 'value' and 'value' are incompatible.
!!! error TS2453: Type 'string' is not assignable to type 'number'.
var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok
var r11: IPromise<number>;
@@ -346,9 +343,8 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of
!!! error TS2345: Types of property 'then' are incompatible.
!!! error TS2345: Type '{ <TResult1 = number, TResult2 = never>(onfulfilled?: (value: number) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => Promise<U>, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => Promise<U>, progress?: (progress: any) => void): Promise<U>; <U>(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise<U>; }' is not assignable to type '<U>(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise<U>'.
!!! error TS2345: Types of parameters 'onfulfilled' and 'success' are incompatible.
!!! error TS2345: Type '(value: string) => any' is not assignable to type '(value: number) => any'.
!!! error TS2345: Types of parameters 'value' and 'value' are incompatible.
!!! error TS2345: Type 'number' is not assignable to type 'string'.
!!! error TS2345: Types of parameters 'value' and 'value' are incompatible.
!!! error TS2345: Type 'number' is not assignable to type 'string'.
var r12 = testFunction12(x => x);
var r12a = r12.then(testFunction12, testFunction12, testFunction12); // ok
@@ -0,0 +1,36 @@
tests/cases/compiler/promisesWithConstraints.ts(15,1): error TS2322: Type 'Promise<Foo>' is not assignable to type 'Promise<Bar>'.
Type 'Foo' is not assignable to type 'Bar'.
Property 'y' is missing in type 'Foo'.
tests/cases/compiler/promisesWithConstraints.ts(20,1): error TS2322: Type 'CPromise<Foo>' is not assignable to type 'CPromise<Bar>'.
Type 'Foo' is not assignable to type 'Bar'.
==== tests/cases/compiler/promisesWithConstraints.ts (2 errors) ====
interface Promise<T> {
then<U>(cb: (x: T) => Promise<U>): Promise<U>;
}
interface CPromise<T extends { x: any; }> {
then<U extends { x: any; }>(cb: (x: T) => Promise<U>): Promise<U>;
}
interface Foo { x; }
interface Bar { x; y; }
var a: Promise<Foo>;
var b: Promise<Bar>;
a = b; // ok
b = a; // ok
~
!!! error TS2322: Type 'Promise<Foo>' is not assignable to type 'Promise<Bar>'.
!!! error TS2322: Type 'Foo' is not assignable to type 'Bar'.
!!! error TS2322: Property 'y' is missing in type 'Foo'.
var a2: CPromise<Foo>;
var b2: CPromise<Bar>;
a2 = b2; // ok
b2 = a2; // was error
~~
!!! error TS2322: Type 'CPromise<Foo>' is not assignable to type 'CPromise<Bar>'.
!!! error TS2322: Type 'Foo' is not assignable to type 'Bar'.
@@ -1,7 +1,9 @@
tests/cases/compiler/recursiveTypeComparison2.ts(13,80): error TS2304: Cannot find name 'StateValue'.
tests/cases/compiler/recursiveTypeComparison2.ts(30,5): error TS2322: Type 'Bus<{}>' is not assignable to type 'Bus<number>'.
Type '{}' is not assignable to type 'number'.
==== tests/cases/compiler/recursiveTypeComparison2.ts (1 errors) ====
==== tests/cases/compiler/recursiveTypeComparison2.ts (2 errors) ====
// Before fix this would cause compiler to hang (#1170)
declare module Bacon {
@@ -33,4 +35,7 @@ tests/cases/compiler/recursiveTypeComparison2.ts(13,80): error TS2304: Cannot fi
var Bus: new <T>() => Bus<T>;
}
var stuck: Bacon.Bus<number> = new Bacon.Bus();
var stuck: Bacon.Bus<number> = new Bacon.Bus();
~~~~~
!!! error TS2322: Type 'Bus<{}>' is not assignable to type 'Bus<number>'.
!!! error TS2322: Type '{}' is not assignable to type 'number'.
@@ -0,0 +1,20 @@
//// [tests/cases/conformance/moduleResolution/scopedPackages.ts] ////
//// [index.d.ts]
export const x: number;
//// [index.d.ts]
export const y: number;
//// [z.d.ts]
export const z: number;
//// [a.ts]
import { x } from "@cow/boy";
import { y } from "@be/bop";
import { z } from "@be/bop/e/z";
//// [a.js]
"use strict";
exports.__esModule = true;
@@ -0,0 +1,22 @@
=== /a.ts ===
import { x } from "@cow/boy";
>x : Symbol(x, Decl(a.ts, 0, 8))
import { y } from "@be/bop";
>y : Symbol(y, Decl(a.ts, 1, 8))
import { z } from "@be/bop/e/z";
>z : Symbol(z, Decl(a.ts, 2, 8))
=== /node_modules/@cow/boy/index.d.ts ===
export const x: number;
>x : Symbol(x, Decl(index.d.ts, 0, 12))
=== /node_modules/@types/be__bop/index.d.ts ===
export const y: number;
>y : Symbol(y, Decl(index.d.ts, 0, 12))
=== /node_modules/@types/be__bop/e/z.d.ts ===
export const z: number;
>z : Symbol(z, Decl(z.d.ts, 0, 12))
@@ -0,0 +1,30 @@
[
"======== Resolving module '@cow/boy' from '/a.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module '@cow/boy' from 'node_modules' folder, target file type 'TypeScript'.",
"File '/node_modules/@cow/boy.ts' does not exist.",
"File '/node_modules/@cow/boy.tsx' does not exist.",
"File '/node_modules/@cow/boy.d.ts' does not exist.",
"File '/node_modules/@cow/boy/package.json' does not exist.",
"File '/node_modules/@cow/boy/index.ts' does not exist.",
"File '/node_modules/@cow/boy/index.tsx' does not exist.",
"File '/node_modules/@cow/boy/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/node_modules/@cow/boy/index.d.ts', result '/node_modules/@cow/boy/index.d.ts'.",
"======== Module name '@cow/boy' was successfully resolved to '/node_modules/@cow/boy/index.d.ts'. ========",
"======== Resolving module '@be/bop' from '/a.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module '@be/bop' from 'node_modules' folder, target file type 'TypeScript'.",
"Scoped package detected, looking in 'be__bop'",
"File '/node_modules/@types/be__bop.d.ts' does not exist.",
"File '/node_modules/@types/be__bop/package.json' does not exist.",
"File '/node_modules/@types/be__bop/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/node_modules/@types/be__bop/index.d.ts', result '/node_modules/@types/be__bop/index.d.ts'.",
"======== Module name '@be/bop' was successfully resolved to '/node_modules/@types/be__bop/index.d.ts'. ========",
"======== Resolving module '@be/bop/e/z' from '/a.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module '@be/bop/e/z' from 'node_modules' folder, target file type 'TypeScript'.",
"Scoped package detected, looking in 'be__bop/e/z'",
"File '/node_modules/@types/be__bop/e/z.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/node_modules/@types/be__bop/e/z.d.ts', result '/node_modules/@types/be__bop/e/z.d.ts'.",
"======== Module name '@be/bop/e/z' was successfully resolved to '/node_modules/@types/be__bop/e/z.d.ts'. ========"
]
@@ -0,0 +1,22 @@
=== /a.ts ===
import { x } from "@cow/boy";
>x : number
import { y } from "@be/bop";
>y : number
import { z } from "@be/bop/e/z";
>z : number
=== /node_modules/@cow/boy/index.d.ts ===
export const x: number;
>x : number
=== /node_modules/@types/be__bop/index.d.ts ===
export const y: number;
>y : number
=== /node_modules/@types/be__bop/e/z.d.ts ===
export const z: number;
>z : number
@@ -0,0 +1,12 @@
//// [tests/cases/conformance/moduleResolution/scopedPackagesClassic.ts] ////
//// [index.d.ts]
export const x = 0;
//// [a.ts]
import { x } from "@see/saw";
//// [a.js]
"use strict";
exports.__esModule = true;
@@ -0,0 +1,8 @@
=== /a.ts ===
import { x } from "@see/saw";
>x : Symbol(x, Decl(a.ts, 0, 8))
=== /node_modules/@types/see__saw/index.d.ts ===
export const x = 0;
>x : Symbol(x, Decl(index.d.ts, 0, 12))
@@ -0,0 +1,9 @@
[
"======== Resolving module '@see/saw' from '/a.ts'. ========",
"Explicitly specified module resolution kind: 'Classic'.",
"Scoped package detected, looking in 'see__saw'",
"File '/node_modules/@types/see__saw.d.ts' does not exist.",
"File '/node_modules/@types/see__saw/package.json' does not exist.",
"File '/node_modules/@types/see__saw/index.d.ts' exist - use it as a name resolution result.",
"======== Module name '@see/saw' was successfully resolved to '/node_modules/@types/see__saw/index.d.ts'. ========"
]
@@ -0,0 +1,9 @@
=== /a.ts ===
import { x } from "@see/saw";
>x : 0
=== /node_modules/@types/see__saw/index.d.ts ===
export const x = 0;
>x : 0
>0 : 0
@@ -681,14 +681,14 @@ var r9 = foo9(r9arg1); // any
>r9arg1 : <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U
var r9a = [r9arg1, r9arg2];
>r9a : (<T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U)[]
>[r9arg1, r9arg2] : (<T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U)[]
>r9a : ((<T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U) | ((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived))[]
>[r9arg1, r9arg2] : ((<T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U) | ((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived))[]
>r9arg1 : <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U
>r9arg2 : (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived
var r9b = [r9arg2, r9arg1];
>r9b : (<T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U)[]
>[r9arg2, r9arg1] : (<T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U)[]
>r9b : ((<T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U) | ((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived))[]
>[r9arg2, r9arg1] : ((<T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U) | ((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived))[]
>r9arg2 : (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived
>r9arg1 : <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U
@@ -0,0 +1,19 @@
//// [typeofUsedBeforeBlockScoped.ts]
type T = typeof C & typeof C.s & typeof o & typeof o.n;
class C {
static s = 2;
}
type W = typeof o.n;
let o2: typeof o;
let o = { n: 12 };
//// [typeofUsedBeforeBlockScoped.js]
var C = (function () {
function C() {
}
return C;
}());
C.s = 2;
var o2;
var o = { n: 12 };
@@ -0,0 +1,32 @@
=== tests/cases/compiler/typeofUsedBeforeBlockScoped.ts ===
type T = typeof C & typeof C.s & typeof o & typeof o.n;
>T : Symbol(T, Decl(typeofUsedBeforeBlockScoped.ts, 0, 0))
>C : Symbol(C, Decl(typeofUsedBeforeBlockScoped.ts, 0, 55))
>C.s : Symbol(C.s, Decl(typeofUsedBeforeBlockScoped.ts, 1, 9))
>C : Symbol(C, Decl(typeofUsedBeforeBlockScoped.ts, 0, 55))
>s : Symbol(C.s, Decl(typeofUsedBeforeBlockScoped.ts, 1, 9))
>o : Symbol(o, Decl(typeofUsedBeforeBlockScoped.ts, 6, 3))
>o.n : Symbol(n, Decl(typeofUsedBeforeBlockScoped.ts, 6, 9))
>o : Symbol(o, Decl(typeofUsedBeforeBlockScoped.ts, 6, 3))
>n : Symbol(n, Decl(typeofUsedBeforeBlockScoped.ts, 6, 9))
class C {
>C : Symbol(C, Decl(typeofUsedBeforeBlockScoped.ts, 0, 55))
static s = 2;
>s : Symbol(C.s, Decl(typeofUsedBeforeBlockScoped.ts, 1, 9))
}
type W = typeof o.n;
>W : Symbol(W, Decl(typeofUsedBeforeBlockScoped.ts, 3, 1))
>o.n : Symbol(n, Decl(typeofUsedBeforeBlockScoped.ts, 6, 9))
>o : Symbol(o, Decl(typeofUsedBeforeBlockScoped.ts, 6, 3))
>n : Symbol(n, Decl(typeofUsedBeforeBlockScoped.ts, 6, 9))
let o2: typeof o;
>o2 : Symbol(o2, Decl(typeofUsedBeforeBlockScoped.ts, 5, 3))
>o : Symbol(o, Decl(typeofUsedBeforeBlockScoped.ts, 6, 3))
let o = { n: 12 };
>o : Symbol(o, Decl(typeofUsedBeforeBlockScoped.ts, 6, 3))
>n : Symbol(n, Decl(typeofUsedBeforeBlockScoped.ts, 6, 9))
@@ -0,0 +1,35 @@
=== tests/cases/compiler/typeofUsedBeforeBlockScoped.ts ===
type T = typeof C & typeof C.s & typeof o & typeof o.n;
>T : T
>C : typeof C
>C.s : number
>C : typeof C
>s : number
>o : { n: number; }
>o.n : number
>o : { n: number; }
>n : number
class C {
>C : C
static s = 2;
>s : number
>2 : 2
}
type W = typeof o.n;
>W : number
>o.n : number
>o : { n: number; }
>n : number
let o2: typeof o;
>o2 : { n: number; }
>o : { n: number; }
let o = { n: 12 };
>o : { n: number; }
>{ n: 12 } : { n: number; }
>n : number
>12 : 12
@@ -0,0 +1,8 @@
//// [unknownPropertiesAreAssignableToObjectUnion.ts]
const x: Object | string = { x: 0 };
const y: Object | undefined = { x: 0 };
//// [unknownPropertiesAreAssignableToObjectUnion.js]
var x = { x: 0 };
var y = { x: 0 };
@@ -0,0 +1,11 @@
=== tests/cases/compiler/unknownPropertiesAreAssignableToObjectUnion.ts ===
const x: Object | string = { x: 0 };
>x : Symbol(x, Decl(unknownPropertiesAreAssignableToObjectUnion.ts, 0, 5))
>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>x : Symbol(x, Decl(unknownPropertiesAreAssignableToObjectUnion.ts, 0, 28))
const y: Object | undefined = { x: 0 };
>y : Symbol(y, Decl(unknownPropertiesAreAssignableToObjectUnion.ts, 1, 5))
>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>x : Symbol(x, Decl(unknownPropertiesAreAssignableToObjectUnion.ts, 1, 31))
@@ -0,0 +1,15 @@
=== tests/cases/compiler/unknownPropertiesAreAssignableToObjectUnion.ts ===
const x: Object | string = { x: 0 };
>x : string | Object
>Object : Object
>{ x: 0 } : { x: number; }
>x : number
>0 : 0
const y: Object | undefined = { x: 0 };
>y : Object | undefined
>Object : Object
>{ x: 0 } : { x: number; }
>x : number
>0 : 0
@@ -0,0 +1,27 @@
// @noImplicitAny: true
// Fixes exponential time/space in #14628
let x = []
x[0] = { foo: 'hi' }
x[0] = { foo: 'hi' }
x[0] = { foo: 'hi' }
x[0] = { foo: 'hi' }
x[0] = { foo: 'hi' }
x[0] = { foo: 'hi' }
x[0] = { foo: 'hi' }
x[0] = { foo: 'hi' }
x[0] = { foo: 'hi' }
x[0] = { foo: 'hi' }
x[0] = { foo: 'hi' }
x[0] = { foo: 'hi' }
x[0] = { foo: 'hi' } // previously ran out of memory here
x[0] = { foo: 'hi' }
x[0] = { foo: 'hi' }
x[0] = { foo: 'hi' }
x[0] = { foo: 'hi' }
x[0] = { foo: 'hi' }
x[0] = { foo: 'hi' }
x[0] = { foo: 'hi' }
x[0] = { foo: 'hi' }
x[0] = { foo: 'hi' }
x[0] = { foo: 'hi' }
x[0] = { foo: 'hi' }
@@ -0,0 +1,24 @@
// @allowJs: true
// @checkJs: true
// @noEmit: true
// @fileName: a.js
// @ts-check
class A {
constructor() {
}
foo() {
return 4;
}
}
class B extends A {
constructor() {
super();
this.foo = () => 3;
}
}
const i = new B();
i.foo();
@@ -0,0 +1,10 @@
// @allowJs: true
// @noEmit: true
// @filename: foo.js
module.exports = function () {
class A { }
return {
c: A.b = 1,
}
};
@@ -0,0 +1,7 @@
type T = typeof C & typeof C.s & typeof o & typeof o.n;
class C {
static s = 2;
}
type W = typeof o.n;
let o2: typeof o;
let o = { n: 12 };
@@ -0,0 +1,3 @@
// @strictNullChecks: true
const x: Object | string = { x: 0 };
const y: Object | undefined = { x: 0 };
@@ -0,0 +1,5 @@
export { x }
const x = 'x'
export { Y as Z }
class Y {}
@@ -0,0 +1,17 @@
// @noImplicitReferences: true
// @traceResolution: true
// @typeRoots: types
// @filename: /node_modules/@cow/boy/index.d.ts
export const x: number;
// @filename: /node_modules/@types/be__bop/index.d.ts
export const y: number;
// @filename: /node_modules/@types/be__bop/e/z.d.ts
export const z: number;
// @filename: /a.ts
import { x } from "@cow/boy";
import { y } from "@be/bop";
import { z } from "@be/bop/e/z";
@@ -0,0 +1,10 @@
// @noImplicitReferences: true
// @traceResolution: true
// @typeRoots: types
// @moduleResolution: classic
// @filename: /node_modules/@types/see__saw/index.d.ts
export const x = 0;
// @filename: /a.ts
import { x } from "@see/saw";
@@ -0,0 +1,9 @@
// @noImplicitReferences: true
// @traceResolution: true
// @typeRoots: types
// @filename: /node_modules/@types/beep__boop/index.d.ts
export const y = 0;
// @filename: /a.ts
/// <reference types="@beep/boop" />
@@ -0,0 +1,73 @@
// @target: es2015
// @strict: true
// Test that callback parameters are related covariantly
interface P<T> {
then(cb: (value: T) => void): void;
};
interface A { a: string }
interface B extends A { b: string }
function f1(a: P<A>, b: P<B>) {
a = b;
b = a; // Error
}
function f2(a: Promise<A>, b: Promise<B>) {
a = b;
b = a; // Error
}
interface AList1 {
forEach(cb: (item: A) => void): void;
}
interface BList1 {
forEach(cb: (item: B) => void): void;
}
function f11(a: AList1, b: BList1) {
a = b;
b = a; // Error
}
interface AList2 {
forEach(cb: (item: A) => boolean): void;
}
interface BList2 {
forEach(cb: (item: A) => void): void;
}
function f12(a: AList2, b: BList2) {
a = b;
b = a; // Error
}
interface AList3 {
forEach(cb: (item: A) => void): void;
}
interface BList3 {
forEach(cb: (item: A, context: any) => void): void;
}
function f13(a: AList3, b: BList3) {
a = b;
b = a; // Error
}
interface AList4 {
forEach(cb: (item: A) => A): void;
}
interface BList4 {
forEach(cb: (item: B) => B): void;
}
function f14(a: AList4, b: BList4) {
a = b;
b = a; // Error
}
+2
View File
@@ -60,6 +60,8 @@
"object-literal-surrounding-space": true,
"no-type-assertion-whitespace": true,
"no-in-operator": true,
"no-switch-case-fall-through": true,
"triple-equals": true,
"jsdoc-format": true
}
}