Merge branch 'master' into isInMultiLineComment

This commit is contained in:
Arthur Ozga
2017-08-09 10:49:12 -07:00
117 changed files with 2105 additions and 1124 deletions
+6 -5
View File
@@ -1122,14 +1122,15 @@ task("update-sublime", ["local", serverFile], function () {
var tslintRuleDir = "scripts/tslint";
var tslintRules = [
"nextLineRule",
"booleanTriviaRule",
"typeOperatorSpacingRule",
"noInOperatorRule",
"debugAssertRule",
"nextLineRule",
"noBomRule",
"noIncrementDecrementRule",
"objectLiteralSurroundingSpaceRule",
"noInOperatorRule",
"noTypeAssertionWhitespaceRule",
"noBomRule"
"objectLiteralSurroundingSpaceRule",
"typeOperatorSpacingRule",
];
var tslintRulesFiles = tslintRules.map(function (p) {
return path.join(tslintRuleDir, p + ".ts");
+2 -1
View File
@@ -34,6 +34,7 @@ function walk(ctx: Lint.WalkContext<void>): void {
switch (methodName) {
case "apply":
case "assert":
case "assertEqual":
case "call":
case "equal":
case "fail":
@@ -69,7 +70,7 @@ function walk(ctx: Lint.WalkContext<void>): void {
const ranges = ts.getTrailingCommentRanges(sourceFile.text, arg.pos) || ts.getLeadingCommentRanges(sourceFile.text, arg.pos);
if (ranges === undefined || ranges.length !== 1 || ranges[0].kind !== ts.SyntaxKind.MultiLineCommentTrivia) {
ctx.addFailureAtNode(arg, "Tag boolean argument with parameter name");
ctx.addFailureAtNode(arg, "Tag argument with parameter name");
return;
}
+45
View File
@@ -0,0 +1,45 @@
import * as Lint from "tslint/lib";
import * as ts from "typescript";
export class Rule extends Lint.Rules.AbstractRule {
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
return this.applyWithFunction(sourceFile, ctx => walk(ctx));
}
}
function walk(ctx: Lint.WalkContext<void>): void {
ts.forEachChild(ctx.sourceFile, function recur(node) {
if (ts.isCallExpression(node)) {
checkCall(node);
}
ts.forEachChild(node, recur);
});
function checkCall(node: ts.CallExpression) {
if (!isDebugAssert(node.expression) || node.arguments.length < 2) {
return;
}
const message = node.arguments[1];
if (!ts.isStringLiteral(message)) {
ctx.addFailureAtNode(message, "Second argument to 'Debug.assert' should be a string literal.");
}
if (node.arguments.length < 3) {
return;
}
const message2 = node.arguments[2];
if (!ts.isStringLiteral(message2) && !ts.isArrowFunction(message2)) {
ctx.addFailureAtNode(message, "Third argument to 'Debug.assert' should be a string literal or arrow function.");
}
}
function isDebugAssert(expr: ts.Node): boolean {
return ts.isPropertyAccessExpression(expr) && isName(expr.expression, "Debug") && isName(expr.name, "assert");
}
function isName(expr: ts.Node, text: string): boolean {
return ts.isIdentifier(expr) && expr.text === text;
}
}
+4 -1
View File
@@ -2921,7 +2921,10 @@ namespace ts {
function computeCatchClause(node: CatchClause, subtreeFlags: TransformFlags) {
let transformFlags = subtreeFlags;
if (node.variableDeclaration && isBindingPattern(node.variableDeclaration.name)) {
if (!node.variableDeclaration) {
transformFlags |= TransformFlags.AssertESNext;
}
else if (isBindingPattern(node.variableDeclaration.name)) {
transformFlags |= TransformFlags.AssertES2015;
}
+94 -96
View File
@@ -481,7 +481,7 @@ namespace ts {
Type,
ResolvedBaseConstructorType,
DeclaredType,
ResolvedReturnType
ResolvedReturnType,
}
const enum CheckMode {
@@ -1086,7 +1086,10 @@ namespace ts {
location = location.parent;
}
if (result && nameNotFoundMessage && noUnusedIdentifiers) {
// We just climbed up parents looking for the name, meaning that we started in a descendant node of `lastLocation`.
// If `result === lastLocation.symbol`, that means that we are somewhere inside `lastLocation` looking up a name, and resolving to `lastLocation` itself.
// That means that this is a self-reference of `lastLocation`, and shouldn't count this when considering whether `lastLocation` is used.
if (result && nameNotFoundMessage && noUnusedIdentifiers && result !== lastLocation.symbol) {
result.isReferenced = true;
}
@@ -1754,7 +1757,7 @@ namespace ts {
// An external module with an 'export =' declaration resolves to the target of the 'export =' declaration,
// and an external module with no 'export =' declaration resolves to the module itself.
function resolveExternalModuleSymbol(moduleSymbol: Symbol, dontResolveAlias?: boolean): Symbol {
return moduleSymbol && getMergedSymbol(resolveSymbol(moduleSymbol.exports.get("export=" as __String), dontResolveAlias)) || moduleSymbol;
return moduleSymbol && getMergedSymbol(resolveSymbol(moduleSymbol.exports.get(InternalSymbolName.ExportEquals), dontResolveAlias)) || moduleSymbol;
}
// An external module with an 'export =' declaration may be referenced as an ES6 module provided the 'export ='
@@ -1769,7 +1772,7 @@ namespace ts {
}
function hasExportAssignmentSymbol(moduleSymbol: Symbol): boolean {
return moduleSymbol.exports.get("export=" as __String) !== undefined;
return moduleSymbol.exports.get(InternalSymbolName.ExportEquals) !== undefined;
}
function getExportsOfModuleAsArray(moduleSymbol: Symbol): Symbol[] {
@@ -3417,9 +3420,7 @@ namespace ts {
if (!symbolStack) {
symbolStack = [];
}
const isConstructorObject = type.flags & TypeFlags.Object &&
getObjectFlags(type) & ObjectFlags.Anonymous &&
type.symbol && type.symbol.flags & SymbolFlags.Class;
const isConstructorObject = type.objectFlags & ObjectFlags.Anonymous && type.symbol && type.symbol.flags & SymbolFlags.Class;
if (isConstructorObject) {
writeLiteralType(type, flags);
}
@@ -7555,11 +7556,11 @@ namespace ts {
return getTypeOfSymbol(prop);
}
}
if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, TypeFlags.StringLike | TypeFlags.NumberLike | TypeFlags.ESSymbol)) {
if (!(indexType.flags & TypeFlags.Nullable) && isTypeAssignableToKind(indexType, TypeFlags.StringLike | TypeFlags.NumberLike | TypeFlags.ESSymbol)) {
if (isTypeAny(objectType)) {
return anyType;
}
const indexInfo = isTypeAnyOrAllConstituentTypesHaveKind(indexType, TypeFlags.NumberLike) && getIndexInfoOfType(objectType, IndexKind.Number) ||
const indexInfo = isTypeAssignableToKind(indexType, TypeFlags.NumberLike) && getIndexInfoOfType(objectType, IndexKind.Number) ||
getIndexInfoOfType(objectType, IndexKind.String) ||
undefined;
if (indexInfo) {
@@ -8938,11 +8939,21 @@ namespace ts {
!(target.flags & TypeFlags.Union) &&
!isIntersectionConstituent &&
source !== globalObjectType &&
getPropertiesOfType(source).length > 0 &&
(getPropertiesOfType(source).length > 0 ||
getSignaturesOfType(source, SignatureKind.Call).length > 0 ||
getSignaturesOfType(source, SignatureKind.Construct).length > 0) &&
isWeakType(target) &&
!hasCommonProperties(source, target)) {
if (reportErrors) {
reportError(Diagnostics.Type_0_has_no_properties_in_common_with_type_1, typeToString(source), typeToString(target));
const calls = getSignaturesOfType(source, SignatureKind.Call);
const constructs = getSignaturesOfType(source, SignatureKind.Construct);
if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, /*reportErrors*/ false) ||
constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, /*reportErrors*/ false)) {
reportError(Diagnostics.Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it, typeToString(source), typeToString(target));
}
else {
reportError(Diagnostics.Type_0_has_no_properties_in_common_with_type_1, typeToString(source), typeToString(target));
}
}
return Ternary.False;
}
@@ -10800,17 +10811,6 @@ namespace ts {
return undefined;
}
function getLeftmostIdentifierOrThis(node: Node): Node {
switch (node.kind) {
case SyntaxKind.Identifier:
case SyntaxKind.ThisKeyword:
return node;
case SyntaxKind.PropertyAccessExpression:
return getLeftmostIdentifierOrThis((<PropertyAccessExpression>node).expression);
}
return undefined;
}
function getBindingElementNameText(element: BindingElement): string | undefined {
if (element.parent.kind === SyntaxKind.ObjectBindingPattern) {
const name = element.propertyName || element.name;
@@ -11384,7 +11384,7 @@ namespace ts {
(<BinaryExpression>parent.parent).operatorToken.kind === SyntaxKind.EqualsToken &&
(<BinaryExpression>parent.parent).left === parent &&
!isAssignmentTarget(parent.parent) &&
isTypeAnyOrAllConstituentTypesHaveKind(getTypeOfExpression((<ElementAccessExpression>parent).argumentExpression), TypeFlags.NumberLike | TypeFlags.Undefined);
isTypeAssignableToKind(getTypeOfExpression((<ElementAccessExpression>parent).argumentExpression), TypeFlags.NumberLike);
return isLengthPushOrUnshift || isElementAssignment;
}
@@ -11556,7 +11556,7 @@ namespace ts {
}
else {
const indexType = getTypeOfExpression((<ElementAccessExpression>(<BinaryExpression>node).left).argumentExpression);
if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, TypeFlags.NumberLike | TypeFlags.Undefined)) {
if (isTypeAssignableToKind(indexType, TypeFlags.NumberLike)) {
evolvedType = addEvolvingArrayElementType(evolvedType, (<BinaryExpression>node).right);
}
}
@@ -13398,11 +13398,7 @@ namespace ts {
function isNumericComputedName(name: ComputedPropertyName): boolean {
// It seems odd to consider an expression of type Any to result in a numeric name,
// but this behavior is consistent with checkIndexedAccess
return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), TypeFlags.NumberLike);
}
function isTypeAnyOrAllConstituentTypesHaveKind(type: Type, kind: TypeFlags): boolean {
return isTypeAny(type) || isTypeOfKind(type, kind);
return isTypeAssignableToKind(checkComputedPropertyName(name), TypeFlags.NumberLike);
}
function isInfinityOrNaNString(name: string | __String): boolean {
@@ -13438,10 +13434,11 @@ namespace ts {
const links = getNodeLinks(node.expression);
if (!links.resolvedType) {
links.resolvedType = checkExpression(node.expression);
// This will allow types number, string, symbol or any. It will also allow enums, the unknown
// type, and any union of these types (like string | number).
if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, TypeFlags.NumberLike | TypeFlags.StringLike | TypeFlags.ESSymbol)) {
if (links.resolvedType.flags & TypeFlags.Nullable ||
!isTypeAssignableToKind(links.resolvedType, TypeFlags.StringLike | TypeFlags.NumberLike | TypeFlags.ESSymbol) &&
!isTypeAssignableTo(links.resolvedType, getUnionType([stringType, numberType, esSymbolType]))) {
error(node, Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any);
}
else {
@@ -14105,11 +14102,8 @@ namespace ts {
*/
function resolveCustomJsxElementAttributesType(openingLikeElement: JsxOpeningLikeElement,
shouldIncludeAllStatelessAttributesType: boolean,
elementType?: Type,
elementType: Type = checkExpression(openingLikeElement.tagName),
elementClassType?: Type): Type {
if (!elementType) {
elementType = checkExpression(openingLikeElement.tagName);
}
if (elementType.flags & TypeFlags.Union) {
const types = (elementType as UnionType).types;
@@ -14243,11 +14237,12 @@ namespace ts {
*/
function getCustomJsxElementAttributesType(node: JsxOpeningLikeElement, shouldIncludeAllStatelessAttributesType: boolean): Type {
const links = getNodeLinks(node);
if (!links.resolvedJsxElementAttributesType) {
const linkLocation = shouldIncludeAllStatelessAttributesType ? "resolvedJsxElementAllAttributesType" : "resolvedJsxElementAttributesType";
if (!links[linkLocation]) {
const elemClassType = getJsxGlobalElementClassType();
return links.resolvedJsxElementAttributesType = resolveCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType, /*elementType*/ undefined, elemClassType);
return links[linkLocation] = resolveCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType, /*elementType*/ undefined, elemClassType);
}
return links.resolvedJsxElementAttributesType;
return links[linkLocation];
}
/**
@@ -15548,7 +15543,7 @@ namespace ts {
case SyntaxKind.ComputedPropertyName:
const nameType = checkComputedPropertyName(element.name);
if (isTypeOfKind(nameType, TypeFlags.ESSymbol)) {
if (isTypeAssignableToKind(nameType, TypeFlags.ESSymbol)) {
return nameType;
}
else {
@@ -16407,12 +16402,35 @@ namespace ts {
if (moduleSymbol) {
const esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, /*dontRecursivelyResolve*/ true);
if (esModuleSymbol) {
return createPromiseReturnType(node, getTypeOfSymbol(esModuleSymbol));
return createPromiseReturnType(node, getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol));
}
}
return createPromiseReturnType(node, anyType);
}
function getTypeWithSyntheticDefaultImportType(type: Type, symbol: Symbol): Type {
if (allowSyntheticDefaultImports && type && type !== unknownType) {
const synthType = type as SyntheticDefaultModuleType;
if (!synthType.syntheticType) {
if (!getPropertyOfType(type, InternalSymbolName.Default)) {
const memberTable = createSymbolTable();
const newSymbol = createSymbol(SymbolFlags.Alias, InternalSymbolName.Default);
newSymbol.target = resolveSymbol(symbol);
memberTable.set(InternalSymbolName.Default, newSymbol);
const anonymousSymbol = createSymbol(SymbolFlags.TypeLiteral, InternalSymbolName.Type);
const defaultContainingObject = createAnonymousType(anonymousSymbol, memberTable, emptyArray, emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined);
anonymousSymbol.type = defaultContainingObject;
synthType.syntheticType = getIntersectionType([type, defaultContainingObject]);
}
else {
synthType.syntheticType = type;
}
}
return synthType.syntheticType;
}
return type;
}
function isCommonJsRequire(node: Node) {
if (!isRequireCall(node, /*checkArgumentIsStringLiteral*/ true)) {
return false;
@@ -16938,7 +16956,7 @@ namespace ts {
}
function checkArithmeticOperandType(operand: Node, type: Type, diagnostic: DiagnosticMessage): boolean {
if (!isTypeAnyOrAllConstituentTypesHaveKind(type, TypeFlags.NumberLike)) {
if (!isTypeAssignableToKind(type, TypeFlags.NumberLike)) {
error(operand, diagnostic);
return false;
}
@@ -17116,31 +17134,22 @@ namespace ts {
return false;
}
// Return true if type is of the given kind. A union type is of a given kind if all constituent types
// are of the given kind. An intersection type is of a given kind if at least one constituent type is
// of the given kind.
function isTypeOfKind(type: Type, kind: TypeFlags): boolean {
if (type.flags & kind) {
function isTypeAssignableToKind(source: Type, kind: TypeFlags, strict?: boolean): boolean {
if (source.flags & kind) {
return true;
}
if (type.flags & TypeFlags.Union) {
const types = (<UnionOrIntersectionType>type).types;
for (const t of types) {
if (!isTypeOfKind(t, kind)) {
return false;
}
}
return true;
if (strict && source.flags & (TypeFlags.Any | TypeFlags.Void | TypeFlags.Undefined | TypeFlags.Null)) {
return false;
}
if (type.flags & TypeFlags.Intersection) {
const types = (<UnionOrIntersectionType>type).types;
for (const t of types) {
if (isTypeOfKind(t, kind)) {
return true;
}
}
}
return false;
return (kind & TypeFlags.NumberLike && isTypeAssignableTo(source, numberType)) ||
(kind & TypeFlags.StringLike && isTypeAssignableTo(source, stringType)) ||
(kind & TypeFlags.BooleanLike && isTypeAssignableTo(source, booleanType)) ||
(kind & TypeFlags.Void && isTypeAssignableTo(source, voidType)) ||
(kind & TypeFlags.Never && isTypeAssignableTo(source, neverType)) ||
(kind & TypeFlags.Null && isTypeAssignableTo(source, nullType)) ||
(kind & TypeFlags.Undefined && isTypeAssignableTo(source, undefinedType)) ||
(kind & TypeFlags.ESSymbol && isTypeAssignableTo(source, esSymbolType)) ||
(kind & TypeFlags.NonPrimitive && isTypeAssignableTo(source, nonPrimitiveType));
}
function isConstEnumObjectType(type: Type): boolean {
@@ -17160,7 +17169,7 @@ namespace ts {
// and the right operand to be of type Any, a subtype of the 'Function' interface type, or have a call or construct signature.
// The result is always of the Boolean primitive type.
// NOTE: do not raise error if leftType is unknown as related error was already reported
if (isTypeOfKind(leftType, TypeFlags.Primitive)) {
if (!isTypeAny(leftType) && isTypeAssignableToKind(leftType, TypeFlags.Primitive)) {
error(left, Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
}
// NOTE: do not raise error if right is unknown as related error was already reported
@@ -17183,10 +17192,10 @@ namespace ts {
// The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type,
// and the right operand to be of type Any, an object type, or a type parameter type.
// The result is always of the Boolean primitive type.
if (!(isTypeComparableTo(leftType, stringType) || isTypeOfKind(leftType, TypeFlags.NumberLike | TypeFlags.ESSymbol))) {
if (!(isTypeComparableTo(leftType, stringType) || isTypeAssignableToKind(leftType, TypeFlags.NumberLike | TypeFlags.ESSymbol))) {
error(left, Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol);
}
if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, TypeFlags.Object | TypeFlags.TypeVariable | TypeFlags.NonPrimitive)) {
if (!isTypeAssignableToKind(rightType, TypeFlags.NonPrimitive | TypeFlags.TypeVariable)) {
error(right, Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
}
return booleanType;
@@ -17495,32 +17504,30 @@ namespace ts {
return silentNeverType;
}
if (!isTypeOfKind(leftType, TypeFlags.Any | TypeFlags.StringLike) && !isTypeOfKind(rightType, TypeFlags.Any | TypeFlags.StringLike)) {
if (!isTypeAssignableToKind(leftType, TypeFlags.StringLike) && !isTypeAssignableToKind(rightType, TypeFlags.StringLike)) {
leftType = checkNonNullType(leftType, left);
rightType = checkNonNullType(rightType, right);
}
let resultType: Type;
if (isTypeOfKind(leftType, TypeFlags.NumberLike) && isTypeOfKind(rightType, TypeFlags.NumberLike)) {
if (isTypeAssignableToKind(leftType, TypeFlags.NumberLike, /*strict*/ true) && isTypeAssignableToKind(rightType, TypeFlags.NumberLike, /*strict*/ true)) {
// Operands of an enum type are treated as having the primitive type Number.
// If both operands are of the Number primitive type, the result is of the Number primitive type.
resultType = numberType;
}
else {
if (isTypeOfKind(leftType, TypeFlags.StringLike) || isTypeOfKind(rightType, TypeFlags.StringLike)) {
else if (isTypeAssignableToKind(leftType, TypeFlags.StringLike, /*strict*/ true) || isTypeAssignableToKind(rightType, TypeFlags.StringLike, /*strict*/ true)) {
// If one or both operands are of the String primitive type, the result is of the String primitive type.
resultType = stringType;
}
else if (isTypeAny(leftType) || isTypeAny(rightType)) {
// Otherwise, the result is of type Any.
// NOTE: unknown type here denotes error type. Old compiler treated this case as any type so do we.
resultType = leftType === unknownType || rightType === unknownType ? unknownType : anyType;
}
}
else if (isTypeAny(leftType) || isTypeAny(rightType)) {
// Otherwise, the result is of type Any.
// NOTE: unknown type here denotes error type. Old compiler treated this case as any type so do we.
resultType = leftType === unknownType || rightType === unknownType ? unknownType : anyType;
}
// Symbols are not allowed at all in arithmetic expressions
if (resultType && !checkForDisallowedESSymbolOperand(operator)) {
return resultType;
}
// Symbols are not allowed at all in arithmetic expressions
if (resultType && !checkForDisallowedESSymbolOperand(operator)) {
return resultType;
}
if (!resultType) {
@@ -18520,15 +18527,6 @@ namespace ts {
return forEachChild(n, containsSuperCall);
}
function markThisReferencesAsErrors(n: Node): void {
if (n.kind === SyntaxKind.ThisKeyword) {
error(n, Diagnostics.this_cannot_be_referenced_in_current_location);
}
else if (n.kind !== SyntaxKind.FunctionExpression && n.kind !== SyntaxKind.FunctionDeclaration) {
forEachChild(n, markThisReferencesAsErrors);
}
}
function isInstancePropertyWithInitializer(n: Node): boolean {
return n.kind === SyntaxKind.PropertyDeclaration &&
!(getModifierFlags(n) & ModifierFlags.Static) &&
@@ -18743,7 +18741,7 @@ namespace ts {
}
// Check if we're indexing with a numeric type and the object type is a generic
// type with a constraint that has a numeric index signature.
if (maybeTypeOfKind(objectType, TypeFlags.TypeVariable) && isTypeOfKind(indexType, TypeFlags.NumberLike)) {
if (maybeTypeOfKind(objectType, TypeFlags.TypeVariable) && isTypeAssignableToKind(indexType, TypeFlags.NumberLike)) {
const constraint = getBaseConstraintOfType(objectType);
if (constraint && getIndexInfoOfType(constraint, IndexKind.Number)) {
return type;
@@ -20450,7 +20448,7 @@ namespace ts {
// unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved
// in this case error about missing name is already reported - do not report extra one
if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, TypeFlags.Object | TypeFlags.TypeVariable | TypeFlags.NonPrimitive)) {
if (!isTypeAssignableToKind(rightType, TypeFlags.NonPrimitive | TypeFlags.TypeVariable)) {
error(node.expression, Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter);
}
@@ -23437,22 +23435,22 @@ namespace ts {
else if (type.flags & TypeFlags.Any) {
return TypeReferenceSerializationKind.ObjectType;
}
else if (isTypeOfKind(type, TypeFlags.Void | TypeFlags.Nullable | TypeFlags.Never)) {
else if (isTypeAssignableToKind(type, TypeFlags.Void | TypeFlags.Nullable | TypeFlags.Never)) {
return TypeReferenceSerializationKind.VoidNullableOrNeverType;
}
else if (isTypeOfKind(type, TypeFlags.BooleanLike)) {
else if (isTypeAssignableToKind(type, TypeFlags.BooleanLike)) {
return TypeReferenceSerializationKind.BooleanType;
}
else if (isTypeOfKind(type, TypeFlags.NumberLike)) {
else if (isTypeAssignableToKind(type, TypeFlags.NumberLike)) {
return TypeReferenceSerializationKind.NumberLikeType;
}
else if (isTypeOfKind(type, TypeFlags.StringLike)) {
else if (isTypeAssignableToKind(type, TypeFlags.StringLike)) {
return TypeReferenceSerializationKind.StringLikeType;
}
else if (isTupleType(type)) {
return TypeReferenceSerializationKind.ArrayLikeType;
}
else if (isTypeOfKind(type, TypeFlags.ESSymbol)) {
else if (isTypeAssignableToKind(type, TypeFlags.ESSymbol)) {
return TypeReferenceSerializationKind.ESSymbolType;
}
else if (isFunctionType(type)) {
+19 -21
View File
@@ -1446,14 +1446,10 @@ namespace ts {
}
}
else {
// If no includes were specified, exclude common package folders and the outDir
const specs = includeSpecs ? [] : ["node_modules", "bower_components", "jspm_packages"];
const outDir = raw["compilerOptions"] && raw["compilerOptions"]["outDir"];
if (outDir) {
specs.push(outDir);
excludeSpecs = [outDir];
}
excludeSpecs = specs;
}
if (fileNames === undefined && includeSpecs === undefined) {
@@ -2015,23 +2011,13 @@ namespace ts {
}
function validateSpecs(specs: ReadonlyArray<string>, errors: Push<Diagnostic>, allowTrailingRecursion: boolean, jsonSourceFile: JsonSourceFile, specKey: string) {
const validSpecs: string[] = [];
for (const spec of specs) {
if (!allowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) {
errors.push(createDiagnostic(Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec));
return specs.filter(spec => {
const diag = specToDiagnostic(spec, allowTrailingRecursion);
if (diag !== undefined) {
errors.push(createDiagnostic(diag, spec));
}
else if (invalidMultipleRecursionPatterns.test(spec)) {
errors.push(createDiagnostic(Diagnostics.File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0, spec));
}
else if (invalidDotDotAfterRecursiveWildcardPattern.test(spec)) {
errors.push(createDiagnostic(Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec));
}
else {
validSpecs.push(spec);
}
}
return validSpecs;
return diag === undefined;
});
function createDiagnostic(message: DiagnosticMessage, spec: string): Diagnostic {
if (jsonSourceFile && jsonSourceFile.jsonObject) {
@@ -2049,6 +2035,18 @@ namespace ts {
}
}
function specToDiagnostic(spec: string, allowTrailingRecursion: boolean): ts.DiagnosticMessage | undefined {
if (!allowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) {
return Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0;
}
else if (invalidMultipleRecursionPatterns.test(spec)) {
return Diagnostics.File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0;
}
else if (invalidDotDotAfterRecursiveWildcardPattern.test(spec)) {
return Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0;
}
}
/**
* Gets directories in a set of include patterns that should be watched for changes.
*/
+3 -3
View File
@@ -8,7 +8,7 @@ namespace ts {
setWriter(writer: EmitTextWriter): void;
emitNodeWithComments(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void): void;
emitBodyWithDetachedComments(node: Node, detachedRange: TextRange, emitCallback: (node: Node) => void): void;
emitTrailingCommentsOfPosition(pos: number): void;
emitTrailingCommentsOfPosition(pos: number, prefixSpace?: boolean): void;
emitLeadingCommentsOfPosition(pos: number): void;
}
@@ -306,7 +306,7 @@ namespace ts {
}
}
function emitTrailingCommentsOfPosition(pos: number) {
function emitTrailingCommentsOfPosition(pos: number, prefixSpace?: boolean) {
if (disabled) {
return;
}
@@ -315,7 +315,7 @@ namespace ts {
performance.mark("beforeEmitTrailingCommentsOfPosition");
}
forEachTrailingCommentToEmit(pos, emitTrailingCommentOfPosition);
forEachTrailingCommentToEmit(pos, prefixSpace ? emitTrailingComment : emitTrailingCommentOfPosition);
if (extendedDiagnostics) {
performance.measure("commentTime", "beforeEmitTrailingCommentsOfPosition");
+105 -41
View File
@@ -361,11 +361,11 @@ namespace ts {
return false;
}
export function filterMutate<T>(array: T[], f: (x: T) => boolean): void {
export function filterMutate<T>(array: T[], f: (x: T, i: number, array: T[]) => boolean): void {
let outIndex = 0;
for (const item of array) {
if (f(item)) {
array[outIndex] = item;
for (let i = 0; i < array.length; i++) {
if (f(array[i], i, array)) {
array[outIndex] = array[i];
outIndex++;
}
}
@@ -1290,12 +1290,12 @@ namespace ts {
export function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage): Diagnostic {
const end = start + length;
Debug.assert(start >= 0, "start must be non-negative, is " + start);
Debug.assert(length >= 0, "length must be non-negative, is " + length);
Debug.assertGreaterThanOrEqual(start, 0);
Debug.assertGreaterThanOrEqual(length, 0);
if (file) {
Debug.assert(start <= file.text.length, `start must be within the bounds of the file. ${start} > ${file.text.length}`);
Debug.assert(end <= file.text.length, `end must be the bounds of the file. ${end} > ${file.text.length}`);
Debug.assertLessThanOrEqual(start, file.text.length);
Debug.assertLessThanOrEqual(end, file.text.length);
}
let text = getLocaleSpecificMessage(message);
@@ -1875,14 +1875,54 @@ namespace ts {
const reservedCharacterPattern = /[^\w\s\/]/g;
const wildcardCharCodes = [CharacterCodes.asterisk, CharacterCodes.question];
/**
* Matches any single directory segment unless it is the last segment and a .min.js file
* Breakdown:
* [^./] # matches everything up to the first . character (excluding directory seperators)
* (\\.(?!min\\.js$))? # matches . characters but not if they are part of the .min.js file extension
*/
const singleAsteriskRegexFragmentFiles = "([^./]|(\\.(?!min\\.js$))?)*";
const singleAsteriskRegexFragmentOther = "[^/]*";
/* @internal */
export const commonPackageFolders: ReadonlyArray<string> = ["node_modules", "bower_components", "jspm_packages"];
const implicitExcludePathRegexPattern = `(?!(${commonPackageFolders.join("|")})(/|$))`;
interface WildcardMatcher {
singleAsteriskRegexFragment: string;
doubleAsteriskRegexFragment: string;
replaceWildcardCharacter: (match: string) => string;
}
const filesMatcher: WildcardMatcher = {
/**
* Matches any single directory segment unless it is the last segment and a .min.js file
* Breakdown:
* [^./] # matches everything up to the first . character (excluding directory seperators)
* (\\.(?!min\\.js$))? # matches . characters but not if they are part of the .min.js file extension
*/
singleAsteriskRegexFragment: "([^./]|(\\.(?!min\\.js$))?)*",
/**
* Regex for the ** wildcard. Matches any number of subdirectories. When used for including
* files or directories, does not match subdirectories that start with a . character
*/
doubleAsteriskRegexFragment: `(/${implicitExcludePathRegexPattern}[^/.][^/]*)*?`,
replaceWildcardCharacter: match => replaceWildcardCharacter(match, filesMatcher.singleAsteriskRegexFragment)
};
const directoriesMatcher: WildcardMatcher = {
singleAsteriskRegexFragment: "[^/]*",
/**
* Regex for the ** wildcard. Matches any number of subdirectories. When used for including
* files or directories, does not match subdirectories that start with a . character
*/
doubleAsteriskRegexFragment: `(/${implicitExcludePathRegexPattern}[^/.][^/]*)*?`,
replaceWildcardCharacter: match => replaceWildcardCharacter(match, directoriesMatcher.singleAsteriskRegexFragment)
};
const excludeMatcher: WildcardMatcher = {
singleAsteriskRegexFragment: "[^/]*",
doubleAsteriskRegexFragment: "(/.+?)?",
replaceWildcardCharacter: match => replaceWildcardCharacter(match, excludeMatcher.singleAsteriskRegexFragment)
};
const wildcardMatchers = {
files: filesMatcher,
directories: directoriesMatcher,
exclude: excludeMatcher
};
export function getRegularExpressionForWildcard(specs: ReadonlyArray<string>, basePath: string, usage: "files" | "directories" | "exclude"): string | undefined {
const patterns = getRegularExpressionsForWildcards(specs, basePath, usage);
@@ -1901,17 +1941,8 @@ namespace ts {
return undefined;
}
const replaceWildcardCharacter = usage === "files" ? replaceWildCardCharacterFiles : replaceWildCardCharacterOther;
const singleAsteriskRegexFragment = usage === "files" ? singleAsteriskRegexFragmentFiles : singleAsteriskRegexFragmentOther;
/**
* Regex for the ** wildcard. Matches any number of subdirectories. When used for including
* files or directories, does not match subdirectories that start with a . character
*/
const doubleAsteriskRegexFragment = usage === "exclude" ? "(/.+?)?" : "(/[^/.][^/]*)*?";
return flatMap(specs, spec =>
spec && getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter));
spec && getSubPatternFromSpec(spec, basePath, usage, wildcardMatchers[usage]));
}
/**
@@ -1922,7 +1953,7 @@ namespace ts {
return !/[.*?]/.test(lastPathComponent);
}
function getSubPatternFromSpec(spec: string, basePath: string, usage: "files" | "directories" | "exclude", singleAsteriskRegexFragment: string, doubleAsteriskRegexFragment: string, replaceWildcardCharacter: (match: string) => string): string | undefined {
function getSubPatternFromSpec(spec: string, basePath: string, usage: "files" | "directories" | "exclude", { singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter }: WildcardMatcher): string | undefined {
let subpattern = "";
let hasRecursiveDirectoryWildcard = false;
let hasWrittenComponent = false;
@@ -1961,20 +1992,36 @@ namespace ts {
}
if (usage !== "exclude") {
let componentPattern = "";
// The * and ? wildcards should not match directories or files that start with . if they
// appear first in a component. Dotted directories and files can be included explicitly
// like so: **/.*/.*
if (component.charCodeAt(0) === CharacterCodes.asterisk) {
subpattern += "([^./]" + singleAsteriskRegexFragment + ")?";
componentPattern += "([^./]" + singleAsteriskRegexFragment + ")?";
component = component.substr(1);
}
else if (component.charCodeAt(0) === CharacterCodes.question) {
subpattern += "[^./]";
componentPattern += "[^./]";
component = component.substr(1);
}
}
subpattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter);
componentPattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter);
// Patterns should not include subfolders like node_modules unless they are
// explicitly included as part of the path.
//
// As an optimization, if the component pattern is the same as the component,
// then there definitely were no wildcard characters and we do not need to
// add the exclusion pattern.
if (componentPattern !== component) {
subpattern += implicitExcludePathRegexPattern;
}
subpattern += componentPattern;
}
else {
subpattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter);
}
}
hasWrittenComponent = true;
@@ -1988,14 +2035,6 @@ namespace ts {
return subpattern;
}
function replaceWildCardCharacterFiles(match: string) {
return replaceWildcardCharacter(match, singleAsteriskRegexFragmentFiles);
}
function replaceWildCardCharacterOther(match: string) {
return replaceWildcardCharacter(match, singleAsteriskRegexFragmentOther);
}
function replaceWildcardCharacter(match: string, singleAsteriskRegexFragment: string) {
return match === "*" ? singleAsteriskRegexFragment : match === "?" ? "[^/]" : "\\" + match;
}
@@ -2350,15 +2389,40 @@ namespace ts {
return currentAssertionLevel >= level;
}
export function assert(expression: boolean, message?: string, verboseDebugInfo?: () => string, stackCrawlMark?: Function): void {
export function assert(expression: boolean, message?: string, verboseDebugInfo?: string | (() => string), stackCrawlMark?: Function): void {
if (!expression) {
if (verboseDebugInfo) {
message += "\r\nVerbose Debug Information: " + verboseDebugInfo();
message += "\r\nVerbose Debug Information: " + (typeof verboseDebugInfo === "string" ? verboseDebugInfo : verboseDebugInfo());
}
fail(message ? "False expression: " + message : "False expression.", stackCrawlMark || assert);
}
}
export function assertEqual<T>(a: T, b: T, msg?: string, msg2?: string): void {
if (a !== b) {
const message = msg ? msg2 ? `${msg} ${msg2}` : msg : "";
fail(`Expected ${a} === ${b}. ${message}`);
}
}
export function assertLessThan(a: number, b: number, msg?: string): void {
if (a >= b) {
fail(`Expected ${a} < ${b}. ${msg || ""}`);
}
}
export function assertLessThanOrEqual(a: number, b: number): void {
if (a > b) {
fail(`Expected ${a} <= ${b}`);
}
}
export function assertGreaterThanOrEqual(a: number, b: number): void {
if (a < b) {
fail(`Expected ${a} >= ${b}`);
}
}
export function fail(message?: string, stackCrawlMark?: Function): void {
debugger;
const e = new Error(message ? `Debug Failure. ${message}` : "Debug Failure.");
+4
View File
@@ -1908,6 +1908,10 @@
"category": "Error",
"code": 2559
},
"Value of type '{0}' has no properties in common with type '{1}'. Did you mean to call it?": {
"category": "Error",
"code": 2560
},
"JSX element attributes type '{0}' may not be a union type.": {
"category": "Error",
"code": 2600
+19 -5
View File
@@ -1572,8 +1572,20 @@ namespace ts {
write(";");
}
function emitTokenWithComment(token: SyntaxKind, pos: number, contextNode?: Node) {
const node = contextNode && getParseTreeNode(contextNode);
if (node && node.kind === contextNode.kind) {
pos = skipTrivia(currentSourceFile.text, pos);
}
pos = writeToken(token, pos, /*contextNode*/ contextNode);
if (node && node.kind === contextNode.kind) {
emitTrailingCommentsOfPosition(pos, /*prefixSpace*/ true);
}
return pos;
}
function emitReturnStatement(node: ReturnStatement) {
writeToken(SyntaxKind.ReturnKeyword, node.pos, /*contextNode*/ node);
emitTokenWithComment(SyntaxKind.ReturnKeyword, node.pos, /*contextNode*/ node);
emitExpressionWithPrefix(" ", node.expression);
write(";");
}
@@ -2133,10 +2145,12 @@ namespace ts {
function emitCatchClause(node: CatchClause) {
const openParenPos = writeToken(SyntaxKind.CatchKeyword, node.pos);
write(" ");
writeToken(SyntaxKind.OpenParenToken, openParenPos);
emit(node.variableDeclaration);
writeToken(SyntaxKind.CloseParenToken, node.variableDeclaration ? node.variableDeclaration.end : openParenPos);
write(" ");
if (node.variableDeclaration) {
writeToken(SyntaxKind.OpenParenToken, openParenPos);
emit(node.variableDeclaration);
writeToken(SyntaxKind.CloseParenToken, node.variableDeclaration.end);
write(" ");
}
emit(node.block);
}
+2 -2
View File
@@ -2128,14 +2128,14 @@ namespace ts {
: node;
}
export function createCatchClause(variableDeclaration: string | VariableDeclaration, block: Block) {
export function createCatchClause(variableDeclaration: string | VariableDeclaration | undefined, block: Block) {
const node = <CatchClause>createSynthesizedNode(SyntaxKind.CatchClause);
node.variableDeclaration = typeof variableDeclaration === "string" ? createVariableDeclaration(variableDeclaration) : variableDeclaration;
node.block = block;
return node;
}
export function updateCatchClause(node: CatchClause, variableDeclaration: VariableDeclaration, block: Block) {
export function updateCatchClause(node: CatchClause, variableDeclaration: VariableDeclaration | undefined, block: Block) {
return node.variableDeclaration !== variableDeclaration
|| node.block !== block
? updateNode(createCatchClause(variableDeclaration, block), node)
+1 -1
View File
@@ -678,7 +678,7 @@ namespace ts {
const { resolvedModule, failedLookupLocations } =
nodeModuleNameResolverWorker(moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, /*jsOnly*/ true);
if (!resolvedModule) {
throw new Error(`Could not resolve JS module ${moduleName} starting at ${initialDir}. Looked in: ${failedLookupLocations.join(", ")}`);
throw new Error(`Could not resolve JS module '${moduleName}' starting at '${initialDir}'. Looked in: ${failedLookupLocations.join(", ")}`);
}
return resolvedModule.resolvedFileName;
}
+7 -2
View File
@@ -4799,11 +4799,16 @@ namespace ts {
function parseCatchClause(): CatchClause {
const result = <CatchClause>createNode(SyntaxKind.CatchClause);
parseExpected(SyntaxKind.CatchKeyword);
if (parseExpected(SyntaxKind.OpenParenToken)) {
if (parseOptional(SyntaxKind.OpenParenToken)) {
result.variableDeclaration = parseVariableDeclaration();
parseExpected(SyntaxKind.CloseParenToken);
}
else {
// Keep shape of node to avoid degrading performance.
result.variableDeclaration = undefined;
}
parseExpected(SyntaxKind.CloseParenToken);
result.block = parseBlock(/*ignoreMissingOpenBrace*/ false);
return finishNode(result);
}
+1 -1
View File
@@ -153,7 +153,7 @@ namespace ts {
return;
}
watcher = _fs.watch(
dirPath,
dirPath || ".",
{ persistent: true },
(eventName: string, relativeFileName: string) => fileEventHandler(eventName, relativeFileName, dirPath)
);
+2 -1
View File
@@ -2491,7 +2491,7 @@ namespace ts {
const catchVariable = getGeneratedNameForNode(errorRecord);
const returnMethod = createTempVariable(/*recordTempVariable*/ undefined);
const values = createValuesHelper(context, expression, node.expression);
const next = createCall(createPropertyAccess(iterator, "next" ), /*typeArguments*/ undefined, []);
const next = createCall(createPropertyAccess(iterator, "next"), /*typeArguments*/ undefined, []);
hoistVariableDeclaration(errorRecord);
hoistVariableDeclaration(returnMethod);
@@ -3173,6 +3173,7 @@ namespace ts {
function visitCatchClause(node: CatchClause): CatchClause {
const ancestorFacts = enterSubtree(HierarchyFacts.BlockScopeExcludes, HierarchyFacts.BlockScopeIncludes);
let updated: CatchClause;
Debug.assert(!!node.variableDeclaration, "Catch clause variable should always be present when downleveling ES2015.");
if (isBindingPattern(node.variableDeclaration.name)) {
const temp = createTempVariable(/*recordTempVariable*/ undefined);
const newVariableDeclaration = createVariableDeclaration(temp);
+13
View File
@@ -101,6 +101,8 @@ namespace ts {
return visitExpressionStatement(node as ExpressionStatement);
case SyntaxKind.ParenthesizedExpression:
return visitParenthesizedExpression(node as ParenthesizedExpression, noDestructuringValue);
case SyntaxKind.CatchClause:
return visitCatchClause(node as CatchClause);
default:
return visitEachChild(node, visitor, context);
}
@@ -212,6 +214,17 @@ namespace ts {
return visitEachChild(node, noDestructuringValue ? visitorNoDestructuringValue : visitor, context);
}
function visitCatchClause(node: CatchClause): CatchClause {
if (!node.variableDeclaration) {
return updateCatchClause(
node,
createVariableDeclaration(createTempVariable(/*recordTempVariable*/ undefined)),
visitNode(node.block, visitor, isBlock)
);
}
return visitEachChild(node, visitor, context);
}
/**
* Visits a BinaryExpression that contains a destructuring assignment.
*
+1 -1
View File
@@ -2448,7 +2448,7 @@ namespace ts {
* @param location An optional source map location for the statement.
*/
function createInlineBreak(label: Label, location?: TextRange): ReturnStatement {
Debug.assert(label > 0, `Invalid label: ${label}`);
Debug.assertLessThan(0, label, "Invalid label");
return setTextRange(
createReturn(
createArrayLiteral([
+7 -2
View File
@@ -1808,7 +1808,7 @@ namespace ts {
export interface CatchClause extends Node {
kind: SyntaxKind.CatchClause;
parent?: TryStatement;
variableDeclaration: VariableDeclaration;
variableDeclaration?: VariableDeclaration;
block: Block;
}
@@ -3067,6 +3067,7 @@ namespace ts {
hasReportedStatementInAmbientContext?: boolean; // Cache boolean if we report statements in ambient context
jsxFlags?: JsxFlags; // flags for knowing what kind of element/attributes we're dealing with
resolvedJsxElementAttributesType?: Type; // resolved element attributes type of a JSX openinglike element
resolvedJsxElementAllAttributesType?: Type; // resolved all element attributes type of a JSX openinglike element
hasSuperCall?: boolean; // recorded result when we try to find super-call. We only try to find one if this flag is undefined, indicating that we haven't made an attempt.
superCall?: ExpressionStatement; // Cached first super-call found in the constructor. Used in checking whether super is called before this-accessing
switchTypes?: Type[]; // Cached array of switch case expression types
@@ -3317,6 +3318,11 @@ namespace ts {
awaitedTypeOfType?: Type;
}
/* @internal */
export interface SyntheticDefaultModuleType extends Type {
syntheticType?: Type;
}
export interface TypeVariable extends Type {
/* @internal */
resolvedBaseConstraint: Type;
@@ -4019,7 +4025,6 @@ namespace ts {
ContainsBindingPattern = 1 << 23,
ContainsYield = 1 << 24,
ContainsHoistedDeclarationOrCompletion = 1 << 25,
ContainsDynamicImport = 1 << 26,
// Please leave this as 1 << 29.
+1 -1
View File
@@ -420,7 +420,7 @@ namespace Utils {
const maxHarnessFrames = 1;
export function filterStack(error: Error, stackTraceLimit: number = Infinity) {
export function filterStack(error: Error, stackTraceLimit = Infinity) {
const stack = <string>(<any>error).stack;
if (stack) {
const lines = stack.split(/\r\n?|\n/g);
+5 -10
View File
@@ -684,11 +684,11 @@ namespace Harness.LanguageService {
}
info(message: string): void {
return this.host.log(message);
this.host.log(message);
}
msg(message: string) {
return this.host.log(message);
err(message: string): void {
this.host.log(message);
}
loggingEnabled() {
@@ -703,17 +703,12 @@ namespace Harness.LanguageService {
return false;
}
endGroup(): void {
}
group() { throw ts.notImplemented(); }
perftrc(message: string): void {
return this.host.log(message);
}
startGroup(): void {
}
setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): any {
return setTimeout(callback, ms, args);
}
@@ -798,7 +793,7 @@ namespace Harness.LanguageService {
default:
return {
module: undefined,
error: "Could not resolve module"
error: new Error("Could not resolve module")
};
}
+1 -13
View File
@@ -52,21 +52,9 @@ namespace ts {
}
function createProject(rootFile: string, serverHost: server.ServerHost): { project: server.Project, rootScriptInfo: server.ScriptInfo } {
const logger: server.Logger = {
close: noop,
hasLevel: () => false,
loggingEnabled: () => false,
perftrc: noop,
info: noop,
startGroup: noop,
endGroup: noop,
msg: noop,
getLogFileName: (): string => undefined
};
const svcOpts: server.ProjectServiceOptions = {
host: serverHost,
logger,
logger: projectSystem.nullLogger,
cancellationToken: { isCancellationRequested: () => false },
useSingleInferredProject: false,
typingsInstaller: undefined
+126 -67
View File
@@ -73,6 +73,7 @@ namespace ts {
"c:/dev/a.d.ts",
"c:/dev/a.js",
"c:/dev/b.ts",
"c:/dev/x/a.ts",
"c:/dev/node_modules/a.ts",
"c:/dev/bower_components/a.ts",
"c:/dev/jspm_packages/a.ts"
@@ -141,7 +142,8 @@ namespace ts {
errors: [],
fileNames: [
"c:/dev/a.ts",
"c:/dev/b.ts"
"c:/dev/b.ts",
"c:/dev/x/a.ts"
],
wildcardDirectories: {
"c:/dev": ts.WatchDirectoryFlags.Recursive
@@ -462,7 +464,6 @@ namespace ts {
};
validateMatches(expected, json, caseInsensitiveHost, caseInsensitiveBasePath);
});
it("same named declarations are excluded", () => {
const json = {
include: [
@@ -651,71 +652,127 @@ namespace ts {
};
validateMatches(expected, json, caseInsensitiveHost, caseInsensitiveBasePath);
});
it("with common package folders and no exclusions", () => {
const json = {
include: [
"**/a.ts"
]
};
const expected: ts.ParsedCommandLine = {
options: {},
errors: [],
fileNames: [
"c:/dev/a.ts",
"c:/dev/bower_components/a.ts",
"c:/dev/jspm_packages/a.ts",
"c:/dev/node_modules/a.ts"
],
wildcardDirectories: {
"c:/dev": ts.WatchDirectoryFlags.Recursive
},
};
validateMatches(expected, json, caseInsensitiveCommonFoldersHost, caseInsensitiveBasePath);
});
it("with common package folders and exclusions", () => {
const json = {
include: [
"**/a.ts"
],
exclude: [
"a.ts"
]
};
const expected: ts.ParsedCommandLine = {
options: {},
errors: [],
fileNames: [
"c:/dev/bower_components/a.ts",
"c:/dev/jspm_packages/a.ts",
"c:/dev/node_modules/a.ts"
],
wildcardDirectories: {
"c:/dev": ts.WatchDirectoryFlags.Recursive
},
};
validateMatches(expected, json, caseInsensitiveCommonFoldersHost, caseInsensitiveBasePath);
});
it("with common package folders and empty exclude", () => {
const json = {
include: [
"**/a.ts"
],
exclude: <string[]>[]
};
const expected: ts.ParsedCommandLine = {
options: {},
errors: [],
fileNames: [
"c:/dev/a.ts",
"c:/dev/bower_components/a.ts",
"c:/dev/jspm_packages/a.ts",
"c:/dev/node_modules/a.ts"
],
wildcardDirectories: {
"c:/dev": ts.WatchDirectoryFlags.Recursive
},
};
validateMatches(expected, json, caseInsensitiveCommonFoldersHost, caseInsensitiveBasePath);
describe("with common package folders", () => {
it("and no exclusions", () => {
const json = {
include: [
"**/a.ts"
]
};
const expected: ts.ParsedCommandLine = {
options: {},
errors: [],
fileNames: [
"c:/dev/a.ts",
"c:/dev/x/a.ts"
],
wildcardDirectories: {
"c:/dev": ts.WatchDirectoryFlags.Recursive
},
};
validateMatches(expected, json, caseInsensitiveCommonFoldersHost, caseInsensitiveBasePath);
});
it("and exclusions", () => {
const json = {
include: [
"**/?.ts"
],
exclude: [
"a.ts"
]
};
const expected: ts.ParsedCommandLine = {
options: {},
errors: [],
fileNames: [
"c:/dev/b.ts",
"c:/dev/x/a.ts"
],
wildcardDirectories: {
"c:/dev": ts.WatchDirectoryFlags.Recursive
},
};
validateMatches(expected, json, caseInsensitiveCommonFoldersHost, caseInsensitiveBasePath);
});
it("and empty exclude", () => {
const json = {
include: [
"**/a.ts"
],
exclude: <string[]>[]
};
const expected: ts.ParsedCommandLine = {
options: {},
errors: [],
fileNames: [
"c:/dev/a.ts",
"c:/dev/x/a.ts"
],
wildcardDirectories: {
"c:/dev": ts.WatchDirectoryFlags.Recursive
},
};
validateMatches(expected, json, caseInsensitiveCommonFoldersHost, caseInsensitiveBasePath);
});
it("and explicit recursive include", () => {
const json = {
include: [
"**/a.ts",
"**/node_modules/a.ts"
]
};
const expected: ts.ParsedCommandLine = {
options: {},
errors: [],
fileNames: [
"c:/dev/a.ts",
"c:/dev/x/a.ts",
"c:/dev/node_modules/a.ts"
],
wildcardDirectories: {
"c:/dev": ts.WatchDirectoryFlags.Recursive
},
};
validateMatches(expected, json, caseInsensitiveCommonFoldersHost, caseInsensitiveBasePath);
});
it("and wildcard include", () => {
const json = {
include: [
"*/a.ts"
]
};
const expected: ts.ParsedCommandLine = {
options: {},
errors: [],
fileNames: [
"c:/dev/x/a.ts"
],
wildcardDirectories: {
"c:/dev": ts.WatchDirectoryFlags.Recursive
},
};
validateMatches(expected, json, caseInsensitiveCommonFoldersHost, caseInsensitiveBasePath);
});
it("and explicit wildcard include", () => {
const json = {
include: [
"*/a.ts",
"node_modules/a.ts"
]
};
const expected: ts.ParsedCommandLine = {
options: {},
errors: [],
fileNames: [
"c:/dev/x/a.ts",
"c:/dev/node_modules/a.ts"
],
wildcardDirectories: {
"c:/dev": ts.WatchDirectoryFlags.Recursive
},
};
validateMatches(expected, json, caseInsensitiveCommonFoldersHost, caseInsensitiveBasePath);
});
});
it("exclude .js files when allowJs=false", () => {
const json = {
@@ -1066,6 +1123,7 @@ namespace ts {
};
validateMatches(expected, json, caseInsensitiveHost, caseInsensitiveBasePath);
});
describe("with trailing recursive directory", () => {
it("in includes", () => {
const json = {
@@ -1264,6 +1322,7 @@ namespace ts {
});
});
});
describe("with files or folders that begin with a .", () => {
it("that are not explicitly included", () => {
const json = {
+3 -15
View File
@@ -28,18 +28,6 @@ namespace ts.server {
createHash: Harness.LanguageService.mockHash,
};
const mockLogger: Logger = {
close: noop,
hasLevel(): boolean { return false; },
loggingEnabled(): boolean { return false; },
perftrc: noop,
info: noop,
startGroup: noop,
endGroup: noop,
msg: noop,
getLogFileName: (): string => undefined
};
class TestSession extends Session {
getProjectService() {
return this.projectService;
@@ -58,7 +46,7 @@ namespace ts.server {
typingsInstaller: undefined,
byteLength: Utils.byteLength,
hrtime: process.hrtime,
logger: mockLogger,
logger: projectSystem.nullLogger,
canUseEvents: true
};
return new TestSession(opts);
@@ -408,7 +396,7 @@ namespace ts.server {
typingsInstaller: undefined,
byteLength: Utils.byteLength,
hrtime: process.hrtime,
logger: mockLogger,
logger: projectSystem.nullLogger,
canUseEvents: true
});
this.addProtocolHandler(this.customHandler, () => {
@@ -475,7 +463,7 @@ namespace ts.server {
typingsInstaller: undefined,
byteLength: Utils.byteLength,
hrtime: process.hrtime,
logger: mockLogger,
logger: projectSystem.nullLogger,
canUseEvents: true
});
this.addProtocolHandler("echo", (req: protocol.Request) => ({
+23 -24
View File
@@ -34,18 +34,17 @@ namespace ts.projectSystem {
}
export const nullLogger: server.Logger = {
close: () => void 0,
hasLevel: () => void 0,
close: noop,
hasLevel: () => false,
loggingEnabled: () => false,
perftrc: () => void 0,
info: () => void 0,
startGroup: () => void 0,
endGroup: () => void 0,
msg: () => void 0,
perftrc: noop,
info: noop,
err: noop,
group: noop,
getLogFileName: (): string => undefined
};
export const { content: libFileContent } = Harness.getDefaultLibraryFile(Harness.IO);
const { content: libFileContent } = Harness.getDefaultLibraryFile(Harness.IO);
export const libFile: FileOrFolder = {
path: "/a/lib/lib.d.ts",
content: libFileContent
@@ -118,7 +117,7 @@ namespace ts.projectSystem {
return JSON.stringify({ dependencies });
}
export function getExecutingFilePathFromLibFile(): string {
function getExecutingFilePathFromLibFile(): string {
return combinePaths(getDirectoryPath(libFile.path), "tsc.js");
}
@@ -130,7 +129,7 @@ namespace ts.projectSystem {
return map(fileNames, toExternalFile);
}
export class TestServerEventManager {
class TestServerEventManager {
public events: server.ProjectServiceEvent[] = [];
handler: server.ProjectServiceEventHandler = (event: server.ProjectServiceEvent) => {
@@ -143,7 +142,7 @@ namespace ts.projectSystem {
}
}
export interface TestServerHostCreationParameters {
interface TestServerHostCreationParameters {
useCaseSensitiveFileNames?: boolean;
executingFilePath?: string;
currentDirectory?: string;
@@ -205,7 +204,7 @@ namespace ts.projectSystem {
return new TestSession(opts);
}
export interface CreateProjectServiceParameters {
interface CreateProjectServiceParameters {
cancellationToken?: HostCancellationToken;
logger?: server.Logger;
useSingleInferredProject?: boolean;
@@ -253,15 +252,15 @@ namespace ts.projectSystem {
entries: FSEntry[];
}
export function isFolder(s: FSEntry): s is Folder {
function isFolder(s: FSEntry): s is Folder {
return isArray((<Folder>s).entries);
}
export function isFile(s: FSEntry): s is File {
function isFile(s: FSEntry): s is File {
return typeof (<File>s).content === "string";
}
export function addFolder(fullPath: string, toPath: (s: string) => Path, fs: Map<FSEntry>): Folder {
function addFolder(fullPath: string, toPath: (s: string) => Path, fs: Map<FSEntry>): Folder {
const path = toPath(fullPath);
if (fs.has(path)) {
Debug.assert(isFolder(fs.get(path)));
@@ -279,29 +278,29 @@ namespace ts.projectSystem {
return entry;
}
export function checkMapKeys(caption: string, map: Map<any>, expectedKeys: string[]) {
function checkMapKeys(caption: string, map: Map<any>, expectedKeys: string[]) {
assert.equal(map.size, expectedKeys.length, `${caption}: incorrect size of map`);
for (const name of expectedKeys) {
assert.isTrue(map.has(name), `${caption} is expected to contain ${name}, actual keys: ${arrayFrom(map.keys())}`);
}
}
export function checkFileNames(caption: string, actualFileNames: string[], expectedFileNames: string[]) {
function checkFileNames(caption: string, actualFileNames: string[], expectedFileNames: string[]) {
assert.equal(actualFileNames.length, expectedFileNames.length, `${caption}: incorrect actual number of files, expected ${JSON.stringify(expectedFileNames)}, got ${actualFileNames}`);
for (const f of expectedFileNames) {
assert.isTrue(contains(actualFileNames, f), `${caption}: expected to find ${f} in ${JSON.stringify(actualFileNames)}`);
}
}
export function checkNumberOfConfiguredProjects(projectService: server.ProjectService, expected: number) {
function checkNumberOfConfiguredProjects(projectService: server.ProjectService, expected: number) {
assert.equal(projectService.configuredProjects.length, expected, `expected ${expected} configured project(s)`);
}
export function checkNumberOfExternalProjects(projectService: server.ProjectService, expected: number) {
function checkNumberOfExternalProjects(projectService: server.ProjectService, expected: number) {
assert.equal(projectService.externalProjects.length, expected, `expected ${expected} external project(s)`);
}
export function checkNumberOfInferredProjects(projectService: server.ProjectService, expected: number) {
function checkNumberOfInferredProjects(projectService: server.ProjectService, expected: number) {
assert.equal(projectService.inferredProjects.length, expected, `expected ${expected} inferred project(s)`);
}
@@ -315,7 +314,7 @@ namespace ts.projectSystem {
checkMapKeys("watchedFiles", host.watchedFiles, expectedFiles);
}
export function checkWatchedDirectories(host: TestServerHost, expectedDirectories: string[]) {
function checkWatchedDirectories(host: TestServerHost, expectedDirectories: string[]) {
checkMapKeys("watchedDirectories", host.watchedDirectories, expectedDirectories);
}
@@ -323,11 +322,11 @@ namespace ts.projectSystem {
checkFileNames(`${server.ProjectKind[project.projectKind]} project, actual files`, project.getFileNames(), expectedFiles);
}
export function checkProjectRootFiles(project: server.Project, expectedFiles: string[]) {
function checkProjectRootFiles(project: server.Project, expectedFiles: string[]) {
checkFileNames(`${server.ProjectKind[project.projectKind]} project, rootFileNames`, project.getRootFiles(), expectedFiles);
}
export class Callbacks {
class Callbacks {
private map: TimeOutCallback[] = [];
private nextId = 1;
@@ -363,7 +362,7 @@ namespace ts.projectSystem {
}
}
export type TimeOutCallback = () => any;
type TimeOutCallback = () => any;
export class TestServerHost implements server.ServerHost {
args: string[] = [];
+1 -1
View File
@@ -110,7 +110,7 @@ interface Map<K, V> {
readonly [Symbol.toStringTag]: "Map";
}
interface WeakMap<K extends object, V>{
interface WeakMap<K extends object, V> {
readonly [Symbol.toStringTag]: "WeakMap";
}
+16 -18
View File
@@ -326,8 +326,8 @@ namespace ts.server {
typingsInstaller: ITypingsInstaller;
eventHandler?: ProjectServiceEventHandler;
throttleWaitMilliseconds?: number;
globalPlugins?: string[];
pluginProbeLocations?: string[];
globalPlugins?: ReadonlyArray<string>;
pluginProbeLocations?: ReadonlyArray<string>;
allowLocalPluginLoads?: boolean;
}
@@ -928,26 +928,24 @@ namespace ts.server {
return;
}
this.logger.startGroup();
this.logger.group(info => {
let counter = 0;
counter = printProjects(this.externalProjects, info, counter);
counter = printProjects(this.configuredProjects, info, counter);
printProjects(this.inferredProjects, info, counter);
let counter = 0;
counter = printProjects(this.logger, this.externalProjects, counter);
counter = printProjects(this.logger, this.configuredProjects, counter);
counter = printProjects(this.logger, this.inferredProjects, counter);
info("Open files: ");
for (const rootFile of this.openFiles) {
info(`\t${rootFile.fileName}`);
}
});
this.logger.info("Open files: ");
for (const rootFile of this.openFiles) {
this.logger.info(`\t${rootFile.fileName}`);
}
this.logger.endGroup();
function printProjects(logger: Logger, projects: Project[], counter: number) {
function printProjects(projects: Project[], info: (msg: string) => void, counter: number): number {
for (const project of projects) {
project.updateGraph();
logger.info(`Project '${project.getProjectName()}' (${ProjectKind[project.projectKind]}) ${counter}`);
logger.info(project.filesToString());
logger.info("-----------------------------------------------");
info(`Project '${project.getProjectName()}' (${ProjectKind[project.projectKind]}) ${counter}`);
info(project.filesToString());
info("-----------------------------------------------");
counter++;
}
return counter;
+5 -4
View File
@@ -170,7 +170,8 @@ namespace ts.server {
log(`Loading ${moduleName} from ${initialDir} (resolved to ${resolvedPath})`);
const result = host.require(resolvedPath, moduleName);
if (result.error) {
log(`Failed to load module: ${JSON.stringify(result.error)}`);
const err = result.error.stack || result.error.message || JSON.stringify(result.error);
log(`Failed to load module '${moduleName}': ${err}`);
return undefined;
}
return result.module;
@@ -362,7 +363,7 @@ namespace ts.server {
return map(this.program.getSourceFiles(), sourceFile => {
const scriptInfo = this.projectService.getScriptInfoForPath(sourceFile.path);
if (!scriptInfo) {
Debug.assert(false, `scriptInfo for a file '${sourceFile.fileName}' is missing.`);
Debug.fail(`scriptInfo for a file '${sourceFile.fileName}' is missing.`);
}
return scriptInfo;
});
@@ -494,7 +495,7 @@ namespace ts.server {
this.projectStateVersion++;
}
private extractUnresolvedImportsFromSourceFile(file: SourceFile, result: string[]) {
private extractUnresolvedImportsFromSourceFile(file: SourceFile, result: Push<string>) {
const cached = this.cachedUnresolvedImportsPerFile.get(file.path);
if (cached) {
// found cached result - use it and return
@@ -554,7 +555,7 @@ namespace ts.server {
for (const sourceFile of this.program.getSourceFiles()) {
this.extractUnresolvedImportsFromSourceFile(sourceFile, result);
}
this.lastCachedUnresolvedImportsList = toSortedArray(result);
this.lastCachedUnresolvedImportsList = toDeduplicatedSortedArray(result);
}
unresolvedImports = this.lastCachedUnresolvedImportsList;
+47 -35
View File
@@ -15,8 +15,8 @@ namespace ts.server {
typingSafeListLocation: string;
npmLocation: string | undefined;
telemetryEnabled: boolean;
globalPlugins: string[];
pluginProbeLocations: string[];
globalPlugins: ReadonlyArray<string>;
pluginProbeLocations: ReadonlyArray<string>;
allowLocalPluginLoads: boolean;
}
@@ -116,8 +116,6 @@ namespace ts.server {
birthtime: Date;
}
type RequireResult = { module: {}, error: undefined } | { module: undefined, error: {} };
const readline: {
createInterface(options: ReadLineOptions): NodeJS.EventEmitter;
} = require("readline");
@@ -141,8 +139,6 @@ namespace ts.server {
class Logger implements server.Logger {
private fd = -1;
private seq = 0;
private inGroup = false;
private firstInGroup = true;
constructor(private readonly logFilename: string,
private readonly traceToConsole: boolean,
@@ -172,22 +168,24 @@ namespace ts.server {
}
perftrc(s: string) {
this.msg(s, Msg.Perf);
this.msg(s, "Perf");
}
info(s: string) {
this.msg(s, Msg.Info);
this.msg(s, "Info");
}
startGroup() {
this.inGroup = true;
this.firstInGroup = true;
err(s: string) {
this.msg(s, "Err");
}
endGroup() {
this.inGroup = false;
group(logGroupEntries: (log: (msg: string) => void) => void) {
let firstInGroup = false;
logGroupEntries(s => {
this.msg(s, "Info", /*inGroup*/ true, firstInGroup);
firstInGroup = false;
});
this.seq++;
this.firstInGroup = true;
}
loggingEnabled() {
@@ -198,26 +196,32 @@ namespace ts.server {
return this.loggingEnabled() && this.level >= level;
}
msg(s: string, type: Msg.Types = Msg.Err) {
if (this.fd >= 0 || this.traceToConsole) {
s = `[${nowString()}] ${s}\n`;
private msg(s: string, type: string, inGroup = false, firstInGroup = false) {
if (!this.canWrite) return;
s = `[${nowString()}] ${s}\n`;
if (!inGroup || firstInGroup) {
const prefix = Logger.padStringRight(type + " " + this.seq.toString(), " ");
if (this.firstInGroup) {
s = prefix + s;
this.firstInGroup = false;
}
if (!this.inGroup) {
this.seq++;
this.firstInGroup = true;
}
if (this.fd >= 0) {
const buf = new Buffer(s);
// tslint:disable-next-line no-null-keyword
fs.writeSync(this.fd, buf, 0, buf.length, /*position*/ null);
}
if (this.traceToConsole) {
console.warn(s);
}
s = prefix + s;
}
this.write(s);
if (!inGroup) {
this.seq++;
}
}
private get canWrite() {
return this.fd >= 0 || this.traceToConsole;
}
private write(s: string) {
if (this.fd >= 0) {
const buf = new Buffer(s);
// tslint:disable-next-line no-null-keyword
fs.writeSync(this.fd, buf, 0, buf.length, /*position*/ null);
}
if (this.traceToConsole) {
console.warn(s);
}
}
}
@@ -762,8 +766,16 @@ namespace ts.server {
const typingSafeListLocation = findArgument(Arguments.TypingSafeListLocation);
const npmLocation = findArgument(Arguments.NpmLocation);
const globalPlugins = (findArgument("--globalPlugins") || "").split(",");
const pluginProbeLocations = (findArgument("--pluginProbeLocations") || "").split(",");
function parseStringArray(argName: string): ReadonlyArray<string> {
const arg = findArgument(argName);
if (arg === undefined) {
return emptyArray;
}
return arg.split(",").filter(name => name !== "");
}
const globalPlugins = parseStringArray("--globalPlugins");
const pluginProbeLocations = parseStringArray("--pluginProbeLocations");
const allowLocalPluginLoads = hasArgument("--allowLocalPluginLoads");
const useSingleInferredProject = hasArgument("--useSingleInferredProject");
+23 -26
View File
@@ -163,26 +163,22 @@ namespace ts.server {
* Scheduling is done via instance of NextStep. If on current step subsequent step was not scheduled - operation is assumed to be completed.
*/
class MultistepOperation implements NextStep {
private requestId: number;
private requestId: number | undefined;
private timerHandle: any;
private immediateId: any;
private completed = true;
private immediateId: number | undefined;
constructor(private readonly operationHost: MultistepOperationHost) {}
public startNew(action: (next: NextStep) => void) {
this.complete();
this.requestId = this.operationHost.getCurrentRequestId();
this.completed = false;
this.executeAction(action);
}
private complete() {
if (!this.completed) {
if (this.requestId) {
this.operationHost.sendRequestCompletedEvent(this.requestId);
}
this.completed = true;
if (this.requestId !== undefined) {
this.operationHost.sendRequestCompletedEvent(this.requestId);
this.requestId = undefined;
}
this.setTimerHandle(undefined);
this.setImmediateId(undefined);
@@ -259,8 +255,8 @@ namespace ts.server {
eventHandler?: ProjectServiceEventHandler;
throttleWaitMilliseconds?: number;
globalPlugins?: string[];
pluginProbeLocations?: string[];
globalPlugins?: ReadonlyArray<string>;
pluginProbeLocations?: ReadonlyArray<string>;
allowLocalPluginLoads?: boolean;
}
@@ -337,7 +333,7 @@ namespace ts.server {
case ContextEvent:
const { project, fileName } = event.data;
this.projectService.logger.info(`got context event, updating diagnostics for ${fileName}`);
this.errorCheck.startNew(next => this.updateErrorCheck(next, [{ fileName, project }], this.changeSeq, (n) => n === this.changeSeq, 100));
this.errorCheck.startNew(next => this.updateErrorCheck(next, [{ fileName, project }], 100));
break;
case ConfigFileDiagEvent:
const { triggerFile, configFileName, diagnostics } = event.data;
@@ -370,7 +366,7 @@ namespace ts.server {
msg += "\n" + (<StackTraceError>err).stack;
}
}
this.logger.msg(msg, Msg.Err);
this.logger.err(msg);
}
public send(msg: protocol.Message) {
@@ -453,22 +449,23 @@ namespace ts.server {
}
}
private updateProjectStructure(seq: number, matchSeq: (seq: number) => boolean, ms = 1500) {
private updateProjectStructure() {
const ms = 1500;
const seq = this.changeSeq;
this.host.setTimeout(() => {
if (matchSeq(seq)) {
if (this.changeSeq === seq) {
this.projectService.refreshInferredProjects();
}
}, ms);
}
private updateErrorCheck(next: NextStep, checkList: PendingErrorCheck[], seq: number, matchSeq: (seq: number) => boolean, ms = 1500, followMs = 200, requireOpen = true) {
if (followMs > ms) {
followMs = ms;
}
private updateErrorCheck(next: NextStep, checkList: PendingErrorCheck[], ms: number, requireOpen = true) {
const seq = this.changeSeq;
const followMs = Math.min(ms, 200);
let index = 0;
const checkOne = () => {
if (matchSeq(seq)) {
if (this.changeSeq === seq) {
const checkSpec = checkList[index];
index++;
if (checkSpec.project.containsFile(checkSpec.fileName, requireOpen)) {
@@ -483,7 +480,7 @@ namespace ts.server {
}
};
if ((checkList.length > index) && (matchSeq(seq))) {
if (checkList.length > index && this.changeSeq === seq) {
next.delay(ms, checkOne);
}
}
@@ -1270,14 +1267,14 @@ namespace ts.server {
}
private getDiagnostics(next: NextStep, delay: number, fileNames: string[]): void {
const checkList = mapDefined(fileNames, uncheckedFileName => {
const checkList = mapDefined<string, PendingErrorCheck>(fileNames, uncheckedFileName => {
const fileName = toNormalizedPath(uncheckedFileName);
const project = this.projectService.getDefaultProjectForFile(fileName, /*refreshInferredProjects*/ true);
return project && { fileName, project };
});
if (checkList.length > 0) {
this.updateErrorCheck(next, checkList, this.changeSeq, (n) => n === this.changeSeq, delay);
this.updateErrorCheck(next, checkList, delay);
}
}
@@ -1291,7 +1288,7 @@ namespace ts.server {
scriptInfo.editContent(start, end, args.insertString);
this.changeSeq++;
}
this.updateProjectStructure(this.changeSeq, n => n === this.changeSeq);
this.updateProjectStructure();
}
}
@@ -1646,7 +1643,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, delay, /*requireOpen*/ false);
}
}
@@ -1960,7 +1957,7 @@ namespace ts.server {
return this.executeWithRequestId(request.seq, () => handler(request));
}
else {
this.logger.msg(`Unrecognized JSON command: ${JSON.stringify(request)}`, Msg.Err);
this.logger.err(`Unrecognized JSON command: ${JSON.stringify(request)}`);
this.output(undefined, CommandNames.Unknown, request.seq, `Unrecognized JSON command: ${request.command}`);
return { responseRequired: false };
}
+1 -1
View File
@@ -9,7 +9,7 @@ declare namespace ts.server {
data: any;
}
type RequireResult = { module: {}, error: undefined } | { module: undefined, error: {} };
type RequireResult = { module: {}, error: undefined } | { module: undefined, error: { stack?: string, message?: string } };
export interface ServerHost extends System {
setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): any;
clearTimeout(timeoutId: any): void;
+11 -13
View File
@@ -17,22 +17,11 @@ namespace ts.server {
loggingEnabled(): boolean;
perftrc(s: string): void;
info(s: string): void;
startGroup(): void;
endGroup(): void;
msg(s: string, type?: Msg.Types): void;
err(s: string): void;
group(logGroupEntries: (log: (msg: string) => void) => void): void;
getLogFileName(): string;
}
export namespace Msg {
export type Err = "Err";
export const Err: Err = "Err";
export type Info = "Info";
export const Info: Info = "Info";
export type Perf = "Perf";
export const Perf: Perf = "Perf";
export type Types = Err | Info | Perf;
}
function getProjectRootPath(project: Project): Path {
switch (project.projectKind) {
case ProjectKind.Configured:
@@ -262,6 +251,15 @@ namespace ts.server {
return arr as SortedArray<T>;
}
export function toDeduplicatedSortedArray(arr: string[]): SortedArray<string> {
arr.sort();
filterMutate(arr, isNonDuplicateInSortedArray);
return arr as SortedArray<string>;
}
function isNonDuplicateInSortedArray<T>(value: T, index: number, array: T[]) {
return index === 0 || value !== array[index - 1];
}
export function enumerateInsertsAndDeletes<T>(newItems: SortedReadonlyArray<T>, oldItems: SortedReadonlyArray<T>, inserted: (newItem: T) => void, deleted: (oldItem: T) => void, compare?: Comparer<T>) {
compare = compare || compareValues;
let newIndex = 0;
+2 -2
View File
@@ -260,11 +260,11 @@ namespace ts {
templateStack.pop();
}
else {
Debug.assert(token === SyntaxKind.TemplateMiddle, "Should have been a template middle. Was " + token);
Debug.assertEqual(token, SyntaxKind.TemplateMiddle, "Should have been a template middle.");
}
}
else {
Debug.assert(lastTemplateStackToken === SyntaxKind.OpenBraceToken, "Should have been an open brace. Was: " + token);
Debug.assertEqual(lastTemplateStackToken, SyntaxKind.OpenBraceToken, "Should have been an open brace");
templateStack.pop();
}
}
+3 -1
View File
@@ -195,6 +195,7 @@ namespace ts.formatting {
// Insert space after opening and before closing nonempty parenthesis
public SpaceAfterOpenParen: Rule;
public SpaceBeforeCloseParen: Rule;
public SpaceBetweenOpenParens: Rule;
public NoSpaceBetweenParens: Rule;
public NoSpaceAfterOpenParen: Rule;
public NoSpaceBeforeCloseParen: Rule;
@@ -457,6 +458,7 @@ namespace ts.formatting {
// Insert space after opening and before closing nonempty parenthesis
this.SpaceAfterOpenParen = new Rule(RuleDescriptor.create3(SyntaxKind.OpenParenToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), Rules.IsNonJsxSameLineTokenContext), RuleAction.Space));
this.SpaceBeforeCloseParen = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), Rules.IsNonJsxSameLineTokenContext), RuleAction.Space));
this.SpaceBetweenOpenParens = new Rule(RuleDescriptor.create1(SyntaxKind.OpenParenToken, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), Rules.IsNonJsxSameLineTokenContext), RuleAction.Space));
this.NoSpaceBetweenParens = new Rule(RuleDescriptor.create1(SyntaxKind.OpenParenToken, SyntaxKind.CloseParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete));
this.NoSpaceAfterOpenParen = new Rule(RuleDescriptor.create3(SyntaxKind.OpenParenToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete));
this.NoSpaceBeforeCloseParen = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete));
@@ -544,7 +546,7 @@ namespace ts.formatting {
this.SpaceAfterComma, this.NoSpaceAfterComma,
this.SpaceAfterAnonymousFunctionKeyword, this.NoSpaceAfterAnonymousFunctionKeyword,
this.SpaceAfterKeywordInControl, this.NoSpaceAfterKeywordInControl,
this.SpaceAfterOpenParen, this.SpaceBeforeCloseParen, this.NoSpaceBetweenParens, this.NoSpaceAfterOpenParen, this.NoSpaceBeforeCloseParen,
this.SpaceAfterOpenParen, this.SpaceBeforeCloseParen, this.SpaceBetweenOpenParens, this.NoSpaceBetweenParens, this.NoSpaceAfterOpenParen, this.NoSpaceBeforeCloseParen,
this.SpaceAfterOpenBracket, this.SpaceBeforeCloseBracket, this.NoSpaceBetweenBrackets, this.NoSpaceAfterOpenBracket, this.NoSpaceBeforeCloseBracket,
this.SpaceAfterOpenBrace, this.SpaceBeforeCloseBrace, this.NoSpaceBetweenEmptyBraceBrackets, this.NoSpaceAfterOpenBrace, this.NoSpaceBeforeCloseBrace,
this.SpaceAfterTemplateHeadAndMiddle, this.SpaceBeforeTemplateMiddleAndTail, this.NoSpaceAfterTemplateHeadAndMiddle, this.NoSpaceBeforeTemplateMiddleAndTail,
+1 -1
View File
@@ -35,7 +35,7 @@ namespace ts.JsTyping {
"crypto", "stream", "util", "assert", "tty", "domain",
"constants", "process", "v8", "timers", "console"];
const nodeCoreModules = arrayToMap(<string[]>nodeCoreModuleList, x => x);
const nodeCoreModules = arrayToSet(nodeCoreModuleList);
/**
* A map of loose file names to library names that we are confident require typings
+1 -1
View File
@@ -1258,7 +1258,7 @@ namespace ts {
// We do not support the scenario where a host can modify a registered
// file's script kind, i.e. in one project some file is treated as ".ts"
// and in another as ".js"
Debug.assert(hostFileInformation.scriptKind === oldSourceFile.scriptKind, "Registered script kind (" + oldSourceFile.scriptKind + ") should match new script kind (" + hostFileInformation.scriptKind + ") for file: " + path);
Debug.assertEqual(hostFileInformation.scriptKind, oldSourceFile.scriptKind, "Registered script kind should match new script kind.", path);
return documentRegistry.updateDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind);
}
+9 -3
View File
@@ -136,7 +136,9 @@ namespace ts.SignatureHelp {
const kind = invocation.typeArguments && invocation.typeArguments.pos === list.pos ? ArgumentListKind.TypeArguments : ArgumentListKind.CallArguments;
const argumentCount = getArgumentCount(list);
Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, `argumentCount < argumentIndex, ${argumentCount} < ${argumentIndex}`);
if (argumentIndex !== 0) {
Debug.assertLessThan(argumentIndex, argumentCount);
}
const argumentsSpan = getApplicableSpanForArguments(list, sourceFile);
return { kind, invocation, argumentsSpan, argumentIndex, argumentCount };
}
@@ -270,7 +272,9 @@ namespace ts.SignatureHelp {
? 1
: (<TemplateExpression>tagExpression.template).templateSpans.length + 1;
Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, `argumentCount < argumentIndex, ${argumentCount} < ${argumentIndex}`);
if (argumentIndex !== 0) {
Debug.assertLessThan(argumentIndex, argumentCount);
}
return {
kind: ArgumentListKind.TaggedTemplateArguments,
invocation: tagExpression,
@@ -402,7 +406,9 @@ namespace ts.SignatureHelp {
};
});
Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, `argumentCount < argumentIndex, ${argumentCount} < ${argumentIndex}`);
if (argumentIndex !== 0) {
Debug.assertLessThan(argumentIndex, argumentCount);
}
const selectedItemIndex = candidates.indexOf(resolvedSignature);
Debug.assert(selectedItemIndex !== -1); // If candidates is non-empty it should always include bestSignature. We check for an empty candidates before calling this function.
+2 -2
View File
@@ -78,11 +78,11 @@ namespace ts {
getSourceFile: (fileName) => fileName === normalizePath(inputFileName) ? sourceFile : undefined,
writeFile: (name, text) => {
if (fileExtensionIs(name, ".map")) {
Debug.assert(sourceMapText === undefined, `Unexpected multiple source map outputs for the file '${name}'`);
Debug.assertEqual(sourceMapText, undefined, "Unexpected multiple source map outputs, file:", name);
sourceMapText = text;
}
else {
Debug.assert(outputText === undefined, `Unexpected multiple outputs for the file: '${name}'`);
Debug.assertEqual(outputText, undefined, "Unexpected multiple outputs, file:", name);
outputText = text;
}
},
@@ -1,14 +1,14 @@
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(11,10): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(12,10): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(13,10): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(14,14): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(15,14): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(16,10): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(19,10): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(20,10): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(21,10): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(22,11): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(23,11): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(11,10): error TS2365: Operator '+' cannot be applied to types 'null' and 'boolean'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(12,10): error TS2365: Operator '+' cannot be applied to types 'null' and 'Object'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(13,10): error TS2365: Operator '+' cannot be applied to types 'null' and 'void'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(14,10): error TS2365: Operator '+' cannot be applied to types 'boolean' and 'null'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(15,10): error TS2365: Operator '+' cannot be applied to types 'Object' and 'null'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(16,10): error TS2365: Operator '+' cannot be applied to types 'null' and 'void'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(19,10): error TS2365: Operator '+' cannot be applied to types 'null' and 'Number'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(20,10): error TS2365: Operator '+' cannot be applied to types 'null' and 'true'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(21,10): error TS2365: Operator '+' cannot be applied to types 'null' and '{ a: string; }'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(22,11): error TS2365: Operator '+' cannot be applied to types 'null' and 'void'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(23,11): error TS2365: Operator '+' cannot be applied to types 'null' and '() => void'.
==== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts (11 errors) ====
@@ -23,37 +23,37 @@ tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOpe
// null + boolean/Object
var r1 = null + a;
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'boolean'.
var r2 = null + b;
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'Object'.
var r3 = null + c;
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'void'.
var r4 = a + null;
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'boolean' and 'null'.
var r5 = b + null;
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'Object' and 'null'.
var r6 = null + c;
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'void'.
// other cases
var r7 = null + d;
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'Number'.
var r8 = null + true;
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'true'.
var r9 = null + { a: '' };
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'null' and '{ a: string; }'.
var r10 = null + foo();
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'void'.
var r11 = null + (() => { });
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'null' and '() => void'.
@@ -1,13 +1,13 @@
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(15,10): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(16,10): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(17,10): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(18,10): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(19,10): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(20,14): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(21,14): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(22,15): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(23,17): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(24,20): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(15,10): error TS2365: Operator '+' cannot be applied to types 'null' and 'number'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(16,10): error TS2365: Operator '+' cannot be applied to types 'null' and '1'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(17,10): error TS2365: Operator '+' cannot be applied to types 'null' and 'E'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(18,10): error TS2365: Operator '+' cannot be applied to types 'null' and 'E.a'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(19,10): error TS2365: Operator '+' cannot be applied to types 'null' and 'E.a'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(20,10): error TS2365: Operator '+' cannot be applied to types 'number' and 'null'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(21,10): error TS2365: Operator '+' cannot be applied to types '1' and 'null'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(22,11): error TS2365: Operator '+' cannot be applied to types 'E' and 'null'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(23,11): error TS2365: Operator '+' cannot be applied to types 'E.a' and 'null'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts(24,11): error TS2365: Operator '+' cannot be applied to types 'E.a' and 'null'.
==== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndValidOperator.ts (10 errors) ====
@@ -26,35 +26,35 @@ tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOpe
// null + number/enum
var r3 = null + b;
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'number'.
var r4 = null + 1;
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'null' and '1'.
var r5 = null + c;
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'E'.
var r6 = null + E.a;
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'E.a'.
var r7 = null + E['a'];
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'E.a'.
var r8 = b + null;
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'number' and 'null'.
var r9 = 1 + null;
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types '1' and 'null'.
var r10 = c + null
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'E' and 'null'.
var r11 = E.a + null;
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'E.a' and 'null'.
var r12 = E['a'] + null;
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'E.a' and 'null'.
// null + string
var r13 = null + d;
@@ -1,32 +1,20 @@
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(2,10): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(2,17): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(3,10): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(3,17): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(4,10): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(4,22): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(5,10): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(5,22): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(2,10): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(3,10): error TS2365: Operator '+' cannot be applied to types 'null' and 'undefined'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(4,10): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'null'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(5,10): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
==== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts (8 errors) ====
==== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts (4 errors) ====
// bug 819721
var r1 = null + null;
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
var r2 = null + undefined;
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'undefined'.
var r3 = undefined + null;
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'null'.
var r4 = undefined + undefined;
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
@@ -8,8 +8,8 @@ tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOpe
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(27,15): error TS2365: Operator '+' cannot be applied to types 'Object' and 'T'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(28,15): error TS2365: Operator '+' cannot be applied to types 'E' and 'T'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(29,15): error TS2365: Operator '+' cannot be applied to types 'void' and 'T'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(32,19): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(33,19): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(32,15): error TS2365: Operator '+' cannot be applied to types 'T' and 'null'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(33,15): error TS2365: Operator '+' cannot be applied to types 'T' and 'undefined'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(34,15): error TS2365: Operator '+' cannot be applied to types 'T' and 'T'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(35,15): error TS2365: Operator '+' cannot be applied to types 'T' and 'U'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(36,15): error TS2365: Operator '+' cannot be applied to types 'T' and '() => void'.
@@ -69,11 +69,11 @@ tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOpe
// other cases
var r15 = t + null;
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'T' and 'null'.
var r16 = t + undefined;
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'T' and 'undefined'.
var r17 = t + t;
~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'T' and 'T'.
@@ -1,14 +1,14 @@
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(11,10): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(12,10): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(13,10): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(14,14): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(15,14): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(16,10): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(19,10): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(20,10): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(21,10): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(22,11): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(23,11): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(11,10): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'boolean'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(12,10): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'Object'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(13,10): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'void'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(14,10): error TS2365: Operator '+' cannot be applied to types 'boolean' and 'undefined'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(15,10): error TS2365: Operator '+' cannot be applied to types 'Object' and 'undefined'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(16,10): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'void'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(19,10): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'Number'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(20,10): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'true'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(21,10): error TS2365: Operator '+' cannot be applied to types 'undefined' and '{ a: string; }'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(22,11): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'void'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(23,11): error TS2365: Operator '+' cannot be applied to types 'undefined' and '() => void'.
==== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts (11 errors) ====
@@ -23,37 +23,37 @@ tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOpe
// undefined + boolean/Object
var r1 = undefined + a;
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'boolean'.
var r2 = undefined + b;
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'Object'.
var r3 = undefined + c;
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'void'.
var r4 = a + undefined;
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'boolean' and 'undefined'.
var r5 = b + undefined;
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'Object' and 'undefined'.
var r6 = undefined + c;
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'void'.
// other cases
var r7 = undefined + d;
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'Number'.
var r8 = undefined + true;
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'true'.
var r9 = undefined + { a: '' };
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and '{ a: string; }'.
var r10 = undefined + foo();
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'void'.
var r11 = undefined + (() => { });
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and '() => void'.
@@ -1,13 +1,13 @@
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(15,10): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(16,10): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(17,10): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(18,10): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(19,10): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(20,14): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(21,14): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(22,15): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(23,17): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(24,20): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(15,10): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'number'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(16,10): error TS2365: Operator '+' cannot be applied to types 'undefined' and '1'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(17,10): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'E'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(18,10): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'E.a'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(19,10): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'E.a'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(20,10): error TS2365: Operator '+' cannot be applied to types 'number' and 'undefined'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(21,10): error TS2365: Operator '+' cannot be applied to types '1' and 'undefined'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(22,11): error TS2365: Operator '+' cannot be applied to types 'E' and 'undefined'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(23,11): error TS2365: Operator '+' cannot be applied to types 'E.a' and 'undefined'.
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts(24,11): error TS2365: Operator '+' cannot be applied to types 'E.a' and 'undefined'.
==== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndValidOperator.ts (10 errors) ====
@@ -26,35 +26,35 @@ tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOpe
// undefined + number/enum
var r3 = undefined + b;
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'number'.
var r4 = undefined + 1;
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and '1'.
var r5 = undefined + c;
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'E'.
var r6 = undefined + E.a;
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'E.a'.
var r7 = undefined + E['a'];
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'E.a'.
var r8 = b + undefined;
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'number' and 'undefined'.
var r9 = 1 + undefined;
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types '1' and 'undefined'.
var r10 = c + undefined
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'E' and 'undefined'.
var r11 = E.a + undefined;
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'E.a' and 'undefined'.
var r12 = E['a'] + undefined;
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'E.a' and 'undefined'.
// undefined + string
var r13 = undefined + d;
@@ -1,14 +1,11 @@
tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(34,24): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(35,24): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(46,26): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(46,33): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(47,26): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(47,33): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(48,26): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(48,38): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(46,26): error TS2365: Operator '+' cannot be applied to types 'null' and 'undefined'.
tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(47,26): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts(48,26): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
==== tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts (8 errors) ====
==== tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts (5 errors) ====
// ~ operator on any type
var ANY: any;
@@ -59,20 +56,14 @@ tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNot
var ResultIsNumber14 = ~A.foo();
var ResultIsNumber15 = ~(ANY + ANY1);
var ResultIsNumber16 = ~(null + undefined);
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'undefined'.
var ResultIsNumber17 = ~(null + null);
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
var ResultIsNumber18 = ~(undefined + undefined);
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
// multiple ~ operators
var ResultIsNumber19 = ~~ANY;
@@ -0,0 +1,13 @@
tests/cases/compiler/checkTypePredicateForRedundantProperties.ts(1,35): error TS2300: Duplicate identifier 'a'.
tests/cases/compiler/checkTypePredicateForRedundantProperties.ts(1,46): error TS2300: Duplicate identifier 'a'.
==== tests/cases/compiler/checkTypePredicateForRedundantProperties.ts (2 errors) ====
function addProp2(x: any): x is { a: string; a: string; } {
~
!!! error TS2300: Duplicate identifier 'a'.
~
!!! error TS2300: Duplicate identifier 'a'.
return true;
}
@@ -0,0 +1,10 @@
//// [checkTypePredicateForRedundantProperties.ts]
function addProp2(x: any): x is { a: string; a: string; } {
return true;
}
//// [checkTypePredicateForRedundantProperties.js]
function addProp2(x) {
return true;
}
@@ -1,7 +1,7 @@
tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentLHSCanBeAssigned.ts(32,7): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentLHSCanBeAssigned.ts(33,7): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentLHSCanBeAssigned.ts(39,7): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentLHSCanBeAssigned.ts(40,7): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentLHSCanBeAssigned.ts(32,1): error TS2365: Operator '+=' cannot be applied to types 'number' and 'null'.
tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentLHSCanBeAssigned.ts(33,1): error TS2365: Operator '+=' cannot be applied to types 'number' and 'undefined'.
tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentLHSCanBeAssigned.ts(39,1): error TS2365: Operator '+=' cannot be applied to types 'E' and 'null'.
tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentLHSCanBeAssigned.ts(40,1): error TS2365: Operator '+=' cannot be applied to types 'E' and 'undefined'.
==== tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentLHSCanBeAssigned.ts (4 errors) ====
@@ -37,22 +37,22 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmen
x3 += 0;
x3 += E.a;
x3 += null;
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~~~
!!! error TS2365: Operator '+=' cannot be applied to types 'number' and 'null'.
x3 += undefined;
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+=' cannot be applied to types 'number' and 'undefined'.
var x4: E;
x4 += a;
x4 += 0;
x4 += E.a;
x4 += null;
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~~~
!!! error TS2365: Operator '+=' cannot be applied to types 'E' and 'null'.
x4 += undefined;
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+=' cannot be applied to types 'E' and 'undefined'.
var x5: boolean;
x5 += a;
@@ -3,22 +3,22 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmen
tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(8,1): error TS2365: Operator '+=' cannot be applied to types 'boolean' and '0'.
tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(9,1): error TS2365: Operator '+=' cannot be applied to types 'boolean' and 'E.a'.
tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(10,1): error TS2365: Operator '+=' cannot be applied to types 'boolean' and '{}'.
tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(11,7): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(12,7): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(11,1): error TS2365: Operator '+=' cannot be applied to types 'boolean' and 'null'.
tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(12,1): error TS2365: Operator '+=' cannot be applied to types 'boolean' and 'undefined'.
tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(15,1): error TS2365: Operator '+=' cannot be applied to types '{}' and 'void'.
tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(16,1): error TS2365: Operator '+=' cannot be applied to types '{}' and 'true'.
tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(17,1): error TS2365: Operator '+=' cannot be applied to types '{}' and '0'.
tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(18,1): error TS2365: Operator '+=' cannot be applied to types '{}' and 'E.a'.
tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(19,1): error TS2365: Operator '+=' cannot be applied to types '{}' and '{}'.
tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(20,7): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(21,7): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(20,1): error TS2365: Operator '+=' cannot be applied to types '{}' and 'null'.
tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(21,1): error TS2365: Operator '+=' cannot be applied to types '{}' and 'undefined'.
tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(24,1): error TS2365: Operator '+=' cannot be applied to types 'void' and 'void'.
tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(25,1): error TS2365: Operator '+=' cannot be applied to types 'void' and 'true'.
tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(26,1): error TS2365: Operator '+=' cannot be applied to types 'void' and '0'.
tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(27,1): error TS2365: Operator '+=' cannot be applied to types 'void' and 'E.a'.
tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(28,1): error TS2365: Operator '+=' cannot be applied to types 'void' and '{}'.
tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(29,7): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(30,7): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(29,1): error TS2365: Operator '+=' cannot be applied to types 'void' and 'null'.
tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(30,1): error TS2365: Operator '+=' cannot be applied to types 'void' and 'undefined'.
tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(33,1): error TS2365: Operator '+=' cannot be applied to types 'number' and 'void'.
tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(34,1): error TS2365: Operator '+=' cannot be applied to types 'number' and 'true'.
tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(35,1): error TS2365: Operator '+=' cannot be applied to types 'number' and '{}'.
@@ -49,11 +49,11 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmen
~~~~~~~~
!!! error TS2365: Operator '+=' cannot be applied to types 'boolean' and '{}'.
x1 += null;
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~~~
!!! error TS2365: Operator '+=' cannot be applied to types 'boolean' and 'null'.
x1 += undefined;
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+=' cannot be applied to types 'boolean' and 'undefined'.
var x2: {};
x2 += a;
@@ -72,11 +72,11 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmen
~~~~~~~~
!!! error TS2365: Operator '+=' cannot be applied to types '{}' and '{}'.
x2 += null;
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~~~
!!! error TS2365: Operator '+=' cannot be applied to types '{}' and 'null'.
x2 += undefined;
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+=' cannot be applied to types '{}' and 'undefined'.
var x3: void;
x3 += a;
@@ -95,11 +95,11 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmen
~~~~~~~~
!!! error TS2365: Operator '+=' cannot be applied to types 'void' and '{}'.
x3 += null;
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~~~
!!! error TS2365: Operator '+=' cannot be applied to types 'void' and 'null'.
x3 += undefined;
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+=' cannot be applied to types 'void' and 'undefined'.
var x4: number;
x4 += a;
@@ -0,0 +1,15 @@
tests/cases/conformance/es6/computedProperties/computedPropertyNames51_ES5.ts(5,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames51_ES5.ts (1 errors) ====
function f<T, K extends keyof T>() {
var t: T;
var k: K;
var v = {
[t]: 0,
~~~
!!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
[k]: 1
};
}
@@ -0,0 +1,21 @@
//// [computedPropertyNames51_ES5.ts]
function f<T, K extends keyof T>() {
var t: T;
var k: K;
var v = {
[t]: 0,
[k]: 1
};
}
//// [computedPropertyNames51_ES5.js]
function f() {
var t;
var k;
var v = (_a = {},
_a[t] = 0,
_a[k] = 1,
_a);
var _a;
}
@@ -0,0 +1,15 @@
tests/cases/conformance/es6/computedProperties/computedPropertyNames51_ES6.ts(5,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames51_ES6.ts (1 errors) ====
function f<T, K extends keyof T>() {
var t: T;
var k: K;
var v = {
[t]: 0,
~~~
!!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
[k]: 1
};
}
@@ -0,0 +1,20 @@
//// [computedPropertyNames51_ES6.ts]
function f<T, K extends keyof T>() {
var t: T;
var k: K;
var v = {
[t]: 0,
[k]: 1
};
}
//// [computedPropertyNames51_ES6.js]
function f() {
var t;
var k;
var v = {
[t]: 0,
[k]: 1
};
}
@@ -1,8 +1,7 @@
tests/cases/conformance/es6/computedProperties/computedPropertyNames8_ES5.ts(5,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
tests/cases/conformance/es6/computedProperties/computedPropertyNames8_ES5.ts(6,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames8_ES5.ts (2 errors) ====
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames8_ES5.ts (1 errors) ====
function f<T, U extends string>() {
var t: T;
var u: U;
@@ -11,7 +10,5 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames8_ES5.ts(6,9
~~~
!!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
[u]: 1
~~~
!!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
};
}
@@ -1,8 +1,7 @@
tests/cases/conformance/es6/computedProperties/computedPropertyNames8_ES6.ts(5,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
tests/cases/conformance/es6/computedProperties/computedPropertyNames8_ES6.ts(6,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames8_ES6.ts (2 errors) ====
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames8_ES6.ts (1 errors) ====
function f<T, U extends string>() {
var t: T;
var u: U;
@@ -11,7 +10,5 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames8_ES6.ts(6,9
~~~
!!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
[u]: 1
~~~
!!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
};
}
@@ -34,7 +34,7 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(138,13): error T
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(141,32): error TS1005: '{' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(143,13): error TS1005: 'try' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(159,24): error TS1109: Expression expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(159,30): error TS1005: '(' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(159,30): error TS1005: '{' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(159,31): error TS2304: Cannot find name 'Property'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(166,13): error TS2365: Operator '+=' cannot be applied to types 'number' and 'void'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(180,40): error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead.
@@ -323,7 +323,7 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS
~~~~~
!!! error TS1109: Expression expected.
~
!!! error TS1005: '(' expected.
!!! error TS1005: '{' expected.
~~~~~~~~
!!! error TS2304: Cannot find name 'Property'.
retVal += c.Member();
@@ -441,7 +441,7 @@ var BasicFeatures = (function () {
var xx = c;
retVal += ;
try { }
catch () { }
catch (_a) { }
Property;
retVal += c.Member();
retVal += xx.Foo() ? 0 : 1;
@@ -19,27 +19,21 @@ tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOp
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(46,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(47,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(48,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(48,27): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(48,34): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(48,27): error TS2365: Operator '+' cannot be applied to types 'null' and 'undefined'.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(49,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(49,27): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(49,34): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(49,27): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(50,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(50,27): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(50,39): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(50,27): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(51,26): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(52,26): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(54,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(55,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(56,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(56,25): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(56,32): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(56,25): error TS2365: Operator '+' cannot be applied to types 'null' and 'undefined'.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(57,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(57,25): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(57,32): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(57,25): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(58,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(58,25): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(58,37): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(58,25): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(59,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(60,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(63,3): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
@@ -58,7 +52,7 @@ tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOp
tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts(72,12): error TS1109: Expression expected.
==== tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts (58 errors) ====
==== tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOperatorWithAnyOtherTypeInvalidOperations.ts (52 errors) ====
// -- operator on any type
var ANY1: any;
var ANY2: any[] = ["", ""];
@@ -149,24 +143,18 @@ tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOp
var ResultIsNumber19 = --(null + undefined);
~~~~~~~~~~~~~~~~~~
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'undefined'.
var ResultIsNumber20 = --(null + null);
~~~~~~~~~~~~~
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
var ResultIsNumber21 = --(undefined + undefined);
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
var ResultIsNumber22 = --obj1.x;
~~~~~~
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
@@ -183,24 +171,18 @@ tests/cases/conformance/expressions/unaryOperators/decrementOperator/decrementOp
var ResultIsNumber26 = (null + undefined)--;
~~~~~~~~~~~~~~~~~~
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'undefined'.
var ResultIsNumber27 = (null + null)--;
~~~~~~~~~~~~~
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
var ResultIsNumber28 = (undefined + undefined)--;
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
var ResultIsNumber29 = obj1.x--;
~~~~~~
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
@@ -9,15 +9,12 @@ tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperator
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(42,32): error TS2703: The operand of a delete operator must be a property reference.
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(43,32): error TS2703: The operand of a delete operator must be a property reference.
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(44,33): error TS2703: The operand of a delete operator must be a property reference.
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(45,33): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(45,33): error TS2365: Operator '+' cannot be applied to types 'null' and 'undefined'.
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(45,33): error TS2703: The operand of a delete operator must be a property reference.
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(45,40): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(46,33): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(46,33): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(46,33): error TS2703: The operand of a delete operator must be a property reference.
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(46,40): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(47,33): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(47,33): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(47,33): error TS2703: The operand of a delete operator must be a property reference.
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(47,45): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(50,32): error TS2703: The operand of a delete operator must be a property reference.
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(50,39): error TS2703: The operand of a delete operator must be a property reference.
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(51,32): error TS2703: The operand of a delete operator must be a property reference.
@@ -28,7 +25,7 @@ tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperator
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts(57,8): error TS2703: The operand of a delete operator must be a property reference.
==== tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts (28 errors) ====
==== tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorWithAnyOtherType.ts (25 errors) ====
// delete operator on any type
var ANY: any;
@@ -96,26 +93,20 @@ tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperator
~~~~~~~~~~
!!! error TS2703: The operand of a delete operator must be a property reference.
var ResultIsBoolean17 = delete (null + undefined);
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'undefined'.
~~~~~~~~~~~~~~~~
!!! error TS2703: The operand of a delete operator must be a property reference.
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
var ResultIsBoolean18 = delete (null + null);
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
~~~~~~~~~~~
!!! error TS2703: The operand of a delete operator must be a property reference.
~~~~
!!! error TS2531: Object is possibly 'null'.
var ResultIsBoolean19 = delete (undefined + undefined);
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2703: The operand of a delete operator must be a property reference.
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
// multiple delete operators
var ResultIsBoolean20 = delete delete ANY;
@@ -0,0 +1,22 @@
//// [emitter.noCatchBinding.esnext.ts]
function f() {
try { } catch { }
try { } catch {
try { } catch { }
}
try { } catch { } finally { }
}
//// [emitter.noCatchBinding.esnext.js]
function f() {
try { }
catch { }
try { }
catch {
try { }
catch { }
}
try { }
catch { }
finally { }
}
@@ -0,0 +1,10 @@
=== tests/cases/conformance/emitter/esnext/noCatchBinding/emitter.noCatchBinding.esnext.ts ===
function f() {
>f : Symbol(f, Decl(emitter.noCatchBinding.esnext.ts, 0, 0))
try { } catch { }
try { } catch {
try { } catch { }
}
try { } catch { } finally { }
}
@@ -0,0 +1,10 @@
=== tests/cases/conformance/emitter/esnext/noCatchBinding/emitter.noCatchBinding.esnext.ts ===
function f() {
>f : () => void
try { } catch { }
try { } catch {
try { } catch { }
}
try { } catch { } finally { }
}
@@ -3,9 +3,9 @@ export async function fn() {
>fn : () => Promise<void>
const req = await import('./test') // ONE
>req : typeof "tests/cases/conformance/dynamicImport/test"
>await import('./test') : typeof "tests/cases/conformance/dynamicImport/test"
>import('./test') : Promise<typeof "tests/cases/conformance/dynamicImport/test">
>req : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; }
>await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; }
>import('./test') : Promise<typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; }>
>'./test' : "./test"
}
@@ -16,9 +16,9 @@ export class cl1 {
>m : () => Promise<void>
const req = await import('./test') // TWO
>req : typeof "tests/cases/conformance/dynamicImport/test"
>await import('./test') : typeof "tests/cases/conformance/dynamicImport/test"
>import('./test') : Promise<typeof "tests/cases/conformance/dynamicImport/test">
>req : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; }
>await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; }
>import('./test') : Promise<typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; }>
>'./test' : "./test"
}
}
@@ -32,9 +32,9 @@ export const obj = {
>async () => { const req = await import('./test') // THREE } : () => Promise<void>
const req = await import('./test') // THREE
>req : typeof "tests/cases/conformance/dynamicImport/test"
>await import('./test') : typeof "tests/cases/conformance/dynamicImport/test"
>import('./test') : Promise<typeof "tests/cases/conformance/dynamicImport/test">
>req : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; }
>await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; }
>import('./test') : Promise<typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; }>
>'./test' : "./test"
}
}
@@ -51,9 +51,9 @@ export class cl2 {
>async () => { const req = await import('./test') // FOUR } : () => Promise<void>
const req = await import('./test') // FOUR
>req : typeof "tests/cases/conformance/dynamicImport/test"
>await import('./test') : typeof "tests/cases/conformance/dynamicImport/test"
>import('./test') : Promise<typeof "tests/cases/conformance/dynamicImport/test">
>req : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; }
>await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; }
>import('./test') : Promise<typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; }>
>'./test' : "./test"
}
}
@@ -64,9 +64,9 @@ export const l = async () => {
>async () => { const req = await import('./test') // FIVE} : () => Promise<void>
const req = await import('./test') // FIVE
>req : typeof "tests/cases/conformance/dynamicImport/test"
>await import('./test') : typeof "tests/cases/conformance/dynamicImport/test"
>import('./test') : Promise<typeof "tests/cases/conformance/dynamicImport/test">
>req : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; }
>await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; }
>import('./test') : Promise<typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; }>
>'./test' : "./test"
}
@@ -3,9 +3,9 @@ export async function fn() {
>fn : () => Promise<void>
const req = await import('./test') // ONE
>req : typeof "tests/cases/conformance/dynamicImport/test"
>await import('./test') : typeof "tests/cases/conformance/dynamicImport/test"
>import('./test') : Promise<typeof "tests/cases/conformance/dynamicImport/test">
>req : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; }
>await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; }
>import('./test') : Promise<typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; }>
>'./test' : "./test"
}
@@ -16,9 +16,9 @@ export class cl1 {
>m : () => Promise<void>
const req = await import('./test') // TWO
>req : typeof "tests/cases/conformance/dynamicImport/test"
>await import('./test') : typeof "tests/cases/conformance/dynamicImport/test"
>import('./test') : Promise<typeof "tests/cases/conformance/dynamicImport/test">
>req : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; }
>await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; }
>import('./test') : Promise<typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; }>
>'./test' : "./test"
}
}
@@ -32,9 +32,9 @@ export const obj = {
>async () => { const req = await import('./test') // THREE } : () => Promise<void>
const req = await import('./test') // THREE
>req : typeof "tests/cases/conformance/dynamicImport/test"
>await import('./test') : typeof "tests/cases/conformance/dynamicImport/test"
>import('./test') : Promise<typeof "tests/cases/conformance/dynamicImport/test">
>req : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; }
>await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; }
>import('./test') : Promise<typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; }>
>'./test' : "./test"
}
}
@@ -51,9 +51,9 @@ export class cl2 {
>async () => { const req = await import('./test') // FOUR } : () => Promise<void>
const req = await import('./test') // FOUR
>req : typeof "tests/cases/conformance/dynamicImport/test"
>await import('./test') : typeof "tests/cases/conformance/dynamicImport/test"
>import('./test') : Promise<typeof "tests/cases/conformance/dynamicImport/test">
>req : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; }
>await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; }
>import('./test') : Promise<typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; }>
>'./test' : "./test"
}
}
@@ -64,9 +64,9 @@ export const l = async () => {
>async () => { const req = await import('./test') // FIVE} : () => Promise<void>
const req = await import('./test') // FIVE
>req : typeof "tests/cases/conformance/dynamicImport/test"
>await import('./test') : typeof "tests/cases/conformance/dynamicImport/test"
>import('./test') : Promise<typeof "tests/cases/conformance/dynamicImport/test">
>req : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; }
>await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; }
>import('./test') : Promise<typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; }>
>'./test' : "./test"
}
@@ -3,9 +3,9 @@ export async function fn() {
>fn : () => Promise<void>
const req = await import('./test') // ONE
>req : typeof "tests/cases/conformance/dynamicImport/test"
>await import('./test') : typeof "tests/cases/conformance/dynamicImport/test"
>import('./test') : Promise<typeof "tests/cases/conformance/dynamicImport/test">
>req : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; }
>await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; }
>import('./test') : Promise<typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; }>
>'./test' : "./test"
}
@@ -16,9 +16,9 @@ export class cl1 {
>m : () => Promise<void>
const req = await import('./test') // TWO
>req : typeof "tests/cases/conformance/dynamicImport/test"
>await import('./test') : typeof "tests/cases/conformance/dynamicImport/test"
>import('./test') : Promise<typeof "tests/cases/conformance/dynamicImport/test">
>req : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; }
>await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; }
>import('./test') : Promise<typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; }>
>'./test' : "./test"
}
}
@@ -32,9 +32,9 @@ export const obj = {
>async () => { const req = await import('./test') // THREE } : () => Promise<void>
const req = await import('./test') // THREE
>req : typeof "tests/cases/conformance/dynamicImport/test"
>await import('./test') : typeof "tests/cases/conformance/dynamicImport/test"
>import('./test') : Promise<typeof "tests/cases/conformance/dynamicImport/test">
>req : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; }
>await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; }
>import('./test') : Promise<typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; }>
>'./test' : "./test"
}
}
@@ -51,9 +51,9 @@ export class cl2 {
>async () => { const req = await import('./test') // FOUR } : () => Promise<void>
const req = await import('./test') // FOUR
>req : typeof "tests/cases/conformance/dynamicImport/test"
>await import('./test') : typeof "tests/cases/conformance/dynamicImport/test"
>import('./test') : Promise<typeof "tests/cases/conformance/dynamicImport/test">
>req : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; }
>await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; }
>import('./test') : Promise<typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; }>
>'./test' : "./test"
}
}
@@ -64,9 +64,9 @@ export const l = async () => {
>async () => { const req = await import('./test') // FIVE} : () => Promise<void>
const req = await import('./test') // FIVE
>req : typeof "tests/cases/conformance/dynamicImport/test"
>await import('./test') : typeof "tests/cases/conformance/dynamicImport/test"
>import('./test') : Promise<typeof "tests/cases/conformance/dynamicImport/test">
>req : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; }
>await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; }
>import('./test') : Promise<typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; }>
>'./test' : "./test"
}
@@ -5,41 +5,41 @@ export function foo() { return "foo"; }
=== tests/cases/conformance/dynamicImport/1.ts ===
import("./0");
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }>
>"./0" : "./0"
var p1 = import("./0");
>p1 : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>p1 : Promise<typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }>
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }>
>"./0" : "./0"
p1.then(zero => {
>p1.then(zero => { return zero.foo();}) : Promise<string>
>p1.then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>p1 : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/dynamicImport/0") => string
>zero : typeof "tests/cases/conformance/dynamicImport/0"
>p1.then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }, TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>p1 : Promise<typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }>
>then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }, TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }) => string
>zero : typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }
return zero.foo();
>zero.foo() : string
>zero.foo : () => string
>zero : typeof "tests/cases/conformance/dynamicImport/0"
>zero : typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }
>foo : () => string
});
export var p2 = import("./0");
>p2 : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>p2 : Promise<typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }>
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }>
>"./0" : "./0"
function foo() {
>foo : () => void
const p2 = import("./0");
>p2 : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>p2 : Promise<typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }>
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }>
>"./0" : "./0"
}
@@ -50,8 +50,8 @@ class C {
>method : () => void
const loadAsync = import ("./0");
>loadAsync : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>import ("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>loadAsync : Promise<typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }>
>import ("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }>
>"./0" : "./0"
}
}
@@ -63,8 +63,8 @@ export class D {
>method : () => void
const loadAsync = import ("./0");
>loadAsync : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>import ("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>loadAsync : Promise<typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }>
>import ("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }>
>"./0" : "./0"
}
}
@@ -5,41 +5,41 @@ export function foo() { return "foo"; }
=== tests/cases/conformance/dynamicImport/1.ts ===
import("./0");
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }>
>"./0" : "./0"
var p1 = import("./0");
>p1 : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>p1 : Promise<typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }>
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }>
>"./0" : "./0"
p1.then(zero => {
>p1.then(zero => { return zero.foo();}) : Promise<string>
>p1.then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>p1 : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/dynamicImport/0") => string
>zero : typeof "tests/cases/conformance/dynamicImport/0"
>p1.then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }, TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>p1 : Promise<typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }>
>then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }, TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }) => string
>zero : typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }
return zero.foo();
>zero.foo() : string
>zero.foo : () => string
>zero : typeof "tests/cases/conformance/dynamicImport/0"
>zero : typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }
>foo : () => string
});
export var p2 = import("./0");
>p2 : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>p2 : Promise<typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }>
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }>
>"./0" : "./0"
function foo() {
>foo : () => void
const p2 = import("./0");
>p2 : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>p2 : Promise<typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }>
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }>
>"./0" : "./0"
}
@@ -50,8 +50,8 @@ class C {
>method : () => void
const loadAsync = import ("./0");
>loadAsync : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>import ("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>loadAsync : Promise<typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }>
>import ("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }>
>"./0" : "./0"
}
}
@@ -63,8 +63,8 @@ export class D {
>method : () => void
const loadAsync = import ("./0");
>loadAsync : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>import ("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>loadAsync : Promise<typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }>
>import ("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }>
>"./0" : "./0"
}
}
@@ -5,40 +5,40 @@ export function foo() { return "foo"; }
=== tests/cases/conformance/dynamicImport/1.ts ===
import("./0");
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }>
>"./0" : "./0"
var p1 = import("./0");
>p1 : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>p1 : Promise<typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }>
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }>
>"./0" : "./0"
p1.then(zero => {
>p1.then(zero => { return zero.foo();}) : Promise<string>
>p1.then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>p1 : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/dynamicImport/0") => string
>zero : typeof "tests/cases/conformance/dynamicImport/0"
>p1.then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }, TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>p1 : Promise<typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }>
>then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }, TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }) => string
>zero : typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }
return zero.foo();
>zero.foo() : string
>zero.foo : () => string
>zero : typeof "tests/cases/conformance/dynamicImport/0"
>zero : typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }
>foo : () => string
});
export var p2 = import("./0");
>p2 : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>p2 : Promise<typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }>
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }>
>"./0" : "./0"
function foo() {
>foo : () => void
const p2 = import("./0");
>p2 : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>p2 : Promise<typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }>
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }>
>"./0" : "./0"
}
@@ -41,6 +41,6 @@ function foo(x: Promise<any>) {
foo(import("./0"));
>foo(import("./0")) : void
>foo : (x: Promise<any>) => void
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }>
>"./0" : "./0"
@@ -14,9 +14,9 @@ async function foo() {
class C extends (await import("./0")).B {}
>C : C
>(await import("./0")).B : B
>(await import("./0")) : typeof "tests/cases/conformance/dynamicImport/0"
>await import("./0") : typeof "tests/cases/conformance/dynamicImport/0"
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>(await import("./0")) : typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }
>await import("./0") : typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }>
>"./0" : "./0"
>B : typeof B
@@ -24,27 +24,27 @@ class C {
>C : C
private myModule = import("./0");
>myModule : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>myModule : Promise<typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }>
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }>
>"./0" : "./0"
method() {
>method : () => void
const loadAsync = import("./0");
>loadAsync : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>loadAsync : Promise<typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }>
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }>
>"./0" : "./0"
this.myModule.then(Zero => {
>this.myModule.then(Zero => { console.log(Zero.foo()); }, async err => { console.log(err); let one = await import("./1"); console.log(one.backup()); }) : Promise<void>
>this.myModule.then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>this.myModule : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>this.myModule.then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }, TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>this.myModule : Promise<typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }>
>this : this
>myModule : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>Zero => { console.log(Zero.foo()); } : (Zero: typeof "tests/cases/conformance/dynamicImport/0") => void
>Zero : typeof "tests/cases/conformance/dynamicImport/0"
>myModule : Promise<typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }>
>then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }, TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>Zero => { console.log(Zero.foo()); } : (Zero: typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }) => void
>Zero : typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }
console.log(Zero.foo());
>console.log(Zero.foo()) : any
@@ -53,7 +53,7 @@ class C {
>log : any
>Zero.foo() : string
>Zero.foo : () => string
>Zero : typeof "tests/cases/conformance/dynamicImport/0"
>Zero : typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }
>foo : () => string
}, async err => {
@@ -68,9 +68,9 @@ class C {
>err : any
let one = await import("./1");
>one : typeof "tests/cases/conformance/dynamicImport/1"
>await import("./1") : typeof "tests/cases/conformance/dynamicImport/1"
>import("./1") : Promise<typeof "tests/cases/conformance/dynamicImport/1">
>one : typeof "tests/cases/conformance/dynamicImport/1" & { default: typeof "tests/cases/conformance/dynamicImport/1"; }
>await import("./1") : typeof "tests/cases/conformance/dynamicImport/1" & { default: typeof "tests/cases/conformance/dynamicImport/1"; }
>import("./1") : Promise<typeof "tests/cases/conformance/dynamicImport/1" & { default: typeof "tests/cases/conformance/dynamicImport/1"; }>
>"./1" : "./1"
console.log(one.backup());
@@ -80,7 +80,7 @@ class C {
>log : any
>one.backup() : string
>one.backup : () => string
>one : typeof "tests/cases/conformance/dynamicImport/1"
>one : typeof "tests/cases/conformance/dynamicImport/1" & { default: typeof "tests/cases/conformance/dynamicImport/1"; }
>backup : () => string
});
@@ -91,27 +91,27 @@ export class D {
>D : D
private myModule = import("./0");
>myModule : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>myModule : Promise<typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }>
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }>
>"./0" : "./0"
method() {
>method : () => void
const loadAsync = import("./0");
>loadAsync : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>loadAsync : Promise<typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }>
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }>
>"./0" : "./0"
this.myModule.then(Zero => {
>this.myModule.then(Zero => { console.log(Zero.foo()); }, async err => { console.log(err); let one = await import("./1"); console.log(one.backup()); }) : Promise<void>
>this.myModule.then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>this.myModule : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>this.myModule.then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }, TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>this.myModule : Promise<typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }>
>this : this
>myModule : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>Zero => { console.log(Zero.foo()); } : (Zero: typeof "tests/cases/conformance/dynamicImport/0") => void
>Zero : typeof "tests/cases/conformance/dynamicImport/0"
>myModule : Promise<typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }>
>then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }, TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>Zero => { console.log(Zero.foo()); } : (Zero: typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }) => void
>Zero : typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }
console.log(Zero.foo());
>console.log(Zero.foo()) : any
@@ -120,7 +120,7 @@ export class D {
>log : any
>Zero.foo() : string
>Zero.foo : () => string
>Zero : typeof "tests/cases/conformance/dynamicImport/0"
>Zero : typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }
>foo : () => string
}, async err => {
@@ -135,9 +135,9 @@ export class D {
>err : any
let one = await import("./1");
>one : typeof "tests/cases/conformance/dynamicImport/1"
>await import("./1") : typeof "tests/cases/conformance/dynamicImport/1"
>import("./1") : Promise<typeof "tests/cases/conformance/dynamicImport/1">
>one : typeof "tests/cases/conformance/dynamicImport/1" & { default: typeof "tests/cases/conformance/dynamicImport/1"; }
>await import("./1") : typeof "tests/cases/conformance/dynamicImport/1" & { default: typeof "tests/cases/conformance/dynamicImport/1"; }
>import("./1") : Promise<typeof "tests/cases/conformance/dynamicImport/1" & { default: typeof "tests/cases/conformance/dynamicImport/1"; }>
>"./1" : "./1"
console.log(one.backup());
@@ -147,7 +147,7 @@ export class D {
>log : any
>one.backup() : string
>one.backup : () => string
>one : typeof "tests/cases/conformance/dynamicImport/1"
>one : typeof "tests/cases/conformance/dynamicImport/1" & { default: typeof "tests/cases/conformance/dynamicImport/1"; }
>backup : () => string
});
@@ -19,27 +19,21 @@ tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOp
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(46,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(47,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(48,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(48,27): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(48,34): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(48,27): error TS2365: Operator '+' cannot be applied to types 'null' and 'undefined'.
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(49,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(49,27): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(49,34): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(49,27): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(50,26): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(50,27): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(50,39): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(50,27): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(51,26): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(52,26): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(54,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(55,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(56,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(56,25): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(56,32): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(56,25): error TS2365: Operator '+' cannot be applied to types 'null' and 'undefined'.
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(57,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(57,25): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(57,32): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(57,25): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(58,24): error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(58,25): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(58,37): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(58,25): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(59,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(60,24): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(63,3): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
@@ -53,7 +47,7 @@ tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOp
tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts(69,12): error TS1109: Expression expected.
==== tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts (53 errors) ====
==== tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOperatorWithAnyOtherTypeInvalidOperations.ts (47 errors) ====
// ++ operator on any type
var ANY1: any;
var ANY2: any[] = [1, 2];
@@ -144,24 +138,18 @@ tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOp
var ResultIsNumber19 = ++(null + undefined);
~~~~~~~~~~~~~~~~~~
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'undefined'.
var ResultIsNumber20 = ++(null + null);
~~~~~~~~~~~~~
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
var ResultIsNumber21 = ++(undefined + undefined);
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
var ResultIsNumber22 = ++obj1.x;
~~~~~~
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
@@ -178,24 +166,18 @@ tests/cases/conformance/expressions/unaryOperators/incrementOperator/incrementOp
var ResultIsNumber26 = (null + undefined)++;
~~~~~~~~~~~~~~~~~~
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'undefined'.
var ResultIsNumber27 = (null + null)++;
~~~~~~~~~~~~~
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
var ResultIsNumber28 = (undefined + undefined)++;
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2357: The operand of an increment or decrement operator must be a variable or a property access.
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
var ResultIsNumber29 = obj1.x++;
~~~~~~
!!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type.
@@ -1,24 +1,23 @@
tests/cases/conformance/statements/tryStatements/invalidTryStatements2.ts(3,13): error TS1005: '(' expected.
tests/cases/conformance/statements/tryStatements/invalidTryStatements2.ts(6,5): error TS1005: 'try' expected.
tests/cases/conformance/statements/tryStatements/invalidTryStatements2.ts(12,5): error TS1005: 'try' expected.
tests/cases/conformance/statements/tryStatements/invalidTryStatements2.ts(13,5): error TS1005: 'try' expected.
tests/cases/conformance/statements/tryStatements/invalidTryStatements2.ts(22,5): error TS1005: 'try' expected.
tests/cases/conformance/statements/tryStatements/invalidTryStatements2.ts(26,5): error TS1005: 'try' expected.
tests/cases/conformance/statements/tryStatements/invalidTryStatements2.ts(2,5): error TS1005: 'try' expected.
tests/cases/conformance/statements/tryStatements/invalidTryStatements2.ts(6,12): error TS1005: 'finally' expected.
tests/cases/conformance/statements/tryStatements/invalidTryStatements2.ts(10,5): error TS1005: 'try' expected.
tests/cases/conformance/statements/tryStatements/invalidTryStatements2.ts(11,5): error TS1005: 'try' expected.
tests/cases/conformance/statements/tryStatements/invalidTryStatements2.ts(15,5): error TS1005: 'try' expected.
tests/cases/conformance/statements/tryStatements/invalidTryStatements2.ts(17,5): error TS1005: 'try' expected.
tests/cases/conformance/statements/tryStatements/invalidTryStatements2.ts(19,20): error TS1003: Identifier expected.
==== tests/cases/conformance/statements/tryStatements/invalidTryStatements2.ts (6 errors) ====
==== tests/cases/conformance/statements/tryStatements/invalidTryStatements2.ts (7 errors) ====
function fn() {
try {
} catch { // syntax error, missing '(x)'
~
!!! error TS1005: '(' expected.
}
catch(x) { } // error missing try
~~~~~
!!! error TS1005: 'try' expected.
finally{ } // potential error; can be absorbed by the 'catch'
finally { } // potential error; can be absorbed by the 'catch'
try { }; // error missing finally
~
!!! error TS1005: 'finally' expected.
}
function fn2() {
@@ -28,22 +27,18 @@ tests/cases/conformance/statements/tryStatements/invalidTryStatements2.ts(26,5):
catch (x) { } // error missing try
~~~~~
!!! error TS1005: 'try' expected.
try { } finally { } // statement is here, so the 'catch' clause above doesn't absorb errors from the 'finally' clause below
// no error
try {
}
finally {
}
// error missing try
finally {
finally { } // error missing try
~~~~~~~
!!! error TS1005: 'try' expected.
}
// error missing try
catch (x) {
catch (x) { } // error missing try
~~~~~
!!! error TS1005: 'try' expected.
}
try { } catch () { } // error missing catch binding
~
!!! error TS1003: Identifier expected.
}
@@ -1,43 +1,34 @@
//// [invalidTryStatements2.ts]
function fn() {
try {
} catch { // syntax error, missing '(x)'
}
catch(x) { } // error missing try
finally{ } // potential error; can be absorbed by the 'catch'
finally { } // potential error; can be absorbed by the 'catch'
try { }; // error missing finally
}
function fn2() {
finally { } // error missing try
catch (x) { } // error missing try
try { } finally { } // statement is here, so the 'catch' clause above doesn't absorb errors from the 'finally' clause below
// no error
try {
}
finally {
}
finally { } // error missing try
catch (x) { } // error missing try
// error missing try
finally {
}
// error missing try
catch (x) {
}
try { } catch () { } // error missing catch binding
}
//// [invalidTryStatements2.js]
function fn() {
try {
}
catch () {
}
try {
}
catch (x) { } // error missing try
finally { } // potential error; can be absorbed by the 'catch'
try { }
finally { }
; // error missing finally
}
function fn2() {
try {
@@ -46,19 +37,14 @@ function fn2() {
try {
}
catch (x) { } // error missing try
// no error
try { }
finally { } // statement is here, so the 'catch' clause above doesn't absorb errors from the 'finally' clause below
try {
}
finally {
}
// error missing try
finally { } // error missing try
try {
}
finally {
}
// error missing try
try {
}
catch (x) {
}
catch (x) { } // error missing try
try { }
catch () { } // error missing catch binding
}
@@ -0,0 +1,17 @@
//// [jsdocCastCommentEmit.ts]
// allowJs: true
// checkJs: true
// outDir: out/
// filename: input.js
function f() {
return /* @type {number} */ 42;
}
//// [jsdocCastCommentEmit.js]
// allowJs: true
// checkJs: true
// outDir: out/
// filename: input.js
function f() {
return /* @type {number} */ 42;
}
@@ -0,0 +1,10 @@
=== tests/cases/compiler/jsdocCastCommentEmit.ts ===
// allowJs: true
// checkJs: true
// outDir: out/
// filename: input.js
function f() {
>f : Symbol(f, Decl(jsdocCastCommentEmit.ts, 0, 0))
return /* @type {number} */ 42;
}
@@ -0,0 +1,11 @@
=== tests/cases/compiler/jsdocCastCommentEmit.ts ===
// allowJs: true
// checkJs: true
// outDir: out/
// filename: input.js
function f() {
>f : () => number
return /* @type {number} */ 42;
>42 : 42
}
@@ -1,13 +1,10 @@
tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts(45,27): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts(45,34): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts(46,27): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts(46,34): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts(47,27): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts(47,39): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts(45,27): error TS2365: Operator '+' cannot be applied to types 'null' and 'undefined'.
tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts(46,27): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts(47,27): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts(57,1): error TS2695: Left side of comma operator is unused and has no side effects.
==== tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts (7 errors) ====
==== tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNotOperatorWithAnyOtherType.ts (4 errors) ====
// ! operator on any type
var ANY: any;
@@ -53,20 +50,14 @@ tests/cases/conformance/expressions/unaryOperators/logicalNotOperator/logicalNot
var ResultIsBoolean15 = !A.foo();
var ResultIsBoolean16 = !(ANY + ANY1);
var ResultIsBoolean17 = !(null + undefined);
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'undefined'.
var ResultIsBoolean18 = !(null + null);
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
var ResultIsBoolean19 = !(undefined + undefined);
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
// multiple ! operators
var ResultIsBoolean20 = !!ANY;
@@ -0,0 +1,84 @@
//// [mixingApparentTypeOverrides.ts]
type Constructor<T> = new(...args: any[]) => T;
function Tagged<T extends Constructor<{}>>(Base: T) {
return class extends Base {
_tag: string;
constructor(...args: any[]) {
super(...args);
this._tag = "";
}
};
}
class A {
toString () {
return "class A";
}
}
class B extends Tagged(A) {
toString () { // Should not be an error
return "class B";
}
}
class C extends A {
toString () { // Should not be an error
return "class C";
}
}
//// [mixingApparentTypeOverrides.js]
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
function Tagged(Base) {
return (function (_super) {
__extends(class_1, _super);
function class_1() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var _this = _super.apply(this, args) || this;
_this._tag = "";
return _this;
}
return class_1;
}(Base));
}
var A = (function () {
function A() {
}
A.prototype.toString = function () {
return "class A";
};
return A;
}());
var B = (function (_super) {
__extends(B, _super);
function B() {
return _super !== null && _super.apply(this, arguments) || this;
}
B.prototype.toString = function () {
return "class B";
};
return B;
}(Tagged(A)));
var C = (function (_super) {
__extends(C, _super);
function C() {
return _super !== null && _super.apply(this, arguments) || this;
}
C.prototype.toString = function () {
return "class C";
};
return C;
}(A));
@@ -0,0 +1,67 @@
=== tests/cases/compiler/mixingApparentTypeOverrides.ts ===
type Constructor<T> = new(...args: any[]) => T;
>Constructor : Symbol(Constructor, Decl(mixingApparentTypeOverrides.ts, 0, 0))
>T : Symbol(T, Decl(mixingApparentTypeOverrides.ts, 0, 17))
>args : Symbol(args, Decl(mixingApparentTypeOverrides.ts, 0, 26))
>T : Symbol(T, Decl(mixingApparentTypeOverrides.ts, 0, 17))
function Tagged<T extends Constructor<{}>>(Base: T) {
>Tagged : Symbol(Tagged, Decl(mixingApparentTypeOverrides.ts, 0, 47))
>T : Symbol(T, Decl(mixingApparentTypeOverrides.ts, 1, 16))
>Constructor : Symbol(Constructor, Decl(mixingApparentTypeOverrides.ts, 0, 0))
>Base : Symbol(Base, Decl(mixingApparentTypeOverrides.ts, 1, 43))
>T : Symbol(T, Decl(mixingApparentTypeOverrides.ts, 1, 16))
return class extends Base {
>Base : Symbol(Base, Decl(mixingApparentTypeOverrides.ts, 1, 43))
_tag: string;
>_tag : Symbol((Anonymous class)._tag, Decl(mixingApparentTypeOverrides.ts, 2, 29))
constructor(...args: any[]) {
>args : Symbol(args, Decl(mixingApparentTypeOverrides.ts, 4, 16))
super(...args);
>super : Symbol(T, Decl(mixingApparentTypeOverrides.ts, 1, 16))
>args : Symbol(args, Decl(mixingApparentTypeOverrides.ts, 4, 16))
this._tag = "";
>this._tag : Symbol((Anonymous class)._tag, Decl(mixingApparentTypeOverrides.ts, 2, 29))
>this : Symbol((Anonymous class), Decl(mixingApparentTypeOverrides.ts, 2, 8))
>_tag : Symbol((Anonymous class)._tag, Decl(mixingApparentTypeOverrides.ts, 2, 29))
}
};
}
class A {
>A : Symbol(A, Decl(mixingApparentTypeOverrides.ts, 9, 1))
toString () {
>toString : Symbol(A.toString, Decl(mixingApparentTypeOverrides.ts, 11, 9))
return "class A";
}
}
class B extends Tagged(A) {
>B : Symbol(B, Decl(mixingApparentTypeOverrides.ts, 15, 1))
>Tagged : Symbol(Tagged, Decl(mixingApparentTypeOverrides.ts, 0, 47))
>A : Symbol(A, Decl(mixingApparentTypeOverrides.ts, 9, 1))
toString () { // Should not be an error
>toString : Symbol(B.toString, Decl(mixingApparentTypeOverrides.ts, 17, 27))
return "class B";
}
}
class C extends A {
>C : Symbol(C, Decl(mixingApparentTypeOverrides.ts, 21, 1))
>A : Symbol(A, Decl(mixingApparentTypeOverrides.ts, 9, 1))
toString () { // Should not be an error
>toString : Symbol(C.toString, Decl(mixingApparentTypeOverrides.ts, 23, 19))
return "class C";
}
}
@@ -0,0 +1,76 @@
=== tests/cases/compiler/mixingApparentTypeOverrides.ts ===
type Constructor<T> = new(...args: any[]) => T;
>Constructor : Constructor<T>
>T : T
>args : any[]
>T : T
function Tagged<T extends Constructor<{}>>(Base: T) {
>Tagged : <T extends Constructor<{}>>(Base: T) => { new (...args: any[]): (Anonymous class); prototype: Tagged<any>.(Anonymous class); } & T
>T : T
>Constructor : Constructor<T>
>Base : T
>T : T
return class extends Base {
>class extends Base { _tag: string; constructor(...args: any[]) { super(...args); this._tag = ""; } } : { new (...args: any[]): (Anonymous class); prototype: Tagged<any>.(Anonymous class); } & T
>Base : {}
_tag: string;
>_tag : string
constructor(...args: any[]) {
>args : any[]
super(...args);
>super(...args) : void
>super : T
>...args : any
>args : any[]
this._tag = "";
>this._tag = "" : ""
>this._tag : string
>this : this
>_tag : string
>"" : ""
}
};
}
class A {
>A : A
toString () {
>toString : () => string
return "class A";
>"class A" : "class A"
}
}
class B extends Tagged(A) {
>B : B
>Tagged(A) : Tagged<typeof A>.(Anonymous class) & A
>Tagged : <T extends Constructor<{}>>(Base: T) => { new (...args: any[]): (Anonymous class); prototype: Tagged<any>.(Anonymous class); } & T
>A : typeof A
toString () { // Should not be an error
>toString : () => string
return "class B";
>"class B" : "class B"
}
}
class C extends A {
>C : C
>A : A
toString () { // Should not be an error
>toString : () => string
return "class C";
>"class C" : "class C"
}
}
@@ -0,0 +1,28 @@
tests/cases/compiler/noUnusedLocals_selfReference.ts(3,10): error TS6133: 'f' is declared but never used.
tests/cases/compiler/noUnusedLocals_selfReference.ts(4,7): error TS6133: 'C' is declared but never used.
tests/cases/compiler/noUnusedLocals_selfReference.ts(7,6): error TS6133: 'E' is declared but never used.
==== tests/cases/compiler/noUnusedLocals_selfReference.ts (3 errors) ====
export {}; // Make this a module scope, so these are local variables.
function f() { f; }
~
!!! error TS6133: 'f' is declared but never used.
class C {
~
!!! error TS6133: 'C' is declared but never used.
m() { C; }
}
enum E { A = 0, B = E.A }
~
!!! error TS6133: 'E' is declared but never used.
// Does not detect mutual recursion.
function g() { D; }
class D { m() { g; } }
// Does not work on private methods.
class P { private m() { this.m; } }
P;
@@ -0,0 +1,49 @@
//// [noUnusedLocals_selfReference.ts]
export {}; // Make this a module scope, so these are local variables.
function f() { f; }
class C {
m() { C; }
}
enum E { A = 0, B = E.A }
// Does not detect mutual recursion.
function g() { D; }
class D { m() { g; } }
// Does not work on private methods.
class P { private m() { this.m; } }
P;
//// [noUnusedLocals_selfReference.js]
"use strict";
exports.__esModule = true;
function f() { f; }
var C = (function () {
function C() {
}
C.prototype.m = function () { C; };
return C;
}());
var E;
(function (E) {
E[E["A"] = 0] = "A";
E[E["B"] = 0] = "B";
})(E || (E = {}));
// Does not detect mutual recursion.
function g() { D; }
var D = (function () {
function D() {
}
D.prototype.m = function () { g; };
return D;
}());
// Does not work on private methods.
var P = (function () {
function P() {
}
P.prototype.m = function () { this.m; };
return P;
}());
P;
+3 -3
View File
@@ -1,12 +1,12 @@
tests/cases/compiler/null.ts(3,9): error TS2531: Object is possibly 'null'.
tests/cases/compiler/null.ts(3,7): error TS2365: Operator '+' cannot be applied to types '3' and 'null'.
==== tests/cases/compiler/null.ts (1 errors) ====
var x=null;
var y=3+x;
var z=3+null;
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types '3' and 'null'.
class C {
}
function f() {
@@ -1,68 +1,56 @@
tests/cases/compiler/operatorAddNullUndefined.ts(2,10): error TS2531: Object is possibly 'null'.
tests/cases/compiler/operatorAddNullUndefined.ts(2,17): error TS2531: Object is possibly 'null'.
tests/cases/compiler/operatorAddNullUndefined.ts(3,10): error TS2531: Object is possibly 'null'.
tests/cases/compiler/operatorAddNullUndefined.ts(3,17): error TS2532: Object is possibly 'undefined'.
tests/cases/compiler/operatorAddNullUndefined.ts(4,10): error TS2532: Object is possibly 'undefined'.
tests/cases/compiler/operatorAddNullUndefined.ts(4,22): error TS2531: Object is possibly 'null'.
tests/cases/compiler/operatorAddNullUndefined.ts(5,10): error TS2532: Object is possibly 'undefined'.
tests/cases/compiler/operatorAddNullUndefined.ts(5,22): error TS2532: Object is possibly 'undefined'.
tests/cases/compiler/operatorAddNullUndefined.ts(6,14): error TS2531: Object is possibly 'null'.
tests/cases/compiler/operatorAddNullUndefined.ts(7,14): error TS2532: Object is possibly 'undefined'.
tests/cases/compiler/operatorAddNullUndefined.ts(8,10): error TS2531: Object is possibly 'null'.
tests/cases/compiler/operatorAddNullUndefined.ts(9,10): error TS2532: Object is possibly 'undefined'.
tests/cases/compiler/operatorAddNullUndefined.ts(14,11): error TS2531: Object is possibly 'null'.
tests/cases/compiler/operatorAddNullUndefined.ts(15,11): error TS2532: Object is possibly 'undefined'.
tests/cases/compiler/operatorAddNullUndefined.ts(16,17): error TS2531: Object is possibly 'null'.
tests/cases/compiler/operatorAddNullUndefined.ts(17,17): error TS2532: Object is possibly 'undefined'.
tests/cases/compiler/operatorAddNullUndefined.ts(2,10): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
tests/cases/compiler/operatorAddNullUndefined.ts(3,10): error TS2365: Operator '+' cannot be applied to types 'null' and 'undefined'.
tests/cases/compiler/operatorAddNullUndefined.ts(4,10): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'null'.
tests/cases/compiler/operatorAddNullUndefined.ts(5,10): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
tests/cases/compiler/operatorAddNullUndefined.ts(6,10): error TS2365: Operator '+' cannot be applied to types '1' and 'null'.
tests/cases/compiler/operatorAddNullUndefined.ts(7,10): error TS2365: Operator '+' cannot be applied to types '1' and 'undefined'.
tests/cases/compiler/operatorAddNullUndefined.ts(8,10): error TS2365: Operator '+' cannot be applied to types 'null' and '1'.
tests/cases/compiler/operatorAddNullUndefined.ts(9,10): error TS2365: Operator '+' cannot be applied to types 'undefined' and '1'.
tests/cases/compiler/operatorAddNullUndefined.ts(14,11): error TS2365: Operator '+' cannot be applied to types 'null' and 'E'.
tests/cases/compiler/operatorAddNullUndefined.ts(15,11): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'E'.
tests/cases/compiler/operatorAddNullUndefined.ts(16,11): error TS2365: Operator '+' cannot be applied to types 'E' and 'null'.
tests/cases/compiler/operatorAddNullUndefined.ts(17,11): error TS2365: Operator '+' cannot be applied to types 'E' and 'undefined'.
==== tests/cases/compiler/operatorAddNullUndefined.ts (16 errors) ====
==== tests/cases/compiler/operatorAddNullUndefined.ts (12 errors) ====
enum E { x }
var x1 = null + null;
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
var x2 = null + undefined;
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'undefined'.
var x3 = undefined + null;
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'null'.
var x4 = undefined + undefined;
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
var x5 = 1 + null;
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types '1' and 'null'.
var x6 = 1 + undefined;
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types '1' and 'undefined'.
var x7 = null + 1;
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'null' and '1'.
var x8 = undefined + 1;
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and '1'.
var x9 = "test" + null;
var x10 = "test" + undefined;
var x11 = null + "test";
var x12 = undefined + "test";
var x13 = null + E.x
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'E'.
var x14 = undefined + E.x
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'E'.
var x15 = E.x + null
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'E' and 'null'.
var x16 = E.x + undefined
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'E' and 'undefined'.
@@ -1,15 +1,12 @@
tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(34,24): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(35,24): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(46,26): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(46,33): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(47,26): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(47,33): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(48,26): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(48,38): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(46,26): error TS2365: Operator '+' cannot be applied to types 'null' and 'undefined'.
tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(47,26): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(48,26): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts(54,1): error TS2695: Left side of comma operator is unused and has no side effects.
==== tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts (9 errors) ====
==== tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithAnyOtherType.ts (6 errors) ====
// + operator on any type
var ANY: any;
@@ -60,20 +57,14 @@ tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWith
var ResultIsNumber15 = +A.foo();
var ResultIsNumber16 = +(ANY + ANY1);
var ResultIsNumber17 = +(null + undefined);
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'undefined'.
var ResultIsNumber18 = +(null + null);
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
var ResultIsNumber19 = +(undefined + undefined);
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
// miss assignment operators
+ANY;
@@ -9,7 +9,7 @@ maxDepthExceeded/root.ts(4,4): error TS2540: Cannot assign to 'rel' because it i
"maxNodeModuleJsDepth": 1, // Note: Module m1 is already included as a root file
"outDir": "built"
},
"include": ["**/*"],
"include": ["**/*", "node_modules/**/*"],
"exclude": ["node_modules/m2/**/*"]
}
@@ -9,7 +9,7 @@ maxDepthExceeded/root.ts(4,4): error TS2540: Cannot assign to 'rel' because it i
"maxNodeModuleJsDepth": 1, // Note: Module m1 is already included as a root file
"outDir": "built"
},
"include": ["**/*"],
"include": ["**/*", "node_modules/**/*"],
"exclude": ["node_modules/m2/**/*"]
}
@@ -0,0 +1,19 @@
//// [tests/cases/compiler/syntheticDefaultExportsWithDynamicImports.ts] ////
//// [index.d.ts]
declare function packageExport(x: number): string;
export = packageExport;
//// [index.ts]
import("package").then(({default: foo}) => foo(42));
//// [index.js]
System.register([], function (exports_1, context_1) {
var __moduleName = context_1 && context_1.id;
return {
setters: [],
execute: function () {
context_1.import("package").then(({ default: foo }) => foo(42));
}
};
});
@@ -0,0 +1,17 @@
=== tests/cases/compiler/node_modules/package/index.d.ts ===
declare function packageExport(x: number): string;
>packageExport : Symbol(packageExport, Decl(index.d.ts, 0, 0))
>x : Symbol(x, Decl(index.d.ts, 0, 31))
export = packageExport;
>packageExport : Symbol(packageExport, Decl(index.d.ts, 0, 0))
=== tests/cases/compiler/index.ts ===
import("package").then(({default: foo}) => foo(42));
>import("package").then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>"package" : Symbol("tests/cases/compiler/node_modules/package/index", Decl(index.d.ts, 0, 0))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>default : Symbol(default)
>foo : Symbol(foo, Decl(index.ts, 0, 25))
>foo : Symbol(foo, Decl(index.ts, 0, 25))
@@ -0,0 +1,22 @@
=== tests/cases/compiler/node_modules/package/index.d.ts ===
declare function packageExport(x: number): string;
>packageExport : (x: number) => string
>x : number
export = packageExport;
>packageExport : (x: number) => string
=== tests/cases/compiler/index.ts ===
import("package").then(({default: foo}) => foo(42));
>import("package").then(({default: foo}) => foo(42)) : Promise<string>
>import("package").then : <TResult1 = ((x: number) => string) & { default: (x: number) => string; }, TResult2 = never>(onfulfilled?: (value: ((x: number) => string) & { default: (x: number) => string; }) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>import("package") : Promise<((x: number) => string) & { default: (x: number) => string; }>
>"package" : "package"
>then : <TResult1 = ((x: number) => string) & { default: (x: number) => string; }, TResult2 = never>(onfulfilled?: (value: ((x: number) => string) & { default: (x: number) => string; }) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>({default: foo}) => foo(42) : ({ default: foo }: ((x: number) => string) & { default: (x: number) => string; }) => string
>default : any
>foo : (x: number) => string
>foo(42) : string
>foo : (x: number) => string
>42 : 42
+26 -5
View File
@@ -1,26 +1,47 @@
//// [tryStatements.ts]
function fn() {
try {
try { } catch { }
} catch (x) {
var x: any;
try { } catch {
try { } catch {
try { } catch { }
}
try { } catch { }
}
try { } catch (x) { var x: any; }
try { } finally { }
try { }catch(z){ } finally { }
try { } catch { } finally { }
try { } catch (z) { } finally { }
}
//// [tryStatements.js]
function fn() {
try {
try { }
catch (_a) { }
try { }
catch (_b) {
try { }
catch (_c) {
try { }
catch (_d) { }
}
try { }
catch (_e) { }
}
try { }
catch (x) {
var x;
}
try { }
finally { }
try { }
catch (_f) { }
finally { }
try { }
catch (z) { }
finally { }
}
@@ -2,17 +2,23 @@
function fn() {
>fn : Symbol(fn, Decl(tryStatements.ts, 0, 0))
try {
try { } catch { }
} catch (x) {
>x : Symbol(x, Decl(tryStatements.ts, 3, 13))
var x: any;
>x : Symbol(x, Decl(tryStatements.ts, 4, 11))
try { } catch {
try { } catch {
try { } catch { }
}
try { } catch { }
}
try { } catch (x) { var x: any; }
>x : Symbol(x, Decl(tryStatements.ts, 10, 19))
>x : Symbol(x, Decl(tryStatements.ts, 10, 27))
try { } finally { }
try { }catch(z){ } finally { }
>z : Symbol(z, Decl(tryStatements.ts, 9, 17))
try { } catch { } finally { }
try { } catch (z) { } finally { }
>z : Symbol(z, Decl(tryStatements.ts, 16, 19))
}
+13 -7
View File
@@ -2,17 +2,23 @@
function fn() {
>fn : () => void
try {
try { } catch { }
} catch (x) {
>x : any
var x: any;
>x : any
try { } catch {
try { } catch {
try { } catch { }
}
try { } catch { }
}
try { } catch (x) { var x: any; }
>x : any
>x : any
try { } finally { }
try { }catch(z){ } finally { }
try { } catch { } finally { }
try { } catch (z) { } finally { }
>z : any
}
@@ -0,0 +1,51 @@
//// [typeParameterExtendsPrimitive.ts]
// #14473
function f<T extends number>() {
var t: T;
var v = {
[t]: 0
}
return t + t;
}
// #15501
interface I { x: number }
type IdMap<T> = { [P in keyof T]: T[P] };
function g<T extends I>(i: IdMap<T>) {
const n: number = i.x;
return i.x * 2;
}
// #17069
function h<T extends Record<K, number>, K extends string>(array: T[], prop: K): number {
let result = 0;
for (const v of array) {
result += v[prop];
}
return result;
}
//// [typeParameterExtendsPrimitive.js]
// #14473
function f() {
var t;
var v = (_a = {},
_a[t] = 0,
_a);
return t + t;
var _a;
}
function g(i) {
var n = i.x;
return i.x * 2;
}
// #17069
function h(array, prop) {
var result = 0;
for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
var v = array_1[_i];
result += v[prop];
}
return result;
}
@@ -0,0 +1,82 @@
=== tests/cases/compiler/typeParameterExtendsPrimitive.ts ===
// #14473
function f<T extends number>() {
>f : Symbol(f, Decl(typeParameterExtendsPrimitive.ts, 0, 0))
>T : Symbol(T, Decl(typeParameterExtendsPrimitive.ts, 1, 11))
var t: T;
>t : Symbol(t, Decl(typeParameterExtendsPrimitive.ts, 2, 7))
>T : Symbol(T, Decl(typeParameterExtendsPrimitive.ts, 1, 11))
var v = {
>v : Symbol(v, Decl(typeParameterExtendsPrimitive.ts, 3, 7))
[t]: 0
>t : Symbol(t, Decl(typeParameterExtendsPrimitive.ts, 2, 7))
}
return t + t;
>t : Symbol(t, Decl(typeParameterExtendsPrimitive.ts, 2, 7))
>t : Symbol(t, Decl(typeParameterExtendsPrimitive.ts, 2, 7))
}
// #15501
interface I { x: number }
>I : Symbol(I, Decl(typeParameterExtendsPrimitive.ts, 7, 1))
>x : Symbol(I.x, Decl(typeParameterExtendsPrimitive.ts, 10, 13))
type IdMap<T> = { [P in keyof T]: T[P] };
>IdMap : Symbol(IdMap, Decl(typeParameterExtendsPrimitive.ts, 10, 25))
>T : Symbol(T, Decl(typeParameterExtendsPrimitive.ts, 11, 11))
>P : Symbol(P, Decl(typeParameterExtendsPrimitive.ts, 11, 19))
>T : Symbol(T, Decl(typeParameterExtendsPrimitive.ts, 11, 11))
>T : Symbol(T, Decl(typeParameterExtendsPrimitive.ts, 11, 11))
>P : Symbol(P, Decl(typeParameterExtendsPrimitive.ts, 11, 19))
function g<T extends I>(i: IdMap<T>) {
>g : Symbol(g, Decl(typeParameterExtendsPrimitive.ts, 11, 41))
>T : Symbol(T, Decl(typeParameterExtendsPrimitive.ts, 12, 11))
>I : Symbol(I, Decl(typeParameterExtendsPrimitive.ts, 7, 1))
>i : Symbol(i, Decl(typeParameterExtendsPrimitive.ts, 12, 24))
>IdMap : Symbol(IdMap, Decl(typeParameterExtendsPrimitive.ts, 10, 25))
>T : Symbol(T, Decl(typeParameterExtendsPrimitive.ts, 12, 11))
const n: number = i.x;
>n : Symbol(n, Decl(typeParameterExtendsPrimitive.ts, 13, 9))
>i.x : Symbol(x, Decl(typeParameterExtendsPrimitive.ts, 10, 13))
>i : Symbol(i, Decl(typeParameterExtendsPrimitive.ts, 12, 24))
>x : Symbol(x, Decl(typeParameterExtendsPrimitive.ts, 10, 13))
return i.x * 2;
>i.x : Symbol(x, Decl(typeParameterExtendsPrimitive.ts, 10, 13))
>i : Symbol(i, Decl(typeParameterExtendsPrimitive.ts, 12, 24))
>x : Symbol(x, Decl(typeParameterExtendsPrimitive.ts, 10, 13))
}
// #17069
function h<T extends Record<K, number>, K extends string>(array: T[], prop: K): number {
>h : Symbol(h, Decl(typeParameterExtendsPrimitive.ts, 15, 1))
>T : Symbol(T, Decl(typeParameterExtendsPrimitive.ts, 18, 11))
>Record : Symbol(Record, Decl(lib.d.ts, --, --))
>K : Symbol(K, Decl(typeParameterExtendsPrimitive.ts, 18, 39))
>K : Symbol(K, Decl(typeParameterExtendsPrimitive.ts, 18, 39))
>array : Symbol(array, Decl(typeParameterExtendsPrimitive.ts, 18, 58))
>T : Symbol(T, Decl(typeParameterExtendsPrimitive.ts, 18, 11))
>prop : Symbol(prop, Decl(typeParameterExtendsPrimitive.ts, 18, 69))
>K : Symbol(K, Decl(typeParameterExtendsPrimitive.ts, 18, 39))
let result = 0;
>result : Symbol(result, Decl(typeParameterExtendsPrimitive.ts, 19, 7))
for (const v of array) {
>v : Symbol(v, Decl(typeParameterExtendsPrimitive.ts, 20, 14))
>array : Symbol(array, Decl(typeParameterExtendsPrimitive.ts, 18, 58))
result += v[prop];
>result : Symbol(result, Decl(typeParameterExtendsPrimitive.ts, 19, 7))
>v : Symbol(v, Decl(typeParameterExtendsPrimitive.ts, 20, 14))
>prop : Symbol(prop, Decl(typeParameterExtendsPrimitive.ts, 18, 69))
}
return result;
>result : Symbol(result, Decl(typeParameterExtendsPrimitive.ts, 19, 7))
}
@@ -0,0 +1,90 @@
=== tests/cases/compiler/typeParameterExtendsPrimitive.ts ===
// #14473
function f<T extends number>() {
>f : <T extends number>() => number
>T : T
var t: T;
>t : T
>T : T
var v = {
>v : { [x: number]: number; }
>{ [t]: 0 } : { [x: number]: number; }
[t]: 0
>t : T
>0 : 0
}
return t + t;
>t + t : number
>t : T
>t : T
}
// #15501
interface I { x: number }
>I : I
>x : number
type IdMap<T> = { [P in keyof T]: T[P] };
>IdMap : IdMap<T>
>T : T
>P : P
>T : T
>T : T
>P : P
function g<T extends I>(i: IdMap<T>) {
>g : <T extends I>(i: IdMap<T>) => number
>T : T
>I : I
>i : IdMap<T>
>IdMap : IdMap<T>
>T : T
const n: number = i.x;
>n : number
>i.x : T["x"]
>i : IdMap<T>
>x : T["x"]
return i.x * 2;
>i.x * 2 : number
>i.x : T["x"]
>i : IdMap<T>
>x : T["x"]
>2 : 2
}
// #17069
function h<T extends Record<K, number>, K extends string>(array: T[], prop: K): number {
>h : <T extends Record<K, number>, K extends string>(array: T[], prop: K) => number
>T : T
>Record : Record<K, T>
>K : K
>K : K
>array : T[]
>T : T
>prop : K
>K : K
let result = 0;
>result : number
>0 : 0
for (const v of array) {
>v : T
>array : T[]
result += v[prop];
>result += v[prop] : number
>result : number
>v[prop] : T[K]
>v : T
>prop : K
}
return result;
>result : number
}
@@ -1,9 +1,6 @@
tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(46,32): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(46,39): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(47,32): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(47,39): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(48,32): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(48,44): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(46,32): error TS2365: Operator '+' cannot be applied to types 'null' and 'undefined'.
tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(47,32): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(48,32): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(58,1): error TS2695: Left side of comma operator is unused and has no side effects.
tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(68,1): error TS7028: Unused label.
tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(69,1): error TS7028: Unused label.
@@ -14,7 +11,7 @@ tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperator
tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts(74,1): error TS7028: Unused label.
==== tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts (14 errors) ====
==== tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithAnyOtherType.ts (11 errors) ====
// typeof operator on any type
var ANY: any;
@@ -61,20 +58,14 @@ tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperator
var ResultIsString15 = typeof A.foo();
var ResultIsString16 = typeof (ANY + ANY1);
var ResultIsString17 = typeof (null + undefined);
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'undefined'.
var ResultIsString18 = typeof (null + null);
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
var ResultIsString19 = typeof (undefined + undefined);
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
// multiple typeof operators
var ResultIsString20 = typeof typeof ANY;
@@ -1,8 +1,9 @@
tests/cases/compiler/unusedLocalsAndParametersTypeAliases2.ts(2,6): error TS6133: 'handler1' is declared but never used.
tests/cases/compiler/unusedLocalsAndParametersTypeAliases2.ts(5,10): error TS6133: 'foo' is declared but never used.
tests/cases/compiler/unusedLocalsAndParametersTypeAliases2.ts(6,10): error TS6133: 'handler2' is declared but never used.
==== tests/cases/compiler/unusedLocalsAndParametersTypeAliases2.ts (2 errors) ====
==== tests/cases/compiler/unusedLocalsAndParametersTypeAliases2.ts (3 errors) ====
// unused
type handler1 = () => void;
~~~~~~~~
@@ -10,6 +11,8 @@ tests/cases/compiler/unusedLocalsAndParametersTypeAliases2.ts(6,10): error TS613
function foo() {
~~~
!!! error TS6133: 'foo' is declared but never used.
type handler2 = () => void;
~~~~~~~~
!!! error TS6133: 'handler2' is declared but never used.
@@ -1,12 +1,9 @@
tests/cases/conformance/expressions/unaryOperators/voidOperator/voidOperatorWithAnyOtherType.ts(46,27): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/unaryOperators/voidOperator/voidOperatorWithAnyOtherType.ts(46,34): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/unaryOperators/voidOperator/voidOperatorWithAnyOtherType.ts(47,27): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/unaryOperators/voidOperator/voidOperatorWithAnyOtherType.ts(47,34): error TS2531: Object is possibly 'null'.
tests/cases/conformance/expressions/unaryOperators/voidOperator/voidOperatorWithAnyOtherType.ts(48,27): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/unaryOperators/voidOperator/voidOperatorWithAnyOtherType.ts(48,39): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/expressions/unaryOperators/voidOperator/voidOperatorWithAnyOtherType.ts(46,27): error TS2365: Operator '+' cannot be applied to types 'null' and 'undefined'.
tests/cases/conformance/expressions/unaryOperators/voidOperator/voidOperatorWithAnyOtherType.ts(47,27): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
tests/cases/conformance/expressions/unaryOperators/voidOperator/voidOperatorWithAnyOtherType.ts(48,27): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
==== tests/cases/conformance/expressions/unaryOperators/voidOperator/voidOperatorWithAnyOtherType.ts (6 errors) ====
==== tests/cases/conformance/expressions/unaryOperators/voidOperator/voidOperatorWithAnyOtherType.ts (3 errors) ====
// void operator on any type
var ANY: any;
@@ -53,20 +50,14 @@ tests/cases/conformance/expressions/unaryOperators/voidOperator/voidOperatorWith
var ResultIsAny15 = void A.foo();
var ResultIsAny16 = void (ANY + ANY1);
var ResultIsAny17 = void (null + undefined);
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'undefined'.
var ResultIsAny18 = void (null + null);
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~
!!! error TS2531: Object is possibly 'null'.
~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
var ResultIsAny19 = void (undefined + undefined);
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~
!!! error TS2532: Object is possibly 'undefined'.
~~~~~~~~~~~~~~~~~~~~~
!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
// multiple void operators
var ResultIsAny20 = void void ANY;
+21 -9
View File
@@ -1,14 +1,17 @@
tests/cases/compiler/weakType.ts(16,13): error TS2559: Type '12' has no properties in common with type 'Settings'.
tests/cases/compiler/weakType.ts(17,13): error TS2559: Type '"completely wrong"' has no properties in common with type 'Settings'.
tests/cases/compiler/weakType.ts(18,13): error TS2559: Type 'false' has no properties in common with type 'Settings'.
tests/cases/compiler/weakType.ts(35,18): error TS2559: Type '{ error?: number; }' has no properties in common with type 'ChangeOptions'.
tests/cases/compiler/weakType.ts(60,5): error TS2322: Type '{ properties: { wrong: string; }; }' is not assignable to type 'Weak & Spoiler'.
tests/cases/compiler/weakType.ts(15,13): error TS2560: Value of type '() => { timeout: number; }' has no properties in common with type 'Settings'. Did you mean to call it?
tests/cases/compiler/weakType.ts(16,13): error TS2560: Value of type '() => { timeout: number; }' has no properties in common with type 'Settings'. Did you mean to call it?
tests/cases/compiler/weakType.ts(17,13): error TS2560: Value of type 'CtorOnly' has no properties in common with type 'Settings'. Did you mean to call it?
tests/cases/compiler/weakType.ts(18,13): error TS2559: Type '12' has no properties in common with type 'Settings'.
tests/cases/compiler/weakType.ts(19,13): error TS2559: Type '"completely wrong"' has no properties in common with type 'Settings'.
tests/cases/compiler/weakType.ts(20,13): error TS2559: Type 'false' has no properties in common with type 'Settings'.
tests/cases/compiler/weakType.ts(37,18): error TS2559: Type '{ error?: number; }' has no properties in common with type 'ChangeOptions'.
tests/cases/compiler/weakType.ts(62,5): error TS2322: Type '{ properties: { wrong: string; }; }' is not assignable to type 'Weak & Spoiler'.
Type '{ properties: { wrong: string; }; }' is not assignable to type 'Weak'.
Types of property 'properties' are incompatible.
Type '{ wrong: string; }' has no properties in common with type '{ b?: number; }'.
==== tests/cases/compiler/weakType.ts (5 errors) ====
==== tests/cases/compiler/weakType.ts (8 errors) ====
interface Settings {
timeout?: number;
onError?(): void;
@@ -17,13 +20,21 @@ tests/cases/compiler/weakType.ts(60,5): error TS2322: Type '{ properties: { wron
function getDefaultSettings() {
return { timeout: 1000 };
}
interface CtorOnly {
new(s: string): { timeout: 1000 }
}
function doSomething(settings: Settings) { /* ... */ }
// forgot to call `getDefaultSettings`
// but it is not caught because we don't check for call signatures
doSomething(getDefaultSettings);
// same for arrow expressions:
doSomething(() => { });
~~~~~~~~~~~~~~~~~~
!!! error TS2560: Value of type '() => { timeout: number; }' has no properties in common with type 'Settings'. Did you mean to call it?
doSomething(() => ({ timeout: 1000 }));
~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2560: Value of type '() => { timeout: number; }' has no properties in common with type 'Settings'. Did you mean to call it?
doSomething(null as CtorOnly);
~~~~~~~~~~~~~~~~
!!! error TS2560: Value of type 'CtorOnly' has no properties in common with type 'Settings'. Did you mean to call it?
doSomething(12);
~~
!!! error TS2559: Type '12' has no properties in common with type 'Settings'.
@@ -82,4 +93,5 @@ tests/cases/compiler/weakType.ts(60,5): error TS2322: Type '{ properties: { wron
!!! error TS2322: Type '{ properties: { wrong: string; }; }' is not assignable to type 'Weak'.
!!! error TS2322: Types of property 'properties' are incompatible.
!!! error TS2322: Type '{ wrong: string; }' has no properties in common with type '{ b?: number; }'.

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