Merge branch 'master' into moveEmitFlagsToBinder

This commit is contained in:
Ron Buckton 2016-01-19 16:13:38 -08:00
commit 6e5948f622
279 changed files with 8461 additions and 554 deletions

View file

@ -36,7 +36,7 @@
"istanbul": "latest",
"mocha-fivemat-progress-reporter": "latest",
"tslint": "next",
"typescript": "1.8.0-dev.20160113",
"typescript": "next",
"tsd": "latest"
},
"scripts": {

View file

@ -137,6 +137,7 @@ namespace ts {
options = opts;
inStrictMode = !!file.externalModuleIndicator;
classifiableNames = {};
Symbol = objectAllocator.getSymbolConstructor();
if (!file.locals) {
@ -201,8 +202,8 @@ namespace ts {
// unless it is a well known Symbol.
function getDeclarationName(node: Declaration): string {
if (node.name) {
if (node.kind === SyntaxKind.ModuleDeclaration && node.name.kind === SyntaxKind.StringLiteral) {
return `"${(<LiteralExpression>node.name).text}"`;
if (isAmbientModule(node)) {
return isGlobalScopeAugmentation(<ModuleDeclaration>node) ? "__global" : `"${(<LiteralExpression>node.name).text}"`;
}
if (node.name.kind === SyntaxKind.ComputedPropertyName) {
const nameExpression = (<ComputedPropertyName>node.name).expression;
@ -358,7 +359,12 @@ namespace ts {
// 2. When we checkIdentifier in the checker, we set its resolved symbol to the local symbol,
// but return the export symbol (by calling getExportSymbolOfValueSymbolIfExported). That way
// when the emitter comes back to it, it knows not to qualify the name if it was found in a containing scope.
if (hasExportModifier || container.flags & NodeFlags.ExportContext) {
// NOTE: Nested ambient modules always should go to to 'locals' table to prevent their automatic merge
// during global merging in the checker. Why? The only case when ambient module is permitted inside another module is module augmentation
// and this case is specially handled. Module augmentations should only be merged with original module definition
// and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed.
if (!isAmbientModule(node) && (hasExportModifier || container.flags & NodeFlags.ExportContext)) {
const exportKind =
(symbolFlags & SymbolFlags.Value ? SymbolFlags.ExportValue : 0) |
(symbolFlags & SymbolFlags.Type ? SymbolFlags.ExportType : 0) |
@ -871,7 +877,10 @@ namespace ts {
function bindModuleDeclaration(node: ModuleDeclaration) {
setExportContextFlag(node);
if (node.name.kind === SyntaxKind.StringLiteral) {
if (isAmbientModule(node)) {
if (node.flags & NodeFlags.Export) {
errorOnFirstToken(node, Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible);
}
declareSymbolAndAddToSymbolTable(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes);
}
else {

View file

@ -372,6 +372,32 @@ namespace ts {
}
}
function mergeModuleAugmentation(moduleName: LiteralExpression): void {
const moduleAugmentation = <ModuleDeclaration>moduleName.parent;
if (moduleAugmentation.symbol.valueDeclaration !== moduleAugmentation) {
// this is a combined symbol for multiple augmentations within the same file.
// its symbol already has accumulated information for all declarations
// so we need to add it just once - do the work only for first declaration
Debug.assert(moduleAugmentation.symbol.declarations.length > 1);
return;
}
if (isGlobalScopeAugmentation(moduleAugmentation)) {
mergeSymbolTable(globals, moduleAugmentation.symbol.exports);
}
else {
// find a module that about to be augmented
let mainModule = resolveExternalModuleNameWorker(moduleName, moduleName, Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found);
if (!mainModule) {
return;
}
// if module symbol has already been merged - it is safe to use it.
// otherwise clone it
mainModule = mainModule.flags & SymbolFlags.Merged ? mainModule : cloneSymbol(mainModule);
mergeSymbol(mainModule, moduleAugmentation.symbol);
}
}
function addToSymbolTable(target: SymbolTable, source: SymbolTable, message: DiagnosticMessage) {
for (const id in source) {
if (hasProperty(source, id)) {
@ -401,22 +427,10 @@ namespace ts {
return nodeLinks[nodeId] || (nodeLinks[nodeId] = {});
}
function getSourceFile(node: Node): SourceFile {
return <SourceFile>getAncestor(node, SyntaxKind.SourceFile);
}
function isGlobalSourceFile(node: Node) {
return node.kind === SyntaxKind.SourceFile && !isExternalOrCommonJsModule(<SourceFile>node);
}
/** Is this type one of the apparent types created from the primitive types. */
function isPrimitiveApparentType(type: Type): boolean {
return type === globalStringType ||
type === globalNumberType ||
type === globalBooleanType ||
type === globalESSymbolType;
}
function getSymbol(symbols: SymbolTable, name: string, meaning: SymbolFlags): Symbol {
if (meaning && hasProperty(symbols, name)) {
const symbol = symbols[name];
@ -579,8 +593,7 @@ namespace ts {
if (!isExternalOrCommonJsModule(<SourceFile>location)) break;
case SyntaxKind.ModuleDeclaration:
const moduleExports = getSymbolOfNode(location).exports;
if (location.kind === SyntaxKind.SourceFile ||
(location.kind === SyntaxKind.ModuleDeclaration && (<ModuleDeclaration>location).name.kind === SyntaxKind.StringLiteral)) {
if (location.kind === SyntaxKind.SourceFile || isAmbientModule(location)) {
// It's an external module. First see if the module has an export default and if the local
// name of that export default matches.
@ -736,7 +749,9 @@ namespace ts {
if (!result) {
if (nameNotFoundMessage) {
error(errorLocation, nameNotFoundMessage, typeof nameArg === "string" ? nameArg : declarationNameToString(nameArg));
if (!checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg)) {
error(errorLocation, nameNotFoundMessage, typeof nameArg === "string" ? nameArg : declarationNameToString(nameArg));
}
}
return undefined;
}
@ -773,6 +788,43 @@ namespace ts {
return result;
}
function checkAndReportErrorForMissingPrefix(errorLocation: Node, name: string, nameArg: string | Identifier): boolean {
if (!errorLocation || (errorLocation.kind === SyntaxKind.Identifier && (isTypeReferenceIdentifier(<Identifier>errorLocation)) || isInTypeQuery(errorLocation))) {
return false;
}
const container = getThisContainer(errorLocation, /* includeArrowFunctions */ true);
let location = container;
while (location) {
if (isClassLike(location.parent)) {
const classSymbol = getSymbolOfNode(location.parent);
if (!classSymbol) {
break;
}
// Check to see if a static member exists.
const constructorType = getTypeOfSymbol(classSymbol);
if (getPropertyOfType(constructorType, name)) {
error(errorLocation, Diagnostics.Cannot_find_name_0_Did_you_mean_the_static_member_1_0, typeof nameArg === "string" ? nameArg : declarationNameToString(nameArg), symbolToString(classSymbol));
return true;
}
// No static member is present.
// Check if we're in an instance method and look for a relevant instance member.
if (location === container && !(location.flags & NodeFlags.Static)) {
const instanceType = (<InterfaceType>getDeclaredTypeOfSymbol(classSymbol)).thisType;
if (getPropertyOfType(instanceType, name)) {
error(errorLocation, Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0, typeof nameArg === "string" ? nameArg : declarationNameToString(nameArg));
return true;
}
}
}
location = location.parent;
}
return false;
}
function checkResolvedBlockScopedVariable(result: Symbol, errorLocation: Node): void {
Debug.assert((result.flags & SymbolFlags.BlockScopedVariable) !== 0);
// Block-scoped variables cannot be used before their definition
@ -1074,6 +1126,10 @@ namespace ts {
}
function resolveExternalModuleName(location: Node, moduleReferenceExpression: Expression): Symbol {
return resolveExternalModuleNameWorker(location, moduleReferenceExpression, Diagnostics.Cannot_find_module_0);
}
function resolveExternalModuleNameWorker(location: Node, moduleReferenceExpression: Expression, moduleNotFoundError: DiagnosticMessage): Symbol {
if (moduleReferenceExpression.kind !== SyntaxKind.StringLiteral) {
return;
}
@ -1092,20 +1148,29 @@ namespace ts {
if (!isRelative) {
const symbol = getSymbol(globals, "\"" + moduleName + "\"", SymbolFlags.ValueModule);
if (symbol) {
return symbol;
// merged symbol is module declaration symbol combined with all augmentations
return getMergedSymbol(symbol);
}
}
const resolvedModule = getResolvedModule(getSourceFile(location), moduleReferenceLiteral.text);
const resolvedModule = getResolvedModule(getSourceFileOfNode(location), moduleReferenceLiteral.text);
const sourceFile = resolvedModule && host.getSourceFile(resolvedModule.resolvedFileName);
if (sourceFile) {
if (sourceFile.symbol) {
return sourceFile.symbol;
// merged symbol is module declaration symbol combined with all augmentations
return getMergedSymbol(sourceFile.symbol);
}
error(moduleReferenceLiteral, Diagnostics.File_0_is_not_a_module, sourceFile.fileName);
return;
if (moduleNotFoundError) {
// report errors only if it was requested
error(moduleReferenceLiteral, Diagnostics.File_0_is_not_a_module, sourceFile.fileName);
}
return undefined;
}
error(moduleReferenceLiteral, Diagnostics.Cannot_find_module_0, moduleName);
if (moduleNotFoundError) {
// report errors only if it was requested
error(moduleReferenceLiteral, moduleNotFoundError, moduleName);
}
return undefined;
}
// An external module with an 'export =' declaration resolves to the target of the 'export =' declaration,
@ -1522,8 +1587,7 @@ namespace ts {
}
function hasExternalModuleSymbol(declaration: Node) {
return (declaration.kind === SyntaxKind.ModuleDeclaration && (<ModuleDeclaration>declaration).name.kind === SyntaxKind.StringLiteral) ||
(declaration.kind === SyntaxKind.SourceFile && isExternalOrCommonJsModule(<SourceFile>declaration));
return isAmbientModule(declaration) || (declaration.kind === SyntaxKind.SourceFile && isExternalOrCommonJsModule(<SourceFile>declaration));
}
function hasVisibleDeclarations(symbol: Symbol): SymbolVisibilityResult {
@ -1647,6 +1711,12 @@ namespace ts {
return undefined;
}
function isTopLevelInExternalModuleAugmentation(node: Node): boolean {
return node && node.parent &&
node.parent.kind === SyntaxKind.ModuleBlock &&
isExternalModuleAugmentation(node.parent.parent);
}
function getSymbolDisplayBuilder(): SymbolDisplayBuilder {
function getNameOfSymbol(symbol: Symbol): string {
@ -2229,6 +2299,10 @@ namespace ts {
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.EnumDeclaration:
case SyntaxKind.ImportEqualsDeclaration:
// external module augmentation is always visible
if (isExternalModuleAugmentation(node)) {
return true;
}
const parent = getDeclarationContainer(node);
// If the node is not exported or it is not ambient module element (except import declaration)
if (!(getCombinedNodeFlags(node) & NodeFlags.Export) &&
@ -2321,7 +2395,9 @@ namespace ts {
const firstIdentifier = getFirstIdentifier(internalModuleReference);
const importSymbol = resolveName(declaration, firstIdentifier.text, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace,
Diagnostics.Cannot_find_name_0, firstIdentifier);
buildVisibleNodeList(importSymbol.declarations);
if (importSymbol) {
buildVisibleNodeList(importSymbol.declarations);
}
}
});
}
@ -2406,7 +2482,7 @@ namespace ts {
// Every class automatically contains a static property member named 'prototype',
// the type of which is an instantiation of the class type with type Any supplied as a type argument for each type parameter.
// It is an error to explicitly declare a static property member with the name 'prototype'.
const classType = <InterfaceType>getDeclaredTypeOfSymbol(prototype.parent);
const classType = <InterfaceType>getDeclaredTypeOfSymbol(getMergedSymbol(prototype.parent));
return classType.typeParameters ? createTypeReference(<GenericType>classType, map(classType.typeParameters, _ => anyType)) : classType;
}
@ -4900,6 +4976,10 @@ namespace ts {
return checkTypeRelatedTo(source, target, identityRelation, /*errorNode*/ undefined) ? Ternary.True : Ternary.False;
}
function compareTypesAssignable(source: Type, target: Type): Ternary {
return checkTypeRelatedTo(source, target, assignableRelation, /*errorNode*/ undefined) ? Ternary.True : Ternary.False;
}
function isTypeSubtypeOf(source: Type, target: Type): boolean {
return checkTypeSubtypeOf(source, target, /*errorNode*/ undefined);
}
@ -4916,16 +4996,27 @@ namespace ts {
return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain);
}
function isSignatureAssignableTo(source: Signature,
target: Signature,
ignoreReturnTypes: boolean): boolean {
return compareSignaturesRelated(source, target, ignoreReturnTypes, /*reportErrors*/ false, /*errorReporter*/ undefined, compareTypesAssignable) !== Ternary.False;
}
/**
* See signatureRelatedTo, compareSignaturesIdentical
*/
function isSignatureAssignableTo(source: Signature, target: Signature, ignoreReturnTypes: boolean): boolean {
function compareSignaturesRelated(source: Signature,
target: Signature,
ignoreReturnTypes: boolean,
reportErrors: boolean,
errorReporter: (d: DiagnosticMessage, arg0?: string, arg1?: string) => void,
compareTypes: (s: Type, t: Type, reportErrors?: boolean) => Ternary): Ternary {
// TODO (drosen): De-duplicate code between related functions.
if (source === target) {
return true;
return Ternary.True;
}
if (!target.hasRestParameter && source.minArgumentCount > target.parameters.length) {
return false;
return Ternary.False;
}
// Spec 1.0 Section 3.8.3 & 3.8.4:
@ -4933,36 +5024,49 @@ namespace ts {
source = getErasedSignature(source);
target = getErasedSignature(target);
let result = Ternary.True;
const sourceMax = getNumNonRestParameters(source);
const targetMax = getNumNonRestParameters(target);
const checkCount = getNumParametersToCheckForSignatureRelatability(source, sourceMax, target, targetMax);
const sourceParams = source.parameters;
const targetParams = target.parameters;
for (let i = 0; i < checkCount; i++) {
const s = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source);
const t = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target);
const related = isTypeAssignableTo(t, s) || isTypeAssignableTo(s, t);
const s = i < sourceMax ? getTypeOfSymbol(sourceParams[i]) : getRestTypeOfSignature(source);
const t = i < targetMax ? getTypeOfSymbol(targetParams[i]) : getRestTypeOfSignature(target);
const related = compareTypes(t, s, /*reportErrors*/ false) || compareTypes(s, t, reportErrors);
if (!related) {
return false;
if (reportErrors) {
errorReporter(Diagnostics.Types_of_parameters_0_and_1_are_incompatible,
sourceParams[i < sourceMax ? i : sourceMax].name,
targetParams[i < targetMax ? i : targetMax].name);
}
return Ternary.False;
}
result &= related;
}
if (!ignoreReturnTypes) {
const targetReturnType = getReturnTypeOfSignature(target);
if (targetReturnType === voidType) {
return true;
return result;
}
const sourceReturnType = getReturnTypeOfSignature(source);
// The following block preserves behavior forbidding boolean returning functions from being assignable to type guard returning functions
if (targetReturnType.flags & TypeFlags.PredicateType && (targetReturnType as PredicateType).predicate.kind === TypePredicateKind.Identifier) {
if (!(sourceReturnType.flags & TypeFlags.PredicateType)) {
return false;
if (reportErrors) {
errorReporter(Diagnostics.Signature_0_must_have_a_type_predicate, signatureToString(source));
}
return Ternary.False;
}
}
return isTypeAssignableTo(sourceReturnType, targetReturnType);
result &= compareTypes(sourceReturnType, targetReturnType, reportErrors);
}
return true;
return result;
}
function isImplementationCompatibleWithOverload(implementation: Signature, overload: Signature): boolean {
@ -5033,24 +5137,14 @@ namespace ts {
let expandingFlags: number;
let depth = 0;
let overflow = false;
let elaborateErrors = false;
Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking");
const result = isRelatedTo(source, target, errorNode !== undefined, headMessage);
const result = isRelatedTo(source, target, /*reportErrors*/ !!errorNode, headMessage);
if (overflow) {
error(errorNode, Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target));
}
else if (errorInfo) {
// If we already computed this relation, but in a context where we didn't want to report errors (e.g. overload resolution),
// then we'll only have a top-level error (e.g. 'Class X does not implement interface Y') without any details. If this happened,
// request a recompuation to get a complete error message. This will be skipped if we've already done this computation in a context
// where errors were being reported.
if (errorInfo.next === undefined) {
errorInfo = undefined;
elaborateErrors = true;
isRelatedTo(source, target, errorNode !== undefined, headMessage);
}
if (containingMessageChain) {
errorInfo = concatenateDiagnosticMessageChains(containingMessageChain, errorInfo);
}
@ -5060,6 +5154,7 @@ namespace ts {
return result !== Ternary.False;
function reportError(message: DiagnosticMessage, arg0?: string, arg1?: string, arg2?: string): void {
Debug.assert(!!errorNode);
errorInfo = chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2);
}
@ -5197,14 +5292,14 @@ namespace ts {
}
// Even if relationship doesn't hold for unions, intersections, or generic type references,
// it may hold in a structural comparison.
const apparentType = getApparentType(source);
const apparentSource = getApparentType(source);
// In a check of the form X = A & B, we will have previously checked if A relates to X or B relates
// to X. Failing both of those we want to check if the aggregation of A and B's members structurally
// relates to X. Thus, we include intersection types on the source side here.
if (apparentType.flags & (TypeFlags.ObjectType | TypeFlags.Intersection) && target.flags & TypeFlags.ObjectType) {
if (apparentSource.flags & (TypeFlags.ObjectType | TypeFlags.Intersection) && target.flags & TypeFlags.ObjectType) {
// Report structural errors only if we haven't reported any errors yet
const reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo;
if (result = objectTypeRelatedTo(apparentType, source, target, reportStructuralErrors)) {
const reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !(source.flags & TypeFlags.Primitive);
if (result = objectTypeRelatedTo(apparentSource, source, target, reportStructuralErrors)) {
errorInfo = saveErrorInfo;
return result;
}
@ -5269,6 +5364,7 @@ namespace ts {
// We know *exactly* where things went wrong when comparing the types.
// Use this property as the error node as this will be more helpful in
// reasoning about what went wrong.
Debug.assert(!!errorNode);
errorNode = prop.valueDeclaration;
reportError(Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1,
symbolToString(prop), typeToString(target));
@ -5371,7 +5467,7 @@ namespace ts {
const id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id;
const related = relation[id];
if (related !== undefined) {
if (elaborateErrors && related === RelationComparisonResult.Failed) {
if (reportErrors && related === RelationComparisonResult.Failed) {
// We are elaborating errors and the cached result is an unreported failure. Record the result as a reported
// failure and continue computing the relation such that errors get reported.
relation[id] = RelationComparisonResult.FailedAndReported;
@ -5591,7 +5687,7 @@ namespace ts {
}
// don't elaborate the primitive apparent types (like Number)
// because the actual primitives will have already been reported.
if (shouldElaborateErrors && !isPrimitiveApparentType(source)) {
if (shouldElaborateErrors) {
reportError(Diagnostics.Type_0_provides_no_match_for_the_signature_1,
typeToString(source),
signatureToString(t, /*enclosingDeclaration*/ undefined, /*flags*/ undefined, kind));
@ -5603,77 +5699,10 @@ namespace ts {
}
/**
* See signatureAssignableTo, signatureAssignableTo
* See signatureAssignableTo, compareSignaturesIdentical
*/
function signatureRelatedTo(source: Signature, target: Signature, reportErrors: boolean): Ternary {
// TODO (drosen): De-duplicate code between related functions.
if (source === target) {
return Ternary.True;
}
if (!target.hasRestParameter && source.minArgumentCount > target.parameters.length) {
return Ternary.False;
}
let sourceMax = source.parameters.length;
let targetMax = target.parameters.length;
let checkCount: number;
if (source.hasRestParameter && target.hasRestParameter) {
checkCount = sourceMax > targetMax ? sourceMax : targetMax;
sourceMax--;
targetMax--;
}
else if (source.hasRestParameter) {
sourceMax--;
checkCount = targetMax;
}
else if (target.hasRestParameter) {
targetMax--;
checkCount = sourceMax;
}
else {
checkCount = sourceMax < targetMax ? sourceMax : targetMax;
}
// Spec 1.0 Section 3.8.3 & 3.8.4:
// M and N (the signatures) are instantiated using type Any as the type argument for all type parameters declared by M and N
source = getErasedSignature(source);
target = getErasedSignature(target);
let result = Ternary.True;
for (let i = 0; i < checkCount; i++) {
const s = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source);
const t = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target);
const saveErrorInfo = errorInfo;
let related = isRelatedTo(s, t, reportErrors);
if (!related) {
related = isRelatedTo(t, s, /*reportErrors*/ false);
if (!related) {
if (reportErrors) {
reportError(Diagnostics.Types_of_parameters_0_and_1_are_incompatible,
source.parameters[i < sourceMax ? i : sourceMax].name,
target.parameters[i < targetMax ? i : targetMax].name);
}
return Ternary.False;
}
errorInfo = saveErrorInfo;
}
result &= related;
}
const targetReturnType = getReturnTypeOfSignature(target);
if (targetReturnType === voidType) {
return result;
}
const sourceReturnType = getReturnTypeOfSignature(source);
// The following block preserves behavior forbidding boolean returning functions from being assignable to type guard returning functions
if (targetReturnType.flags & TypeFlags.PredicateType && (targetReturnType as PredicateType).predicate.kind === TypePredicateKind.Identifier) {
if (!(sourceReturnType.flags & TypeFlags.PredicateType)) {
if (reportErrors) {
reportError(Diagnostics.Signature_0_must_have_a_type_predicate, signatureToString(source));
}
return Ternary.False;
}
}
return result & isRelatedTo(sourceReturnType, targetReturnType, reportErrors);
return compareSignaturesRelated(source, target, /*ignoreReturnTypes*/ false, reportErrors, reportError, isRelatedTo);
}
function signaturesIdenticalTo(source: Type, target: Type, kind: SignatureKind): Ternary {
@ -6681,10 +6710,6 @@ namespace ts {
if (typeInfo && typeInfo.type === undefinedType) {
return type;
}
// If the type to be narrowed is any and we're checking a primitive with assumeTrue=true, return the primitive
if (!!(type.flags & TypeFlags.Any) && typeInfo && assumeTrue) {
return typeInfo.type;
}
let flags: TypeFlags;
if (typeInfo) {
flags = typeInfo.flags;
@ -6695,6 +6720,10 @@ namespace ts {
}
// At this point we can bail if it's not a union
if (!(type.flags & TypeFlags.Union)) {
// If we're on the true branch and the type is a subtype, we should return the primitive type
if (assumeTrue && typeInfo && isTypeSubtypeOf(typeInfo.type, type)) {
return typeInfo.type;
}
// If the active non-union type would be removed from a union by this type guard, return an empty union
return filterUnion(type) ? type : emptyUnionType;
}
@ -8619,7 +8648,7 @@ namespace ts {
function checkIndexedAccess(node: ElementAccessExpression): Type {
// Grammar checking
if (!node.argumentExpression) {
const sourceFile = getSourceFile(node);
const sourceFile = getSourceFileOfNode(node);
if (node.parent.kind === SyntaxKind.NewExpression && (<NewExpression>node.parent).expression === node) {
const start = skipTrivia(sourceFile.text, node.expression.end);
const end = node.end;
@ -11990,7 +12019,7 @@ namespace ts {
case SyntaxKind.InterfaceDeclaration:
return SymbolFlags.ExportType;
case SyntaxKind.ModuleDeclaration:
return (<ModuleDeclaration>d).name.kind === SyntaxKind.StringLiteral || getModuleInstanceState(d) !== ModuleInstanceState.NonInstantiated
return isAmbientModule(d) || getModuleInstanceState(d) !== ModuleInstanceState.NonInstantiated
? SymbolFlags.ExportNamespace | SymbolFlags.ExportValue
: SymbolFlags.ExportNamespace;
case SyntaxKind.ClassDeclaration:
@ -12438,7 +12467,7 @@ namespace ts {
// checkFunctionOrConstructorSymbol wouldn't be called if we didnt ignore javascript function.
const firstDeclaration = forEach(localSymbol.declarations,
// Get first non javascript function declaration
declaration => declaration.kind === node.kind && !isSourceFileJavaScript(getSourceFile(declaration)) ?
declaration => declaration.kind === node.kind && !isSourceFileJavaScript(getSourceFileOfNode(declaration)) ?
declaration : undefined);
// Only type check the symbol once
@ -14123,7 +14152,13 @@ namespace ts {
function checkModuleDeclaration(node: ModuleDeclaration) {
if (produceDiagnostics) {
// Grammar checking
const isAmbientExternalModule = node.name.kind === SyntaxKind.StringLiteral;
const isGlobalAugmentation = isGlobalScopeAugmentation(node);
const inAmbientContext = isInAmbientContext(node);
if (isGlobalAugmentation && !inAmbientContext) {
error(node.name, Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context);
}
const isAmbientExternalModule = isAmbientModule(node);
const contextErrorMessage = isAmbientExternalModule
? Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file
: Diagnostics.A_namespace_declaration_is_only_allowed_in_a_namespace_or_module;
@ -14133,7 +14168,7 @@ namespace ts {
}
if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) {
if (!isInAmbientContext(node) && node.name.kind === SyntaxKind.StringLiteral) {
if (!inAmbientContext && node.name.kind === SyntaxKind.StringLiteral) {
grammarErrorOnNode(node.name, Diagnostics.Only_ambient_modules_can_use_quoted_names);
}
}
@ -14146,7 +14181,7 @@ namespace ts {
// The following checks only apply on a non-ambient instantiated module declaration.
if (symbol.flags & SymbolFlags.ValueModule
&& symbol.declarations.length > 1
&& !isInAmbientContext(node)
&& !inAmbientContext
&& isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules)) {
const firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol);
if (firstNonAmbientClassOrFunc) {
@ -14167,19 +14202,107 @@ namespace ts {
}
}
// Checks for ambient external modules.
if (isAmbientExternalModule) {
if (!isGlobalSourceFile(node.parent)) {
error(node.name, Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces);
if (isExternalModuleAugmentation(node)) {
// body of the augmentation should be checked for consistency only if augmentation was applied to its target (either global scope or module)
// otherwise we'll be swamped in cascading errors.
// We can detect if augmentation was applied using following rules:
// - augmentation for a global scope is always applied
// - augmentation for some external module is applied if symbol for augmentation is merged (it was combined with target module).
const checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & SymbolFlags.Merged);
if (checkBody) {
// body of ambient external module is always a module block
for (const statement of (<ModuleBlock>node.body).statements) {
checkModuleAugmentationElement(statement, isGlobalAugmentation);
}
}
}
if (isExternalModuleNameRelative(node.name.text)) {
error(node.name, Diagnostics.Ambient_module_declaration_cannot_specify_relative_module_name);
else if (isGlobalSourceFile(node.parent)) {
if (isGlobalAugmentation) {
error(node.name, Diagnostics.Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations);
}
else if (isExternalModuleNameRelative(node.name.text)) {
error(node.name, Diagnostics.Ambient_module_declaration_cannot_specify_relative_module_name);
}
}
else {
if (isGlobalAugmentation) {
error(node.name, Diagnostics.Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations);
}
else {
// Node is not an augmentation and is not located on the script level.
// This means that this is declaration of ambient module that is located in other module or namespace which is prohibited.
error(node.name, Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces);
}
}
}
}
checkSourceElement(node.body);
}
function checkModuleAugmentationElement(node: Node, isGlobalAugmentation: boolean): void {
switch (node.kind) {
case SyntaxKind.VariableStatement:
// error each individual name in variable statement instead of marking the entire variable statement
for (const decl of (<VariableStatement>node).declarationList.declarations) {
checkModuleAugmentationElement(decl, isGlobalAugmentation);
}
break;
case SyntaxKind.ExportAssignment:
case SyntaxKind.ExportDeclaration:
grammarErrorOnFirstToken(node, Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations);
break;
case SyntaxKind.ImportEqualsDeclaration:
if ((<ImportEqualsDeclaration>node).moduleReference.kind !== SyntaxKind.StringLiteral) {
error((<ImportEqualsDeclaration>node).name, Diagnostics.Module_augmentation_cannot_introduce_new_names_in_the_top_level_scope);
break;
}
// fallthrough
case SyntaxKind.ImportDeclaration:
grammarErrorOnFirstToken(node, Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module);
break;
case SyntaxKind.BindingElement:
case SyntaxKind.VariableDeclaration:
const name = (<VariableDeclaration | BindingElement>node).name;
if (isBindingPattern(name)) {
for (const el of name.elements) {
// mark individual names in binding pattern
checkModuleAugmentationElement(el, isGlobalAugmentation);
}
break;
}
// fallthrough
case SyntaxKind.ClassDeclaration:
case SyntaxKind.EnumDeclaration:
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.InterfaceDeclaration:
case SyntaxKind.ModuleDeclaration:
case SyntaxKind.TypeAliasDeclaration:
const symbol = getSymbolOfNode(node);
if (symbol) {
// module augmentations cannot introduce new names on the top level scope of the module
// this is done it two steps
// 1. quick check - if symbol for node is not merged - this is local symbol to this augmentation - report error
// 2. main check - report error if value declaration of the parent symbol is module augmentation)
let reportError = !(symbol.flags & SymbolFlags.Merged);
if (!reportError) {
if (isGlobalAugmentation) {
// global symbol should not have parent since it is not explicitly exported
reportError = symbol.parent !== undefined;
}
else {
// symbol should not originate in augmentation
reportError = isExternalModuleAugmentation(symbol.parent.valueDeclaration);
}
}
if (reportError) {
error(node, Diagnostics.Module_augmentation_cannot_introduce_new_names_in_the_top_level_scope);
}
}
break;
}
}
function getFirstIdentifier(node: EntityName | Expression): Identifier {
while (true) {
if (node.kind === SyntaxKind.QualifiedName) {
@ -14202,7 +14325,7 @@ namespace ts {
error(moduleName, Diagnostics.String_literal_expected);
return false;
}
const inAmbientExternalModule = node.parent.kind === SyntaxKind.ModuleBlock && (<ModuleDeclaration>node.parent.parent).name.kind === SyntaxKind.StringLiteral;
const inAmbientExternalModule = node.parent.kind === SyntaxKind.ModuleBlock && isAmbientModule(<ModuleDeclaration>node.parent.parent);
if (node.parent.kind !== SyntaxKind.SourceFile && !inAmbientExternalModule) {
error(moduleName, node.kind === SyntaxKind.ExportDeclaration ?
Diagnostics.Export_declarations_are_not_permitted_in_a_namespace :
@ -14210,12 +14333,16 @@ namespace ts {
return false;
}
if (inAmbientExternalModule && isExternalModuleNameRelative((<LiteralExpression>moduleName).text)) {
// TypeScript 1.0 spec (April 2013): 12.1.6
// An ExternalImportDeclaration in an AmbientExternalModuleDeclaration may reference
// other external modules only through top - level external module names.
// Relative external module names are not permitted.
error(node, Diagnostics.Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name);
return false;
// we have already reported errors on top level imports\exports in external module augmentations in checkModuleDeclaration
// no need to do this again.
if (!isTopLevelInExternalModuleAugmentation(node)) {
// TypeScript 1.0 spec (April 2013): 12.1.6
// An ExternalImportDeclaration in an AmbientExternalModuleDeclaration may reference
// other external modules only through top - level external module names.
// Relative external module names are not permitted.
error(node, Diagnostics.Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name);
return false;
}
}
return true;
}
@ -14321,7 +14448,7 @@ namespace ts {
// export { x, y } from "foo"
forEach(node.exportClause.elements, checkExportSpecifier);
const inAmbientExternalModule = node.parent.kind === SyntaxKind.ModuleBlock && (<ModuleDeclaration>node.parent.parent).name.kind === SyntaxKind.StringLiteral;
const inAmbientExternalModule = node.parent.kind === SyntaxKind.ModuleBlock && isAmbientModule(node.parent.parent);
if (node.parent.kind !== SyntaxKind.SourceFile && !inAmbientExternalModule) {
error(node, Diagnostics.Export_declarations_are_not_permitted_in_a_namespace);
}
@ -14365,7 +14492,7 @@ namespace ts {
}
const container = node.parent.kind === SyntaxKind.SourceFile ? <SourceFile>node.parent : <ModuleDeclaration>node.parent.parent;
if (container.kind === SyntaxKind.ModuleDeclaration && (<ModuleDeclaration>container).name.kind === SyntaxKind.Identifier) {
if (container.kind === SyntaxKind.ModuleDeclaration && !isAmbientModule(container)) {
error(node, Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace);
return;
}
@ -14395,7 +14522,7 @@ namespace ts {
}
function hasExportedMembers(moduleSymbol: Symbol) {
for (var id in moduleSymbol.exports) {
for (const id in moduleSymbol.exports) {
if (id !== "export=") {
return true;
}
@ -14410,7 +14537,9 @@ namespace ts {
const exportEqualsSymbol = moduleSymbol.exports["export="];
if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) {
const declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration;
error(declaration, Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements);
if (!isTopLevelInExternalModuleAugmentation(declaration)) {
error(declaration, Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements);
}
}
// Checks for export * conflicts
const exports = getExportsOfModule(moduleSymbol);
@ -15470,13 +15599,13 @@ namespace ts {
};
}
function getExternalModuleFileFromDeclaration(declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration): SourceFile {
const specifier = getExternalModuleName(declaration);
const moduleSymbol = getSymbolAtLocation(specifier);
if (!moduleSymbol) {
return undefined;
}
return getDeclarationOfKind(moduleSymbol, SyntaxKind.SourceFile) as SourceFile;
function getExternalModuleFileFromDeclaration(declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration): SourceFile {
const specifier = getExternalModuleName(declaration);
const moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, /*moduleNotFoundError*/ undefined);
if (!moduleSymbol) {
return undefined;
}
return getDeclarationOfKind(moduleSymbol, SyntaxKind.SourceFile) as SourceFile;
}
function initializeTypeChecker() {
@ -15485,13 +15614,27 @@ namespace ts {
bindSourceFile(file, compilerOptions);
});
let augmentations: LiteralExpression[][];
// Initialize global symbol table
forEach(host.getSourceFiles(), file => {
if (!isExternalOrCommonJsModule(file)) {
mergeSymbolTable(globals, file.locals);
}
if (file.moduleAugmentations) {
(augmentations || (augmentations = [])).push(file.moduleAugmentations);
}
});
if (augmentations) {
// merge module augmentations.
// this needs to be done after global symbol table is initialized to make sure that all ambient modules are indexed
for (const list of augmentations) {
for (const augmentation of list) {
mergeModuleAugmentation(augmentation);
}
}
}
// Setup global builtins
addToSymbolTable(globals, builtinGlobals, Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0);
@ -16307,7 +16450,7 @@ namespace ts {
return true;
}
else if (node.body === undefined) {
return grammarErrorAtPos(getSourceFile(node), node.end - 1, ";".length, Diagnostics._0_expected, "{");
return grammarErrorAtPos(getSourceFileOfNode(node), node.end - 1, ";".length, Diagnostics._0_expected, "{");
}
}

View file

@ -718,7 +718,8 @@ namespace ts {
}
// Find the component that differs
for (var joinStartIndex = 0; joinStartIndex < pathComponents.length && joinStartIndex < directoryComponents.length; joinStartIndex++) {
let joinStartIndex: number;
for (joinStartIndex = 0; joinStartIndex < pathComponents.length && joinStartIndex < directoryComponents.length; joinStartIndex++) {
if (getCanonicalFileName(directoryComponents[joinStartIndex]) !== getCanonicalFileName(pathComponents[joinStartIndex])) {
break;
}

View file

@ -54,6 +54,7 @@ namespace ts {
let writer = createAndSetNewTextWriterWithSymbolWriter();
let enclosingDeclaration: Node;
let resultHasExternalModuleIndicator: boolean;
let currentText: string;
let currentLineMap: number[];
let currentIdentifiers: Map<string>;
@ -101,6 +102,7 @@ namespace ts {
});
}
resultHasExternalModuleIndicator = false;
if (!isBundledEmit || !isExternalModule(sourceFile)) {
noDeclare = false;
emitSourceFile(sourceFile);
@ -139,6 +141,14 @@ namespace ts {
allSourcesModuleElementDeclarationEmitInfo = allSourcesModuleElementDeclarationEmitInfo.concat(moduleElementDeclarationEmitInfo);
moduleElementDeclarationEmitInfo = [];
}
if (!isBundledEmit && isExternalModule(sourceFile) && sourceFile.moduleAugmentations.length && !resultHasExternalModuleIndicator) {
// if file was external module with augmentations - this fact should be preserved in .d.ts as well.
// in case if we didn't write any external module specifiers in .d.ts we need to emit something
// that will force compiler to think that this file is an external module - 'export {}' is a reasonable choice here.
write("export {};");
writeLine();
}
});
return {
@ -721,16 +731,25 @@ namespace ts {
writer.writeLine();
}
function emitExternalModuleSpecifier(parent: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration) {
function emitExternalModuleSpecifier(parent: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration) {
// emitExternalModuleSpecifier is usually called when we emit something in the.d.ts file that will make it an external module (i.e. import/export declarations).
// the only case when it is not true is when we call it to emit correct name for module augmentation - d.ts files with just module augmentations are not considered
// external modules since they are indistingushable from script files with ambient modules. To fix this in such d.ts files we'll emit top level 'export {}'
// so compiler will treat them as external modules.
resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== SyntaxKind.ModuleDeclaration;
let moduleSpecifier: Node;
if (parent.kind === SyntaxKind.ImportEqualsDeclaration) {
const node = parent as ImportEqualsDeclaration;
moduleSpecifier = getExternalModuleImportEqualsDeclarationExpression(node);
}
else if (parent.kind === SyntaxKind.ModuleDeclaration) {
moduleSpecifier = (<ModuleDeclaration>parent).name;
}
else {
const node = parent as (ImportDeclaration | ExportDeclaration);
moduleSpecifier = node.moduleSpecifier;
}
if (moduleSpecifier.kind === SyntaxKind.StringLiteral && isBundledEmit && (compilerOptions.out || compilerOptions.outFile)) {
const moduleName = getExternalModuleNameFromDeclaration(host, resolver, parent);
if (moduleName) {
@ -784,13 +803,23 @@ namespace ts {
function writeModuleDeclaration(node: ModuleDeclaration) {
emitJsDocComments(node);
emitModuleElementDeclarationFlags(node);
if (node.flags & NodeFlags.Namespace) {
write("namespace ");
if (isGlobalScopeAugmentation(node)) {
write("global ");
}
else {
write("module ");
if (node.flags & NodeFlags.Namespace) {
write("namespace ");
}
else {
write("module ");
}
if (isExternalModuleAugmentation(node)) {
emitExternalModuleSpecifier(node);
}
else {
writeTextOfNode(currentText, node.name);
}
}
writeTextOfNode(currentText, node.name);
while (node.body.kind !== SyntaxKind.ModuleBlock) {
node = <ModuleDeclaration>node.body;
write(".");

View file

@ -1767,6 +1767,42 @@
"category": "Error",
"code": 2661
},
"Cannot find name '{0}'. Did you mean the static member '{1}.{0}'?": {
"category": "Error",
"code": 2662
},
"Cannot find name '{0}'. Did you mean the instance member 'this.{0}'?": {
"category": "Error",
"code": 2663
},
"Invalid module name in augmentation, module '{0}' cannot be found.": {
"category": "Error",
"code": 2664
},
"Module augmentation cannot introduce new names in the top level scope.": {
"category": "Error",
"code": 2665
},
"Exports and export assignments are not permitted in module augmentations.": {
"category": "Error",
"code": 2666
},
"Imports are not permitted in module augmentations. Consider moving them to the enclosing external module.": {
"category": "Error",
"code": 2667
},
"'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible.": {
"category": "Error",
"code": 2668
},
"Augmentations for the global scope can only be directly nested in external modules or ambient module declarations.": {
"category": "Error",
"code": 2669
},
"Augmentations for the global scope should have 'declare' modifier unless they appear in already ambient context.": {
"category": "Error",
"code": 2670
},
"Import declaration '{0}' is using private name '{1}'.": {
"category": "Error",
"code": 4000

View file

@ -1250,7 +1250,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
else {
// One object literal with all the attributes in them
write("{");
for (var i = 0; i < attrs.length; i++) {
for (let i = 0, n = attrs.length; i < n; i++) {
if (i > 0) {
write(", ");
}
@ -1262,7 +1262,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
// Children
if (children) {
for (var i = 0; i < children.length; i++) {
for (let i = 0; i < children.length; i++) {
// Don't emit empty expressions
if (children[i].kind === SyntaxKind.JsxExpression && !((<JsxExpression>children[i]).expression)) {
continue;
@ -1356,7 +1356,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
function emitJsxElement(node: JsxElement) {
emitJsxOpeningOrSelfClosingElement(node.openingElement);
for (var i = 0, n = node.children.length; i < n; i++) {
for (let i = 0, n = node.children.length; i < n; i++) {
emit(node.children[i]);
}
@ -2886,7 +2886,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
case SyntaxKind.ForStatement:
case SyntaxKind.ForInStatement:
case SyntaxKind.ForOfStatement:
if ((<ForStatement | ForInStatement | ForOfStatement>node).initializer.kind === SyntaxKind.VariableDeclarationList) {
const initializer = (<ForStatement | ForInStatement | ForOfStatement>node).initializer;
if (initializer && initializer.kind === SyntaxKind.VariableDeclarationList) {
loopInitializer = <VariableDeclarationList>(<ForStatement | ForInStatement | ForOfStatement>node).initializer;
}
break;
@ -5171,7 +5172,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
// a lexical declaration such as a LexicalDeclaration or a ClassDeclaration.
if (isClassExpressionWithStaticProperties) {
for (var property of staticProperties) {
for (const property of staticProperties) {
write(",");
writeLine();
emitPropertyDeclaration(node, property, /*receiver*/ tempVariable, /*isExpression*/ true);
@ -5718,7 +5719,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
const parameters = valueDeclaration.parameters;
const parameterCount = parameters.length;
if (parameterCount > 0) {
for (var i = 0; i < parameterCount; i++) {
for (let i = 0; i < parameterCount; i++) {
if (i > 0) {
write(", ");
}

View file

@ -4430,6 +4430,9 @@ namespace ts {
}
continue;
case SyntaxKind.GlobalKeyword:
return nextToken() === SyntaxKind.OpenBraceToken;
case SyntaxKind.ImportKeyword:
nextToken();
return token === SyntaxKind.StringLiteral || token === SyntaxKind.AsteriskToken ||
@ -4494,6 +4497,7 @@ namespace ts {
case SyntaxKind.ModuleKeyword:
case SyntaxKind.NamespaceKeyword:
case SyntaxKind.TypeKeyword:
case SyntaxKind.GlobalKeyword:
// When these don't start a declaration, they're an identifier in an expression statement
return true;
@ -4582,6 +4586,7 @@ namespace ts {
case SyntaxKind.PublicKeyword:
case SyntaxKind.AbstractKeyword:
case SyntaxKind.StaticKeyword:
case SyntaxKind.GlobalKeyword:
if (isStartOfDeclaration()) {
return parseDeclaration();
}
@ -4609,6 +4614,7 @@ namespace ts {
return parseTypeAliasDeclaration(fullStart, decorators, modifiers);
case SyntaxKind.EnumKeyword:
return parseEnumDeclaration(fullStart, decorators, modifiers);
case SyntaxKind.GlobalKeyword:
case SyntaxKind.ModuleKeyword:
case SyntaxKind.NamespaceKeyword:
return parseModuleDeclaration(fullStart, decorators, modifiers);
@ -5243,14 +5249,25 @@ namespace ts {
const node = <ModuleDeclaration>createNode(SyntaxKind.ModuleDeclaration, fullStart);
node.decorators = decorators;
setModifiers(node, modifiers);
node.name = parseLiteralNode(/*internName*/ true);
if (token === SyntaxKind.GlobalKeyword) {
// parse 'global' as name of global scope augmentation
node.name = parseIdentifier();
node.flags |= NodeFlags.GlobalAugmentation;
}
else {
node.name = parseLiteralNode(/*internName*/ true);
}
node.body = parseModuleBlock();
return finishNode(node);
}
function parseModuleDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): ModuleDeclaration {
let flags = modifiers ? modifiers.flags : 0;
if (parseOptional(SyntaxKind.NamespaceKeyword)) {
if (token === SyntaxKind.GlobalKeyword) {
// global augmentation
return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers);
}
else if (parseOptional(SyntaxKind.NamespaceKeyword)) {
flags |= NodeFlags.Namespace;
}
else {

View file

@ -361,7 +361,24 @@ namespace ts {
const currentDirectory = host.getCurrentDirectory();
const resolveModuleNamesWorker = host.resolveModuleNames
? ((moduleNames: string[], containingFile: string) => host.resolveModuleNames(moduleNames, containingFile))
: ((moduleNames: string[], containingFile: string) => map(moduleNames, moduleName => resolveModuleName(moduleName, containingFile, options, host).resolvedModule));
: ((moduleNames: string[], containingFile: string) => {
const resolvedModuleNames: ResolvedModule[] = [];
// resolveModuleName does not store any results between calls.
// lookup is a local cache to avoid resolving the same module name several times
const lookup: Map<ResolvedModule> = {};
for (const moduleName of moduleNames) {
let resolvedName: ResolvedModule;
if (hasProperty(lookup, moduleName)) {
resolvedName = lookup[moduleName];
}
else {
resolvedName = resolveModuleName(moduleName, containingFile, options, host).resolvedModule;
lookup[moduleName] = resolvedName;
}
resolvedModuleNames.push(resolvedName);
}
return resolvedModuleNames;
});
const filesByName = createFileMap<SourceFile>();
// stores 'filename -> file association' ignoring case
@ -498,15 +515,19 @@ namespace ts {
return false;
}
// check imports
// check imports and module augmentations
collectExternalModuleReferences(newSourceFile);
if (!arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) {
// imports has changed
return false;
}
if (!arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) {
// moduleAugmentations has changed
return false;
}
if (resolveModuleNamesWorker) {
const moduleNames = map(newSourceFile.imports, name => name.text);
const moduleNames = map(concatenate(newSourceFile.imports, newSourceFile.moduleAugmentations), getTextOfLiteral);
const resolutions = resolveModuleNamesWorker(moduleNames, getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory));
// ensure that module resolution results are still correct
for (let i = 0; i < moduleNames.length; i++) {
@ -895,65 +916,85 @@ namespace ts {
return a.text === b.text;
}
function getTextOfLiteral(literal: LiteralExpression): string {
return literal.text;
}
function collectExternalModuleReferences(file: SourceFile): void {
if (file.imports) {
return;
}
const isJavaScriptFile = isSourceFileJavaScript(file);
const isExternalModuleFile = isExternalModule(file);
let imports: LiteralExpression[];
let moduleAugmentations: LiteralExpression[];
for (const node of file.statements) {
collect(node, /*allowRelativeModuleNames*/ true, /*collectOnlyRequireCalls*/ false);
collectModuleReferences(node, /*inAmbientModule*/ false);
if (isJavaScriptFile) {
collectRequireCalls(node);
}
}
file.imports = imports || emptyArray;
file.moduleAugmentations = moduleAugmentations || emptyArray;
return;
function collect(node: Node, allowRelativeModuleNames: boolean, collectOnlyRequireCalls: boolean): void {
if (!collectOnlyRequireCalls) {
switch (node.kind) {
case SyntaxKind.ImportDeclaration:
case SyntaxKind.ImportEqualsDeclaration:
case SyntaxKind.ExportDeclaration:
let moduleNameExpr = getExternalModuleName(node);
if (!moduleNameExpr || moduleNameExpr.kind !== SyntaxKind.StringLiteral) {
break;
}
if (!(<LiteralExpression>moduleNameExpr).text) {
break;
}
if (allowRelativeModuleNames || !isExternalModuleNameRelative((<LiteralExpression>moduleNameExpr).text)) {
(imports || (imports = [])).push(<LiteralExpression>moduleNameExpr);
}
function collectModuleReferences(node: Node, inAmbientModule: boolean): void {
switch (node.kind) {
case SyntaxKind.ImportDeclaration:
case SyntaxKind.ImportEqualsDeclaration:
case SyntaxKind.ExportDeclaration:
let moduleNameExpr = getExternalModuleName(node);
if (!moduleNameExpr || moduleNameExpr.kind !== SyntaxKind.StringLiteral) {
break;
case SyntaxKind.ModuleDeclaration:
if ((<ModuleDeclaration>node).name.kind === SyntaxKind.StringLiteral && (node.flags & NodeFlags.Ambient || isDeclarationFile(file))) {
// TypeScript 1.0 spec (April 2014): 12.1.6
}
if (!(<LiteralExpression>moduleNameExpr).text) {
break;
}
// TypeScript 1.0 spec (April 2014): 12.1.6
// An ExternalImportDeclaration in an AmbientExternalModuleDeclaration may reference other external modules
// only through top - level external module names. Relative external module names are not permitted.
if (!inAmbientModule || !isExternalModuleNameRelative((<LiteralExpression>moduleNameExpr).text)) {
(imports || (imports = [])).push(<LiteralExpression>moduleNameExpr);
}
break;
case SyntaxKind.ModuleDeclaration:
if (isAmbientModule(<ModuleDeclaration>node) && (inAmbientModule || node.flags & NodeFlags.Ambient || isDeclarationFile(file))) {
const moduleName = <LiteralExpression>(<ModuleDeclaration>node).name;
// Ambient module declarations can be interpreted as augmentations for some existing external modules.
// This will happen in two cases:
// - if current file is external module then module augmentation is a ambient module declaration defined in the top level scope
// - if current file is not external module then module augmentation is an ambient module declaration with non-relative module name
// immediately nested in top level ambient module declaration .
if (isExternalModuleFile || (inAmbientModule && !isExternalModuleNameRelative(moduleName.text))) {
(moduleAugmentations || (moduleAugmentations = [])).push(moduleName);
}
else if (!inAmbientModule) {
// An AmbientExternalModuleDeclaration declares an external module.
// This type of declaration is permitted only in the global module.
// The StringLiteral must specify a top - level external module name.
// Relative external module names are not permitted
forEachChild((<ModuleDeclaration>node).body, node => {
// TypeScript 1.0 spec (April 2014): 12.1.6
// An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules
// only through top - level external module names. Relative external module names are not permitted.
collect(node, /*allowRelativeModuleNames*/ false, collectOnlyRequireCalls);
});
}
break;
}
}
if (isJavaScriptFile) {
if (isRequireCall(node)) {
(imports || (imports = [])).push(<StringLiteral>(<CallExpression>node).arguments[0]);
}
else {
forEachChild(node, node => collect(node, allowRelativeModuleNames, /*collectOnlyRequireCalls*/ true));
}
// NOTE: body of ambient module is always a module block
for (const statement of (<ModuleBlock>(<ModuleDeclaration>node).body).statements) {
collectModuleReferences(statement, /*inAmbientModule*/ true);
}
}
}
}
}
function collectRequireCalls(node: Node): void {
if (isRequireCall(node)) {
(imports || (imports = [])).push(<StringLiteral>(<CallExpression>node).arguments[0]);
}
else {
forEachChild(node, collectRequireCalls);
}
}
}
@ -1083,14 +1124,22 @@ namespace ts {
function processImportedModules(file: SourceFile, basePath: string) {
collectExternalModuleReferences(file);
if (file.imports.length) {
if (file.imports.length || file.moduleAugmentations.length) {
file.resolvedModules = {};
const moduleNames = map(file.imports, name => name.text);
const moduleNames = map(concatenate(file.imports, file.moduleAugmentations), getTextOfLiteral);
const resolutions = resolveModuleNamesWorker(moduleNames, getNormalizedAbsolutePath(file.fileName, currentDirectory));
for (let i = 0; i < file.imports.length; i++) {
for (let i = 0; i < moduleNames.length; i++) {
const resolution = resolutions[i];
setResolvedModule(file, moduleNames[i], resolution);
if (resolution && !options.noResolve) {
// add file to program only if:
// - resolution was successfull
// - noResolve is falsy
// - module name come from the list fo imports
const shouldAddFile = resolution &&
!options.noResolve &&
i < file.imports.length;
if (shouldAddFile) {
const importedFile = findSourceFile(resolution.resolvedFileName, toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), /*isDefaultLib*/ false, file, skipTrivia(file.text, file.imports[i].pos), file.imports[i].end);
if (importedFile && resolution.isExternalLibraryImport) {
@ -1168,7 +1217,7 @@ namespace ts {
if (sourceFiles) {
const absoluteRootDirectoryPath = host.getCanonicalFileName(getNormalizedAbsolutePath(rootDirectory, currentDirectory));
for (var sourceFile of sourceFiles) {
for (const sourceFile of sourceFiles) {
if (!isDeclarationFile(sourceFile)) {
const absoluteSourceFilePath = host.getCanonicalFileName(getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory));
if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) {

View file

@ -94,6 +94,7 @@ namespace ts {
"protected": SyntaxKind.ProtectedKeyword,
"public": SyntaxKind.PublicKeyword,
"require": SyntaxKind.RequireKeyword,
"global": SyntaxKind.GlobalKeyword,
"return": SyntaxKind.ReturnKeyword,
"set": SyntaxKind.SetKeyword,
"static": SyntaxKind.StaticKeyword,

View file

@ -376,9 +376,11 @@ namespace ts {
/**
* @param watcherPath is the path from which the watcher is triggered.
*/
function fileEventHandler(eventName: string, relativefileName: string, baseDirPath: Path) {
function fileEventHandler(eventName: string, relativeFileName: string, baseDirPath: Path) {
// When files are deleted from disk, the triggered "rename" event would have a relativefileName of "undefined"
const filePath = relativefileName === undefined ? undefined : toPath(relativefileName, baseDirPath, getCanonicalPath);
const filePath = typeof relativeFileName !== "string"
? undefined
: toPath(relativeFileName, baseDirPath, createGetCanonicalFileName(sys.useCaseSensitiveFileNames));
if (eventName === "change" && fileWatcherCallbacks.contains(filePath)) {
for (const fileCallback of fileWatcherCallbacks.get(filePath)) {
fileCallback(filePath);
@ -460,7 +462,7 @@ namespace ts {
}
function getCanonicalPath(path: string): string {
return useCaseSensitiveFileNames ? path.toLowerCase() : path;
return useCaseSensitiveFileNames ? path : path.toLowerCase();
}
function readDirectory(path: string, extension?: string, exclude?: string[]): string[] {

View file

@ -170,6 +170,7 @@ namespace ts {
SymbolKeyword,
TypeKeyword,
FromKeyword,
GlobalKeyword,
OfKeyword, // LastKeyword and LastToken
// Parse tree nodes
@ -389,10 +390,11 @@ namespace ts {
ContainsThis = 1 << 18, // Interface contains references to "this"
HasImplicitReturn = 1 << 19, // If function implicitly returns on one of codepaths (initialized by binding)
HasExplicitReturn = 1 << 20, // If function has explicit reachable return on one of codepaths (initialized by binding)
HasClassExtends = 1 << 21, // If the file has a non-ambient class with an extends clause in ES5 or lower (initialized by binding)
HasDecorators = 1 << 22, // If the file has decorators (initialized by binding)
HasParamDecorators = 1 << 23, // If the file has parameter decorators (initialized by binding)
HasAsyncFunctions = 1 << 24, // If the file has async functions (initialized by binding)
GlobalAugmentation = 1 << 21, // Set if module declaration is an augmentation for the global scope
HasClassExtends = 1 << 22, // If the file has a non-ambient class with an extends clause in ES5 or lower (initialized by binding)
HasDecorators = 1 << 23, // If the file has decorators (initialized by binding)
HasParamDecorators = 1 << 24, // If the file has parameter decorators (initialized by binding)
HasAsyncFunctions = 1 << 25, // If the file has async functions (initialized by binding)
Modifier = Export | Ambient | Public | Private | Protected | Static | Abstract | Default | Async,
AccessibilityModifier = Public | Private | Protected,
@ -1583,6 +1585,7 @@ namespace ts {
// Content of this fiels should never be used directly - use getResolvedModuleFileName/setResolvedModuleFileName functions instead
/* @internal */ resolvedModules: Map<ResolvedModule>;
/* @internal */ imports: LiteralExpression[];
/* @internal */ moduleAugmentations: LiteralExpression[];
}
export interface ScriptReferenceHost {
@ -1917,7 +1920,7 @@ namespace ts {
isOptionalParameter(node: ParameterDeclaration): boolean;
moduleExportsSomeValue(moduleReferenceExpression: Expression): boolean;
isArgumentsLocalBinding(node: Identifier): boolean;
getExternalModuleFileFromDeclaration(declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration): SourceFile;
getExternalModuleFileFromDeclaration(declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration): SourceFile;
}
export const enum SymbolFlags {

View file

@ -251,6 +251,31 @@ namespace ts {
isCatchClauseVariableDeclaration(declaration);
}
export function isAmbientModule(node: Node): boolean {
return node && node.kind === SyntaxKind.ModuleDeclaration &&
((<ModuleDeclaration>node).name.kind === SyntaxKind.StringLiteral || isGlobalScopeAugmentation(<ModuleDeclaration>node));
}
export function isGlobalScopeAugmentation(module: ModuleDeclaration): boolean {
return !!(module.flags & NodeFlags.GlobalAugmentation);
}
export function isExternalModuleAugmentation(node: Node): boolean {
// external module augmentation is a ambient module declaration that is either:
// - defined in the top level scope and source file is an external module
// - defined inside ambient module declaration located in the top level scope and source file not an external module
if (!node || !isAmbientModule(node)) {
return false;
}
switch (node.parent.kind) {
case SyntaxKind.SourceFile:
return isExternalModule(<SourceFile>node.parent);
case SyntaxKind.ModuleBlock:
return isAmbientModule(node.parent.parent) && !isExternalModule(<SourceFile>node.parent.parent.parent);
}
return false;
}
// Gets the nearest enclosing block scope container that has the provided node
// as a descendant, that is not the provided node.
export function getEnclosingBlockScopeContainer(node: Node): Node {
@ -343,6 +368,7 @@ namespace ts {
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.FunctionExpression:
case SyntaxKind.MethodDeclaration:
case SyntaxKind.TypeAliasDeclaration:
errorNode = (<Declaration>node).name;
break;
}
@ -1115,6 +1141,9 @@ namespace ts {
if (node.kind === SyntaxKind.ExportDeclaration) {
return (<ExportDeclaration>node).moduleSpecifier;
}
if (node.kind === SyntaxKind.ModuleDeclaration && (<ModuleDeclaration>node).name.kind === SyntaxKind.StringLiteral) {
return (<ModuleDeclaration>node).name;
}
}
export function hasQuestionToken(node: Node) {

View file

@ -1002,7 +1002,9 @@ namespace ts.server {
info.setFormatOptions(this.getFormatCodeOptions());
this.filenameToScriptInfo[fileName] = info;
if (!info.isOpen) {
info.fileWatcher = this.host.watchFile(<Path>fileName, _ => { this.watchedFileChanged(fileName); });
info.fileWatcher = this.host.watchFile(
toPath(fileName, fileName, createGetCanonicalFileName(sys.useCaseSensitiveFileNames)),
_ => { this.watchedFileChanged(fileName); });
}
}
}
@ -1215,7 +1217,9 @@ namespace ts.server {
}
}
project.finishGraph();
project.projectFileWatcher = this.host.watchFile(<Path>configFilename, _ => this.watchedProjectConfigFileChanged(project));
project.projectFileWatcher = this.host.watchFile(
toPath(configFilename, configFilename, createGetCanonicalFileName(sys.useCaseSensitiveFileNames)),
_ => this.watchedProjectConfigFileChanged(project));
this.log("Add recursive watcher for: " + ts.getDirectoryPath(configFilename));
project.directoryWatcher = this.host.watchDirectory(
ts.getDirectoryPath(configFilename),

View file

@ -387,7 +387,7 @@ namespace ts.NavigationBar {
function getModuleName(moduleDeclaration: ModuleDeclaration): string {
// We want to maintain quotation marks.
if (moduleDeclaration.name.kind === SyntaxKind.StringLiteral) {
if (isAmbientModule(moduleDeclaration)) {
return getTextOfNode(moduleDeclaration.name);
}

View file

@ -811,6 +811,7 @@ namespace ts {
public nameTable: Map<string>;
public resolvedModules: Map<ResolvedModule>;
public imports: LiteralExpression[];
public moduleAugmentations: LiteralExpression[];
private namedDeclarations: Map<Declaration[]>;
constructor(kind: SyntaxKind, pos: number, end: number) {
@ -6028,6 +6029,10 @@ namespace ts {
*/
function getPropertySymbolsFromBaseTypes(symbol: Symbol, propertyName: string, result: Symbol[],
previousIterationSymbolsCache: SymbolTable): void {
if (!symbol) {
return;
}
// If the current symbol is the same as the previous-iteration symbol, we can just return the symbol that has already been visited
// This is particularly important for the following cases, so that we do not infinitely visit the same symbol.
// For example:
@ -6043,7 +6048,7 @@ namespace ts {
return;
}
if (symbol && symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface)) {
if (symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface)) {
forEach(symbol.getDeclarations(), declaration => {
if (declaration.kind === SyntaxKind.ClassDeclaration) {
getPropertySymbolFromTypeReference(getClassExtendsHeritageClauseElement(<ClassDeclaration>declaration));
@ -6292,7 +6297,7 @@ namespace ts {
return SemanticMeaning.Value | SemanticMeaning.Type;
case SyntaxKind.ModuleDeclaration:
if ((<ModuleDeclaration>node).name.kind === SyntaxKind.StringLiteral) {
if (isAmbientModule(<ModuleDeclaration>node)) {
return SemanticMeaning.Namespace | SemanticMeaning.Value;
}
else if (getModuleInstanceState(node) === ModuleInstanceState.Instantiated) {
@ -6823,7 +6828,8 @@ namespace ts {
function classifyDisabledMergeCode(text: string, start: number, end: number) {
// Classify the line that the ======= marker is on as a comment. Then just lex
// all further tokens and add them to the result.
for (var i = start; i < end; i++) {
let i: number;
for (i = start; i < end; i++) {
if (isLineBreak(text.charCodeAt(i))) {
break;
}

View file

@ -1,5 +1,5 @@
tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts(2,3): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts(3,11): error TS2304: Cannot find name 'foo'.
tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts(3,11): error TS2663: Cannot find name 'foo'. Did you mean the instance member 'this.foo'?
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts (2 errors) ====
@ -9,6 +9,6 @@ tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts(3,11): err
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
yield(foo);
~~~
!!! error TS2304: Cannot find name 'foo'.
!!! error TS2663: Cannot find name 'foo'. Did you mean the instance member 'this.foo'?
}
}

View file

@ -0,0 +1,13 @@
tests/cases/compiler/accessInstanceMemberFromStaticMethod01.ts(5,17): error TS2662: Cannot find name 'foo'. Did you mean the static member 'C.foo'?
==== tests/cases/compiler/accessInstanceMemberFromStaticMethod01.ts (1 errors) ====
class C {
static foo: string;
bar() {
let k = foo;
~~~
!!! error TS2662: Cannot find name 'foo'. Did you mean the static member 'C.foo'?
}
}

View file

@ -0,0 +1,18 @@
//// [accessInstanceMemberFromStaticMethod01.ts]
class C {
static foo: string;
bar() {
let k = foo;
}
}
//// [accessInstanceMemberFromStaticMethod01.js]
var C = (function () {
function C() {
}
C.prototype.bar = function () {
var k = foo;
};
return C;
}());

View file

@ -0,0 +1,13 @@
tests/cases/compiler/accessStaticMemberFromInstanceMethod01.ts(5,17): error TS2304: Cannot find name 'foo'.
==== tests/cases/compiler/accessStaticMemberFromInstanceMethod01.ts (1 errors) ====
class C {
foo: string;
static bar() {
let k = foo;
~~~
!!! error TS2304: Cannot find name 'foo'.
}
}

View file

@ -0,0 +1,18 @@
//// [accessStaticMemberFromInstanceMethod01.ts]
class C {
foo: string;
static bar() {
let k = foo;
}
}
//// [accessStaticMemberFromInstanceMethod01.js]
var C = (function () {
function C() {
}
C.bar = function () {
var k = foo;
};
return C;
}());

View file

@ -1,5 +1,4 @@
tests/cases/compiler/aliasAssignments_1.ts(3,1): error TS2322: Type 'number' is not assignable to type 'typeof "tests/cases/compiler/aliasAssignments_moduleA"'.
Property 'someClass' is missing in type 'Number'.
tests/cases/compiler/aliasAssignments_1.ts(5,1): error TS2322: Type 'typeof "tests/cases/compiler/aliasAssignments_moduleA"' is not assignable to type 'number'.
@ -9,7 +8,6 @@ tests/cases/compiler/aliasAssignments_1.ts(5,1): error TS2322: Type 'typeof "tes
x = 1; // Should be error
~
!!! error TS2322: Type 'number' is not assignable to type 'typeof "tests/cases/compiler/aliasAssignments_moduleA"'.
!!! error TS2322: Property 'someClass' is missing in type 'Number'.
var y = 1;
y = moduleA; // should be error
~

View file

@ -1,4 +1,4 @@
tests/cases/compiler/ambientExternalModuleInAnotherExternalModule.ts(5,16): error TS2435: Ambient modules cannot be nested in other modules or namespaces.
tests/cases/compiler/ambientExternalModuleInAnotherExternalModule.ts(5,16): error TS2664: Invalid module name in augmentation, module 'ext' cannot be found.
tests/cases/compiler/ambientExternalModuleInAnotherExternalModule.ts(10,22): error TS2307: Cannot find module 'ext'.
@ -9,7 +9,7 @@ tests/cases/compiler/ambientExternalModuleInAnotherExternalModule.ts(10,22): err
declare module "ext" {
~~~~~
!!! error TS2435: Ambient modules cannot be nested in other modules or namespaces.
!!! error TS2664: Invalid module name in augmentation, module 'ext' cannot be found.
export class C { }
}

View file

@ -1,9 +1,12 @@
tests/cases/conformance/ambient/ambientExternalModuleInsideNonAmbient.ts(2,5): error TS2668: 'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible.
tests/cases/conformance/ambient/ambientExternalModuleInsideNonAmbient.ts(2,27): error TS2435: Ambient modules cannot be nested in other modules or namespaces.
==== tests/cases/conformance/ambient/ambientExternalModuleInsideNonAmbient.ts (1 errors) ====
==== tests/cases/conformance/ambient/ambientExternalModuleInsideNonAmbient.ts (2 errors) ====
module M {
export declare module "M" { }
~~~~~~
!!! error TS2668: 'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible.
~~~
!!! error TS2435: Ambient modules cannot be nested in other modules or namespaces.
}

View file

@ -1,7 +1,10 @@
tests/cases/conformance/ambient/ambientExternalModuleInsideNonAmbientExternalModule.ts(1,23): error TS2435: Ambient modules cannot be nested in other modules or namespaces.
tests/cases/conformance/ambient/ambientExternalModuleInsideNonAmbientExternalModule.ts(1,1): error TS2668: 'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible.
tests/cases/conformance/ambient/ambientExternalModuleInsideNonAmbientExternalModule.ts(1,23): error TS2664: Invalid module name in augmentation, module 'M' cannot be found.
==== tests/cases/conformance/ambient/ambientExternalModuleInsideNonAmbientExternalModule.ts (1 errors) ====
==== tests/cases/conformance/ambient/ambientExternalModuleInsideNonAmbientExternalModule.ts (2 errors) ====
export declare module "M" { }
~~~~~~
!!! error TS2668: 'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible.
~~~
!!! error TS2435: Ambient modules cannot be nested in other modules or namespaces.
!!! error TS2664: Invalid module name in augmentation, module 'M' cannot be found.

View file

@ -1,5 +1,4 @@
tests/cases/compiler/argumentsBindsToFunctionScopeArgumentList.ts(3,5): error TS2322: Type 'number' is not assignable to type 'IArguments'.
Property 'length' is missing in type 'Number'.
==== tests/cases/compiler/argumentsBindsToFunctionScopeArgumentList.ts (1 errors) ====
@ -8,5 +7,4 @@ tests/cases/compiler/argumentsBindsToFunctionScopeArgumentList.ts(3,5): error TS
arguments = 10; /// This shouldnt be of type number and result in error.
~~~~~~~~~
!!! error TS2322: Type 'number' is not assignable to type 'IArguments'.
!!! error TS2322: Property 'length' is missing in type 'Number'.
}

View file

@ -26,10 +26,13 @@ tests/cases/compiler/arrayAssignmentTest1.ts(70,1): error TS2322: Type 'C3[]' is
Property 'C2M1' is missing in type 'C3'.
tests/cases/compiler/arrayAssignmentTest1.ts(75,1): error TS2322: Type 'C2[]' is not assignable to type 'C3[]'.
Type 'C2' is not assignable to type 'C3'.
Property 'CM3M1' is missing in type 'C2'.
tests/cases/compiler/arrayAssignmentTest1.ts(76,1): error TS2322: Type 'C1[]' is not assignable to type 'C3[]'.
Type 'C1' is not assignable to type 'C3'.
Property 'CM3M1' is missing in type 'C1'.
tests/cases/compiler/arrayAssignmentTest1.ts(77,1): error TS2322: Type 'I1[]' is not assignable to type 'C3[]'.
Type 'I1' is not assignable to type 'C3'.
Property 'CM3M1' is missing in type 'I1'.
tests/cases/compiler/arrayAssignmentTest1.ts(79,1): error TS2322: Type '() => C1' is not assignable to type 'any[]'.
Property 'push' is missing in type '() => C1'.
tests/cases/compiler/arrayAssignmentTest1.ts(80,1): error TS2322: Type '{ one: number; }' is not assignable to type 'any[]'.
@ -159,14 +162,17 @@ tests/cases/compiler/arrayAssignmentTest1.ts(85,1): error TS2322: Type 'I1' is n
~~~~~~
!!! error TS2322: Type 'C2[]' is not assignable to type 'C3[]'.
!!! error TS2322: Type 'C2' is not assignable to type 'C3'.
!!! error TS2322: Property 'CM3M1' is missing in type 'C2'.
arr_c3 = arr_c1_2; // should be an error - is
~~~~~~
!!! error TS2322: Type 'C1[]' is not assignable to type 'C3[]'.
!!! error TS2322: Type 'C1' is not assignable to type 'C3'.
!!! error TS2322: Property 'CM3M1' is missing in type 'C1'.
arr_c3 = arr_i1_2; // should be an error - is
~~~~~~
!!! error TS2322: Type 'I1[]' is not assignable to type 'C3[]'.
!!! error TS2322: Type 'I1' is not assignable to type 'C3'.
!!! error TS2322: Property 'CM3M1' is missing in type 'I1'.
arr_any = f1; // should be an error - is
~~~~~~~

View file

@ -18,7 +18,6 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error
Types of parameters 'items' and 'items' are incompatible.
Type 'number | string' is not assignable to type 'Number'.
Type 'string' is not assignable to type 'Number'.
Property 'toFixed' is missing in type 'String'.
==== tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts (6 errors) ====
@ -82,5 +81,4 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error
!!! error TS2322: Types of parameters 'items' and 'items' are incompatible.
!!! error TS2322: Type 'number | string' is not assignable to type 'Number'.
!!! error TS2322: Type 'string' is not assignable to type 'Number'.
!!! error TS2322: Property 'toFixed' is missing in type 'String'.

View file

@ -4,7 +4,6 @@ tests/cases/compiler/arraySigChecking.ts(18,5): error TS2322: Type 'void[]' is n
tests/cases/compiler/arraySigChecking.ts(22,1): error TS2322: Type 'number[][]' is not assignable to type 'number[][][]'.
Type 'number[]' is not assignable to type 'number[][]'.
Type 'number' is not assignable to type 'number[]'.
Property 'length' is missing in type 'Number'.
==== tests/cases/compiler/arraySigChecking.ts (3 errors) ====
@ -39,7 +38,6 @@ tests/cases/compiler/arraySigChecking.ts(22,1): error TS2322: Type 'number[][]'
!!! error TS2322: Type 'number[][]' is not assignable to type 'number[][][]'.
!!! error TS2322: Type 'number[]' is not assignable to type 'number[][]'.
!!! error TS2322: Type 'number' is not assignable to type 'number[]'.
!!! error TS2322: Property 'length' is missing in type 'Number'.
function isEmpty(l: { length: number }) {
return l.length === 0;

View file

@ -1,5 +1,4 @@
tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts(6,5): error TS2322: Type 'number' is not assignable to type 'ArrayConstructor'.
Property 'isArray' is missing in type 'Number'.
tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts(6,22): error TS1005: '=' expected.
tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts(6,30): error TS1109: Expression expected.
tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts(7,5): error TS2322: Type 'number' is not assignable to type 'ArrayConstructor'.
@ -16,7 +15,6 @@ tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts(
var xs3: typeof Array<number>;
~~~
!!! error TS2322: Type 'number' is not assignable to type 'ArrayConstructor'.
!!! error TS2322: Property 'isArray' is missing in type 'Number'.
~
!!! error TS1005: '=' expected.
~

View file

@ -3,9 +3,7 @@ tests/cases/compiler/assignmentCompat1.ts(4,1): error TS2322: Type '{ [index: st
tests/cases/compiler/assignmentCompat1.ts(6,1): error TS2322: Type '{ [index: number]: any; }' is not assignable to type '{ one: number; }'.
Property 'one' is missing in type '{ [index: number]: any; }'.
tests/cases/compiler/assignmentCompat1.ts(8,1): error TS2322: Type 'string' is not assignable to type '{ [index: string]: any; }'.
Index signature is missing in type 'String'.
tests/cases/compiler/assignmentCompat1.ts(10,1): error TS2322: Type 'boolean' is not assignable to type '{ [index: number]: any; }'.
Index signature is missing in type 'Boolean'.
==== tests/cases/compiler/assignmentCompat1.ts (4 errors) ====
@ -25,11 +23,9 @@ tests/cases/compiler/assignmentCompat1.ts(10,1): error TS2322: Type 'boolean' is
y = "foo"; // Error
~
!!! error TS2322: Type 'string' is not assignable to type '{ [index: string]: any; }'.
!!! error TS2322: Index signature is missing in type 'String'.
z = "foo"; // OK, string has numeric indexer
z = false; // Error
~
!!! error TS2322: Type 'boolean' is not assignable to type '{ [index: number]: any; }'.
!!! error TS2322: Index signature is missing in type 'Boolean'.

View file

@ -8,6 +8,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts(53,9): error TS2322: Type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type '<T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U'.
Types of parameters 'y' and 'y' are incompatible.
Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'.
Types of parameters 'arg2' and 'arg2' are incompatible.
Type 'Base' is not assignable to type '{ foo: number; }'.
Types of property 'foo' are incompatible.
Type 'string' is not assignable to type 'number'.
==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts (2 errors) ====
@ -76,6 +80,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type '<T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U'.
!!! error TS2322: Types of parameters 'y' and 'y' are incompatible.
!!! error TS2322: Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'.
!!! error TS2322: Types of parameters 'arg2' and 'arg2' are incompatible.
!!! error TS2322: Type 'Base' is not assignable to type '{ foo: number; }'.
!!! error TS2322: Types of property 'foo' are incompatible.
!!! error TS2322: Type 'string' is not assignable to type 'number'.
var b10: <T extends Derived>(...x: T[]) => T;

View file

@ -8,6 +8,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(53,9): error TS2322: Type 'new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type 'new <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U'.
Types of parameters 'y' and 'y' are incompatible.
Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'.
Types of parameters 'arg2' and 'arg2' are incompatible.
Type 'Base' is not assignable to type '{ foo: number; }'.
Types of property 'foo' are incompatible.
Type 'string' is not assignable to type 'number'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(77,9): error TS2322: Type 'new <T>(x: (a: T) => T) => T[]' is not assignable to type '{ new (x: { new (a: number): number; new (a?: number): number; }): number[]; new (x: { new (a: boolean): boolean; new (a?: boolean): boolean; }): boolean[]; }'.
Types of parameters 'x' and 'x' are incompatible.
Type '(a: any) => any' is not assignable to type '{ new (a: number): number; new (a?: number): number; }'.
@ -15,6 +19,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(78,9): error TS2322: Type '{ new (x: { new (a: number): number; new (a?: number): number; }): number[]; new (x: { new (a: boolean): boolean; new (a?: boolean): boolean; }): boolean[]; }' is not assignable to type 'new <T>(x: (a: T) => T) => T[]'.
Types of parameters 'x' and 'x' are incompatible.
Type '{ new (a: number): number; new (a?: number): number; }' is not assignable to type '(a: any) => any'.
Type '{ new (a: number): number; new (a?: number): number; }' provides no match for the signature '(a: any): any'
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(81,9): error TS2322: Type 'new <T>(x: (a: T) => T) => any[]' is not assignable to type '{ new (x: { new <T extends Derived>(a: T): T; new <T extends Base>(a: T): T; }): any[]; new (x: { new <T extends Derived2>(a: T): T; new <T extends Base>(a: T): T; }): any[]; }'.
Types of parameters 'x' and 'x' are incompatible.
Type '(a: any) => any' is not assignable to type '{ new <T extends Derived>(a: T): T; new <T extends Base>(a: T): T; }'.
@ -22,6 +27,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(82,9): error TS2322: Type '{ new (x: { new <T extends Derived>(a: T): T; new <T extends Base>(a: T): T; }): any[]; new (x: { new <T extends Derived2>(a: T): T; new <T extends Base>(a: T): T; }): any[]; }' is not assignable to type 'new <T>(x: (a: T) => T) => any[]'.
Types of parameters 'x' and 'x' are incompatible.
Type '{ new <T extends Derived>(a: T): T; new <T extends Base>(a: T): T; }' is not assignable to type '(a: any) => any'.
Type '{ new <T extends Derived>(a: T): T; new <T extends Base>(a: T): T; }' provides no match for the signature '(a: any): any'
==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts (6 errors) ====
@ -90,6 +96,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Type 'new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type 'new <T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U'.
!!! error TS2322: Types of parameters 'y' and 'y' are incompatible.
!!! error TS2322: Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'.
!!! error TS2322: Types of parameters 'arg2' and 'arg2' are incompatible.
!!! error TS2322: Type 'Base' is not assignable to type '{ foo: number; }'.
!!! error TS2322: Types of property 'foo' are incompatible.
!!! error TS2322: Type 'string' is not assignable to type 'number'.
var b10: new <T extends Derived>(...x: T[]) => T;
@ -124,6 +134,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Type '{ new (x: { new (a: number): number; new (a?: number): number; }): number[]; new (x: { new (a: boolean): boolean; new (a?: boolean): boolean; }): boolean[]; }' is not assignable to type 'new <T>(x: (a: T) => T) => T[]'.
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322: Type '{ new (a: number): number; new (a?: number): number; }' is not assignable to type '(a: any) => any'.
!!! error TS2322: Type '{ new (a: number): number; new (a?: number): number; }' provides no match for the signature '(a: any): any'
var b17: new <T>(x: (a: T) => T) => any[];
a17 = b17; // error
@ -137,6 +148,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Type '{ new (x: { new <T extends Derived>(a: T): T; new <T extends Base>(a: T): T; }): any[]; new (x: { new <T extends Derived2>(a: T): T; new <T extends Base>(a: T): T; }): any[]; }' is not assignable to type 'new <T>(x: (a: T) => T) => any[]'.
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322: Type '{ new <T extends Derived>(a: T): T; new <T extends Base>(a: T): T; }' is not assignable to type '(a: any) => any'.
!!! error TS2322: Type '{ new <T extends Derived>(a: T): T; new <T extends Base>(a: T): T; }' provides no match for the signature '(a: any): any'
}
module WithGenericSignaturesInBaseType {

View file

@ -1,7 +1,6 @@
tests/cases/compiler/assignmentCompatability16.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ one: any[]; }'.
Types of property 'one' are incompatible.
Type 'number' is not assignable to type 'any[]'.
Property 'length' is missing in type 'Number'.
==== tests/cases/compiler/assignmentCompatability16.ts (1 errors) ====
@ -17,5 +16,4 @@ tests/cases/compiler/assignmentCompatability16.ts(9,1): error TS2322: Type 'inte
~~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ one: any[]; }'.
!!! error TS2322: Types of property 'one' are incompatible.
!!! error TS2322: Type 'number' is not assignable to type 'any[]'.
!!! error TS2322: Property 'length' is missing in type 'Number'.
!!! error TS2322: Type 'number' is not assignable to type 'any[]'.

View file

@ -1,7 +1,6 @@
tests/cases/compiler/assignmentCompatability17.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ two: any[]; }'.
Types of property 'two' are incompatible.
Type 'string' is not assignable to type 'any[]'.
Property 'push' is missing in type 'String'.
==== tests/cases/compiler/assignmentCompatability17.ts (1 errors) ====
@ -17,5 +16,4 @@ tests/cases/compiler/assignmentCompatability17.ts(9,1): error TS2322: Type 'inte
~~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ two: any[]; }'.
!!! error TS2322: Types of property 'two' are incompatible.
!!! error TS2322: Type 'string' is not assignable to type 'any[]'.
!!! error TS2322: Property 'push' is missing in type 'String'.
!!! error TS2322: Type 'string' is not assignable to type 'any[]'.

View file

@ -1,7 +1,6 @@
tests/cases/compiler/assignmentCompatability18.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ one: number[]; }'.
Types of property 'one' are incompatible.
Type 'number' is not assignable to type 'number[]'.
Property 'length' is missing in type 'Number'.
==== tests/cases/compiler/assignmentCompatability18.ts (1 errors) ====
@ -17,5 +16,4 @@ tests/cases/compiler/assignmentCompatability18.ts(9,1): error TS2322: Type 'inte
~~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ one: number[]; }'.
!!! error TS2322: Types of property 'one' are incompatible.
!!! error TS2322: Type 'number' is not assignable to type 'number[]'.
!!! error TS2322: Property 'length' is missing in type 'Number'.
!!! error TS2322: Type 'number' is not assignable to type 'number[]'.

View file

@ -1,7 +1,6 @@
tests/cases/compiler/assignmentCompatability19.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ two: number[]; }'.
Types of property 'two' are incompatible.
Type 'string' is not assignable to type 'number[]'.
Property 'push' is missing in type 'String'.
==== tests/cases/compiler/assignmentCompatability19.ts (1 errors) ====
@ -17,5 +16,4 @@ tests/cases/compiler/assignmentCompatability19.ts(9,1): error TS2322: Type 'inte
~~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ two: number[]; }'.
!!! error TS2322: Types of property 'two' are incompatible.
!!! error TS2322: Type 'string' is not assignable to type 'number[]'.
!!! error TS2322: Property 'push' is missing in type 'String'.
!!! error TS2322: Type 'string' is not assignable to type 'number[]'.

View file

@ -1,7 +1,6 @@
tests/cases/compiler/assignmentCompatability20.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ one: string[]; }'.
Types of property 'one' are incompatible.
Type 'number' is not assignable to type 'string[]'.
Property 'length' is missing in type 'Number'.
==== tests/cases/compiler/assignmentCompatability20.ts (1 errors) ====
@ -17,5 +16,4 @@ tests/cases/compiler/assignmentCompatability20.ts(9,1): error TS2322: Type 'inte
~~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ one: string[]; }'.
!!! error TS2322: Types of property 'one' are incompatible.
!!! error TS2322: Type 'number' is not assignable to type 'string[]'.
!!! error TS2322: Property 'length' is missing in type 'Number'.
!!! error TS2322: Type 'number' is not assignable to type 'string[]'.

View file

@ -1,7 +1,6 @@
tests/cases/compiler/assignmentCompatability21.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ two: string[]; }'.
Types of property 'two' are incompatible.
Type 'string' is not assignable to type 'string[]'.
Property 'push' is missing in type 'String'.
==== tests/cases/compiler/assignmentCompatability21.ts (1 errors) ====
@ -17,5 +16,4 @@ tests/cases/compiler/assignmentCompatability21.ts(9,1): error TS2322: Type 'inte
~~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ two: string[]; }'.
!!! error TS2322: Types of property 'two' are incompatible.
!!! error TS2322: Type 'string' is not assignable to type 'string[]'.
!!! error TS2322: Property 'push' is missing in type 'String'.
!!! error TS2322: Type 'string' is not assignable to type 'string[]'.

View file

@ -1,7 +1,6 @@
tests/cases/compiler/assignmentCompatability22.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ one: boolean[]; }'.
Types of property 'one' are incompatible.
Type 'number' is not assignable to type 'boolean[]'.
Property 'length' is missing in type 'Number'.
==== tests/cases/compiler/assignmentCompatability22.ts (1 errors) ====
@ -17,5 +16,4 @@ tests/cases/compiler/assignmentCompatability22.ts(9,1): error TS2322: Type 'inte
~~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ one: boolean[]; }'.
!!! error TS2322: Types of property 'one' are incompatible.
!!! error TS2322: Type 'number' is not assignable to type 'boolean[]'.
!!! error TS2322: Property 'length' is missing in type 'Number'.
!!! error TS2322: Type 'number' is not assignable to type 'boolean[]'.

View file

@ -1,7 +1,6 @@
tests/cases/compiler/assignmentCompatability23.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ two: boolean[]; }'.
Types of property 'two' are incompatible.
Type 'string' is not assignable to type 'boolean[]'.
Property 'push' is missing in type 'String'.
==== tests/cases/compiler/assignmentCompatability23.ts (1 errors) ====
@ -17,5 +16,4 @@ tests/cases/compiler/assignmentCompatability23.ts(9,1): error TS2322: Type 'inte
~~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ two: boolean[]; }'.
!!! error TS2322: Types of property 'two' are incompatible.
!!! error TS2322: Type 'string' is not assignable to type 'boolean[]'.
!!! error TS2322: Property 'push' is missing in type 'String'.
!!! error TS2322: Type 'string' is not assignable to type 'boolean[]'.

View file

@ -1,7 +1,6 @@
tests/cases/compiler/assignmentCompatability29.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ one: any[]; }'.
Types of property 'one' are incompatible.
Type 'number' is not assignable to type 'any[]'.
Property 'length' is missing in type 'Number'.
==== tests/cases/compiler/assignmentCompatability29.ts (1 errors) ====
@ -17,5 +16,4 @@ tests/cases/compiler/assignmentCompatability29.ts(9,1): error TS2322: Type 'inte
~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ one: any[]; }'.
!!! error TS2322: Types of property 'one' are incompatible.
!!! error TS2322: Type 'number' is not assignable to type 'any[]'.
!!! error TS2322: Property 'length' is missing in type 'Number'.
!!! error TS2322: Type 'number' is not assignable to type 'any[]'.

View file

@ -1,7 +1,6 @@
tests/cases/compiler/assignmentCompatability30.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ one: number[]; }'.
Types of property 'one' are incompatible.
Type 'number' is not assignable to type 'number[]'.
Property 'length' is missing in type 'Number'.
==== tests/cases/compiler/assignmentCompatability30.ts (1 errors) ====
@ -17,5 +16,4 @@ tests/cases/compiler/assignmentCompatability30.ts(9,1): error TS2322: Type 'inte
~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ one: number[]; }'.
!!! error TS2322: Types of property 'one' are incompatible.
!!! error TS2322: Type 'number' is not assignable to type 'number[]'.
!!! error TS2322: Property 'length' is missing in type 'Number'.
!!! error TS2322: Type 'number' is not assignable to type 'number[]'.

View file

@ -1,7 +1,6 @@
tests/cases/compiler/assignmentCompatability31.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ one: string[]; }'.
Types of property 'one' are incompatible.
Type 'number' is not assignable to type 'string[]'.
Property 'length' is missing in type 'Number'.
==== tests/cases/compiler/assignmentCompatability31.ts (1 errors) ====
@ -17,5 +16,4 @@ tests/cases/compiler/assignmentCompatability31.ts(9,1): error TS2322: Type 'inte
~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ one: string[]; }'.
!!! error TS2322: Types of property 'one' are incompatible.
!!! error TS2322: Type 'number' is not assignable to type 'string[]'.
!!! error TS2322: Property 'length' is missing in type 'Number'.
!!! error TS2322: Type 'number' is not assignable to type 'string[]'.

View file

@ -1,7 +1,6 @@
tests/cases/compiler/assignmentCompatability32.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ one: boolean[]; }'.
Types of property 'one' are incompatible.
Type 'number' is not assignable to type 'boolean[]'.
Property 'length' is missing in type 'Number'.
==== tests/cases/compiler/assignmentCompatability32.ts (1 errors) ====
@ -17,5 +16,4 @@ tests/cases/compiler/assignmentCompatability32.ts(9,1): error TS2322: Type 'inte
~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ one: boolean[]; }'.
!!! error TS2322: Types of property 'one' are incompatible.
!!! error TS2322: Type 'number' is not assignable to type 'boolean[]'.
!!! error TS2322: Property 'length' is missing in type 'Number'.
!!! error TS2322: Type 'number' is not assignable to type 'boolean[]'.

View file

@ -1,9 +1,7 @@
tests/cases/compiler/assignmentCompatability_checking-apply-member-off-of-function-interface.ts(10,1): error TS2322: Type 'string' is not assignable to type 'Applicable'.
Property 'apply' is missing in type 'String'.
tests/cases/compiler/assignmentCompatability_checking-apply-member-off-of-function-interface.ts(11,1): error TS2322: Type 'string[]' is not assignable to type 'Applicable'.
Property 'apply' is missing in type 'string[]'.
tests/cases/compiler/assignmentCompatability_checking-apply-member-off-of-function-interface.ts(12,1): error TS2322: Type 'number' is not assignable to type 'Applicable'.
Property 'apply' is missing in type 'Number'.
tests/cases/compiler/assignmentCompatability_checking-apply-member-off-of-function-interface.ts(13,1): error TS2322: Type '{}' is not assignable to type 'Applicable'.
Property 'apply' is missing in type '{}'.
tests/cases/compiler/assignmentCompatability_checking-apply-member-off-of-function-interface.ts(22,4): error TS2345: Argument of type 'string' is not assignable to parameter of type 'Applicable'.
@ -26,7 +24,6 @@ tests/cases/compiler/assignmentCompatability_checking-apply-member-off-of-functi
x = '';
~
!!! error TS2322: Type 'string' is not assignable to type 'Applicable'.
!!! error TS2322: Property 'apply' is missing in type 'String'.
x = [''];
~
!!! error TS2322: Type 'string[]' is not assignable to type 'Applicable'.
@ -34,7 +31,6 @@ tests/cases/compiler/assignmentCompatability_checking-apply-member-off-of-functi
x = 4;
~
!!! error TS2322: Type 'number' is not assignable to type 'Applicable'.
!!! error TS2322: Property 'apply' is missing in type 'Number'.
x = {};
~
!!! error TS2322: Type '{}' is not assignable to type 'Applicable'.

View file

@ -1,9 +1,7 @@
tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.ts(10,1): error TS2322: Type 'string' is not assignable to type 'Callable'.
Property 'call' is missing in type 'String'.
tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.ts(11,1): error TS2322: Type 'string[]' is not assignable to type 'Callable'.
Property 'call' is missing in type 'string[]'.
tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.ts(12,1): error TS2322: Type 'number' is not assignable to type 'Callable'.
Property 'call' is missing in type 'Number'.
tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.ts(13,1): error TS2322: Type '{}' is not assignable to type 'Callable'.
Property 'call' is missing in type '{}'.
tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.ts(22,4): error TS2345: Argument of type 'string' is not assignable to parameter of type 'Callable'.
@ -26,7 +24,6 @@ tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-functio
x = '';
~
!!! error TS2322: Type 'string' is not assignable to type 'Callable'.
!!! error TS2322: Property 'call' is missing in type 'String'.
x = [''];
~
!!! error TS2322: Type 'string[]' is not assignable to type 'Callable'.
@ -34,7 +31,6 @@ tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-functio
x = 4;
~
!!! error TS2322: Type 'number' is not assignable to type 'Callable'.
!!! error TS2322: Property 'call' is missing in type 'Number'.
x = {};
~
!!! error TS2322: Type '{}' is not assignable to type 'Callable'.

View file

@ -1,11 +1,5 @@
tests/cases/compiler/booleanAssignment.ts(2,1): error TS2322: Type 'number' is not assignable to type 'Boolean'.
Types of property 'valueOf' are incompatible.
Type '() => number' is not assignable to type '() => boolean'.
Type 'number' is not assignable to type 'boolean'.
tests/cases/compiler/booleanAssignment.ts(3,1): error TS2322: Type 'string' is not assignable to type 'Boolean'.
Types of property 'valueOf' are incompatible.
Type '() => string' is not assignable to type '() => boolean'.
Type 'string' is not assignable to type 'boolean'.
tests/cases/compiler/booleanAssignment.ts(4,1): error TS2322: Type '{}' is not assignable to type 'Boolean'.
Types of property 'valueOf' are incompatible.
Type '() => Object' is not assignable to type '() => boolean'.
@ -17,15 +11,9 @@ tests/cases/compiler/booleanAssignment.ts(4,1): error TS2322: Type '{}' is not a
b = 1; // Error
~
!!! error TS2322: Type 'number' is not assignable to type 'Boolean'.
!!! error TS2322: Types of property 'valueOf' are incompatible.
!!! error TS2322: Type '() => number' is not assignable to type '() => boolean'.
!!! error TS2322: Type 'number' is not assignable to type 'boolean'.
b = "a"; // Error
~
!!! error TS2322: Type 'string' is not assignable to type 'Boolean'.
!!! error TS2322: Types of property 'valueOf' are incompatible.
!!! error TS2322: Type '() => string' is not assignable to type '() => boolean'.
!!! error TS2322: Type 'string' is not assignable to type 'boolean'.
b = {}; // Error
~
!!! error TS2322: Type '{}' is not assignable to type 'Boolean'.

View file

@ -0,0 +1,35 @@
//// [capturedLetConstInLoop11.ts]
for (;;) {
let x = 1;
() => x;
}
function foo() {
for (;;) {
const a = 0;
switch(a) {
case 0: return () => a;
}
}
}
//// [capturedLetConstInLoop11.js]
var _loop_1 = function() {
var x = 1;
(function () { return x; });
};
for (;;) {
_loop_1();
}
function foo() {
var _loop_2 = function() {
var a = 0;
switch (a) {
case 0: return { value: function () { return a; } };
}
};
for (;;) {
var state_2 = _loop_2();
if (typeof state_2 === "object") return state_2.value
}
}

View file

@ -0,0 +1,24 @@
=== tests/cases/compiler/capturedLetConstInLoop11.ts ===
for (;;) {
let x = 1;
>x : Symbol(x, Decl(capturedLetConstInLoop11.ts, 1, 7))
() => x;
>x : Symbol(x, Decl(capturedLetConstInLoop11.ts, 1, 7))
}
function foo() {
>foo : Symbol(foo, Decl(capturedLetConstInLoop11.ts, 3, 1))
for (;;) {
const a = 0;
>a : Symbol(a, Decl(capturedLetConstInLoop11.ts, 7, 13))
switch(a) {
>a : Symbol(a, Decl(capturedLetConstInLoop11.ts, 7, 13))
case 0: return () => a;
>a : Symbol(a, Decl(capturedLetConstInLoop11.ts, 7, 13))
}
}
}

View file

@ -0,0 +1,29 @@
=== tests/cases/compiler/capturedLetConstInLoop11.ts ===
for (;;) {
let x = 1;
>x : number
>1 : number
() => x;
>() => x : () => number
>x : number
}
function foo() {
>foo : () => () => number
for (;;) {
const a = 0;
>a : number
>0 : number
switch(a) {
>a : number
case 0: return () => a;
>0 : number
>() => a : () => number
>a : number
}
}
}

View file

@ -0,0 +1,28 @@
//// [capturedLetConstInLoop11_ES6.ts]
for (;;) {
let x = 1;
() => x;
}
function foo() {
for (;;) {
const a = 0;
switch(a) {
case 0: return () => a;
}
}
}
//// [capturedLetConstInLoop11_ES6.js]
for (;;) {
let x = 1;
(() => x);
}
function foo() {
for (;;) {
const a = 0;
switch (a) {
case 0: return () => a;
}
}
}

View file

@ -0,0 +1,24 @@
=== tests/cases/compiler/capturedLetConstInLoop11_ES6.ts ===
for (;;) {
let x = 1;
>x : Symbol(x, Decl(capturedLetConstInLoop11_ES6.ts, 1, 7))
() => x;
>x : Symbol(x, Decl(capturedLetConstInLoop11_ES6.ts, 1, 7))
}
function foo() {
>foo : Symbol(foo, Decl(capturedLetConstInLoop11_ES6.ts, 3, 1))
for (;;) {
const a = 0;
>a : Symbol(a, Decl(capturedLetConstInLoop11_ES6.ts, 7, 13))
switch(a) {
>a : Symbol(a, Decl(capturedLetConstInLoop11_ES6.ts, 7, 13))
case 0: return () => a;
>a : Symbol(a, Decl(capturedLetConstInLoop11_ES6.ts, 7, 13))
}
}
}

View file

@ -0,0 +1,29 @@
=== tests/cases/compiler/capturedLetConstInLoop11_ES6.ts ===
for (;;) {
let x = 1;
>x : number
>1 : number
() => x;
>() => x : () => number
>x : number
}
function foo() {
>foo : () => () => number
for (;;) {
const a = 0;
>a : number
>0 : number
switch(a) {
>a : number
case 0: return () => a;
>0 : number
>() => a : () => number
>a : number
}
}
}

View file

@ -2,7 +2,6 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmen
tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentLHSCannotBeAssigned.ts(8,1): error TS2322: Type 'string' is not assignable to type 'number'.
tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentLHSCannotBeAssigned.ts(11,1): error TS2322: Type 'string' is not assignable to type 'E'.
tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentLHSCannotBeAssigned.ts(14,1): error TS2322: Type 'string' is not assignable to type '{ a: string; }'.
Property 'a' is missing in type 'String'.
tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentLHSCannotBeAssigned.ts(17,1): error TS2322: Type 'string' is not assignable to type 'void'.
@ -29,7 +28,6 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmen
x4 += '';
~~
!!! error TS2322: Type 'string' is not assignable to type '{ a: string; }'.
!!! error TS2322: Property 'a' is missing in type 'String'.
var x5: void;
x5 += '';

View file

@ -1,5 +1,4 @@
tests/cases/compiler/constructorReturnsInvalidType.ts(3,16): error TS2322: Type 'number' is not assignable to type 'X'.
Property 'foo' is missing in type 'Number'.
tests/cases/compiler/constructorReturnsInvalidType.ts(3,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class
@ -9,7 +8,6 @@ tests/cases/compiler/constructorReturnsInvalidType.ts(3,16): error TS2409: Retur
return 1;
~
!!! error TS2322: Type 'number' is not assignable to type 'X'.
!!! error TS2322: Property 'foo' is missing in type 'Number'.
~
!!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class
}

View file

@ -1,5 +1,4 @@
tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts(12,16): error TS2322: Type 'number' is not assignable to type 'D'.
Property 'x' is missing in type 'Number'.
tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts(12,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class
tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts(26,16): error TS2322: Type '{ x: number; }' is not assignable to type 'F<T>'.
Types of property 'x' are incompatible.
@ -22,7 +21,6 @@ tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignabl
return 1; // error
~
!!! error TS2322: Type 'number' is not assignable to type 'D'.
!!! error TS2322: Property 'x' is missing in type 'Number'.
~
!!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class
}

View file

@ -1,7 +1,6 @@
tests/cases/compiler/contextualTyping21.ts(1,36): error TS2322: Type '({ id: number; } | number)[]' is not assignable to type '{ id: number; }[]'.
Type '{ id: number; } | number' is not assignable to type '{ id: number; }'.
Type 'number' is not assignable to type '{ id: number; }'.
Property 'id' is missing in type 'Number'.
==== tests/cases/compiler/contextualTyping21.ts (1 errors) ====
@ -9,5 +8,4 @@ tests/cases/compiler/contextualTyping21.ts(1,36): error TS2322: Type '({ id: num
~~~
!!! error TS2322: Type '({ id: number; } | number)[]' is not assignable to type '{ id: number; }[]'.
!!! error TS2322: Type '{ id: number; } | number' is not assignable to type '{ id: number; }'.
!!! error TS2322: Type 'number' is not assignable to type '{ id: number; }'.
!!! error TS2322: Property 'id' is missing in type 'Number'.
!!! error TS2322: Type 'number' is not assignable to type '{ id: number; }'.

View file

@ -1,6 +1,7 @@
tests/cases/compiler/contextualTyping33.ts(1,66): error TS2345: Argument of type '((() => number) | (() => string))[]' is not assignable to parameter of type '{ (): number; (i: number): number; }[]'.
Type '(() => number) | (() => string)' is not assignable to type '{ (): number; (i: number): number; }'.
Type '() => string' is not assignable to type '{ (): number; (i: number): number; }'.
Type 'string' is not assignable to type 'number'.
==== tests/cases/compiler/contextualTyping33.ts (1 errors) ====
@ -8,4 +9,5 @@ tests/cases/compiler/contextualTyping33.ts(1,66): error TS2345: Argument of type
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '((() => number) | (() => string))[]' is not assignable to parameter of type '{ (): number; (i: number): number; }[]'.
!!! error TS2345: Type '(() => number) | (() => string)' is not assignable to type '{ (): number; (i: number): number; }'.
!!! error TS2345: Type '() => string' is not assignable to type '{ (): number; (i: number): number; }'.
!!! error TS2345: Type '() => string' is not assignable to type '{ (): number; (i: number): number; }'.
!!! error TS2345: Type 'string' is not assignable to type 'number'.

View file

@ -2,7 +2,6 @@ tests/cases/compiler/contextualTypingOfArrayLiterals1.ts(5,5): error TS2322: Typ
Index signatures are incompatible.
Type 'Date | number' is not assignable to type 'Date'.
Type 'number' is not assignable to type 'Date'.
Property 'toDateString' is missing in type 'Number'.
==== tests/cases/compiler/contextualTypingOfArrayLiterals1.ts (1 errors) ====
@ -16,7 +15,6 @@ tests/cases/compiler/contextualTypingOfArrayLiterals1.ts(5,5): error TS2322: Typ
!!! error TS2322: Index signatures are incompatible.
!!! error TS2322: Type 'Date | number' is not assignable to type 'Date'.
!!! error TS2322: Type 'number' is not assignable to type 'Date'.
!!! error TS2322: Property 'toDateString' is missing in type 'Number'.
var r2 = x3[1];
r2.getDate();

View file

@ -2,7 +2,6 @@ tests/cases/compiler/contextualTypingOfConditionalExpression2.ts(11,5): error TS
Type '(b: number) => void' is not assignable to type '(a: A) => void'.
Types of parameters 'b' and 'a' are incompatible.
Type 'number' is not assignable to type 'A'.
Property 'foo' is missing in type 'Number'.
==== tests/cases/compiler/contextualTypingOfConditionalExpression2.ts (1 errors) ====
@ -22,5 +21,4 @@ tests/cases/compiler/contextualTypingOfConditionalExpression2.ts(11,5): error TS
!!! error TS2322: Type '(b: number) => void' is not assignable to type '(a: A) => void'.
!!! error TS2322: Types of parameters 'b' and 'a' are incompatible.
!!! error TS2322: Type 'number' is not assignable to type 'A'.
!!! error TS2322: Property 'foo' is missing in type 'Number'.

View file

@ -1,6 +1,5 @@
tests/cases/compiler/contextualTypingOfGenericFunctionTypedArguments1.ts(16,32): error TS2345: Argument of type '(x: number) => string' is not assignable to parameter of type '(x: number) => Date'.
Type 'string' is not assignable to type 'Date'.
Property 'toDateString' is missing in type 'String'.
tests/cases/compiler/contextualTypingOfGenericFunctionTypedArguments1.ts(17,32): error TS2345: Argument of type '(x: number) => string' is not assignable to parameter of type '(x: number) => Date'.
Type 'string' is not assignable to type 'Date'.
@ -25,7 +24,6 @@ tests/cases/compiler/contextualTypingOfGenericFunctionTypedArguments1.ts(17,32):
~
!!! error TS2345: Argument of type '(x: number) => string' is not assignable to parameter of type '(x: number) => Date'.
!!! error TS2345: Type 'string' is not assignable to type 'Date'.
!!! error TS2345: Property 'toDateString' is missing in type 'String'.
var r6 = _.forEach<number>(c2, (x) => { return x.toFixed() });
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '(x: number) => string' is not assignable to parameter of type '(x: number) => Date'.

View file

@ -0,0 +1,15 @@
tests/cases/compiler/declarationEmit_UnknownImport.ts(2,1): error TS2304: Cannot find name 'SomeNonExistingName'.
tests/cases/compiler/declarationEmit_UnknownImport.ts(2,14): error TS2503: Cannot find namespace 'SomeNonExistingName'.
tests/cases/compiler/declarationEmit_UnknownImport.ts(2,14): error TS4000: Import declaration 'Foo' is using private name 'SomeNonExistingName'.
==== tests/cases/compiler/declarationEmit_UnknownImport.ts (3 errors) ====
import Foo = SomeNonExistingName
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2304: Cannot find name 'SomeNonExistingName'.
~~~~~~~~~~~~~~~~~~~
!!! error TS2503: Cannot find namespace 'SomeNonExistingName'.
~~~~~~~~~~~~~~~~~~~
!!! error TS4000: Import declaration 'Foo' is using private name 'SomeNonExistingName'.
export {Foo}

View file

@ -0,0 +1,7 @@
//// [declarationEmit_UnknownImport.ts]
import Foo = SomeNonExistingName
export {Foo}
//// [declarationEmit_UnknownImport.js]
"use strict";

View file

@ -0,0 +1,21 @@
tests/cases/compiler/declarationEmit_UnknownImport2.ts(2,1): error TS2304: Cannot find name 'From'.
tests/cases/compiler/declarationEmit_UnknownImport2.ts(2,12): error TS1005: '=' expected.
tests/cases/compiler/declarationEmit_UnknownImport2.ts(2,12): error TS2503: Cannot find namespace 'From'.
tests/cases/compiler/declarationEmit_UnknownImport2.ts(2,12): error TS4000: Import declaration 'Foo' is using private name 'From'.
tests/cases/compiler/declarationEmit_UnknownImport2.ts(2,17): error TS1005: ';' expected.
==== tests/cases/compiler/declarationEmit_UnknownImport2.ts (5 errors) ====
import Foo From './Foo'; // Syntax error
~~~~~~~~~~~~~~~
!!! error TS2304: Cannot find name 'From'.
~~~~
!!! error TS1005: '=' expected.
~~~~
!!! error TS2503: Cannot find namespace 'From'.
~~~~
!!! error TS4000: Import declaration 'Foo' is using private name 'From'.
~~~~~~~
!!! error TS1005: ';' expected.
export default Foo

View file

@ -0,0 +1,8 @@
//// [declarationEmit_UnknownImport2.ts]
import Foo From './Foo'; // Syntax error
export default Foo
//// [declarationEmit_UnknownImport2.js]
"use strict";
'./Foo'; // Syntax error

View file

@ -5,7 +5,6 @@ tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAss
Types of property '1' are incompatible.
Type 'number' is not assignable to type 'boolean'.
tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(17,6): error TS2322: Type 'string' is not assignable to type 'Number'.
Property 'toFixed' is missing in type 'String'.
tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(22,5): error TS2322: Type 'number[]' is not assignable to type '[number, number]'.
Property '0' is missing in type 'number[]'.
tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(23,5): error TS2322: Type 'number[]' is not assignable to type '[string, string]'.
@ -43,7 +42,6 @@ tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAss
var [b3 = "string", b4, b5] = bar(); // Error
~~
!!! error TS2322: Type 'string' is not assignable to type 'Number'.
!!! error TS2322: Property 'toFixed' is missing in type 'String'.
// V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V,
// S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E.

View file

@ -8,7 +8,6 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(
Type 'number | string[][] | string' is not assignable to type 'number | string[][]'.
Type 'string' is not assignable to type 'number | string[][]'.
Type 'string' is not assignable to type 'string[][]'.
Property 'push' is missing in type 'String'.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(16,8): error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(16,16): error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(23,14): error TS2345: Argument of type '{ x: string; y: boolean; }' is not assignable to parameter of type '{ x: number; y: any; }'.
@ -34,7 +33,6 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(39,4): error TS2345: Argument of type '[number, number, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]]]'.
Types of property '2' are incompatible.
Type 'boolean' is not assignable to type '[[any]]'.
Property '0' is missing in type 'Boolean'.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(40,4): error TS2345: Argument of type '[number, number, [[string]]]' is not assignable to parameter of type '[any, any, [[number]]]'.
Types of property '2' are incompatible.
Type '[[string]]' is not assignable to type '[[number]]'.
@ -78,7 +76,6 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(
!!! error TS2345: Type 'number | string[][] | string' is not assignable to type 'number | string[][]'.
!!! error TS2345: Type 'string' is not assignable to type 'number | string[][]'.
!!! error TS2345: Type 'string' is not assignable to type 'string[][]'.
!!! error TS2345: Property 'push' is missing in type 'String'.
// If the declaration includes an initializer expression (which is permitted only
@ -146,7 +143,6 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(
!!! error TS2345: Argument of type '[number, number, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]]]'.
!!! error TS2345: Types of property '2' are incompatible.
!!! error TS2345: Type 'boolean' is not assignable to type '[[any]]'.
!!! error TS2345: Property '0' is missing in type 'Boolean'.
c6([1, 2, [["string"]]]); // Error, implied type is [any, any, [[number]]] // Use initializer
~~~~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '[number, number, [[string]]]' is not assignable to parameter of type '[any, any, [[number]]]'.

View file

@ -6,7 +6,6 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(22,4): error TS2345: Argument of type '[number, number, string, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]]]'.
Types of property '2' are incompatible.
Type 'string' is not assignable to type '[[any]]'.
Property '0' is missing in type 'String'.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(23,4): error TS2345: Argument of type '[number, number]' is not assignable to parameter of type '[any, any, [[any]]]'.
Property '2' is missing in type '[number, number]'.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(24,4): error TS2345: Argument of type '(number | string)[]' is not assignable to parameter of type 'number[]'.
@ -53,7 +52,6 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(
!!! error TS2345: Argument of type '[number, number, string, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]]]'.
!!! error TS2345: Types of property '2' are incompatible.
!!! error TS2345: Type 'string' is not assignable to type '[[any]]'.
!!! error TS2345: Property '0' is missing in type 'String'.
a5([1, 2]); // Error, parameter type is [any, any, [[any]]]
~~~~~~
!!! error TS2345: Argument of type '[number, number]' is not assignable to parameter of type '[any, any, [[any]]]'.

View file

@ -1,6 +1,7 @@
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts(47,4): error TS2345: Argument of type '{ y: Class; }' is not assignable to parameter of type '{ y: D; }'.
Types of property 'y' are incompatible.
Type 'Class' is not assignable to type 'D'.
Property 'foo' is missing in type 'Class'.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts(48,4): error TS2345: Argument of type '{}' is not assignable to parameter of type '{ y: D; }'.
Property 'y' is missing in type '{}'.
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts(49,4): error TS2345: Argument of type '{ y: number; }' is not assignable to parameter of type '{ y: D; }'.
@ -63,6 +64,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration5.ts(
!!! error TS2345: Argument of type '{ y: Class; }' is not assignable to parameter of type '{ y: D; }'.
!!! error TS2345: Types of property 'y' are incompatible.
!!! error TS2345: Type 'Class' is not assignable to type 'D'.
!!! error TS2345: Property 'foo' is missing in type 'Class'.
d3({});
~~
!!! error TS2345: Argument of type '{}' is not assignable to parameter of type '{ y: D; }'.

View file

@ -1,5 +1,4 @@
tests/cases/compiler/dontShowCompilerGeneratedMembers.ts(1,5): error TS2322: Type 'number' is not assignable to type '{ (): any; x: number; }'.
Property 'x' is missing in type 'Number'.
tests/cases/compiler/dontShowCompilerGeneratedMembers.ts(3,6): error TS1139: Type parameter declaration expected.
tests/cases/compiler/dontShowCompilerGeneratedMembers.ts(4,1): error TS1109: Expression expected.
@ -8,7 +7,6 @@ tests/cases/compiler/dontShowCompilerGeneratedMembers.ts(4,1): error TS1109: Exp
var f: {
~
!!! error TS2322: Type 'number' is not assignable to type '{ (): any; x: number; }'.
!!! error TS2322: Property 'x' is missing in type 'Number'.
x: number;
<-
~

View file

@ -3,23 +3,16 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssi
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(29,9): error TS2322: Type 'E' is not assignable to type 'string'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(30,9): error TS2322: Type 'E' is not assignable to type 'boolean'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(31,9): error TS2322: Type 'E' is not assignable to type 'Date'.
Property 'toDateString' is missing in type 'Number'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(33,9): error TS2322: Type 'E' is not assignable to type 'void'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(36,9): error TS2322: Type 'E' is not assignable to type '() => {}'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(37,9): error TS2322: Type 'E' is not assignable to type 'Function'.
Property 'apply' is missing in type 'Number'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(38,9): error TS2322: Type 'E' is not assignable to type '(x: number) => string'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(39,5): error TS2322: Type 'E' is not assignable to type 'C'.
Property 'foo' is missing in type 'Number'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(40,5): error TS2322: Type 'E' is not assignable to type 'I'.
Property 'foo' is missing in type 'Number'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(41,9): error TS2322: Type 'E' is not assignable to type 'number[]'.
Property 'length' is missing in type 'Number'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(42,9): error TS2322: Type 'E' is not assignable to type '{ foo: string; }'.
Property 'foo' is missing in type 'Number'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(43,9): error TS2322: Type 'E' is not assignable to type '<T>(x: T) => T'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(45,9): error TS2322: Type 'E' is not assignable to type 'String'.
Property 'charAt' is missing in type 'Number'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(48,9): error TS2322: Type 'E' is not assignable to type 'T'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(49,9): error TS2322: Type 'E' is not assignable to type 'U'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssignability.ts(50,9): error TS2322: Type 'E' is not assignable to type 'V'.
@ -69,7 +62,6 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssi
var ee: Date = e;
~~
!!! error TS2322: Type 'E' is not assignable to type 'Date'.
!!! error TS2322: Property 'toDateString' is missing in type 'Number'.
var f: any = e; // ok
var g: void = e;
~
@ -82,26 +74,21 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssi
var k: Function = e;
~
!!! error TS2322: Type 'E' is not assignable to type 'Function'.
!!! error TS2322: Property 'apply' is missing in type 'Number'.
var l: (x: number) => string = e;
~
!!! error TS2322: Type 'E' is not assignable to type '(x: number) => string'.
ac = e;
~~
!!! error TS2322: Type 'E' is not assignable to type 'C'.
!!! error TS2322: Property 'foo' is missing in type 'Number'.
ai = e;
~~
!!! error TS2322: Type 'E' is not assignable to type 'I'.
!!! error TS2322: Property 'foo' is missing in type 'Number'.
var m: number[] = e;
~
!!! error TS2322: Type 'E' is not assignable to type 'number[]'.
!!! error TS2322: Property 'length' is missing in type 'Number'.
var n: { foo: string } = e;
~
!!! error TS2322: Type 'E' is not assignable to type '{ foo: string; }'.
!!! error TS2322: Property 'foo' is missing in type 'Number'.
var o: <T>(x: T) => T = e;
~
!!! error TS2322: Type 'E' is not assignable to type '<T>(x: T) => T'.
@ -109,7 +96,6 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/enumAssi
var q: String = e;
~
!!! error TS2322: Type 'E' is not assignable to type 'String'.
!!! error TS2322: Property 'charAt' is missing in type 'Number'.
function foo<T, U extends T, V extends Date, A extends Number, B extends E>(x: T, y: U, z: V) {
x = e;

View file

@ -1,9 +1,7 @@
tests/cases/compiler/enumAssignmentCompat.ts(26,5): error TS2322: Type 'typeof W' is not assignable to type 'number'.
tests/cases/compiler/enumAssignmentCompat.ts(28,5): error TS2322: Type 'W' is not assignable to type 'typeof W'.
Property 'D' is missing in type 'Number'.
tests/cases/compiler/enumAssignmentCompat.ts(30,5): error TS2322: Type 'number' is not assignable to type 'typeof W'.
tests/cases/compiler/enumAssignmentCompat.ts(32,5): error TS2322: Type 'W' is not assignable to type 'WStatic'.
Property 'a' is missing in type 'Number'.
tests/cases/compiler/enumAssignmentCompat.ts(33,5): error TS2322: Type 'number' is not assignable to type 'WStatic'.
@ -40,7 +38,6 @@ tests/cases/compiler/enumAssignmentCompat.ts(33,5): error TS2322: Type 'number'
var b: typeof W = W.a; // error
~
!!! error TS2322: Type 'W' is not assignable to type 'typeof W'.
!!! error TS2322: Property 'D' is missing in type 'Number'.
var c: typeof W.a = W.a;
var d: typeof W = 3; // error
~
@ -49,7 +46,6 @@ tests/cases/compiler/enumAssignmentCompat.ts(33,5): error TS2322: Type 'number'
var f: WStatic = W.a; // error
~
!!! error TS2322: Type 'W' is not assignable to type 'WStatic'.
!!! error TS2322: Property 'a' is missing in type 'Number'.
var g: WStatic = 5; // error
~
!!! error TS2322: Type 'number' is not assignable to type 'WStatic'.

View file

@ -1,9 +1,7 @@
tests/cases/compiler/enumAssignmentCompat2.ts(25,5): error TS2322: Type 'typeof W' is not assignable to type 'number'.
tests/cases/compiler/enumAssignmentCompat2.ts(27,5): error TS2322: Type 'W' is not assignable to type 'typeof W'.
Property 'a' is missing in type 'Number'.
tests/cases/compiler/enumAssignmentCompat2.ts(29,5): error TS2322: Type 'number' is not assignable to type 'typeof W'.
tests/cases/compiler/enumAssignmentCompat2.ts(31,5): error TS2322: Type 'W' is not assignable to type 'WStatic'.
Property 'a' is missing in type 'Number'.
tests/cases/compiler/enumAssignmentCompat2.ts(32,5): error TS2322: Type 'number' is not assignable to type 'WStatic'.
@ -39,7 +37,6 @@ tests/cases/compiler/enumAssignmentCompat2.ts(32,5): error TS2322: Type 'number'
var b: typeof W = W.a; // error
~
!!! error TS2322: Type 'W' is not assignable to type 'typeof W'.
!!! error TS2322: Property 'a' is missing in type 'Number'.
var c: typeof W.a = W.a;
var d: typeof W = 3; // error
~
@ -48,7 +45,6 @@ tests/cases/compiler/enumAssignmentCompat2.ts(32,5): error TS2322: Type 'number'
var f: WStatic = W.a; // error
~
!!! error TS2322: Type 'W' is not assignable to type 'WStatic'.
!!! error TS2322: Property 'a' is missing in type 'Number'.
var g: WStatic = 5; // error
~
!!! error TS2322: Type 'number' is not assignable to type 'WStatic'.

View file

@ -1,7 +1,6 @@
tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(34,5): error TS2322: Type 'string' is not assignable to type 'number'.
tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(35,5): error TS2322: Type 'number' is not assignable to type 'string'.
tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(36,5): error TS2322: Type 'number' is not assignable to type 'Date'.
Property 'toDateString' is missing in type 'Number'.
tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(38,5): error TS2322: Type 'number' is not assignable to type 'void'.
tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(40,5): error TS2322: Type 'D<{}>' is not assignable to type 'I'.
Property 'id' is missing in type 'D<{}>'.
@ -76,7 +75,6 @@ tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAnd
var aDate: Date = 9.9;
~~~~~
!!! error TS2322: Type 'number' is not assignable to type 'Date'.
!!! error TS2322: Property 'toDateString' is missing in type 'Number'.
var aVoid: void = 9.9;
~~~~~

View file

@ -1,5 +1,4 @@
tests/cases/conformance/externalModules/foo_1.ts(2,17): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '{ a: string; b: number; }'.
Property 'a' is missing in type 'Boolean'.
==== tests/cases/conformance/externalModules/foo_1.ts (1 errors) ====
@ -7,7 +6,6 @@ tests/cases/conformance/externalModules/foo_1.ts(2,17): error TS2345: Argument o
var x = new foo(true); // Should error
~~~~
!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '{ a: string; b: number; }'.
!!! error TS2345: Property 'a' is missing in type 'Boolean'.
var y = new foo({a: "test", b: 42}); // Should be OK
var z: number = y.test.b;
==== tests/cases/conformance/externalModules/foo_0.ts (0 errors) ====

View file

@ -1,6 +1,5 @@
tests/cases/compiler/functionCall7.ts(5,1): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/compiler/functionCall7.ts(6,5): error TS2345: Argument of type 'number' is not assignable to parameter of type 'c1'.
Property 'a' is missing in type 'Number'.
tests/cases/compiler/functionCall7.ts(7,1): error TS2346: Supplied parameters do not match any signature of call target.
@ -15,7 +14,6 @@ tests/cases/compiler/functionCall7.ts(7,1): error TS2346: Supplied parameters do
foo(4);
~
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'c1'.
!!! error TS2345: Property 'a' is missing in type 'Number'.
foo();
~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.

View file

@ -1,5 +1,4 @@
tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(5,5): error TS2345: Argument of type 'number' is not assignable to parameter of type 'Function'.
Property 'apply' is missing in type 'Number'.
tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(6,1): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(7,1): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(23,14): error TS2345: Argument of type 'Function' is not assignable to parameter of type '(x: string) => string'.
@ -20,9 +19,11 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstrain
Type 'F2' provides no match for the signature '(x: string): string'
tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(37,10): error TS2345: Argument of type 'T' is not assignable to parameter of type '(x: string) => string'.
Type '() => void' is not assignable to type '(x: string) => string'.
Type 'void' is not assignable to type 'string'.
tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(38,10): error TS2345: Argument of type 'U' is not assignable to parameter of type '(x: string) => string'.
Type 'T' is not assignable to type '(x: string) => string'.
Type '() => void' is not assignable to type '(x: string) => string'.
Type 'void' is not assignable to type 'string'.
==== tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts (13 errors) ====
@ -33,7 +34,6 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstrain
foo(1);
~
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'Function'.
!!! error TS2345: Property 'apply' is missing in type 'Number'.
foo(() => { }, 1);
~~~~~~~~~~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
@ -97,10 +97,12 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstrain
~
!!! error TS2345: Argument of type 'T' is not assignable to parameter of type '(x: string) => string'.
!!! error TS2345: Type '() => void' is not assignable to type '(x: string) => string'.
!!! error TS2345: Type 'void' is not assignable to type 'string'.
foo2(y);
~
!!! error TS2345: Argument of type 'U' is not assignable to parameter of type '(x: string) => string'.
!!! error TS2345: Type 'T' is not assignable to type '(x: string) => string'.
!!! error TS2345: Type '() => void' is not assignable to type '(x: string) => string'.
!!! error TS2345: Type 'void' is not assignable to type 'string'.
}

View file

@ -1,5 +1,4 @@
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithConstraintsTypeArgumentInference2.ts(11,26): error TS2345: Argument of type 'number' is not assignable to parameter of type 'Date'.
Property 'toDateString' is missing in type 'Number'.
==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithConstraintsTypeArgumentInference2.ts (1 errors) ====
@ -16,5 +15,4 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithCon
var r4 = foo<Date, Date>(1); // error
~
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'Date'.
!!! error TS2345: Property 'toDateString' is missing in type 'Number'.
var r5 = foo<Date, Date>(new Date()); // no error

View file

@ -1,6 +1,5 @@
tests/cases/compiler/genericCombinators2.ts(15,43): error TS2345: Argument of type '(x: number, y: string) => string' is not assignable to parameter of type '(x: number, y: string) => Date'.
Type 'string' is not assignable to type 'Date'.
Property 'toDateString' is missing in type 'String'.
tests/cases/compiler/genericCombinators2.ts(16,43): error TS2345: Argument of type '(x: number, y: string) => string' is not assignable to parameter of type '(x: number, y: string) => Date'.
Type 'string' is not assignable to type 'Date'.
@ -24,7 +23,6 @@ tests/cases/compiler/genericCombinators2.ts(16,43): error TS2345: Argument of ty
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '(x: number, y: string) => string' is not assignable to parameter of type '(x: number, y: string) => Date'.
!!! error TS2345: Type 'string' is not assignable to type 'Date'.
!!! error TS2345: Property 'toDateString' is missing in type 'String'.
var r5b = _.map<number, string, Date>(c2, rf1);
~~~
!!! error TS2345: Argument of type '(x: number, y: string) => string' is not assignable to parameter of type '(x: number, y: string) => Date'.

View file

@ -1,7 +1,6 @@
tests/cases/compiler/genericDerivedTypeWithSpecializedBase2.ts(11,1): error TS2322: Type 'B<number>' is not assignable to type 'A<{ length: number; foo: number; }>'.
Types of property 'x' are incompatible.
Type 'string' is not assignable to type '{ length: number; foo: number; }'.
Property 'foo' is missing in type 'String'.
==== tests/cases/compiler/genericDerivedTypeWithSpecializedBase2.ts (1 errors) ====
@ -20,5 +19,4 @@ tests/cases/compiler/genericDerivedTypeWithSpecializedBase2.ts(11,1): error TS23
!!! error TS2322: Type 'B<number>' is not assignable to type 'A<{ length: number; foo: number; }>'.
!!! error TS2322: Types of property 'x' are incompatible.
!!! error TS2322: Type 'string' is not assignable to type '{ length: number; foo: number; }'.
!!! error TS2322: Property 'foo' is missing in type 'String'.

View file

@ -4,7 +4,6 @@ tests/cases/compiler/genericRestArgs.ts(5,34): error TS2345: Argument of type 's
tests/cases/compiler/genericRestArgs.ts(10,12): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'string'.
tests/cases/compiler/genericRestArgs.ts(12,30): error TS2345: Argument of type 'number' is not assignable to parameter of type 'any[]'.
Property 'length' is missing in type 'Number'.
==== tests/cases/compiler/genericRestArgs.ts (4 errors) ====
@ -29,5 +28,4 @@ tests/cases/compiler/genericRestArgs.ts(12,30): error TS2345: Argument of type '
var a2Gb = makeArrayG<any>(1, "");
var a2Gc = makeArrayG<any[]>(1, ""); // error
~
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'any[]'.
!!! error TS2345: Property 'length' is missing in type 'Number'.
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'any[]'.

View file

@ -0,0 +1,34 @@
//// [globalIsContextualKeyword.ts]
function a() {
let global = 1;
}
function b() {
class global {}
}
namespace global {
}
function foo(global: number) {
}
let obj = {
global: "123"
}
//// [globalIsContextualKeyword.js]
function a() {
var global = 1;
}
function b() {
var global = (function () {
function global() {
}
return global;
}());
}
function foo(global) {
}
var obj = {
global: "123"
};

View file

@ -0,0 +1,29 @@
=== tests/cases/compiler/globalIsContextualKeyword.ts ===
function a() {
>a : Symbol(a, Decl(globalIsContextualKeyword.ts, 0, 0))
let global = 1;
>global : Symbol(global, Decl(globalIsContextualKeyword.ts, 1, 7))
}
function b() {
>b : Symbol(b, Decl(globalIsContextualKeyword.ts, 2, 1))
class global {}
>global : Symbol(global, Decl(globalIsContextualKeyword.ts, 3, 14))
}
namespace global {
>global : Symbol(global, Decl(globalIsContextualKeyword.ts, 5, 1))
}
function foo(global: number) {
>foo : Symbol(foo, Decl(globalIsContextualKeyword.ts, 8, 1))
>global : Symbol(global, Decl(globalIsContextualKeyword.ts, 10, 13))
}
let obj = {
>obj : Symbol(obj, Decl(globalIsContextualKeyword.ts, 13, 3))
global: "123"
>global : Symbol(global, Decl(globalIsContextualKeyword.ts, 13, 11))
}

View file

@ -0,0 +1,32 @@
=== tests/cases/compiler/globalIsContextualKeyword.ts ===
function a() {
>a : () => void
let global = 1;
>global : number
>1 : number
}
function b() {
>b : () => void
class global {}
>global : global
}
namespace global {
>global : any
}
function foo(global: number) {
>foo : (global: number) => void
>global : number
}
let obj = {
>obj : { global: string; }
>{ global: "123"} : { global: string; }
global: "123"
>global : string
>"123" : string
}

View file

@ -1,6 +1,6 @@
tests/cases/compiler/importDeclRefereingExternalModuleWithNoResolve.ts(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. Consider setting the 'module' compiler option in a 'tsconfig.json' file.
tests/cases/compiler/importDeclRefereingExternalModuleWithNoResolve.ts(1,20): error TS2307: Cannot find module 'externalModule'.
tests/cases/compiler/importDeclRefereingExternalModuleWithNoResolve.ts(2,16): error TS2435: Ambient modules cannot be nested in other modules or namespaces.
tests/cases/compiler/importDeclRefereingExternalModuleWithNoResolve.ts(2,16): error TS2664: Invalid module name in augmentation, module 'm1' cannot be found.
tests/cases/compiler/importDeclRefereingExternalModuleWithNoResolve.ts(3,26): error TS2307: Cannot find module 'externalModule'.
@ -12,7 +12,7 @@ tests/cases/compiler/importDeclRefereingExternalModuleWithNoResolve.ts(3,26): er
!!! error TS2307: Cannot find module 'externalModule'.
declare module "m1" {
~~~~
!!! error TS2435: Ambient modules cannot be nested in other modules or namespaces.
!!! error TS2664: Invalid module name in augmentation, module 'm1' cannot be found.
import im2 = require("externalModule");
~~~~~~~~~~~~~~~~
!!! error TS2307: Cannot find module 'externalModule'.

View file

@ -1,9 +1,9 @@
tests/cases/conformance/classes/propertyMemberDeclarations/initializerReferencingConstructorParameters.ts(4,9): error TS2304: Cannot find name 'x'.
tests/cases/conformance/classes/propertyMemberDeclarations/initializerReferencingConstructorParameters.ts(5,15): error TS2304: Cannot find name 'x'.
tests/cases/conformance/classes/propertyMemberDeclarations/initializerReferencingConstructorParameters.ts(10,9): error TS2304: Cannot find name 'x'.
tests/cases/conformance/classes/propertyMemberDeclarations/initializerReferencingConstructorParameters.ts(10,9): error TS2663: Cannot find name 'x'. Did you mean the instance member 'this.x'?
tests/cases/conformance/classes/propertyMemberDeclarations/initializerReferencingConstructorParameters.ts(11,15): error TS2304: Cannot find name 'x'.
tests/cases/conformance/classes/propertyMemberDeclarations/initializerReferencingConstructorParameters.ts(17,15): error TS1003: Identifier expected.
tests/cases/conformance/classes/propertyMemberDeclarations/initializerReferencingConstructorParameters.ts(23,9): error TS2304: Cannot find name 'x'.
tests/cases/conformance/classes/propertyMemberDeclarations/initializerReferencingConstructorParameters.ts(23,9): error TS2663: Cannot find name 'x'. Did you mean the instance member 'this.x'?
==== tests/cases/conformance/classes/propertyMemberDeclarations/initializerReferencingConstructorParameters.ts (6 errors) ====
@ -22,7 +22,7 @@ tests/cases/conformance/classes/propertyMemberDeclarations/initializerReferencin
class D {
a = x; // error
~
!!! error TS2304: Cannot find name 'x'.
!!! error TS2663: Cannot find name 'x'. Did you mean the instance member 'this.x'?
b: typeof x; // error
~
!!! error TS2304: Cannot find name 'x'.
@ -41,6 +41,6 @@ tests/cases/conformance/classes/propertyMemberDeclarations/initializerReferencin
a = this.x; // ok
b = x; // error
~
!!! error TS2304: Cannot find name 'x'.
!!! error TS2663: Cannot find name 'x'. Did you mean the instance member 'this.x'?
constructor(public x: T) { }
}

View file

@ -1,7 +1,6 @@
tests/cases/compiler/instanceSubtypeCheck2.ts(5,7): error TS2415: Class 'C2<T>' incorrectly extends base class 'C1<T>'.
Types of property 'x' are incompatible.
Type 'string' is not assignable to type 'C2<T>'.
Property 'x' is missing in type 'String'.
==== tests/cases/compiler/instanceSubtypeCheck2.ts (1 errors) ====
@ -14,6 +13,5 @@ tests/cases/compiler/instanceSubtypeCheck2.ts(5,7): error TS2415: Class 'C2<T>'
!!! error TS2415: Class 'C2<T>' incorrectly extends base class 'C1<T>'.
!!! error TS2415: Types of property 'x' are incompatible.
!!! error TS2415: Type 'string' is not assignable to type 'C2<T>'.
!!! error TS2415: Property 'x' is missing in type 'String'.
x: string
}

View file

@ -9,7 +9,6 @@ tests/cases/compiler/intTypeCheck.ts(101,5): error TS2322: Type 'Base' is not as
tests/cases/compiler/intTypeCheck.ts(103,5): error TS2322: Type '() => void' is not assignable to type 'i1'.
Property 'p' is missing in type '() => void'.
tests/cases/compiler/intTypeCheck.ts(106,5): error TS2322: Type 'boolean' is not assignable to type 'i1'.
Property 'p' is missing in type 'Boolean'.
tests/cases/compiler/intTypeCheck.ts(106,20): error TS1109: Expression expected.
tests/cases/compiler/intTypeCheck.ts(106,21): error TS2304: Cannot find name 'i1'.
tests/cases/compiler/intTypeCheck.ts(107,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
@ -38,7 +37,6 @@ tests/cases/compiler/intTypeCheck.ts(134,22): error TS2304: Cannot find name 'i3
tests/cases/compiler/intTypeCheck.ts(135,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
tests/cases/compiler/intTypeCheck.ts(142,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
tests/cases/compiler/intTypeCheck.ts(148,5): error TS2322: Type 'boolean' is not assignable to type 'i4'.
Index signature is missing in type 'Boolean'.
tests/cases/compiler/intTypeCheck.ts(148,21): error TS1109: Expression expected.
tests/cases/compiler/intTypeCheck.ts(148,22): error TS2304: Cannot find name 'i4'.
tests/cases/compiler/intTypeCheck.ts(149,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
@ -52,7 +50,6 @@ tests/cases/compiler/intTypeCheck.ts(157,5): error TS2322: Type 'Base' is not as
tests/cases/compiler/intTypeCheck.ts(159,5): error TS2322: Type '() => void' is not assignable to type 'i5'.
Property 'p' is missing in type '() => void'.
tests/cases/compiler/intTypeCheck.ts(162,5): error TS2322: Type 'boolean' is not assignable to type 'i5'.
Property 'p' is missing in type 'Boolean'.
tests/cases/compiler/intTypeCheck.ts(162,21): error TS1109: Expression expected.
tests/cases/compiler/intTypeCheck.ts(162,22): error TS2304: Cannot find name 'i5'.
tests/cases/compiler/intTypeCheck.ts(163,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
@ -83,7 +80,6 @@ tests/cases/compiler/intTypeCheck.ts(190,22): error TS2304: Cannot find name 'i7
tests/cases/compiler/intTypeCheck.ts(191,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
tests/cases/compiler/intTypeCheck.ts(198,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
tests/cases/compiler/intTypeCheck.ts(204,5): error TS2322: Type 'boolean' is not assignable to type 'i8'.
Index signature is missing in type 'Boolean'.
tests/cases/compiler/intTypeCheck.ts(204,21): error TS1109: Expression expected.
tests/cases/compiler/intTypeCheck.ts(204,22): error TS2304: Cannot find name 'i8'.
tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
@ -215,7 +211,6 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit
var obj9: i1 = new <i1> anyVar;
~~~~
!!! error TS2322: Type 'boolean' is not assignable to type 'i1'.
!!! error TS2322: Property 'p' is missing in type 'Boolean'.
~
!!! error TS1109: Expression expected.
~~
@ -307,7 +302,6 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit
var obj42: i4 = new <i4> anyVar;
~~~~~
!!! error TS2322: Type 'boolean' is not assignable to type 'i4'.
!!! error TS2322: Index signature is missing in type 'Boolean'.
~
!!! error TS1109: Expression expected.
~~
@ -344,7 +338,6 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit
var obj53: i5 = new <i5> anyVar;
~~~~~
!!! error TS2322: Type 'boolean' is not assignable to type 'i5'.
!!! error TS2322: Property 'p' is missing in type 'Boolean'.
~
!!! error TS1109: Expression expected.
~~
@ -439,7 +432,6 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit
var obj86: i8 = new <i8> anyVar;
~~~~~
!!! error TS2322: Type 'boolean' is not assignable to type 'i8'.
!!! error TS2322: Index signature is missing in type 'Boolean'.
~
!!! error TS1109: Expression expected.
~~

View file

@ -4,7 +4,6 @@ tests/cases/compiler/interfaceImplementation7.ts(7,7): error TS2420: Class 'C1'
Types of property 'name' are incompatible.
Type '() => string' is not assignable to type '() => { s: string; n: number; }'.
Type 'string' is not assignable to type '{ s: string; n: number; }'.
Property 's' is missing in type 'String'.
==== tests/cases/compiler/interfaceImplementation7.ts (2 errors) ====
@ -23,7 +22,6 @@ tests/cases/compiler/interfaceImplementation7.ts(7,7): error TS2420: Class 'C1'
!!! error TS2420: Types of property 'name' are incompatible.
!!! error TS2420: Type '() => string' is not assignable to type '() => { s: string; n: number; }'.
!!! error TS2420: Type 'string' is not assignable to type '{ s: string; n: number; }'.
!!! error TS2420: Property 's' is missing in type 'String'.
public name(): string { return ""; }
}

View file

@ -1,5 +1,6 @@
tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(19,1): error TS2322: Type 'A' is not assignable to type 'A & B'.
Type 'A' is not assignable to type 'B'.
Property 'b' is missing in type 'A'.
tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(20,1): error TS2322: Type 'B' is not assignable to type 'A & B'.
Type 'B' is not assignable to type 'A'.
Property 'a' is missing in type 'B'.
@ -7,26 +8,32 @@ tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(23,1): e
Type 'A' is not assignable to type '(A & B) | (C & D)'.
Type 'A' is not assignable to type 'C & D'.
Type 'A' is not assignable to type 'C'.
Property 'c' is missing in type 'A'.
tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(25,1): error TS2322: Type 'C | D' is not assignable to type '(A & B) | (C & D)'.
Type 'C' is not assignable to type '(A & B) | (C & D)'.
Type 'C' is not assignable to type 'C & D'.
Type 'C' is not assignable to type 'D'.
Property 'd' is missing in type 'C'.
tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(26,1): error TS2322: Type '(A & B) | (C & D)' is not assignable to type 'A & B'.
Type 'C & D' is not assignable to type 'A & B'.
Type 'C & D' is not assignable to type 'A'.
Type 'D' is not assignable to type 'A'.
Property 'a' is missing in type 'D'.
tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(27,1): error TS2322: Type '(A & B) | (C & D)' is not assignable to type 'A | B'.
Type 'C & D' is not assignable to type 'A | B'.
Type 'C & D' is not assignable to type 'B'.
Type 'D' is not assignable to type 'B'.
Property 'b' is missing in type 'D'.
tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(28,1): error TS2322: Type '(A & B) | (C & D)' is not assignable to type 'C & D'.
Type 'A & B' is not assignable to type 'C & D'.
Type 'A & B' is not assignable to type 'C'.
Type 'B' is not assignable to type 'C'.
Property 'c' is missing in type 'B'.
tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(29,1): error TS2322: Type '(A & B) | (C & D)' is not assignable to type 'C | D'.
Type 'A & B' is not assignable to type 'C | D'.
Type 'A & B' is not assignable to type 'D'.
Type 'B' is not assignable to type 'D'.
Property 'd' is missing in type 'B'.
tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(31,1): error TS2322: Type 'A & B' is not assignable to type '(A | B) & (C | D)'.
Type 'A & B' is not assignable to type 'C | D'.
Type 'A & B' is not assignable to type 'D'.
@ -35,6 +42,7 @@ tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(32,1): e
Type 'A' is not assignable to type '(A | B) & (C | D)'.
Type 'A' is not assignable to type 'C | D'.
Type 'A' is not assignable to type 'D'.
Property 'd' is missing in type 'A'.
tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(33,1): error TS2322: Type 'C & D' is not assignable to type '(A | B) & (C | D)'.
Type 'C & D' is not assignable to type 'A | B'.
Type 'C & D' is not assignable to type 'B'.
@ -43,14 +51,17 @@ tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(34,1): e
Type 'C' is not assignable to type '(A | B) & (C | D)'.
Type 'C' is not assignable to type 'A | B'.
Type 'C' is not assignable to type 'B'.
Property 'b' is missing in type 'C'.
tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(35,1): error TS2322: Type '(A | B) & (C | D)' is not assignable to type 'A & B'.
Type '(A | B) & (C | D)' is not assignable to type 'A'.
Type 'C | D' is not assignable to type 'A'.
Type 'C' is not assignable to type 'A'.
Property 'a' is missing in type 'C'.
tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(37,1): error TS2322: Type '(A | B) & (C | D)' is not assignable to type 'C & D'.
Type '(A | B) & (C | D)' is not assignable to type 'C'.
Type 'C | D' is not assignable to type 'C'.
Type 'D' is not assignable to type 'C'.
Property 'c' is missing in type 'D'.
==== tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts (14 errors) ====
@ -76,6 +87,7 @@ tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(37,1): e
~~~
!!! error TS2322: Type 'A' is not assignable to type 'A & B'.
!!! error TS2322: Type 'A' is not assignable to type 'B'.
!!! error TS2322: Property 'b' is missing in type 'A'.
anb = b;
~~~
!!! error TS2322: Type 'B' is not assignable to type 'A & B'.
@ -89,6 +101,7 @@ tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(37,1): e
!!! error TS2322: Type 'A' is not assignable to type '(A & B) | (C & D)'.
!!! error TS2322: Type 'A' is not assignable to type 'C & D'.
!!! error TS2322: Type 'A' is not assignable to type 'C'.
!!! error TS2322: Property 'c' is missing in type 'A'.
x = cnd; // Ok
x = cod;
~
@ -96,30 +109,35 @@ tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(37,1): e
!!! error TS2322: Type 'C' is not assignable to type '(A & B) | (C & D)'.
!!! error TS2322: Type 'C' is not assignable to type 'C & D'.
!!! error TS2322: Type 'C' is not assignable to type 'D'.
!!! error TS2322: Property 'd' is missing in type 'C'.
anb = x;
~~~
!!! error TS2322: Type '(A & B) | (C & D)' is not assignable to type 'A & B'.
!!! error TS2322: Type 'C & D' is not assignable to type 'A & B'.
!!! error TS2322: Type 'C & D' is not assignable to type 'A'.
!!! error TS2322: Type 'D' is not assignable to type 'A'.
!!! error TS2322: Property 'a' is missing in type 'D'.
aob = x;
~~~
!!! error TS2322: Type '(A & B) | (C & D)' is not assignable to type 'A | B'.
!!! error TS2322: Type 'C & D' is not assignable to type 'A | B'.
!!! error TS2322: Type 'C & D' is not assignable to type 'B'.
!!! error TS2322: Type 'D' is not assignable to type 'B'.
!!! error TS2322: Property 'b' is missing in type 'D'.
cnd = x;
~~~
!!! error TS2322: Type '(A & B) | (C & D)' is not assignable to type 'C & D'.
!!! error TS2322: Type 'A & B' is not assignable to type 'C & D'.
!!! error TS2322: Type 'A & B' is not assignable to type 'C'.
!!! error TS2322: Type 'B' is not assignable to type 'C'.
!!! error TS2322: Property 'c' is missing in type 'B'.
cod = x;
~~~
!!! error TS2322: Type '(A & B) | (C & D)' is not assignable to type 'C | D'.
!!! error TS2322: Type 'A & B' is not assignable to type 'C | D'.
!!! error TS2322: Type 'A & B' is not assignable to type 'D'.
!!! error TS2322: Type 'B' is not assignable to type 'D'.
!!! error TS2322: Property 'd' is missing in type 'B'.
y = anb;
~
@ -133,6 +151,7 @@ tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(37,1): e
!!! error TS2322: Type 'A' is not assignable to type '(A | B) & (C | D)'.
!!! error TS2322: Type 'A' is not assignable to type 'C | D'.
!!! error TS2322: Type 'A' is not assignable to type 'D'.
!!! error TS2322: Property 'd' is missing in type 'A'.
y = cnd;
~
!!! error TS2322: Type 'C & D' is not assignable to type '(A | B) & (C | D)'.
@ -145,12 +164,14 @@ tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(37,1): e
!!! error TS2322: Type 'C' is not assignable to type '(A | B) & (C | D)'.
!!! error TS2322: Type 'C' is not assignable to type 'A | B'.
!!! error TS2322: Type 'C' is not assignable to type 'B'.
!!! error TS2322: Property 'b' is missing in type 'C'.
anb = y;
~~~
!!! error TS2322: Type '(A | B) & (C | D)' is not assignable to type 'A & B'.
!!! error TS2322: Type '(A | B) & (C | D)' is not assignable to type 'A'.
!!! error TS2322: Type 'C | D' is not assignable to type 'A'.
!!! error TS2322: Type 'C' is not assignable to type 'A'.
!!! error TS2322: Property 'a' is missing in type 'C'.
aob = y; // Ok
cnd = y;
~~~
@ -158,5 +179,6 @@ tests/cases/conformance/types/intersection/intersectionAndUnionTypes.ts(37,1): e
!!! error TS2322: Type '(A | B) & (C | D)' is not assignable to type 'C'.
!!! error TS2322: Type 'C | D' is not assignable to type 'C'.
!!! error TS2322: Type 'D' is not assignable to type 'C'.
!!! error TS2322: Property 'c' is missing in type 'D'.
cod = y; // Ok

View file

@ -3,9 +3,7 @@ tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(4,
tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(5,5): error TS2322: Type 'boolean' is not assignable to type 'void'.
tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(9,5): error TS2322: Type 'boolean' is not assignable to type 'E'.
tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(12,5): error TS2322: Type 'boolean' is not assignable to type 'C'.
Property 'foo' is missing in type 'Boolean'.
tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(15,5): error TS2322: Type 'boolean' is not assignable to type 'I'.
Property 'bar' is missing in type 'Boolean'.
tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(17,5): error TS2322: Type 'boolean' is not assignable to type '() => string'.
tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(21,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(24,5): error TS2322: Type 'boolean' is not assignable to type 'T'.
@ -35,13 +33,11 @@ tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(26
var f: C = x;
~
!!! error TS2322: Type 'boolean' is not assignable to type 'C'.
!!! error TS2322: Property 'foo' is missing in type 'Boolean'.
interface I { bar: string }
var g: I = x;
~
!!! error TS2322: Type 'boolean' is not assignable to type 'I'.
!!! error TS2322: Property 'bar' is missing in type 'Boolean'.
var h: { (): string } = x;
~

View file

@ -2,13 +2,9 @@ tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(3,5)
tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(4,5): error TS2322: Type 'number' is not assignable to type 'string'.
tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(5,5): error TS2322: Type 'number' is not assignable to type 'void'.
tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(9,5): error TS2322: Type 'number' is not assignable to type 'C'.
Property 'foo' is missing in type 'Number'.
tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(12,5): error TS2322: Type 'number' is not assignable to type 'I'.
Property 'bar' is missing in type 'Number'.
tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(14,5): error TS2322: Type 'number' is not assignable to type '{ baz: string; }'.
Property 'baz' is missing in type 'Number'.
tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(15,5): error TS2322: Type 'number' is not assignable to type '{ 0: number; }'.
Property '0' is missing in type 'Number'.
tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(18,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(21,5): error TS2322: Type 'number' is not assignable to type 'T'.
tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(23,1): error TS2364: Invalid left-hand side of assignment expression.
@ -32,22 +28,18 @@ tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(23,1
var e: C = x;
~
!!! error TS2322: Type 'number' is not assignable to type 'C'.
!!! error TS2322: Property 'foo' is missing in type 'Number'.
interface I { bar: string; }
var f: I = x;
~
!!! error TS2322: Type 'number' is not assignable to type 'I'.
!!! error TS2322: Property 'bar' is missing in type 'Number'.
var g: { baz: string } = 1;
~
!!! error TS2322: Type 'number' is not assignable to type '{ baz: string; }'.
!!! error TS2322: Property 'baz' is missing in type 'Number'.
var g2: { 0: number } = 1;
~~
!!! error TS2322: Type 'number' is not assignable to type '{ 0: number; }'.
!!! error TS2322: Property '0' is missing in type 'Number'.
module M { export var x = 1; }
M = x;

View file

@ -2,13 +2,9 @@ tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(3,5)
tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(4,5): error TS2322: Type 'string' is not assignable to type 'number'.
tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(5,5): error TS2322: Type 'string' is not assignable to type 'void'.
tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(9,5): error TS2322: Type 'string' is not assignable to type 'C'.
Property 'foo' is missing in type 'String'.
tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(12,5): error TS2322: Type 'string' is not assignable to type 'I'.
Property 'bar' is missing in type 'String'.
tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(14,5): error TS2322: Type 'number' is not assignable to type '{ baz: string; }'.
Property 'baz' is missing in type 'Number'.
tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(15,5): error TS2322: Type 'number' is not assignable to type '{ 0: number; }'.
Property '0' is missing in type 'Number'.
tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(18,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(21,5): error TS2322: Type 'string' is not assignable to type 'T'.
tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(23,1): error TS2364: Invalid left-hand side of assignment expression.
@ -33,22 +29,18 @@ tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(26,5
var e: C = x;
~
!!! error TS2322: Type 'string' is not assignable to type 'C'.
!!! error TS2322: Property 'foo' is missing in type 'String'.
interface I { bar: string; }
var f: I = x;
~
!!! error TS2322: Type 'string' is not assignable to type 'I'.
!!! error TS2322: Property 'bar' is missing in type 'String'.
var g: { baz: string } = 1;
~
!!! error TS2322: Type 'number' is not assignable to type '{ baz: string; }'.
!!! error TS2322: Property 'baz' is missing in type 'Number'.
var g2: { 0: number } = 1;
~~
!!! error TS2322: Type 'number' is not assignable to type '{ 0: number; }'.
!!! error TS2322: Property '0' is missing in type 'Number'.
module M { export var x = 1; }
M = x;

View file

@ -4,9 +4,7 @@ tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(5,5): er
tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(9,5): error TS2322: Type 'void' is not assignable to type 'C'.
tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(12,5): error TS2322: Type 'void' is not assignable to type 'I'.
tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(14,5): error TS2322: Type 'number' is not assignable to type '{ baz: string; }'.
Property 'baz' is missing in type 'Number'.
tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(15,5): error TS2322: Type 'number' is not assignable to type '{ 0: number; }'.
Property '0' is missing in type 'Number'.
tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(18,1): error TS2364: Invalid left-hand side of assignment expression.
tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(21,5): error TS2322: Type 'void' is not assignable to type 'T'.
tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(23,1): error TS2364: Invalid left-hand side of assignment expression.
@ -42,11 +40,9 @@ tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(29,1): e
var g: { baz: string } = 1;
~
!!! error TS2322: Type 'number' is not assignable to type '{ baz: string; }'.
!!! error TS2322: Property 'baz' is missing in type 'Number'.
var g2: { 0: number } = 1;
~~
!!! error TS2322: Type 'number' is not assignable to type '{ 0: number; }'.
!!! error TS2322: Property '0' is missing in type 'Number'.
module M { export var x = 1; }
M = x;

View file

@ -1,9 +1,9 @@
error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
tests/cases/compiler/a.js(1,1): error TS8008: 'type aliases' can only be used in a .ts file.
tests/cases/compiler/a.js(1,6): error TS8008: 'type aliases' can only be used in a .ts file.
!!! error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
==== tests/cases/compiler/a.js (1 errors) ====
type a = b;
~~~~~~~~~~~
~
!!! error TS8008: 'type aliases' can only be used in a .ts file.

View file

@ -1,6 +1,8 @@
tests/cases/compiler/lastPropertyInLiteralWins.ts(7,6): error TS2345: Argument of type '{ thunk: (num: number) => void; }' is not assignable to parameter of type 'Thing'.
Types of property 'thunk' are incompatible.
Type '(num: number) => void' is not assignable to type '(str: string) => void'.
Types of parameters 'num' and 'str' are incompatible.
Type 'number' is not assignable to type 'string'.
tests/cases/compiler/lastPropertyInLiteralWins.ts(8,5): error TS2300: Duplicate identifier 'thunk'.
tests/cases/compiler/lastPropertyInLiteralWins.ts(9,5): error TS2300: Duplicate identifier 'thunk'.
tests/cases/compiler/lastPropertyInLiteralWins.ts(13,5): error TS2300: Duplicate identifier 'thunk'.
@ -29,6 +31,8 @@ tests/cases/compiler/lastPropertyInLiteralWins.ts(14,5): error TS2300: Duplicate
!!! error TS2345: Argument of type '{ thunk: (num: number) => void; }' is not assignable to parameter of type 'Thing'.
!!! error TS2345: Types of property 'thunk' are incompatible.
!!! error TS2345: Type '(num: number) => void' is not assignable to type '(str: string) => void'.
!!! error TS2345: Types of parameters 'num' and 'str' are incompatible.
!!! error TS2345: Type 'number' is not assignable to type 'string'.
test({ // Should be OK. Last 'thunk' is of correct type
thunk: (num: number) => {},

View file

@ -1,5 +1,4 @@
tests/cases/compiler/maxConstraints.ts(8,22): error TS2345: Argument of type 'number' is not assignable to parameter of type 'Comparable<number>'.
Property 'compareTo' is missing in type 'Number'.
==== tests/cases/compiler/maxConstraints.ts (1 errors) ====
@ -12,5 +11,4 @@ tests/cases/compiler/maxConstraints.ts(8,22): error TS2345: Argument of type 'nu
var max2: Comparer = (x, y) => { return (x.compareTo(y) > 0) ? x : y };
var maxResult = max2(1, 2);
~
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'Comparable<number>'.
!!! error TS2345: Property 'compareTo' is missing in type 'Number'.
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'Comparable<number>'.

View file

@ -0,0 +1,40 @@
tests/cases/compiler/map1.ts(7,15): error TS2665: Module augmentation cannot introduce new names in the top level scope.
tests/cases/compiler/map2.ts(6,15): error TS2665: Module augmentation cannot introduce new names in the top level scope.
==== tests/cases/compiler/map1.ts (1 errors) ====
import { Observable } from "./observable"
(<any>Observable.prototype).map = function() { }
declare module "./observable" {
interface I {x0}
~
!!! error TS2665: Module augmentation cannot introduce new names in the top level scope.
}
==== tests/cases/compiler/map2.ts (1 errors) ====
import { Observable } from "./observable"
(<any>Observable.prototype).map = function() { }
declare module "./observable" {
interface I {x1}
~
!!! error TS2665: Module augmentation cannot introduce new names in the top level scope.
}
==== tests/cases/compiler/observable.ts (0 errors) ====
export declare class Observable<T> {
filter(pred: (e:T) => boolean): Observable<T>;
}
==== tests/cases/compiler/main.ts (0 errors) ====
import { Observable } from "./observable"
import "./map1";
import "./map2";
let x: Observable<number>;

View file

@ -0,0 +1,75 @@
//// [tests/cases/compiler/moduleAugmentationCollidingNamesInAugmentation1.ts] ////
//// [map1.ts]
import { Observable } from "./observable"
(<any>Observable.prototype).map = function() { }
declare module "./observable" {
interface I {x0}
}
//// [map2.ts]
import { Observable } from "./observable"
(<any>Observable.prototype).map = function() { }
declare module "./observable" {
interface I {x1}
}
//// [observable.ts]
export declare class Observable<T> {
filter(pred: (e:T) => boolean): Observable<T>;
}
//// [main.ts]
import { Observable } from "./observable"
import "./map1";
import "./map2";
let x: Observable<number>;
//// [observable.js]
define(["require", "exports"], function (require, exports) {
"use strict";
});
//// [map1.js]
define(["require", "exports", "./observable"], function (require, exports, observable_1) {
"use strict";
observable_1.Observable.prototype.map = function () { };
});
//// [map2.js]
define(["require", "exports", "./observable"], function (require, exports, observable_1) {
"use strict";
observable_1.Observable.prototype.map = function () { };
});
//// [main.js]
define(["require", "exports", "./map1", "./map2"], function (require, exports) {
"use strict";
var x;
});
//// [observable.d.ts]
export declare class Observable<T> {
filter(pred: (e: T) => boolean): Observable<T>;
}
//// [map1.d.ts]
declare module "./observable" {
interface I {
x0: any;
}
}
export {};
//// [map2.d.ts]
declare module "./observable" {
interface I {
x1: any;
}
}
export {};
//// [main.d.ts]

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