Merge branch 'master' into tupleTypes

Conflicts:
	tests/baselines/reference/typeName1.errors.txt
This commit is contained in:
Anders Hejlsberg
2014-08-16 11:11:59 -07:00
948 changed files with 28096 additions and 4975 deletions
+1
View File
@@ -35,3 +35,4 @@ tests/*.d.ts
*.config
scripts/debug.bat
scripts/run.bat
coverage/
+9 -32
View File
@@ -317,13 +317,13 @@ interface String {
* Matches a string with a regular expression, and returns an array containing the results of that search.
* @param regexp A variable name or string literal containing the regular expression pattern and flags.
*/
match(regexp: string): string[];
match(regexp: string): RegExpMatchArray;
/**
* Matches a string with a regular expression, and returns an array containing the results of that search.
* @param regexp A regular expression object that contains the regular expression pattern and applicable flags.
*/
match(regexp: RegExp): string[];
match(regexp: RegExp): RegExpMatchArray;
/**
* Replaces text in a string, using a regular expression or search string.
@@ -790,38 +790,15 @@ declare var Date: {
now(): number;
}
interface RegExpExecArray {
[index: number]: string;
length: number;
index: number;
input: string;
toString(): string;
toLocaleString(): string;
concat(...items: string[][]): string[];
join(separator?: string): string;
pop(): string;
push(...items: string[]): number;
reverse(): string[];
shift(): string;
slice(start?: number, end?: number): string[];
sort(compareFn?: (a: string, b: string) => number): string[];
splice(start: number): string[];
splice(start: number, deleteCount: number, ...items: string[]): string[];
unshift(...items: string[]): number;
indexOf(searchElement: string, fromIndex?: number): number;
lastIndexOf(searchElement: string, fromIndex?: number): number;
every(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): boolean;
some(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): boolean;
forEach(callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any): void;
map(callbackfn: (value: string, index: number, array: string[]) => any, thisArg?: any): any[];
filter(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): string[];
reduce(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: string[]) => any, initialValue?: any): any;
reduceRight(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: string[]) => any, initialValue?: any): any;
interface RegExpMatchArray extends Array<string> {
index?: number;
input?: string;
}
interface RegExpExecArray extends Array<string> {
index: number;
input: string;
}
interface RegExp {
/**
+9 -32
View File
@@ -317,13 +317,13 @@ interface String {
* Matches a string with a regular expression, and returns an array containing the results of that search.
* @param regexp A variable name or string literal containing the regular expression pattern and flags.
*/
match(regexp: string): string[];
match(regexp: string): RegExpMatchArray;
/**
* Matches a string with a regular expression, and returns an array containing the results of that search.
* @param regexp A regular expression object that contains the regular expression pattern and applicable flags.
*/
match(regexp: RegExp): string[];
match(regexp: RegExp): RegExpMatchArray;
/**
* Replaces text in a string, using a regular expression or search string.
@@ -790,38 +790,15 @@ declare var Date: {
now(): number;
}
interface RegExpExecArray {
[index: number]: string;
length: number;
index: number;
input: string;
toString(): string;
toLocaleString(): string;
concat(...items: string[][]): string[];
join(separator?: string): string;
pop(): string;
push(...items: string[]): number;
reverse(): string[];
shift(): string;
slice(start?: number, end?: number): string[];
sort(compareFn?: (a: string, b: string) => number): string[];
splice(start: number): string[];
splice(start: number, deleteCount: number, ...items: string[]): string[];
unshift(...items: string[]): number;
indexOf(searchElement: string, fromIndex?: number): number;
lastIndexOf(searchElement: string, fromIndex?: number): number;
every(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): boolean;
some(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): boolean;
forEach(callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any): void;
map(callbackfn: (value: string, index: number, array: string[]) => any, thisArg?: any): any[];
filter(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): string[];
reduce(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: string[]) => any, initialValue?: any): any;
reduceRight(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: string[]) => any, initialValue?: any): any;
interface RegExpMatchArray extends Array<string> {
index?: number;
input?: string;
}
interface RegExpExecArray extends Array<string> {
index: number;
input: string;
}
interface RegExp {
/**
+1121 -358
View File
File diff suppressed because it is too large Load Diff
+1130 -480
View File
File diff suppressed because it is too large Load Diff
+391 -218
View File
@@ -11,7 +11,11 @@ module ts {
var nextNodeId = 1;
var nextMergeId = 1;
export function createTypeChecker(program: Program): TypeChecker {
/// fullTypeCheck denotes if this instance of the typechecker will be used to get semantic diagnostics.
/// If fullTypeCheck === true - then typechecker should do every possible check to produce all errors
/// If fullTypeCheck === false - typechecker can shortcut and skip checks that only produce errors.
/// NOTE: checks that somehow affects decisions being made during typechecking should be executed in both cases.
export function createTypeChecker(program: Program, fullTypeCheck: boolean): TypeChecker {
var Symbol = objectAllocator.getSymbolConstructor();
var Type = objectAllocator.getTypeConstructor();
@@ -58,8 +62,6 @@ module ts {
var tupleTypes: Map<TupleType> = {};
var stringLiteralTypes: Map<StringLiteralType> = {};
var fullTypeCheck = false;
var emitExtends = false;
var mergedSymbols: Symbol[] = [];
@@ -311,7 +313,7 @@ module ts {
else {
return returnResolvedSymbol(result);
}
}
}
break;
case SyntaxKind.Method:
case SyntaxKind.Constructor:
@@ -451,7 +453,7 @@ module ts {
return moduleSymbol;
}
function getExportAssignmentSymbol(symbol: Symbol): Symbol {
function getExportAssignmentSymbol(symbol: Symbol): Symbol {
checkTypeOfExportAssignmentSymbol(symbol);
var symbolLinks = getSymbolLinks(symbol);
return symbolLinks.exportAssignSymbol === unknownSymbol ? undefined : symbolLinks.exportAssignSymbol;
@@ -661,38 +663,59 @@ module ts {
return callback(globals);
}
function getAccessibleSymbol(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags) {
function getAccessibleSymbolFromSymbolTable(symbols: SymbolTable) {
function getQualifiedLeftMeaning(rightMeaning: SymbolFlags) {
// If we are looking in value space, the parent meaning is value, other wise it is namespace
return rightMeaning === SymbolFlags.Value ? SymbolFlags.Value : SymbolFlags.Namespace;
}
function getAccessibleSymbolChain(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): Symbol[] {
function getAccessibleSymbolChainFromSymbolTable(symbols: SymbolTable): Symbol[] {
function canQualifySymbol(symbolFromSymbolTable: Symbol, meaning: SymbolFlags) {
// If the symbol is equivalent and doesnt need futher qualification, this symbol is accessible
if (!needsQualification(symbolFromSymbolTable, enclosingDeclaration, meaning)) {
return true;
}
// If symbol needs qualification, make sure that parent is accessible, if it is then this symbol is accessible too
var accessibleParent = getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning));
return !!accessibleParent;
}
function isAccessible(symbolFromSymbolTable: Symbol, resolvedAliasSymbol?: Symbol) {
if (symbol === (resolvedAliasSymbol || symbolFromSymbolTable)) {
// If the symbol is equivalent and doesnt need futher qualification, this symbol is accessible
if (!needsQualification(symbolFromSymbolTable, enclosingDeclaration, meaning)) {
return true;
}
// If symbol needs qualification, make sure that parent is accessible, if it is then this symbol is accessible too
var accessibleParent = getAccessibleSymbol(symbolFromSymbolTable.parent, enclosingDeclaration, SymbolFlags.Namespace);
return !!accessibleParent;
// if the symbolFromSymbolTable is not external module (it could be if it was determined as ambient external module and would be in globals table)
// and if symbolfrom symbolTable or alias resolution matches the symbol,
// check the symbol can be qualified, it is only then this symbol is accessible
return !forEach(symbolFromSymbolTable.declarations, declaration => hasExternalModuleSymbol(declaration)) &&
canQualifySymbol(symbolFromSymbolTable, meaning);
}
}
// If symbol is directly available by its name in the symbol table
if (isAccessible(lookUp(symbols, symbol.name))) {
return symbol;
return [symbol];
}
// Check if symbol is any of the alias
return forEachValue(symbols, symbolFromSymbolTable => {
if (symbolFromSymbolTable.flags & SymbolFlags.Import) {
var resolvedImportedSymbol = resolveImport(symbolFromSymbolTable);
if (isAccessible(symbolFromSymbolTable, resolveImport(symbolFromSymbolTable))) {
return symbolFromSymbolTable;
return [symbolFromSymbolTable];
}
// Look in the exported members, if we can find accessibleSymbolChain, symbol is accessible using this chain
// but only if the symbolFromSymbolTable can be qualified
var accessibleSymbolsFromExports = resolvedImportedSymbol.exports ? getAccessibleSymbolChainFromSymbolTable(resolvedImportedSymbol.exports) : undefined;
if (accessibleSymbolsFromExports && canQualifySymbol(symbolFromSymbolTable, getQualifiedLeftMeaning(meaning))) {
return [symbolFromSymbolTable].concat(accessibleSymbolsFromExports);
}
}
});
}
if (symbol) {
return forEachSymbolTableInScope(enclosingDeclaration, getAccessibleSymbolFromSymbolTable);
return forEachSymbolTableInScope(enclosingDeclaration, getAccessibleSymbolChainFromSymbolTable);
}
}
@@ -731,20 +754,19 @@ module ts {
var meaningToLook = meaning;
while (symbol) {
// Symbol is accessible if it by itself is accessible
var accessibleSymbol = getAccessibleSymbol(symbol, enclosingDeclaration, meaningToLook);
if (accessibleSymbol) {
if (forEach(accessibleSymbol.declarations, declaration => !isDeclarationVisible(declaration))) {
var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaningToLook);
if (accessibleSymbolChain) {
var hasAccessibleDeclarations = hasVisibleDeclarations(accessibleSymbolChain[0]);
if (!hasAccessibleDeclarations) {
return {
accessibility: SymbolAccessibility.NotAccessible,
errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning),
errorModuleName: symbol !== initialSymbol ? symbolToString(symbol, enclosingDeclaration, SymbolFlags.Namespace) : undefined
errorModuleName: symbol !== initialSymbol ? symbolToString(symbol, enclosingDeclaration, SymbolFlags.Namespace) : undefined,
};
}
return { accessibility: SymbolAccessibility.Accessible };
return { accessibility: SymbolAccessibility.Accessible, aliasesToMakeVisible: hasAccessibleDeclarations.aliasesToMakeVisible };
}
// TODO(shkamat): Handle static method of class
// If we havent got the accessible symbol doesnt mean the symbol is actually inaccessible.
// It could be qualified symbol and hence verify the path
// eg:
@@ -757,18 +779,91 @@ module ts {
// we are going to see if c can be accessed in scope directly.
// But it cant, hence the accessible is going to be undefined, but that doesnt mean m.c is accessible
// It is accessible if the parent m is accessible because then m.c can be accessed through qualification
meaningToLook = SymbolFlags.Namespace;
meaningToLook = getQualifiedLeftMeaning(meaning);
symbol = symbol.parent;
}
// This is a local symbol that cannot be named
// This could be a symbol that is not exported in the external module
// or it could be a symbol from different external module that is not aliased and hence cannot be named
var symbolExternalModule = forEach(initialSymbol.declarations, declaration => getExternalModuleContainer(declaration));
if (symbolExternalModule) {
var enclosingExternalModule = getExternalModuleContainer(enclosingDeclaration);
if (symbolExternalModule !== enclosingExternalModule) {
// name from different external module that is not visibile
return {
accessibility: SymbolAccessibility.CannotBeNamed,
errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning),
errorModuleName: symbolToString(symbolExternalModule)
};
}
}
// Just a local name that is not accessible
return {
accessibility: SymbolAccessibility.CannotBeNamed,
accessibility: SymbolAccessibility.NotAccessible,
errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning),
};
}
return { accessibility: SymbolAccessibility.Accessible };
function getExternalModuleContainer(declaration: Declaration) {
for (; declaration; declaration = declaration.parent) {
if (hasExternalModuleSymbol(declaration)) {
return getSymbolOfNode(declaration);
}
}
}
}
function hasExternalModuleSymbol(declaration: Declaration) {
return (declaration.kind === SyntaxKind.ModuleDeclaration && declaration.name.kind === SyntaxKind.StringLiteral) ||
(declaration.kind === SyntaxKind.SourceFile && isExternalModule(<SourceFile>declaration));
}
function hasVisibleDeclarations(symbol: Symbol): { aliasesToMakeVisible?: ImportDeclaration[]; } {
var aliasesToMakeVisible: ImportDeclaration[];
if (forEach(symbol.declarations, declaration => !getIsDeclarationVisible(declaration))) {
return undefined;
}
return { aliasesToMakeVisible: aliasesToMakeVisible };
function getIsDeclarationVisible(declaration: Declaration) {
if (!isDeclarationVisible(declaration)) {
// Mark the unexported alias as visible if its parent is visible
// because these kind of aliases can be used to name types in declaration file
if (declaration.kind === SyntaxKind.ImportDeclaration &&
!(declaration.flags & NodeFlags.Export) &&
isDeclarationVisible(declaration.parent)) {
getNodeLinks(declaration).isVisible = true;
if (aliasesToMakeVisible) {
if (!contains(aliasesToMakeVisible, declaration)) {
aliasesToMakeVisible.push(declaration);
}
}
else {
aliasesToMakeVisible = [declaration];
}
return true;
}
// Declaration is not visible
return false;
}
return true;
}
}
function isImportDeclarationEntityNameReferenceDeclarationVisibile(entityName: EntityName): SymbolAccessiblityResult {
var firstIdentifier = getFirstIdentifier(entityName);
var firstIdentifierName = identifierToString(<Identifier>firstIdentifier);
var symbolOfNameSpace = resolveName(entityName.parent, (<Identifier>firstIdentifier).text, SymbolFlags.Namespace, Diagnostics.Cannot_find_name_0, firstIdentifierName);
// Verify if the symbol is accessible
var hasNamespaceDeclarationsVisibile = hasVisibleDeclarations(symbolOfNameSpace);
return hasNamespaceDeclarationsVisibile ?
{ accessibility: SymbolAccessibility.Accessible, aliasesToMakeVisible: hasNamespaceDeclarationsVisibile.aliasesToMakeVisible } :
{ accessibility: SymbolAccessibility.NotAccessible, errorSymbolName: firstIdentifierName };
}
// Enclosing declaration is optional when we dont want to get qualified name in the enclosing declaration scope
@@ -789,15 +884,27 @@ module ts {
// Properties/methods/Signatures/Constructors/TypeParameters do not need qualification
!(symbol.flags & SymbolFlags.PropertyOrAccessor & SymbolFlags.Signature & SymbolFlags.Constructor & SymbolFlags.Method & SymbolFlags.TypeParameter)) {
var symbolName: string;
while (symbol) {
while (symbol) {
var isFirstName = !symbolName;
var meaningToLook = isFirstName ? meaning : SymbolFlags.Namespace;
var accessibleSymbol = getAccessibleSymbol(symbol, enclosingDeclaration, meaningToLook);
symbolName = getSymbolName(accessibleSymbol || symbol) + (isFirstName ? "" : ("." + symbolName));
if (accessibleSymbol && !needsQualification(accessibleSymbol, enclosingDeclaration, meaningToLook)) {
var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning);
var currentSymbolName: string;
if (accessibleSymbolChain) {
currentSymbolName = ts.map(accessibleSymbolChain, accessibleSymbol => getSymbolName(accessibleSymbol)).join(".");
}
else {
// If we didnt find accessible symbol chain for this symbol, break if this is external module
if (!isFirstName && ts.forEach(symbol.declarations, declaration => hasExternalModuleSymbol(declaration))) {
break;
}
currentSymbolName = getSymbolName(symbol);
}
symbolName = currentSymbolName + (isFirstName ? "" : ("." + symbolName));
if (accessibleSymbolChain && !needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) {
break;
}
symbol = accessibleSymbol ? accessibleSymbol.parent : symbol.parent;
symbol = accessibleSymbolChain ? accessibleSymbolChain[0].parent : symbol.parent;
meaning = getQualifiedLeftMeaning(meaning);
}
return symbolName;
@@ -822,7 +929,7 @@ module ts {
};
}
function typeToString(type: Type, enclosingDeclaration?:Node, flags?: TypeFormatFlags): string {
function typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string {
var stringWriter = createSingleLineTextWriter();
// TODO(shkamat): typeToString should take enclosingDeclaration as input, once we have implemented enclosingDeclaration
writeTypeToTextWriter(type, enclosingDeclaration, flags, stringWriter);
@@ -894,10 +1001,13 @@ module ts {
writeTypeofSymbol(type);
}
// Use 'typeof T' for types of functions and methods that circularly reference themselves
// TODO(shkamat): correct the usuage of typeof function - always on functions that are visible
else if (type.symbol && type.symbol.flags & (SymbolFlags.Function | SymbolFlags.Method) && typeStack && contains(typeStack, type)) {
else if (shouldWriteTypeOfFunctionSymbol()) {
writeTypeofSymbol(type);
}
else if (typeStack && contains(typeStack, type)) {
// Recursive usage, use any
writer.write("any");
}
else {
if (!typeStack) {
typeStack = [];
@@ -906,6 +1016,23 @@ module ts {
writeLiteralType(type, allowFunctionOrConstructorTypeLiteral);
typeStack.pop();
}
function shouldWriteTypeOfFunctionSymbol() {
if (type.symbol) {
var isStaticMethodSymbol = !!(type.symbol.flags & SymbolFlags.Method && // typeof static method
ts.forEach(type.symbol.declarations, declaration => declaration.flags & NodeFlags.Static));
var isNonLocalFunctionSymbol = !!(type.symbol.flags & SymbolFlags.Function) &&
(type.symbol.parent || // is exported function symbol
ts.forEach(type.symbol.declarations, declaration =>
declaration.parent.kind === SyntaxKind.SourceFile || declaration.parent.kind === SyntaxKind.ModuleBlock));
if (isStaticMethodSymbol || isNonLocalFunctionSymbol) {
// typeof is allowed only for static/non local functions
return !!(flags & TypeFormatFlags.UseTypeOfFunction) || // use typeof if format flags specify it
(typeStack && contains(typeStack, type)); // it is type of the symbol uses itself recursively
}
}
}
}
function writeTypeofSymbol(type: ObjectType) {
@@ -1050,30 +1177,31 @@ module ts {
// This is export assigned symbol node
var externalModuleSymbol = getSymbolOfNode(externalModule);
var exportAssignmentSymbol = getExportAssignmentSymbol(externalModuleSymbol);
var resolvedExportSymbol: Symbol;
var symbolOfNode = getSymbolOfNode(node);
if (exportAssignmentSymbol === symbolOfNode) {
if (isSymbolUsedInExportAssignment(symbolOfNode)) {
return true;
}
// if symbolOfNode is import declaration, resolve the symbol declaration and check
if (symbolOfNode.flags & SymbolFlags.Import) {
return isSymbolUsedInExportAssignment(resolveImport(symbolOfNode));
}
}
// Check if the symbol is used in export assignment
function isSymbolUsedInExportAssignment(symbol: Symbol) {
if (exportAssignmentSymbol === symbol) {
return true;
}
if (exportAssignmentSymbol && !!(exportAssignmentSymbol.flags & SymbolFlags.Import)) {
// if export assigned symbol is import declaration, resolve the import
var resolvedExportSymbol = resolveImport(exportAssignmentSymbol);
if (resolvedExportSymbol === symbolOfNode) {
resolvedExportSymbol = resolvedExportSymbol || resolveImport(exportAssignmentSymbol);
if (resolvedExportSymbol === symbol) {
return true;
}
// TODO(shkamat): Chained import assignment
// eg. a should be visible too.
//module m {
// export module c {
// export class c {
// }
// }
//}
//import a = m.c;
//import b = a;
//export = b;
// Container of resolvedExportSymbol is visible
return forEach(resolvedExportSymbol.declarations, declaration => {
while (declaration) {
@@ -1090,25 +1218,21 @@ module ts {
function determineIfDeclarationIsVisible() {
switch (node.kind) {
case SyntaxKind.VariableDeclaration:
if (!(node.flags & NodeFlags.Export)) {
// node.parent is variable statement so look at the variable statement's parent
return isGlobalSourceFile(node.parent.parent) || isUsedInExportAssignment(node);
}
// Exported members are visible if parent is visible
return isDeclarationVisible(node.parent.parent);
case SyntaxKind.ModuleDeclaration:
case SyntaxKind.ClassDeclaration:
case SyntaxKind.InterfaceDeclaration:
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.EnumDeclaration:
case SyntaxKind.ImportDeclaration:
if (!(node.flags & NodeFlags.Export)) {
// TODO(shkamat): non exported aliases can be visible if they are referenced else where for value/type/namespace
return isGlobalSourceFile(node.parent) || isUsedInExportAssignment(node);
// In case of variable declaration, node.parent is variable statement so look at the variable statement's parent
var parent = node.kind === SyntaxKind.VariableDeclaration ? node.parent.parent : node.parent;
// If the node is not exported or it is not ambient module element (except import declaration)
if (!(node.flags & NodeFlags.Export) &&
!(node.kind !== SyntaxKind.ImportDeclaration && parent.kind !== SyntaxKind.SourceFile && isInAmbientContext(parent))) {
return isGlobalSourceFile(parent) || isUsedInExportAssignment(node);
}
// Exported members are visible if parent is visible
return isDeclarationVisible(node.parent);
// Exported members/ambient module elements (exception import declaraiton) are visible if parent is visible
return isDeclarationVisible(parent);
case SyntaxKind.Property:
case SyntaxKind.Method:
@@ -1138,7 +1262,7 @@ module ts {
if (node) {
var links = getNodeLinks(node);
if (links.isVisible === undefined) {
links.isVisible = determineIfDeclarationIsVisible();
links.isVisible = !!determineIfDeclarationIsVisible();
}
return links.isVisible;
}
@@ -1211,7 +1335,7 @@ module ts {
return type;
function checkImplicitAny(type: Type) {
if (!program.getCompilerOptions().noImplicitAny) {
if (!fullTypeCheck || !program.getCompilerOptions().noImplicitAny) {
return;
}
// We need to have ended up with 'any', 'any[]', 'any[][]', etc.
@@ -4033,7 +4157,7 @@ module ts {
var typeArgNode = typeArguments[i];
var typeArgument = getTypeFromTypeNode(typeArgNode);
var constraint = getConstraintOfTypeParameter(typeParameters[i]);
if (constraint) {
if (constraint && fullTypeCheck) {
checkTypeAssignableTo(typeArgument, constraint, typeArgNode, Diagnostics.Type_0_does_not_satisfy_the_constraint_1_Colon, Diagnostics.Type_0_does_not_satisfy_the_constraint_1);
}
result.push(typeArgument);
@@ -4249,7 +4373,7 @@ module ts {
function checkTypeAssertion(node: TypeAssertion): Type {
var exprType = checkExpression(node.operand);
var targetType = getTypeFromTypeNode(node.type);
if (targetType !== unknownType) {
if (fullTypeCheck && targetType !== unknownType) {
var widenedType = getWidenedType(exprType);
if (!(isTypeAssignableTo(exprType, targetType) || isTypeAssignableTo(targetType, widenedType))) {
checkTypeAssignableTo(targetType, widenedType, node, Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other_Colon, Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other);
@@ -4283,7 +4407,7 @@ module ts {
var unwidenedType = checkAndMarkExpression(func.body, contextualMapper);
var widenedType = getWidenedType(unwidenedType);
if (program.getCompilerOptions().noImplicitAny && widenedType !== unwidenedType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) {
if (fullTypeCheck && program.getCompilerOptions().noImplicitAny && widenedType !== unwidenedType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) {
error(func, Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeToString(widenedType));
}
@@ -4305,7 +4429,7 @@ module ts {
var widenedType = getWidenedType(commonType);
// Check and report for noImplicitAny if the best common type implicitly gets widened to an 'any'/arrays-of-'any' type.
if (program.getCompilerOptions().noImplicitAny && widenedType !== commonType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) {
if (fullTypeCheck && program.getCompilerOptions().noImplicitAny && widenedType !== commonType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) {
var typeName = typeToString(widenedType);
if (func.name) {
@@ -4385,6 +4509,10 @@ module ts {
// must have at least one return statement somewhere in its body.
// An exception to this rule is if the function implementation consists of a single 'throw' statement.
function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func: FunctionDeclaration, returnType: Type): void {
if (!fullTypeCheck) {
return;
}
// Functions that return 'void' or 'any' don't need any return expressions.
if (returnType === voidType || returnType === anyType) {
return;
@@ -4688,7 +4816,7 @@ module ts {
}
function checkAssignmentOperator(valueType: Type): void {
if (operator >= SyntaxKind.FirstAssignment && operator <= SyntaxKind.LastAssignment) {
if (fullTypeCheck && operator >= SyntaxKind.FirstAssignment && operator <= SyntaxKind.LastAssignment) {
// TypeScript 1.0 spec (April 2014): 4.17
// An assignment of the form
// VarExpr = ValueExpr
@@ -4802,28 +4930,32 @@ module ts {
// DECLARATION AND STATEMENT TYPE CHECKING
function checkTypeParameter(node: TypeParameterDeclaration) {
checkTypeNameIsReserved(node.name, Diagnostics.Type_parameter_name_cannot_be_0);
checkSourceElement(node.constraint);
checkTypeParameterHasIllegalReferencesInConstraint(node);
if (fullTypeCheck) {
checkTypeParameterHasIllegalReferencesInConstraint(node);
checkTypeNameIsReserved(node.name, Diagnostics.Type_parameter_name_cannot_be_0);
}
// TODO: Check multiple declarations are identical
}
function checkParameter(parameterDeclaration: ParameterDeclaration) {
checkVariableDeclaration(parameterDeclaration);
checkCollisionWithIndexVariableInGeneratedCode(parameterDeclaration, parameterDeclaration.name);
if (fullTypeCheck) {
checkCollisionWithIndexVariableInGeneratedCode(parameterDeclaration, parameterDeclaration.name);
if (parameterDeclaration.flags & (NodeFlags.Public | NodeFlags.Private) && !(parameterDeclaration.parent.kind === SyntaxKind.Constructor && (<ConstructorDeclaration>parameterDeclaration.parent).body)) {
error(parameterDeclaration, Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation);
}
if (parameterDeclaration.flags & NodeFlags.Rest) {
if (!isArrayType(getTypeOfSymbol(parameterDeclaration.symbol))) {
error(parameterDeclaration, Diagnostics.A_rest_parameter_must_be_of_an_array_type);
if (parameterDeclaration.flags & (NodeFlags.Public | NodeFlags.Private) && !(parameterDeclaration.parent.kind === SyntaxKind.Constructor && (<ConstructorDeclaration>parameterDeclaration.parent).body)) {
error(parameterDeclaration, Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation);
}
}
else {
if (parameterDeclaration.initializer && !(<FunctionDeclaration>parameterDeclaration.parent).body) {
error(parameterDeclaration, Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation);
if (parameterDeclaration.flags & NodeFlags.Rest) {
if (!isArrayType(getTypeOfSymbol(parameterDeclaration.symbol))) {
error(parameterDeclaration, Diagnostics.A_rest_parameter_must_be_of_an_array_type);
}
}
else {
if (parameterDeclaration.initializer && !(<FunctionDeclaration>parameterDeclaration.parent).body) {
error(parameterDeclaration, Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation);
}
}
}
@@ -4867,18 +4999,19 @@ module ts {
if (node.type) {
checkSourceElement(node.type);
}
checkCollisionWithCapturedSuperVariable(node, node.name);
checkCollisionWithCapturedThisVariable(node, node.name);
checkCollisionWithArgumentsInGeneratedCode(node);
if (program.getCompilerOptions().noImplicitAny && !node.type) {
switch (node.kind) {
case SyntaxKind.ConstructSignature:
error(node, Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type);
break;
case SyntaxKind.CallSignature:
error(node, Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type);
break;
if (fullTypeCheck) {
checkCollisionWithCapturedSuperVariable(node, node.name);
checkCollisionWithCapturedThisVariable(node, node.name);
checkCollisionWithArgumentsInGeneratedCode(node);
if (program.getCompilerOptions().noImplicitAny && !node.type) {
switch (node.kind) {
case SyntaxKind.ConstructSignature:
error(node, Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type);
break;
case SyntaxKind.CallSignature:
error(node, Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type);
break;
}
}
}
@@ -4955,6 +5088,10 @@ module ts {
return;
}
if (!fullTypeCheck) {
return;
}
function isSuperCallExpression(n: Node): boolean {
return n.kind === SyntaxKind.CallExpression && (<CallExpression>n).func.kind === SyntaxKind.SuperKeyword;
}
@@ -5019,29 +5156,31 @@ module ts {
}
function checkAccessorDeclaration(node: AccessorDeclaration) {
if (node.kind === SyntaxKind.GetAccessor) {
if (!isInAmbientContext(node) && node.body && !(bodyContainsAReturnStatement(<Block>node.body) || bodyContainsSingleThrowStatement(<Block>node.body))) {
error(node.name, Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement);
}
}
// TypeScript 1.0 spec (April 2014): 8.4.3
// Accessors for the same member name must specify the same accessibility.
var otherKind = node.kind === SyntaxKind.GetAccessor ? SyntaxKind.SetAccessor : SyntaxKind.GetAccessor;
var otherAccessor = <AccessorDeclaration>getDeclarationOfKind(node.symbol, otherKind);
if (otherAccessor) {
var visibilityFlags = NodeFlags.Private | NodeFlags.Public;
if (((node.flags & visibilityFlags) !== (otherAccessor.flags & visibilityFlags))) {
error(node.name, Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility);
if (fullTypeCheck) {
if (node.kind === SyntaxKind.GetAccessor) {
if (!isInAmbientContext(node) && node.body && !(bodyContainsAReturnStatement(<Block>node.body) || bodyContainsSingleThrowStatement(<Block>node.body))) {
error(node.name, Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement);
}
}
var thisType = getAnnotatedAccessorType(node);
var otherType = getAnnotatedAccessorType(otherAccessor);
// TypeScript 1.0 spec (April 2014): 4.5
// If both accessors include type annotations, the specified types must be identical.
if (thisType && otherType) {
if (!isTypeIdenticalTo(thisType, otherType)) {
error(node, Diagnostics.get_and_set_accessor_must_have_the_same_type);
// TypeScript 1.0 spec (April 2014): 8.4.3
// Accessors for the same member name must specify the same accessibility.
var otherKind = node.kind === SyntaxKind.GetAccessor ? SyntaxKind.SetAccessor : SyntaxKind.GetAccessor;
var otherAccessor = <AccessorDeclaration>getDeclarationOfKind(node.symbol, otherKind);
if (otherAccessor) {
var visibilityFlags = NodeFlags.Private | NodeFlags.Public;
if (((node.flags & visibilityFlags) !== (otherAccessor.flags & visibilityFlags))) {
error(node.name, Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility);
}
var thisType = getAnnotatedAccessorType(node);
var otherType = getAnnotatedAccessorType(otherAccessor);
// TypeScript 1.0 spec (April 2014): 4.5
// If both accessors include type annotations, the specified types must be identical.
if (thisType && otherType) {
if (!isTypeIdenticalTo(thisType, otherType)) {
error(node, Diagnostics.get_and_set_accessor_must_have_the_same_type);
}
}
}
}
@@ -5058,7 +5197,7 @@ module ts {
for (var i = 0; i < len; i++) {
checkSourceElement(node.typeArguments[i]);
var constraint = getConstraintOfTypeParameter((<TypeReference>type).target.typeParameters[i]);
if (constraint) {
if (fullTypeCheck && constraint) {
var typeArgument = (<TypeReference>type).typeArguments[i];
checkTypeAssignableTo(typeArgument, constraint, node, Diagnostics.Type_0_does_not_satisfy_the_constraint_1_Colon, Diagnostics.Type_0_does_not_satisfy_the_constraint_1);
}
@@ -5072,9 +5211,11 @@ module ts {
function checkTypeLiteral(node: TypeLiteralNode) {
forEach(node.members, checkSourceElement);
var type = getTypeFromTypeLiteralNode(node);
checkIndexConstraints(type);
checkTypeForDuplicateIndexSignatures(node);
if (fullTypeCheck) {
var type = getTypeFromTypeLiteralNode(node);
checkIndexConstraints(type);
checkTypeForDuplicateIndexSignatures(node);
}
}
function checkArrayType(node: ArrayTypeNode) {
@@ -5090,6 +5231,9 @@ module ts {
}
function checkSpecializedSignatureDeclaration(signatureDeclarationNode: SignatureDeclaration): void {
if (!fullTypeCheck) {
return;
}
var signature = getSignatureFromDeclaration(signatureDeclarationNode);
if (!signature.hasStringLiterals) {
return;
@@ -5143,7 +5287,10 @@ module ts {
return flags & flagsToCheck;
}
function checkFunctionOrConstructorSymbol(symbol: Symbol) {
function checkFunctionOrConstructorSymbol(symbol: Symbol): void {
if (!fullTypeCheck) {
return;
}
function checkFlagAgreementBetweenOverloads(overloads: Declaration[], implementation: FunctionDeclaration, flagsToCheck: NodeFlags, someOverloadFlags: NodeFlags, allOverloadFlags: NodeFlags): void {
// Error if some overloads have a flag that is not shared by all overloads. To find the
@@ -5313,7 +5460,11 @@ module ts {
}
}
function checkExportsOnMergedDeclarations(node: Node) {
function checkExportsOnMergedDeclarations(node: Node): void {
if (!fullTypeCheck) {
return;
}
var symbol: Symbol;
// Exports should be checked only if enclosing module contains both exported and non exported declarations.
@@ -5383,7 +5534,7 @@ module ts {
}
}
function checkFunctionDeclaration(node: FunctionDeclaration) {
function checkFunctionDeclaration(node: FunctionDeclaration): void {
checkSignatureDeclaration(node);
var symbol = getSymbolOfNode(node);
@@ -5412,7 +5563,7 @@ module ts {
}
// If there is no body and no explicit return type, then report an error.
if (program.getCompilerOptions().noImplicitAny && !node.body && !node.type) {
if (fullTypeCheck && program.getCompilerOptions().noImplicitAny && !node.body && !node.type) {
// Ignore privates within ambient contexts; they exist purely for documentative purposes to avoid name clashing.
// (e.g. privates within .d.ts files do not expose type information)
if (!isPrivateWithinAmbient(node)) {
@@ -5599,36 +5750,38 @@ module ts {
function checkVariableDeclaration(node: VariableDeclaration) {
checkSourceElement(node.type);
checkExportsOnMergedDeclarations(node);
var symbol = getSymbolOfNode(node);
var typeOfValueDeclaration = getTypeOfVariableOrParameterOrProperty(symbol);
var type: Type;
var useTypeFromValueDeclaration = node === symbol.valueDeclaration;
if (useTypeFromValueDeclaration) {
type = typeOfValueDeclaration;
}
else {
type = getTypeOfVariableDeclaration(node);
}
if (fullTypeCheck) {
var symbol = getSymbolOfNode(node);
if (node.initializer) {
if (!(getNodeLinks(node.initializer).flags & NodeCheckFlags.TypeChecked)) {
// Use default messages
checkTypeAssignableTo(checkAndMarkExpression(node.initializer), type, node, /*chainedMessage*/ undefined, /*terminalMessage*/ undefined);
var typeOfValueDeclaration = getTypeOfVariableOrParameterOrProperty(symbol);
var type: Type;
var useTypeFromValueDeclaration = node === symbol.valueDeclaration;
if (useTypeFromValueDeclaration) {
type = typeOfValueDeclaration;
}
else {
type = getTypeOfVariableDeclaration(node);
}
}
checkCollisionWithCapturedSuperVariable(node, node.name);
checkCollisionWithCapturedThisVariable(node, node.name);
if (!useTypeFromValueDeclaration) {
// TypeScript 1.0 spec (April 2014): 5.1
// Multiple declarations for the same variable name in the same declaration space are permitted,
// provided that each declaration associates the same type with the variable.
if (typeOfValueDeclaration !== unknownType && type !== unknownType && !isTypeIdenticalTo(typeOfValueDeclaration, type)) {
error(node.name, Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2, identifierToString(node.name), typeToString(typeOfValueDeclaration), typeToString(type));
if (node.initializer) {
if (!(getNodeLinks(node.initializer).flags & NodeCheckFlags.TypeChecked)) {
// Use default messages
checkTypeAssignableTo(checkAndMarkExpression(node.initializer), type, node, /*chainedMessage*/ undefined, /*terminalMessage*/ undefined);
}
}
checkCollisionWithCapturedSuperVariable(node, node.name);
checkCollisionWithCapturedThisVariable(node, node.name);
if (!useTypeFromValueDeclaration) {
// TypeScript 1.0 spec (April 2014): 5.1
// Multiple declarations for the same variable name in the same declaration space are permitted,
// provided that each declaration associates the same type with the variable.
if (typeOfValueDeclaration !== unknownType && type !== unknownType && !isTypeIdenticalTo(typeOfValueDeclaration, type)) {
error(node.name, Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2, identifierToString(node.name), typeToString(typeOfValueDeclaration), typeToString(type));
}
}
}
}
@@ -5760,7 +5913,7 @@ module ts {
function checkSwitchStatement(node: SwitchStatement) {
var expressionType = checkExpression(node.expression);
forEach(node.clauses, clause => {
if (clause.expression) {
if (fullTypeCheck && clause.expression) {
// TypeScript 1.0 spec (April 2014):5.9
// In a 'switch' statement, each 'case' expression must be of a type that is assignable to or from the type of the 'switch' expression.
var caseType = checkExpression(clause.expression);
@@ -5875,9 +6028,12 @@ module ts {
for (var i = 0; i < typeParameterDeclarations.length; i++) {
var node = typeParameterDeclarations[i];
checkTypeParameter(node);
for (var j = 0; j < i; j++) {
if (typeParameterDeclarations[j].symbol === node.symbol) {
error(node.name, Diagnostics.Duplicate_identifier_0, identifierToString(node.name));
if (fullTypeCheck) {
for (var j = 0; j < i; j++) {
if (typeParameterDeclarations[j].symbol === node.symbol) {
error(node.name, Diagnostics.Duplicate_identifier_0, identifierToString(node.name));
}
}
}
}
@@ -5897,39 +6053,45 @@ module ts {
checkTypeReference(node.baseType);
}
if (type.baseTypes.length) {
var baseType = type.baseTypes[0];
checkTypeAssignableTo(type, baseType, node.name, Diagnostics.Class_0_incorrectly_extends_base_class_1_Colon, Diagnostics.Class_0_incorrectly_extends_base_class_1);
var staticBaseType = getTypeOfSymbol(baseType.symbol);
checkTypeAssignableTo(staticType, getTypeWithoutConstructors(staticBaseType), node.name,
Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1_Colon, Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1);
if (baseType.symbol !== resolveEntityName(node, node.baseType.typeName, SymbolFlags.Value)) {
error(node.baseType, Diagnostics.Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0, typeToString(baseType));
if (fullTypeCheck) {
var baseType = type.baseTypes[0];
checkTypeAssignableTo(type, baseType, node.name, Diagnostics.Class_0_incorrectly_extends_base_class_1_Colon, Diagnostics.Class_0_incorrectly_extends_base_class_1);
var staticBaseType = getTypeOfSymbol(baseType.symbol);
checkTypeAssignableTo(staticType, getTypeWithoutConstructors(staticBaseType), node.name,
Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1_Colon, Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1);
if (baseType.symbol !== resolveEntityName(node, node.baseType.typeName, SymbolFlags.Value)) {
error(node.baseType, Diagnostics.Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0, typeToString(baseType));
}
checkKindsOfPropertyMemberOverrides(type, baseType);
}
// Check that base type can be evaluated as expression
checkExpression(node.baseType.typeName);
checkKindsOfPropertyMemberOverrides(type, baseType);
}
if (node.implementedTypes) {
forEach(node.implementedTypes, typeRefNode => {
checkTypeReference(typeRefNode);
var t = getTypeFromTypeReferenceNode(typeRefNode);
if (t !== unknownType) {
var declaredType = (t.flags & TypeFlags.Reference) ? (<TypeReference>t).target : t;
if (declaredType.flags & (TypeFlags.Class | TypeFlags.Interface)) {
checkTypeAssignableTo(type, t, node.name, Diagnostics.Class_0_incorrectly_implements_interface_1_Colon, Diagnostics.Class_0_incorrectly_implements_interface_1);
}
else {
error(typeRefNode, Diagnostics.A_class_may_only_implement_another_class_or_interface);
if (fullTypeCheck) {
var t = getTypeFromTypeReferenceNode(typeRefNode);
if (t !== unknownType) {
var declaredType = (t.flags & TypeFlags.Reference) ? (<TypeReference>t).target : t;
if (declaredType.flags & (TypeFlags.Class | TypeFlags.Interface)) {
checkTypeAssignableTo(type, t, node.name, Diagnostics.Class_0_incorrectly_implements_interface_1_Colon, Diagnostics.Class_0_incorrectly_implements_interface_1);
}
else {
error(typeRefNode, Diagnostics.A_class_may_only_implement_another_class_or_interface);
}
}
}
});
}
checkIndexConstraints(type);
forEach(node.members, checkSourceElement);
checkTypeForDuplicateIndexSignatures(node);
forEach(node.members, checkSourceElement);
if (fullTypeCheck) {
checkIndexConstraints(type);
checkTypeForDuplicateIndexSignatures(node);
}
}
function getTargetSymbol(s: Symbol) {
@@ -6041,32 +6203,37 @@ module ts {
}
function checkInterfaceDeclaration(node: InterfaceDeclaration) {
checkTypeNameIsReserved(node.name, Diagnostics.Interface_name_cannot_be_0);
checkTypeParameters(node.typeParameters);
checkExportsOnMergedDeclarations(node);
var symbol = getSymbolOfNode(node);
var firstInterfaceDecl = <InterfaceDeclaration>getDeclarationOfKind(symbol, SyntaxKind.InterfaceDeclaration);
if (symbol.declarations.length > 1) {
if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) {
error(node.name, Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters);
}
}
if (fullTypeCheck) {
checkTypeNameIsReserved(node.name, Diagnostics.Interface_name_cannot_be_0);
// Only check this symbol once
if (node === firstInterfaceDecl) {
var type = <InterfaceType>getDeclaredTypeOfSymbol(symbol);
// run subsequent checks only if first set succeeded
if (checkInheritedPropertiesAreIdentical(type, node.name)) {
forEach(type.baseTypes, baseType => {
checkTypeAssignableTo(type, baseType, node.name, Diagnostics.Interface_0_incorrectly_extends_interface_1_Colon, Diagnostics.Interface_0_incorrectly_extends_interface_1);
});
checkIndexConstraints(type);
checkExportsOnMergedDeclarations(node);
var symbol = getSymbolOfNode(node);
var firstInterfaceDecl = <InterfaceDeclaration>getDeclarationOfKind(symbol, SyntaxKind.InterfaceDeclaration);
if (symbol.declarations.length > 1) {
if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) {
error(node.name, Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters);
}
}
// Only check this symbol once
if (node === firstInterfaceDecl) {
var type = <InterfaceType>getDeclaredTypeOfSymbol(symbol);
// run subsequent checks only if first set succeeded
if (checkInheritedPropertiesAreIdentical(type, node.name)) {
forEach(type.baseTypes, baseType => {
checkTypeAssignableTo(type, baseType, node.name, Diagnostics.Interface_0_incorrectly_extends_interface_1_Colon, Diagnostics.Interface_0_incorrectly_extends_interface_1);
});
checkIndexConstraints(type);
}
}
}
forEach(node.baseTypes, checkTypeReference);
forEach(node.members, checkSourceElement);
checkTypeForDuplicateIndexSignatures(node);
if (fullTypeCheck) {
checkTypeForDuplicateIndexSignatures(node);
}
}
function getConstantValue(node: Expression): number {
@@ -6087,6 +6254,9 @@ module ts {
}
function checkEnumDeclaration(node: EnumDeclaration) {
if (!fullTypeCheck) {
return;
}
checkTypeNameIsReserved(node.name, Diagnostics.Enum_name_cannot_be_0);
checkCollisionWithCapturedThisVariable(node, node.name);
checkExportsOnMergedDeclarations(node);
@@ -6160,26 +6330,28 @@ module ts {
}
function checkModuleDeclaration(node: ModuleDeclaration) {
checkCollisionWithCapturedThisVariable(node, node.name);
checkExportsOnMergedDeclarations(node);
var symbol = getSymbolOfNode(node);
if (symbol.flags & SymbolFlags.ValueModule && symbol.declarations.length > 1 && !isInAmbientContext(node)) {
var classOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol);
if (classOrFunc) {
if (getSourceFileOfNode(node) !== getSourceFileOfNode(classOrFunc)) {
error(node.name, Diagnostics.A_module_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged);
}
else if (node.pos < classOrFunc.pos) {
error(node.name, Diagnostics.A_module_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged);
if (fullTypeCheck) {
checkCollisionWithCapturedThisVariable(node, node.name);
checkExportsOnMergedDeclarations(node);
var symbol = getSymbolOfNode(node);
if (symbol.flags & SymbolFlags.ValueModule && symbol.declarations.length > 1 && !isInAmbientContext(node)) {
var classOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol);
if (classOrFunc) {
if (getSourceFileOfNode(node) !== getSourceFileOfNode(classOrFunc)) {
error(node.name, Diagnostics.A_module_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged);
}
else if (node.pos < classOrFunc.pos) {
error(node.name, Diagnostics.A_module_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged);
}
}
}
}
if (node.name.kind === SyntaxKind.StringLiteral) {
if (!isGlobalSourceFile(node.parent)) {
error(node.name, Diagnostics.Ambient_external_modules_cannot_be_nested_in_other_modules);
}
if (isExternalModuleNameRelative(node.name.text)) {
error(node.name, Diagnostics.Ambient_external_module_declaration_cannot_specify_relative_module_name);
if (node.name.kind === SyntaxKind.StringLiteral) {
if (!isGlobalSourceFile(node.parent)) {
error(node.name, Diagnostics.Ambient_external_modules_cannot_be_nested_in_other_modules);
}
if (isExternalModuleNameRelative(node.name.text)) {
error(node.name, Diagnostics.Ambient_external_module_declaration_cannot_specify_relative_module_name);
}
}
}
checkSourceElement(node.body);
@@ -6342,12 +6514,10 @@ module ts {
}
}
// Fully type check a source file and collect the relevant diagnostics. The fullTypeCheck flag is true during this
// operation, but otherwise is false when the compiler is used by the language service.
// Fully type check a source file and collect the relevant diagnostics.
function checkSourceFile(node: SourceFile) {
var links = getNodeLinks(node);
if (!(links.flags & NodeCheckFlags.TypeChecked)) {
fullTypeCheck = true;
emitExtends = false;
potentialThisCollisions.length = 0;
forEach(node.statements, checkSourceElement);
@@ -6364,7 +6534,6 @@ module ts {
}
if (emitExtends) links.flags |= NodeCheckFlags.EmitExtends;
links.flags |= NodeCheckFlags.TypeChecked;
fullTypeCheck = false;
}
}
@@ -6372,7 +6541,9 @@ module ts {
forEach(program.getSourceFiles(), checkSourceFile);
}
function getSortedDiagnostics(): Diagnostic[] {
function getSortedDiagnostics(): Diagnostic[]{
Debug.assert(fullTypeCheck, "diagnostics are available only in the full typecheck mode");
if (diagnosticsModified) {
diagnostics.sort(compareDiagnostics);
diagnostics = deduplicateSortedDiagnostics(diagnostics);
@@ -6381,7 +6552,8 @@ module ts {
return diagnostics;
}
function getDiagnostics(sourceFile?: SourceFile): Diagnostic[] {
function getDiagnostics(sourceFile?: SourceFile): Diagnostic[]{
if (sourceFile) {
checkSourceFile(sourceFile);
return filter(getSortedDiagnostics(), d => d.file === sourceFile);
@@ -6854,7 +7026,8 @@ module ts {
writeTypeAtLocation: writeTypeAtLocation,
writeReturnTypeOfSignatureDeclaration: writeReturnTypeOfSignatureDeclaration,
writeSymbol: writeSymbolToTextWriter,
isSymbolAccessible: isSymbolAccessible
isSymbolAccessible: isSymbolAccessible,
isImportDeclarationEntityNameReferenceDeclarationVisibile: isImportDeclarationEntityNameReferenceDeclarationVisibile
};
checkProgram();
return emitFiles(resolver);
+1 -1
View File
@@ -89,7 +89,7 @@ module ts {
description: Diagnostics.Do_not_emit_comments_to_output,
},
{
name: "sourcemap",
name: "sourceMap",
type: "boolean",
description: Diagnostics.Generates_corresponding_map_file,
},
@@ -114,6 +114,51 @@ module ts {
Extends_clause_of_exported_class_0_has_or_is_using_name_1_from_private_module_2: { code: 2021, category: DiagnosticCategory.Error, key: "Extends clause of exported class '{0}' has or is using name '{1}' from private module '{2}'." },
Implements_clause_of_exported_class_0_has_or_is_using_name_1_from_private_module_2: { code: 2022, category: DiagnosticCategory.Error, key: "Implements clause of exported class '{0}' has or is using name '{1}' from private module '{2}'." },
Extends_clause_of_exported_interface_0_has_or_is_using_name_1_from_private_module_2: { code: 2023, category: DiagnosticCategory.Error, key: "Extends clause of exported interface '{0}' has or is using name '{1}' from private module '{2}'." },
Public_static_property_0_of_exported_class_has_or_is_using_private_name_1: { code: 2024, category: DiagnosticCategory.Error, key: "Public static property '{0}' of exported class has or is using private name '{1}'." },
Public_property_0_of_exported_class_has_or_is_using_private_name_1: { code: 2025, category: DiagnosticCategory.Error, key: "Public property '{0}' of exported class has or is using private name '{1}'." },
Property_0_of_exported_interface_has_or_is_using_private_name_1: { code: 2026, category: DiagnosticCategory.Error, key: "Property '{0}' of exported interface has or is using private name '{1}'." },
Exported_variable_0_has_or_is_using_private_name_1: { code: 2027, category: DiagnosticCategory.Error, key: "Exported variable '{0}' has or is using private name '{1}'." },
Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 2028, category: DiagnosticCategory.Error, key: "Public static property '{0}' of exported class has or is using name '{1}' from private module '{2}'." },
Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 2029, category: DiagnosticCategory.Error, key: "Public property '{0}' of exported class has or is using name '{1}' from private module '{2}'." },
Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 2030, category: DiagnosticCategory.Error, key: "Property '{0}' of exported interface has or is using name '{1}' from private module '{2}'." },
Exported_variable_0_has_or_is_using_name_1_from_private_module_2: { code: 2031, category: DiagnosticCategory.Error, key: "Exported variable '{0}' has or is using name '{1}' from private module '{2}'." },
Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1: { code: 2032, category: DiagnosticCategory.Error, key: "Parameter '{0}' of constructor from exported class has or is using private name '{1}'." },
Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1: { code: 2033, category: DiagnosticCategory.Error, key: "Parameter '{0}' of public static property setter from exported class has or is using private name '{1}'." },
Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1: { code: 2034, category: DiagnosticCategory.Error, key: "Parameter '{0}' of public property setter from exported class has or is using private name '{1}'." },
Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 2035, category: DiagnosticCategory.Error, key: "Parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'." },
Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 2036, category: DiagnosticCategory.Error, key: "Parameter '{0}' of call signature from exported interface has or is using private name '{1}'." },
Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { code: 2037, category: DiagnosticCategory.Error, key: "Parameter '{0}' of public static method from exported class has or is using private name '{1}'." },
Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: { code: 2038, category: DiagnosticCategory.Error, key: "Parameter '{0}' of public method from exported class has or is using private name '{1}'." },
Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { code: 2039, category: DiagnosticCategory.Error, key: "Parameter '{0}' of method from exported interface has or is using private name '{1}'." },
Parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 2040, category: DiagnosticCategory.Error, key: "Parameter '{0}' of exported function has or is using private name '{1}'." },
Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 2041, category: DiagnosticCategory.Error, key: "Parameter '{0}' of constructor from exported class has or is using name '{1}' from private module '{2}'." },
Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 2042, category: DiagnosticCategory.Error, key: "Parameter '{0}' of public static property setter from exported class has or is using name '{1}' from private module '{2}'." },
Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 2043, category: DiagnosticCategory.Error, key: "Parameter '{0}' of public property setter from exported class has or is using name '{1}' from private module '{2}'." },
Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 2044, category: DiagnosticCategory.Error, key: "Parameter '{0}' of constructor signature from exported interface has or is using name '{1}' from private module '{2}'." },
Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 2045, category: DiagnosticCategory.Error, key: "Parameter '{0}' of call signature from exported interface has or is using name '{1}' from private module '{2}'." },
Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 2046, category: DiagnosticCategory.Error, key: "Parameter '{0}' of public static method from exported class has or is using name '{1}' from private module '{2}'." },
Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 2047, category: DiagnosticCategory.Error, key: "Parameter '{0}' of public method from exported class has or is using name '{1}' from private module '{2}'." },
Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 2048, category: DiagnosticCategory.Error, key: "Parameter '{0}' of method from exported interface has or is using name '{1}' from private module '{2}'." },
Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2: { code: 2049, category: DiagnosticCategory.Error, key: "Parameter '{0}' of exported function has or is using name '{1}' from private module '{2}'." },
Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0: { code: 2050, category: DiagnosticCategory.Error, key: "Return type of public static property getter from exported class has or is using private name '{0}'." },
Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0: { code: 2051, category: DiagnosticCategory.Error, key: "Return type of public property getter from exported class has or is using private name '{0}'." },
Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 2052, category: DiagnosticCategory.Error, key: "Return type of constructor signature from exported interface has or is using private name '{0}'." },
Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 2053, category: DiagnosticCategory.Error, key: "Return type of call signature from exported interface has or is using private name '{0}'." },
Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 2054, category: DiagnosticCategory.Error, key: "Return type of index signature from exported interface has or is using private name '{0}'." },
Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0: { code: 2055, category: DiagnosticCategory.Error, key: "Return type of public static method from exported class has or is using private name '{0}'." },
Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0: { code: 2056, category: DiagnosticCategory.Error, key: "Return type of public method from exported class has or is using private name '{0}'." },
Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0: { code: 2057, category: DiagnosticCategory.Error, key: "Return type of method from exported interface has or is using private name '{0}'." },
Return_type_of_exported_function_has_or_is_using_private_name_0: { code: 2058, category: DiagnosticCategory.Error, key: "Return type of exported function has or is using private name '{0}'." },
Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 2059, category: DiagnosticCategory.Error, key: "Return type of public static property getter from exported class has or is using name '{0}' from private module '{1}'." },
Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 2060, category: DiagnosticCategory.Error, key: "Return type of public property getter from exported class has or is using name '{0}' from private module '{1}'." },
Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 2061, category: DiagnosticCategory.Error, key: "Return type of constructor signature from exported interface has or is using name '{0}' from private module '{1}'." },
Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 2062, category: DiagnosticCategory.Error, key: "Return type of call signature from exported interface has or is using name '{0}' from private module '{1}'." },
Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 2063, category: DiagnosticCategory.Error, key: "Return type of index signature from exported interface has or is using name '{0}' from private module '{1}'." },
Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 2064, category: DiagnosticCategory.Error, key: "Return type of public static method from exported class has or is using name '{0}' from private module '{1}'." },
Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 2065, category: DiagnosticCategory.Error, key: "Return type of public method from exported class has or is using name '{0}' from private module '{1}'." },
Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 2066, category: DiagnosticCategory.Error, key: "Return type of method from exported interface has or is using name '{0}' from private module '{1}'." },
Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1: { code: 2067, category: DiagnosticCategory.Error, key: "Return type of exported function has or is using name '{0}' from private module '{1}'." },
Import_declaration_0_is_using_private_name_1: { code: 2181, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." },
Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 2208, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'." },
Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 2209, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of call signature from exported interface has or is using private name '{1}'." },
Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { code: 2210, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of public static method from exported class has or is using private name '{1}'." },
@@ -188,6 +233,18 @@ module ts {
A_parameter_property_is_only_allowed_in_a_constructor_implementation: { code: 2246, category: DiagnosticCategory.Error, key: "A parameter property is only allowed in a constructor implementation." },
Function_overload_must_be_static: { code: 2247, category: DiagnosticCategory.Error, key: "Function overload must be static." },
Function_overload_must_not_be_static: { code: 2248, category: DiagnosticCategory.Error, key: "Function overload must not be static." },
Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 2249, category: DiagnosticCategory.Error, key: "Public static property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named." },
Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 2250, category: DiagnosticCategory.Error, key: "Public property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named." },
Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 2251, category: DiagnosticCategory.Error, key: "Exported variable '{0}' has or is using name '{1}' from external module {2} but cannot be named." },
Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 2252, category: DiagnosticCategory.Error, key: "Parameter '{0}' of constructor from exported class has or is using name '{1}' from external module {2} but cannot be named." },
Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 2253, category: DiagnosticCategory.Error, key: "Parameter '{0}' of public static method from exported class has or is using name '{1}' from external module {2} but cannot be named." },
Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 2254, category: DiagnosticCategory.Error, key: "Parameter '{0}' of public method from exported class has or is using name '{1}' from external module {2} but cannot be named." },
Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 2255, category: DiagnosticCategory.Error, key: "Parameter '{0}' of exported function has or is using name '{1}' from external module {2} but cannot be named." },
Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 2256, category: DiagnosticCategory.Error, key: "Return type of public static property getter from exported class has or is using name '{0}' from external module {1} but cannot be named." },
Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 2257, category: DiagnosticCategory.Error, key: "Return type of public property getter from exported class has or is using name '{0}' from external module {1} but cannot be named." },
Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 2258, category: DiagnosticCategory.Error, key: "Return type of public static method from exported class has or is using name '{0}' from external module {1} but cannot be named." },
Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 2259, category: DiagnosticCategory.Error, key: "Return type of public method from exported class has or is using name '{0}' from external module {1} but cannot be named." },
Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 2260, category: DiagnosticCategory.Error, key: "Return type of exported function has or is using name '{0}' from external module {1} but cannot be named." },
Circular_definition_of_import_alias_0: { code: 3000, category: DiagnosticCategory.Error, key: "Circular definition of import alias '{0}'." },
Cannot_find_name_0: { code: 3001, category: DiagnosticCategory.Error, key: "Cannot find name '{0}'." },
Module_0_has_no_exported_member_1: { code: 3002, category: DiagnosticCategory.Error, key: "Module '{0}' has no exported member '{1}'." },
+228
View File
@@ -448,6 +448,186 @@
"category": "Error",
"code": 2023
},
"Public static property '{0}' of exported class has or is using private name '{1}'.": {
"category": "Error",
"code": 2024
},
"Public property '{0}' of exported class has or is using private name '{1}'.": {
"category": "Error",
"code": 2025
},
"Property '{0}' of exported interface has or is using private name '{1}'.": {
"category": "Error",
"code": 2026
},
"Exported variable '{0}' has or is using private name '{1}'.": {
"category": "Error",
"code": 2027
},
"Public static property '{0}' of exported class has or is using name '{1}' from private module '{2}'.": {
"category": "Error",
"code": 2028
},
"Public property '{0}' of exported class has or is using name '{1}' from private module '{2}'.": {
"category": "Error",
"code": 2029
},
"Property '{0}' of exported interface has or is using name '{1}' from private module '{2}'.": {
"category": "Error",
"code": 2030
},
"Exported variable '{0}' has or is using name '{1}' from private module '{2}'.": {
"category": "Error",
"code": 2031
},
"Parameter '{0}' of constructor from exported class has or is using private name '{1}'.": {
"category": "Error",
"code": 2032
},
"Parameter '{0}' of public static property setter from exported class has or is using private name '{1}'.": {
"category": "Error",
"code": 2033
},
"Parameter '{0}' of public property setter from exported class has or is using private name '{1}'.": {
"category": "Error",
"code": 2034
},
"Parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'.": {
"category": "Error",
"code": 2035
},
"Parameter '{0}' of call signature from exported interface has or is using private name '{1}'.": {
"category": "Error",
"code": 2036
},
"Parameter '{0}' of public static method from exported class has or is using private name '{1}'.": {
"category": "Error",
"code": 2037
},
"Parameter '{0}' of public method from exported class has or is using private name '{1}'.": {
"category": "Error",
"code": 2038
},
"Parameter '{0}' of method from exported interface has or is using private name '{1}'.": {
"category": "Error",
"code": 2039
},
"Parameter '{0}' of exported function has or is using private name '{1}'.": {
"category": "Error",
"code": 2040
},
"Parameter '{0}' of constructor from exported class has or is using name '{1}' from private module '{2}'.": {
"category": "Error",
"code": 2041
},
"Parameter '{0}' of public static property setter from exported class has or is using name '{1}' from private module '{2}'.": {
"category": "Error",
"code": 2042
},
"Parameter '{0}' of public property setter from exported class has or is using name '{1}' from private module '{2}'.": {
"category": "Error",
"code": 2043
},
"Parameter '{0}' of constructor signature from exported interface has or is using name '{1}' from private module '{2}'.": {
"category": "Error",
"code": 2044
},
"Parameter '{0}' of call signature from exported interface has or is using name '{1}' from private module '{2}'.": {
"category": "Error",
"code": 2045
},
"Parameter '{0}' of public static method from exported class has or is using name '{1}' from private module '{2}'.": {
"category": "Error",
"code": 2046
},
"Parameter '{0}' of public method from exported class has or is using name '{1}' from private module '{2}'.": {
"category": "Error",
"code": 2047
},
"Parameter '{0}' of method from exported interface has or is using name '{1}' from private module '{2}'.": {
"category": "Error",
"code": 2048
},
"Parameter '{0}' of exported function has or is using name '{1}' from private module '{2}'.": {
"category": "Error",
"code": 2049
},
"Return type of public static property getter from exported class has or is using private name '{0}'.": {
"category": "Error",
"code": 2050
},
"Return type of public property getter from exported class has or is using private name '{0}'.": {
"category": "Error",
"code": 2051
},
"Return type of constructor signature from exported interface has or is using private name '{0}'.": {
"category": "Error",
"code": 2052
},
"Return type of call signature from exported interface has or is using private name '{0}'.": {
"category": "Error",
"code": 2053
},
"Return type of index signature from exported interface has or is using private name '{0}'.": {
"category": "Error",
"code": 2054
},
"Return type of public static method from exported class has or is using private name '{0}'.": {
"category": "Error",
"code": 2055
},
"Return type of public method from exported class has or is using private name '{0}'.": {
"category": "Error",
"code": 2056
},
"Return type of method from exported interface has or is using private name '{0}'.": {
"category": "Error",
"code": 2057
},
"Return type of exported function has or is using private name '{0}'.": {
"category": "Error",
"code": 2058
},
"Return type of public static property getter from exported class has or is using name '{0}' from private module '{1}'.": {
"category": "Error",
"code": 2059
},
"Return type of public property getter from exported class has or is using name '{0}' from private module '{1}'.": {
"category": "Error",
"code": 2060
},
"Return type of constructor signature from exported interface has or is using name '{0}' from private module '{1}'.": {
"category": "Error",
"code": 2061
},
"Return type of call signature from exported interface has or is using name '{0}' from private module '{1}'.": {
"category": "Error",
"code": 2062
},
"Return type of index signature from exported interface has or is using name '{0}' from private module '{1}'.": {
"category": "Error",
"code": 2063
},
"Return type of public static method from exported class has or is using name '{0}' from private module '{1}'.": {
"category": "Error",
"code": 2064
},
"Return type of public method from exported class has or is using name '{0}' from private module '{1}'.": {
"category": "Error",
"code": 2065
},
"Return type of method from exported interface has or is using name '{0}' from private module '{1}'.": {
"category": "Error",
"code": 2066
},
"Return type of exported function has or is using name '{0}' from private module '{1}'.": {
"category": "Error",
"code": 2067
},
"Import declaration '{0}' is using private name '{1}'.": {
"category": "Error",
"code": 2181
},
"Type parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'.": {
"category": "Error",
"code": 2208
@@ -744,6 +924,54 @@
"category": "Error",
"code": 2248
},
"Public static property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named.": {
"category": "Error",
"code": 2249
},
"Public property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named.": {
"category": "Error",
"code": 2250
},
"Exported variable '{0}' has or is using name '{1}' from external module {2} but cannot be named.": {
"category": "Error",
"code": 2251
},
"Parameter '{0}' of constructor from exported class has or is using name '{1}' from external module {2} but cannot be named.": {
"category": "Error",
"code": 2252
},
"Parameter '{0}' of public static method from exported class has or is using name '{1}' from external module {2} but cannot be named.": {
"category": "Error",
"code": 2253
},
"Parameter '{0}' of public method from exported class has or is using name '{1}' from external module {2} but cannot be named.": {
"category": "Error",
"code": 2254
},
"Parameter '{0}' of exported function has or is using name '{1}' from external module {2} but cannot be named.": {
"category": "Error",
"code": 2255
},
"Return type of public static property getter from exported class has or is using name '{0}' from external module {1} but cannot be named.": {
"category": "Error",
"code": 2256
},
"Return type of public property getter from exported class has or is using name '{0}' from external module {1} but cannot be named.": {
"category": "Error",
"code": 2257
},
"Return type of public static method from exported class has or is using name '{0}' from external module {1} but cannot be named.": {
"category": "Error",
"code": 2258
},
"Return type of public method from exported class has or is using name '{0}' from external module {1} but cannot be named.": {
"category": "Error",
"code": 2259
},
"Return type of exported function has or is using name '{0}' from external module {1} but cannot be named.": {
"category": "Error",
"code": 2260
},
"Circular definition of import alias '{0}'.": {
"category": "Error",
"code": 3000
+353 -63
View File
@@ -9,6 +9,7 @@ module ts {
getTextPos(): number;
getLine(): number;
getColumn(): number;
getIndent(): number;
}
var indentStrings: string[] = [];
@@ -141,6 +142,7 @@ module ts {
writeLine: writeLine,
increaseIndent: () => indent++,
decreaseIndent: () => indent--,
getIndent: () => indent,
getTextPos: () => output.length,
getLine: () => lineCount + 1,
getColumn: () => lineStart ? indent * 4 + 1 : output.length - linePos + 1,
@@ -1867,27 +1869,63 @@ module ts {
var enclosingDeclaration: Node;
var reportedDeclarationError = false;
var aliasDeclarationEmitInfo: {
declaration: ImportDeclaration;
outputPos: number;
indent: number;
asynchronousOutput?: string; // If the output for alias was written asynchronously, the corresponding output
}[] = [];
var getSymbolVisibilityDiagnosticMessage: (symbolAccesibilityResult: SymbolAccessiblityResult) => {
errorNode: Node;
diagnosticMessage: DiagnosticMessage;
typeName: Identifier
typeName?: Identifier
}
function writeAsychronousImportDeclarations(importDeclarations: ImportDeclaration[]) {
var oldWriter = writer;
forEach(importDeclarations, aliasToWrite => {
var aliasEmitInfo = forEach(aliasDeclarationEmitInfo, declEmitInfo => declEmitInfo.declaration === aliasToWrite ? declEmitInfo : undefined);
writer = createTextWriter(writeSymbol);
for (var declarationIndent = aliasEmitInfo.indent; declarationIndent; declarationIndent--) {
writer.increaseIndent();
}
writeImportDeclaration(aliasToWrite);
aliasEmitInfo.asynchronousOutput = writer.getText();
});
writer = oldWriter;
}
function writeSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags) {
var symbolAccesibilityResult = resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning);
// TODO(shkamat): Since we dont have error reporting for all the cases as yet we have this check on handler being present
if (!getSymbolVisibilityDiagnosticMessage || symbolAccesibilityResult.accessibility === SymbolAccessibility.Accessible) {
if (symbolAccesibilityResult.accessibility === SymbolAccessibility.Accessible) {
resolver.writeSymbol(symbol, enclosingDeclaration, meaning, writer);
// write the aliases
if (symbolAccesibilityResult && symbolAccesibilityResult.aliasesToMakeVisible) {
writeAsychronousImportDeclarations(symbolAccesibilityResult.aliasesToMakeVisible);
}
}
else {
// Report error
reportedDeclarationError = true;
var errorInfo = getSymbolVisibilityDiagnosticMessage(symbolAccesibilityResult);
diagnostics.push(createDiagnosticForNode(errorInfo.errorNode,
errorInfo.diagnosticMessage,
getSourceTextOfLocalNode(errorInfo.typeName),
symbolAccesibilityResult.errorSymbolName,
symbolAccesibilityResult.errorModuleName));
if (errorInfo) {
if (errorInfo.typeName) {
diagnostics.push(createDiagnosticForNode(errorInfo.errorNode,
errorInfo.diagnosticMessage,
getSourceTextOfLocalNode(errorInfo.typeName),
symbolAccesibilityResult.errorSymbolName,
symbolAccesibilityResult.errorModuleName));
}
else {
diagnostics.push(createDiagnosticForNode(errorInfo.errorNode,
errorInfo.diagnosticMessage,
symbolAccesibilityResult.errorSymbolName,
symbolAccesibilityResult.errorModuleName));
}
}
}
}
@@ -1951,23 +1989,55 @@ module ts {
}
function emitImportDeclaration(node: ImportDeclaration) {
if (resolver.isDeclarationVisible(node)) {
if (node.flags & NodeFlags.Export) {
write("export ");
}
write("import ");
emitSourceTextOfNode(node.name);
write(" = ");
if (node.entityName) {
emitSourceTextOfNode(node.entityName);
write(";");
var nodeEmitInfo = {
declaration: node,
outputPos: writer.getTextPos(),
indent: writer.getIndent(),
hasWritten: resolver.isDeclarationVisible(node)
};
aliasDeclarationEmitInfo.push(nodeEmitInfo);
if (nodeEmitInfo.hasWritten) {
writeImportDeclaration(node);
}
}
function writeImportDeclaration(node: ImportDeclaration) {
// note usage of writer. methods instead of aliases created, just to make sure we are using
// correct writer especially to handle asynchronous alias writing
if (node.flags & NodeFlags.Export) {
writer.write("export ");
}
writer.write("import ");
writer.write(getSourceTextOfLocalNode(node.name));
writer.write(" = ");
if (node.entityName) {
checkEntityNameAccessible();
writer.write(getSourceTextOfLocalNode(node.entityName));
writer.write(";");
}
else {
writer.write("require(");
writer.write(getSourceTextOfLocalNode(node.externalModuleName));
writer.write(");");
}
writer.writeLine();
function checkEntityNameAccessible() {
var symbolAccesibilityResult = resolver.isImportDeclarationEntityNameReferenceDeclarationVisibile(node.entityName);
if (symbolAccesibilityResult.accessibility === SymbolAccessibility.Accessible) {
// write the aliases
if (symbolAccesibilityResult.aliasesToMakeVisible) {
writeAsychronousImportDeclarations(symbolAccesibilityResult.aliasesToMakeVisible);
}
}
else {
write("require(");
emitSourceTextOfNode(node.externalModuleName);
write(");");
// Report error
reportedDeclarationError = true;
diagnostics.push(createDiagnosticForNode(node,
Diagnostics.Import_declaration_0_is_using_private_name_1,
getSourceTextOfLocalNode(node.name),
symbolAccesibilityResult.errorSymbolName));
}
writeLine();
}
}
@@ -2023,7 +2093,7 @@ module ts {
function emitTypeParameters(typeParameters: TypeParameterDeclaration[]) {
function emitTypeParameter(node: TypeParameterDeclaration) {
function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult) {
// TODO(shkamat) Cannot access name errors
// Type parameter constraints are named by user so we should always be able to name it
var diagnosticMessage: DiagnosticMessage;
switch (node.parent.kind) {
case SyntaxKind.ClassDeclaration:
@@ -2082,7 +2152,7 @@ module ts {
diagnosticMessage: diagnosticMessage,
errorNode: node,
typeName: node.name
}
};
}
emitSourceTextOfNode(node.name);
@@ -2090,9 +2160,7 @@ module ts {
if (node.constraint && (node.parent.kind !== SyntaxKind.Method || !(node.parent.flags & NodeFlags.Private))) {
write(" extends ");
getSymbolVisibilityDiagnosticMessage = getTypeParameterConstraintVisibilityError;
resolver.writeTypeAtLocation(node.constraint, enclosingDeclaration, TypeFormatFlags.None, writer);
// TODO(shkamat) This is just till we get rest of the error reporting up
getSymbolVisibilityDiagnosticMessage = undefined;
resolver.writeTypeAtLocation(node.constraint, enclosingDeclaration, TypeFormatFlags.UseTypeOfFunction, writer);
}
}
@@ -2111,48 +2179,34 @@ module ts {
function emitTypeOfTypeReference(node: Node) {
getSymbolVisibilityDiagnosticMessage = getHeritageClauseVisibilityError;
resolver.writeTypeAtLocation(node, enclosingDeclaration, TypeFormatFlags.WriteArrayAsGenericType, writer);
// TODO(shkamat) This is just till we get rest of the error reporting up
getSymbolVisibilityDiagnosticMessage = undefined;
resolver.writeTypeAtLocation(node, enclosingDeclaration, TypeFormatFlags.WriteArrayAsGenericType | TypeFormatFlags.UseTypeOfFunction, writer);
function getHeritageClauseVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult) {
var diagnosticMessage: DiagnosticMessage;
// Heritage clause is written by user so it can always be named
if (node.parent.kind === SyntaxKind.ClassDeclaration) {
// Class
if (symbolAccesibilityResult.accessibility == SymbolAccessibility.NotAccessible) {
if (symbolAccesibilityResult.errorModuleName) {
// Module is inaccessible
diagnosticMessage = isImplementsList ?
Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_name_1_from_private_module_2;
}
else {
// Class or Interface implemented/extended is inaccessible
diagnosticMessage = isImplementsList ?
Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 :
Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1;
}
if (symbolAccesibilityResult.errorModuleName) {
// Module is inaccessible
diagnosticMessage = isImplementsList ?
Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_name_1_from_private_module_2;
}
else {
// CannotBeNamed
// TODO(shkamat): CannotBeNamed error needs to be handled
// Class or Interface implemented/extended is inaccessible
diagnosticMessage = isImplementsList ?
Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 :
Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1;
}
}
else {
// Interface
if (symbolAccesibilityResult.accessibility == SymbolAccessibility.NotAccessible) {
if (symbolAccesibilityResult.errorModuleName) {
// Module is inaccessible
diagnosticMessage = Diagnostics.Extends_clause_of_exported_interface_0_has_or_is_using_name_1_from_private_module_2;
}
else {
// interface is inaccessible
diagnosticMessage = Diagnostics.Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1;
}
if (symbolAccesibilityResult.errorModuleName) {
// Module is inaccessible
diagnosticMessage = Diagnostics.Extends_clause_of_exported_interface_0_has_or_is_using_name_1_from_private_module_2;
}
else {
// CannotBeNamed
// TODO(shkamat): CannotBeNamed error needs to be handled
// interface is inaccessible
diagnosticMessage = Diagnostics.Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1;
}
}
@@ -2160,7 +2214,7 @@ module ts {
diagnosticMessage: diagnosticMessage,
errorNode: node,
typeName: (<Declaration>node.parent).name
}
};
}
}
}
@@ -2237,9 +2291,50 @@ module ts {
}
if (!(node.flags & NodeFlags.Private)) {
write(": ");
resolver.writeTypeAtLocation(node, enclosingDeclaration, TypeFormatFlags.None, writer);
getSymbolVisibilityDiagnosticMessage = getVariableDeclarationTypeVisibilityError;
resolver.writeTypeAtLocation(node, enclosingDeclaration, TypeFormatFlags.UseTypeOfFunction, writer);
}
}
function getVariableDeclarationTypeVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult) {
var diagnosticMessage: DiagnosticMessage;
if (node.kind === SyntaxKind.VariableDeclaration) {
diagnosticMessage = symbolAccesibilityResult.errorModuleName ?
symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Exported_variable_0_has_or_is_using_private_name_1;
}
// This check is to ensure we dont report error on constructor parameter property as that error would be reported during parameter emit
else if (node.kind === SyntaxKind.Property) {
if (node.flags & NodeFlags.Static) {
diagnosticMessage = symbolAccesibilityResult.errorModuleName ?
symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1;
}
else if (node.parent.kind === SyntaxKind.ClassDeclaration) {
diagnosticMessage = symbolAccesibilityResult.errorModuleName ?
symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1;
}
else {
// Interfaces cannot have types that cannot be named
diagnosticMessage = symbolAccesibilityResult.errorModuleName ?
Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1;
}
}
return diagnosticMessage !== undefined ? {
diagnosticMessage: diagnosticMessage,
errorNode: node,
typeName: node.name
} : undefined;
}
}
function emitVariableStatement(node: VariableStatement) {
@@ -2260,11 +2355,55 @@ module ts {
emitSourceTextOfNode(node.name);
if (!(node.flags & NodeFlags.Private)) {
write(": ");
resolver.writeTypeAtLocation(node, enclosingDeclaration, TypeFormatFlags.None, writer);
getSymbolVisibilityDiagnosticMessage = getAccessorDeclarationTypeVisibilityError;
resolver.writeTypeAtLocation(node, enclosingDeclaration, TypeFormatFlags.UseTypeOfFunction, writer);
}
write(";");
writeLine();
}
function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult) {
var diagnosticMessage: DiagnosticMessage;
if (node.kind === SyntaxKind.SetAccessor) {
// Setters have to have type named and cannot infer it so, the type should always be named
if (node.parent.flags & NodeFlags.Static) {
diagnosticMessage = symbolAccesibilityResult.errorModuleName ?
Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1;
}
else {
diagnosticMessage = symbolAccesibilityResult.errorModuleName ?
Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1;
}
return {
diagnosticMessage: diagnosticMessage,
errorNode: node.parameters[0],
typeName: node.name
};
}
else {
if (node.flags & NodeFlags.Static) {
diagnosticMessage = symbolAccesibilityResult.errorModuleName ?
symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named :
Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 :
Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0;
}
else {
diagnosticMessage = symbolAccesibilityResult.errorModuleName ?
symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named :
Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 :
Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0;
}
return {
diagnosticMessage: diagnosticMessage,
errorNode: node.name,
typeName: undefined
};
}
}
}
function emitFunctionDeclaration(node: FunctionDeclaration) {
@@ -2317,10 +2456,76 @@ module ts {
// If this is not a constructor and is not private, emit the return type
if (node.kind !== SyntaxKind.Constructor && !(node.flags & NodeFlags.Private)) {
write(": ");
resolver.writeReturnTypeOfSignatureDeclaration(node, enclosingDeclaration, TypeFormatFlags.None, writer);
getSymbolVisibilityDiagnosticMessage = getReturnTypeVisibilityError;
resolver.writeReturnTypeOfSignatureDeclaration(node, enclosingDeclaration, TypeFormatFlags.UseTypeOfFunction, writer);
}
write(";");
writeLine();
function getReturnTypeVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult) {
var diagnosticMessage: DiagnosticMessage;
switch (node.kind) {
case SyntaxKind.ConstructSignature:
// Interfaces cannot have return types that cannot be named
diagnosticMessage = symbolAccesibilityResult.errorModuleName ?
Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 :
Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0;
break;
case SyntaxKind.CallSignature:
// Interfaces cannot have return types that cannot be named
diagnosticMessage = symbolAccesibilityResult.errorModuleName ?
Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 :
Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0;
break;
case SyntaxKind.IndexSignature:
// Interfaces cannot have return types that cannot be named
diagnosticMessage = symbolAccesibilityResult.errorModuleName ?
Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 :
Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0;
break;
case SyntaxKind.Method:
if (node.flags & NodeFlags.Static) {
diagnosticMessage = symbolAccesibilityResult.errorModuleName ?
symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named :
Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 :
Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0;
}
else if (node.parent.kind === SyntaxKind.ClassDeclaration) {
diagnosticMessage = symbolAccesibilityResult.errorModuleName ?
symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named :
Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 :
Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0;
}
else {
// Interfaces cannot have return types that cannot be named
diagnosticMessage = symbolAccesibilityResult.errorModuleName ?
Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1 :
Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0;
}
break;
case SyntaxKind.FunctionDeclaration:
diagnosticMessage = symbolAccesibilityResult.errorModuleName ?
symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named :
Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 :
Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0;
break;
default:
Debug.fail("This is unknown kind for signature: " + SyntaxKind[node.kind]);
}
return {
diagnosticMessage: diagnosticMessage,
errorNode: <Node>node.name || node,
};
}
}
function emitParameterDeclaration(node: ParameterDeclaration) {
@@ -2334,7 +2539,75 @@ module ts {
if (!(node.parent.flags & NodeFlags.Private)) {
write(": ");
resolver.writeTypeAtLocation(node, enclosingDeclaration, TypeFormatFlags.None, writer);
getSymbolVisibilityDiagnosticMessage = getParameterDeclarationTypeVisibilityError;
resolver.writeTypeAtLocation(node, enclosingDeclaration, TypeFormatFlags.UseTypeOfFunction, writer);
}
function getParameterDeclarationTypeVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult) {
var diagnosticMessage: DiagnosticMessage;
switch (node.parent.kind) {
case SyntaxKind.Constructor:
diagnosticMessage = symbolAccesibilityResult.errorModuleName ?
symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1;
break;
case SyntaxKind.ConstructSignature:
// Interfaces cannot have parameter types that cannot be named
diagnosticMessage = symbolAccesibilityResult.errorModuleName ?
Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1;
break;
case SyntaxKind.CallSignature:
// Interfaces cannot have parameter types that cannot be named
diagnosticMessage = symbolAccesibilityResult.errorModuleName ?
Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1;
break;
case SyntaxKind.Method:
if (node.parent.flags & NodeFlags.Static) {
diagnosticMessage = symbolAccesibilityResult.errorModuleName ?
symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1;
}
else if (node.parent.parent.kind === SyntaxKind.ClassDeclaration) {
diagnosticMessage = symbolAccesibilityResult.errorModuleName ?
symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1;
}
else {
// Interfaces cannot have parameter types that cannot be named
diagnosticMessage = symbolAccesibilityResult.errorModuleName ?
Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1;
}
break;
case SyntaxKind.FunctionDeclaration:
diagnosticMessage = symbolAccesibilityResult.errorModuleName ?
symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 :
Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1;
break;
default:
Debug.fail("This is unknown parent for parameter: " + SyntaxKind[node.parent.kind]);
}
return {
diagnosticMessage: diagnosticMessage,
errorNode: node,
typeName: node.name
};
}
}
@@ -2448,7 +2721,19 @@ module ts {
// TODO(shkamat): Should we not write any declaration file if any of them can produce error,
// or should we just not write this file like we are doing now
if (!reportedDeclarationError) {
writeFile(getModuleNameFromFilename(jsFilePath) + ".d.ts", referencePathsOutput + writer.getText(), compilerOptions.emitBOM);
var declarationOutput = referencePathsOutput;
var synchronousDeclarationOutput = writer.getText();
// apply additions
var appliedSyncOutputPos = 0;
forEach(aliasDeclarationEmitInfo, aliasEmitInfo => {
if (aliasEmitInfo.asynchronousOutput) {
declarationOutput += synchronousDeclarationOutput.substring(appliedSyncOutputPos, aliasEmitInfo.outputPos);
declarationOutput += aliasEmitInfo.asynchronousOutput;
appliedSyncOutputPos = aliasEmitInfo.outputPos;
}
});
declarationOutput += synchronousDeclarationOutput.substring(appliedSyncOutputPos);
writeFile(getModuleNameFromFilename(jsFilePath) + ".d.ts", declarationOutput, compilerOptions.emitBOM);
}
}
@@ -2469,6 +2754,11 @@ module ts {
if (compilerOptions.out) {
emitFile(compilerOptions.out);
}
// Sort and make the unique list of diagnostics
diagnostics.sort(compareDiagnostics);
diagnostics = deduplicateSortedDiagnostics(diagnostics);
return {
errors: diagnostics,
sourceMaps: sourceMapDataList
+21 -41
View File
@@ -1574,11 +1574,11 @@ module ts {
// Note: for ease of implementation we treat productions '2' and '3' as the same thing.
// (i.e. they're both BinaryExpressions with an assignment operator in it).
// First, check if we have production '4' (an arrow function). Note that if we do, we
// must *not* recurse for productsion 1, 2 or 3. An ArrowFunction is not a
// LeftHandSideExpression, nor does it start a ConditionalExpression. So we are done
// First, check if we have an arrow function (production '4') that starts with a parenthesized
// parameter list. If we do, we must *not* recurse for productsion 1, 2 or 3. An ArrowFunction is
// not a LeftHandSideExpression, nor does it start a ConditionalExpression. So we are done
// with AssignmentExpression if we see one.
var arrowExpression = tryParseArrowFunctionExpression();
var arrowExpression = tryParseParenthesizedArrowFunctionExpression();
if (arrowExpression) {
return arrowExpression;
}
@@ -1587,6 +1587,13 @@ module ts {
// including a conditional expression.
var expr = parseConditionalExpression(noIn);
// To avoid a look-ahead, we did not handle the case of an arrow function with a single un-parenthesized
// parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single
// identifier and the current token is an arrow.
if (expr.kind === SyntaxKind.Identifier && token === SyntaxKind.EqualsGreaterThanToken) {
return parseSimpleArrowFunctionExpression(<Identifier>expr);
}
// Now see if we might be in cases '2' or '3'.
// If the expression was a LHS expression, and we have an assignment operator, then
// we're in '2' or '3'. Consume the assignment and return.
@@ -1633,39 +1640,7 @@ module ts {
return false;
}
function tryParseArrowFunctionExpression(): Expression {
return isSimpleArrowFunctionExpression()
? parseSimpleArrowFunctionExpression()
: tryParseParenthesizedArrowFunctionExpression();
}
function isSimpleArrowFunctionExpression(): boolean {
if (token === SyntaxKind.EqualsGreaterThanToken) {
// ERROR RECOVERY TWEAK:
// If we see a standalone => try to parse it as an arrow function expression as that's
// likely whatthe user intended to write.
return true;
}
if (token === SyntaxKind.Identifier) {
// if we see: a =>
// then this is clearly an arrow function expression.
return lookAhead(() => {
return nextToken() === SyntaxKind.EqualsGreaterThanToken;
});
}
// Definitely not a simple arrow function expression.
return false;
}
function parseSimpleArrowFunctionExpression(): Expression {
Debug.assert(token === SyntaxKind.Identifier || token === SyntaxKind.EqualsGreaterThanToken);
// Get the identifier for the simple arrow. If one isn't there then we'll report a useful
// message that it is missing.
var identifier = parseIdentifier();
function parseSimpleArrowFunctionExpression(identifier: Identifier): Expression {
Debug.assert(token === SyntaxKind.EqualsGreaterThanToken, "parseSimpleArrowFunctionExpression should only have been called if we had a =>");
parseExpected(SyntaxKind.EqualsGreaterThanToken);
@@ -1684,8 +1659,6 @@ module ts {
}
function tryParseParenthesizedArrowFunctionExpression(): Expression {
var pos = getNodePos();
// Indicates whether we are certain that we should parse an arrow expression.
var triState = isParenthesizedArrowFunctionExpression();
@@ -1693,6 +1666,8 @@ module ts {
return undefined;
}
var pos = getNodePos();
if (triState === Tristate.True) {
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken);
@@ -1785,7 +1760,12 @@ module ts {
}
});
}
if (token === SyntaxKind.EqualsGreaterThanToken) {
// ERROR RECOVERY TWEAK:
// If we see a standalone => try to parse it as an arrow function expression as that's
// likely whatthe user intended to write.
return Tristate.True;
}
// Definitely not a parenthesized arrow function.
return Tristate.False;
}
@@ -3602,7 +3582,7 @@ module ts {
getCompilerHost: () => host,
getDiagnostics: getDiagnostics,
getGlobalDiagnostics: getGlobalDiagnostics,
getTypeChecker: () => createTypeChecker(program),
getTypeChecker: fullTypeCheckMode => createTypeChecker(program, fullTypeCheckMode),
getCommonSourceDirectory: () => commonSourceDirectory,
};
return program;
+6 -12
View File
@@ -14,7 +14,7 @@ interface System {
createDirectory(directoryName: string): void;
getExecutingFilePath(): string;
getCurrentDirectory(): string;
getMemoryUsage(): number;
getMemoryUsage?(): number;
exit(exitCode?: number): void;
}
@@ -106,9 +106,6 @@ var sys: System = (function () {
write(s: string): void {
WScript.StdOut.Write(s);
},
writeErr(s: string): void {
WScript.StdErr.Write(s);
},
readFile: readFile,
writeFile: writeFile,
resolvePath(path: string): string {
@@ -131,9 +128,6 @@ var sys: System = (function () {
getCurrentDirectory() {
return new ActiveXObject("WScript.Shell").CurrentDirectory;
},
getMemoryUsage() {
return 0;
},
exit(exitCode?: number): void {
try {
WScript.Quit(exitCode);
@@ -195,10 +189,8 @@ var sys: System = (function () {
newLine: _os.EOL,
useCaseSensitiveFileNames: useCaseSensitiveFileNames,
write(s: string): void {
process.stdout.write(s);
},
writeErr(s: string): void {
process.stderr.write(s);
// 1 is a standard descriptor for stdout
_fs.writeSync(1, s);
},
readFile: readFile,
writeFile: writeFile,
@@ -239,7 +231,9 @@ var sys: System = (function () {
return (<any>process).cwd();
},
getMemoryUsage() {
global.gc();
if (global.gc) {
global.gc();
}
return process.memoryUsage().heapUsed;
},
exit(exitCode?: number): void {
+5 -1
View File
@@ -326,7 +326,7 @@ module ts {
var reportStart = bindStart;
}
else {
var checker = program.getTypeChecker();
var checker = program.getTypeChecker(/*fullTypeCheckMode*/ true);
var checkStart = new Date().getTime();
var semanticErrors = checker.getDiagnostics();
var emitStart = new Date().getTime();
@@ -337,12 +337,16 @@ module ts {
reportDiagnostics(errors);
if (commandLine.options.diagnostics) {
var memoryUsed = sys.getMemoryUsage ? sys.getMemoryUsage() : -1;
reportCountStatistic("Files", program.getSourceFiles().length);
reportCountStatistic("Lines", countLines(program));
reportCountStatistic("Nodes", checker ? checker.getNodeCount() : 0);
reportCountStatistic("Identifiers", checker ? checker.getIdentifierCount() : 0);
reportCountStatistic("Symbols", checker ? checker.getSymbolCount() : 0);
reportCountStatistic("Types", checker ? checker.getTypeCount() : 0);
if (memoryUsed >= 0) {
reportStatisticalValue("Memory used", Math.round(memoryUsed / 1000) + "K");
}
reportTimeStatistic("Parse time", bindStart - parseStart);
reportTimeStatistic("Bind time", checkStart - bindStart);
reportTimeStatistic("Check time", emitStart - checkStart);
+7 -3
View File
@@ -542,7 +542,7 @@ module ts {
getCompilerHost(): CompilerHost;
getDiagnostics(sourceFile?: SourceFile): Diagnostic[];
getGlobalDiagnostics(): Diagnostic[];
getTypeChecker(): TypeChecker;
getTypeChecker(fullTypeCheckMode: boolean): TypeChecker;
getCommonSourceDirectory(): string;
}
@@ -630,6 +630,8 @@ module ts {
/** writes Array<T> instead T[] */
WriteArrayAsGenericType = 0x00000001, // Declarations
UseTypeOfFunction = 0x00000002, // instead of writing signature type of function use typeof
}
export enum SymbolAccessibility {
@@ -640,8 +642,9 @@ module ts {
export interface SymbolAccessiblityResult {
accessibility: SymbolAccessibility;
errorSymbolName?: string; // Optional symbol name that results in error
errorModuleName?: string; // If the symbol is not visibile from module, module's name
errorSymbolName?: string // Optional symbol name that results in error
errorModuleName?: string // If the symbol is not visibile from module, module's name
aliasesToMakeVisible?: ImportDeclaration[]; // aliases that need to have this symbol visible
}
export interface EmitResolver {
@@ -661,6 +664,7 @@ module ts {
writeReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: TextWriter): void;
writeSymbol(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags, writer: TextWriter): void;
isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessiblityResult;
isImportDeclarationEntityNameReferenceDeclarationVisibile(entityName: EntityName): SymbolAccessiblityResult;
}
export enum SymbolFlags {
+3 -89
View File
@@ -126,93 +126,7 @@ class CompilerBaselineRunner extends RunnerBase {
otherFiles: { unitName: string; content: string }[],
result: Harness.Compiler.CompilerResult
) {
var outputLines: string[] = [];
// Count up all the errors we find so we don't miss any
var totalErrorsReported = 0;
function outputErrorText(error: Harness.Compiler.MinimalDiagnostic) {
var errLines = RunnerBase.removeFullPaths(error.message)
.split('\n')
.map(s => s.length > 0 && s.charAt(s.length - 1) === '\r' ? s.substr(0, s.length - 1) : s)
.filter(s => s.length > 0)
.map(s => '!!! ' + s);
errLines.forEach(e => outputLines.push(e));
totalErrorsReported++;
}
// Report glovbal errors:
var globalErrors = result.errors.filter(err => !err.filename);
globalErrors.forEach(err => outputErrorText(err));
// 'merge' the lines of each input file with any errors associated with it
toBeCompiled.concat(otherFiles).forEach(inputFile => {
// Filter down to the errors in the file
var fileErrors = result.errors.filter(e => {
var errFn = e.filename;
return errFn && errFn === inputFile.unitName;
});
// Header
outputLines.push('==== ' + inputFile.unitName + ' (' + fileErrors.length + ' errors) ====');
// Make sure we emit something for every error
var markedErrorCount = 0;
// For each line, emit the line followed by any error squiggles matching this line
// Note: IE JS engine incorrectly handles consecutive delimiters here when using RegExp split, so
// we have to string-based splitting instead and try to figure out the delimiting chars
var lineStarts = ts.getLineStarts(inputFile.content);
var lines = inputFile.content.split('\n');
lines.forEach((line, lineIndex) => {
if (line.length > 0 && line.charAt(line.length - 1) === '\r') {
line = line.substr(0, line.length - 1);
}
var thisLineStart = lineStarts[lineIndex];
var nextLineStart: number;
// On the last line of the file, fake the next line start number so that we handle errors on the last character of the file correctly
if (lineIndex === lines.length - 1) {
nextLineStart = inputFile.content.length;
} else {
nextLineStart = lineStarts[lineIndex + 1];
}
// Emit this line from the original file
outputLines.push(' ' + line);
fileErrors.forEach(err => {
// Does any error start or continue on to this line? Emit squiggles
if ((err.end >= thisLineStart) && ((err.start < nextLineStart) || (lineIndex === lines.length - 1))) {
// How many characters from the start of this line the error starts at (could be positive or negative)
var relativeOffset = err.start - thisLineStart;
// How many characters of the error are on this line (might be longer than this line in reality)
var length = (err.end - err.start) - Math.max(0, thisLineStart - err.start);
// Calculate the start of the squiggle
var squiggleStart = Math.max(0, relativeOffset);
// TODO/REVIEW: this doesn't work quite right in the browser if a multi file test has files whose names are just the right length relative to one another
outputLines.push(' ' + line.substr(0, squiggleStart).replace(/[^\s]/g, ' ') + new Array(Math.min(length, line.length - squiggleStart) + 1).join('~'));
// If the error ended here, or we're at the end of the file, emit its message
if ((lineIndex === lines.length - 1) || nextLineStart > err.end) {
// Just like above, we need to do a split on a string instead of on a regex
// because the JS engine does regexes wrong
outputErrorText(err);
markedErrorCount++;
}
}
});
});
// Verify we didn't miss any errors in this file
assert.equal(markedErrorCount, fileErrors.length, 'count of errors in ' + inputFile.unitName);
});
// Verify we didn't miss any errors in total
assert.equal(totalErrorsReported, result.errors.length, 'total number of errors');
return outputLines.join('\r\n');
return Harness.Compiler.getErrorBaseline(toBeCompiled.concat(otherFiles), result.errors);
}
// check errors
@@ -250,7 +164,7 @@ class CompilerBaselineRunner extends RunnerBase {
var declFile = ts.forEach(result.declFilesCode,
declFile => declFile.fileName === (file.unitName.substr(0, file.unitName.length - ".ts".length) + ".d.ts")
? declFile : undefined);
return { unitName: rootDir + Harness.Path.getFileName(declFile.fileName), content: declFile.code };
return { unitName: declFile.fileName, content: declFile.code };
}
}
@@ -294,7 +208,7 @@ class CompilerBaselineRunner extends RunnerBase {
if (result.declFilesCode.length > 0) {
jsCode += '\r\n\r\n';
for (var i = 0; i < result.files.length; i++) {
for (var i = 0; i < result.declFilesCode.length; i++) {
jsCode += '//// [' + Harness.Path.getFileName(result.declFilesCode[i].fileName) + ']\r\n';
jsCode += getByteOrderMarkText(result.declFilesCode[i]);
jsCode += result.declFilesCode[i].code;
+8 -9
View File
@@ -254,7 +254,7 @@ module FourSlash {
}
});
this.languageServiceShimHost.addScript('lib.d.ts', Harness.Compiler.libTextMinimal);
this.languageServiceShimHost.addDefaultLibrary();
// Sneak into the language service and get its compiler so we can examine the syntax trees
@@ -1419,8 +1419,8 @@ module FourSlash {
for (var i = 0; i < spans.length; i++) {
var expectedSpan = spans[i];
var actualSpan = actual[i];
if (expectedSpan.start !== actualSpan.start() || expectedSpan.end !== actualSpan.end()) {
throw new Error('verifyOutliningSpans failed - span ' + (i + 1) + ' expected: (' + expectedSpan.start + ',' + expectedSpan.end + '), actual: (' + actualSpan.start() + ',' + actualSpan.end() + ')');
if (expectedSpan.start !== actualSpan.textSpan.start() || expectedSpan.end !== actualSpan.textSpan.end()) {
throw new Error('verifyOutliningSpans failed - span ' + (i + 1) + ' expected: (' + expectedSpan.start + ',' + expectedSpan.end + '), actual: (' + actualSpan.textSpan.start() + ',' + actualSpan.textSpan.end() + ')');
}
}
}
@@ -1467,7 +1467,7 @@ module FourSlash {
var referenceLanguageService = referenceLanguageServiceShim.languageService;
// Add lib.d.ts to the reference language service
referenceLanguageServiceShimHost.addScript('lib.d.ts', Harness.Compiler.libTextMinimal);
referenceLanguageServiceShimHost.addDefaultLibrary();
for (var i = 0; i < this.testData.files.length; i++) {
var file = this.testData.files[i];
@@ -1885,7 +1885,7 @@ module FourSlash {
// Cache these between executions so we don't have to re-parse them for every test
var fourslashSourceFile: ts.SourceFile = undefined;
var libdtsSourceFile: ts.SourceFile = undefined;
export function runFourSlashTestContent(content: string, fileName: string): TestXmlData {
// Parse out the files and their metadata
var testData = parseTestData(content, fileName);
@@ -1896,16 +1896,15 @@ module FourSlash {
var fourslashFilename = 'fourslash.ts';
var tsFn = 'tests/cases/fourslash/' + fourslashFilename;
fourslashSourceFile = fourslashSourceFile || ts.createSourceFile(tsFn, Harness.IO.readFile(tsFn), ts.ScriptTarget.ES5, /*version*/ 0, /*isOpen*/ false);
libdtsSourceFile = libdtsSourceFile || ts.createSourceFile('lib.d.ts', Harness.Compiler.libTextMinimal, ts.ScriptTarget.ES3, /*version*/ 0, /*isOpen*/ false);
var files: { [filename: string]: ts.SourceFile; } = {};
files[fourslashFilename] = fourslashSourceFile;
files[fileName] = ts.createSourceFile(fileName, content, ts.ScriptTarget.ES5, /*version*/ 0, /*isOpen*/ false);
files['lib.d.ts'] = libdtsSourceFile;
files[Harness.Compiler.defaultLibFileName] = Harness.Compiler.defaultLibSourceFile;
var host = Harness.Compiler.createCompilerHost(files, (fn, contents) => result = contents);
var program = ts.createProgram([fileName, fourslashFilename], {}, host);
var checker = ts.createTypeChecker(program);
var program = ts.createProgram([fourslashFilename, fileName], { out: "fourslashTestOutput.js" }, host);
var checker = ts.createTypeChecker(program, /*fullTypeCheckMode*/ true);
checker.checkProgram();
var errs = checker.getDiagnostics(files[fileName]);
+107 -11
View File
@@ -434,15 +434,15 @@ module Harness {
export var libFolder: string;
switch (Utils.getExecutionEnvironment()) {
case Utils.ExecutionEnvironment.CScript:
libFolder = Path.filePath(global['WScript'].ScriptFullName);
libFolder = "built/local/";
tcServicesFilename = "built/local/typescriptServices.js";
break;
case Utils.ExecutionEnvironment.Node:
libFolder = (__dirname + '/');
libFolder = "built/local/";
tcServicesFilename = "built/local/typescriptServices.js";
break;
case Utils.ExecutionEnvironment.Browser:
libFolder = "bin/";
libFolder = "built/local/";
tcServicesFilename = "built/local/typescriptServices.js";
break;
default:
@@ -531,8 +531,8 @@ module Harness {
}
}
export var libText = IO.readFile(libFolder + "lib.d.ts");
export var libTextMinimal = IO.readFile('bin/lib.core.d.ts');
export var defaultLibFileName = 'lib.d.ts';
export var defaultLibSourceFile = ts.createSourceFile(defaultLibFileName, IO.readFile(libFolder + 'lib.core.d.ts'), /*languageVersion*/ ts.ScriptTarget.ES5);
export function createCompilerHost(filemap: { [filename: string]: ts.SourceFile; }, writeFile: (fn: string, contents: string, writeByteOrderMark:boolean) => void): ts.CompilerHost {
return {
@@ -542,15 +542,15 @@ module Harness {
if (fn in filemap) {
return filemap[fn];
} else {
var lib = 'lib.d.ts';
if (fn.substr(fn.length - lib.length) === lib) {
return filemap[fn] = ts.createSourceFile('lib.d.ts', libTextMinimal, languageVersion);
var lib = defaultLibFileName;
if (fn === defaultLibFileName) {
return defaultLibSourceFile;
}
// Don't throw here -- the compiler might be looking for a test that actually doesn't exist as part of the TC
return null;
}
},
getDefaultLibFilename: () => 'lib.d.ts',
getDefaultLibFilename: () => defaultLibFileName,
writeFile: writeFile,
getCanonicalFileName: ts.getCanonicalFileName,
useCaseSensitiveFileNames: () => sys.useCaseSensitiveFileNames,
@@ -736,7 +736,7 @@ module Harness {
var hadParseErrors = program.getDiagnostics().length > 0;
var checker = program.getTypeChecker();
var checker = program.getTypeChecker(/*fullTypeCheckMode*/ true);
checker.checkProgram();
// only emit if there weren't parse errors
@@ -748,7 +748,7 @@ module Harness {
var errors: MinimalDiagnostic[] = [];
program.getDiagnostics().concat(checker.getDiagnostics()).concat(emitResult ? emitResult.errors : []).forEach(err => {
// TODO: new compiler formats errors after this point to add . and newlines so we'll just do it manually for now
errors.push({ filename: err.file && err.file.filename, start: err.start, end: err.start + err.length, line: 0, character: 0, message: err.messageText });
errors.push(getMinimalDiagnostic(err));
});
this.lastErrors = errors;
@@ -763,6 +763,102 @@ module Harness {
}
}
export function getMinimalDiagnostic(err: ts.Diagnostic): MinimalDiagnostic {
return { filename: err.file && err.file.filename, start: err.start, end: err.start + err.length, line: 0, character: 0, message: err.messageText };
}
export function getErrorBaseline(inputFiles: { unitName: string; content: string }[],
diagnostics: MinimalDiagnostic[]
) {
var outputLines: string[] = [];
// Count up all the errors we find so we don't miss any
var totalErrorsReported = 0;
function outputErrorText(error: Harness.Compiler.MinimalDiagnostic) {
var errLines = RunnerBase.removeFullPaths(error.message)
.split('\n')
.map(s => s.length > 0 && s.charAt(s.length - 1) === '\r' ? s.substr(0, s.length - 1) : s)
.filter(s => s.length > 0)
.map(s => '!!! ' + s);
errLines.forEach(e => outputLines.push(e));
totalErrorsReported++;
}
// Report glovbal errors:
var globalErrors = diagnostics.filter(err => !err.filename);
globalErrors.forEach(err => outputErrorText(err));
// 'merge' the lines of each input file with any errors associated with it
inputFiles.forEach(inputFile => {
// Filter down to the errors in the file
var fileErrors = diagnostics.filter(e => {
var errFn = e.filename;
return errFn && errFn === inputFile.unitName;
});
// Header
outputLines.push('==== ' + inputFile.unitName + ' (' + fileErrors.length + ' errors) ====');
// Make sure we emit something for every error
var markedErrorCount = 0;
// For each line, emit the line followed by any error squiggles matching this line
// Note: IE JS engine incorrectly handles consecutive delimiters here when using RegExp split, so
// we have to string-based splitting instead and try to figure out the delimiting chars
var lineStarts = ts.getLineStarts(inputFile.content);
var lines = inputFile.content.split('\n');
lines.forEach((line, lineIndex) => {
if (line.length > 0 && line.charAt(line.length - 1) === '\r') {
line = line.substr(0, line.length - 1);
}
var thisLineStart = lineStarts[lineIndex];
var nextLineStart: number;
// On the last line of the file, fake the next line start number so that we handle errors on the last character of the file correctly
if (lineIndex === lines.length - 1) {
nextLineStart = inputFile.content.length;
} else {
nextLineStart = lineStarts[lineIndex + 1];
}
// Emit this line from the original file
outputLines.push(' ' + line);
fileErrors.forEach(err => {
// Does any error start or continue on to this line? Emit squiggles
if ((err.end >= thisLineStart) && ((err.start < nextLineStart) || (lineIndex === lines.length - 1))) {
// How many characters from the start of this line the error starts at (could be positive or negative)
var relativeOffset = err.start - thisLineStart;
// How many characters of the error are on this line (might be longer than this line in reality)
var length = (err.end - err.start) - Math.max(0, thisLineStart - err.start);
// Calculate the start of the squiggle
var squiggleStart = Math.max(0, relativeOffset);
// TODO/REVIEW: this doesn't work quite right in the browser if a multi file test has files whose names are just the right length relative to one another
outputLines.push(' ' + line.substr(0, squiggleStart).replace(/[^\s]/g, ' ') + new Array(Math.min(length, line.length - squiggleStart) + 1).join('~'));
// If the error ended here, or we're at the end of the file, emit its message
if ((lineIndex === lines.length - 1) || nextLineStart > err.end) {
// Just like above, we need to do a split on a string instead of on a regex
// because the JS engine does regexes wrong
outputErrorText(err);
markedErrorCount++;
}
}
});
});
// Verify we didn't miss any errors in this file
assert.equal(markedErrorCount, fileErrors.length, 'count of errors in ' + inputFile.unitName);
});
// Verify we didn't miss any errors in total
assert.equal(totalErrorsReported, diagnostics.length, 'total number of errors');
return outputLines.join('\r\n');
}
/* TODO: Delete?
export function makeDefaultCompilerSettings(options?: { useMinimalDefaultLib: boolean; noImplicitAny: boolean; }) {
var useMinimalDefaultLib = options ? options.useMinimalDefaultLib : true;
+1 -1
View File
@@ -175,7 +175,7 @@ module Harness.LanguageService {
}
public addDefaultLibrary() {
this.addScript("lib.d.ts", Harness.Compiler.libText);
this.addScript(Harness.Compiler.defaultLibFileName, Harness.Compiler.defaultLibSourceFile.text);
}
public getHostIdentifier(): string {
+139 -82
View File
@@ -29,13 +29,15 @@ interface BatchCompileProjectTestCaseEmittedFile extends Harness.Compiler.Genera
emittedFileName: string;
}
interface BatchCompileProjectTestCaseResult {
interface CompileProjectFilesResult {
moduleKind: ts.ModuleKind;
program: ts.Program;
readInputFiles: ts.SourceFile[];
sourceMapData: ts.SourceMapData[];
outputFiles: BatchCompileProjectTestCaseEmittedFile[];
errors: ts.Diagnostic[];
sourceMapData: ts.SourceMapData[];
}
interface BatchCompileProjectTestCaseResult extends CompileProjectFilesResult {
outputFiles: BatchCompileProjectTestCaseEmittedFile[];
nonSubfolderDiskFiles: number;
}
@@ -114,13 +116,43 @@ class ProjectRunner extends RunnerBase {
return url;
}
function batchCompilerProjectTestCase(moduleKind: ts.ModuleKind): BatchCompileProjectTestCaseResult{
var nonSubfolderDiskFiles = 0;
var readInputFiles: ts.SourceFile[] = [];
function getCurrentDirectory() {
return sys.resolvePath(testCase.projectRoot);
}
function compileProjectFiles(moduleKind: ts.ModuleKind, getInputFiles: ()=> string[],
getSourceFileText: (filename: string) => string,
writeFile: (filename: string, data: string, writeByteOrderMark: boolean) => void): CompileProjectFilesResult {
var program = ts.createProgram(getInputFiles(), createCompilerOptions(), createCompilerHost());
var errors = program.getDiagnostics();
var sourceMapData: ts.SourceMapData[] = null;
var outputFiles: BatchCompileProjectTestCaseEmittedFile[] = [];
if (!errors.length) {
var checker = program.getTypeChecker(/*fullTypeCheck*/ true);
errors = checker.getDiagnostics();
var emitResult = checker.emitFiles();
errors = ts.concatenate(errors, emitResult.errors);
sourceMapData = emitResult.sourceMaps;
// Clean up source map data that will be used in baselining
if (sourceMapData) {
for (var i = 0; i < sourceMapData.length; i++) {
for (var j = 0; j < sourceMapData[i].sourceMapSources.length; j++) {
sourceMapData[i].sourceMapSources[j] = cleanProjectUrl(sourceMapData[i].sourceMapSources[j]);
}
sourceMapData[i].jsSourceMappingURL = cleanProjectUrl(sourceMapData[i].jsSourceMappingURL);
sourceMapData[i].sourceMapSourceRoot = cleanProjectUrl(sourceMapData[i].sourceMapSourceRoot);
}
}
}
return {
moduleKind: moduleKind,
program: program,
errors: errors,
sourceMapData: sourceMapData
};
function createCompilerOptions(): ts.CompilerOptions {
return {
@@ -136,32 +168,59 @@ class ProjectRunner extends RunnerBase {
function getSourceFile(filename: string, languageVersion: ts.ScriptTarget): ts.SourceFile {
var sourceFile: ts.SourceFile = undefined;
if (filename === 'lib.d.ts') {
sourceFile = ts.createSourceFile('lib.d.ts', Harness.Compiler.libTextMinimal, languageVersion);
if (filename === Harness.Compiler.defaultLibFileName) {
sourceFile = Harness.Compiler.defaultLibSourceFile;
}
else {
assert.isTrue(!ts.filter(readInputFiles, sourceFile => sourceFile.filename == filename).length, "Compiler trying to read same file again: " + filename);
try {
var text = sys.readFile(ts.isRootedDiskPath(filename)
? filename
: ts.normalizeSlashes(testCase.projectRoot) + "/" + ts.normalizeSlashes(filename));
}
catch (e) {
// text doesn't get defined.
}
var text = getSourceFileText(filename);
if (text !== undefined) {
sourceFile = ts.createSourceFile(filename, text, languageVersion);
}
}
if (sourceFile) {
readInputFiles.push(sourceFile);
}
return sourceFile;
}
function createCompilerHost(): ts.CompilerHost {
return {
getSourceFile: getSourceFile,
getDefaultLibFilename: () => "lib.d.ts",
writeFile: writeFile,
getCurrentDirectory: getCurrentDirectory,
getCanonicalFileName: ts.getCanonicalFileName,
useCaseSensitiveFileNames: () => sys.useCaseSensitiveFileNames,
getNewLine: () => sys.newLine
};
}
}
function batchCompilerProjectTestCase(moduleKind: ts.ModuleKind): BatchCompileProjectTestCaseResult{
var nonSubfolderDiskFiles = 0;
var outputFiles: BatchCompileProjectTestCaseEmittedFile[] = [];
var projectCompilerResult = compileProjectFiles(moduleKind, () => testCase.inputFiles, getSourceFileText, writeFile);
return {
moduleKind: moduleKind,
program: projectCompilerResult.program,
sourceMapData: projectCompilerResult.sourceMapData,
outputFiles: outputFiles,
errors: projectCompilerResult.errors,
nonSubfolderDiskFiles: nonSubfolderDiskFiles,
};
function getSourceFileText(filename: string): string {
try {
var text = sys.readFile(ts.isRootedDiskPath(filename)
? filename
: ts.normalizeSlashes(testCase.projectRoot) + "/" + ts.normalizeSlashes(filename));
}
catch (e) {
// text doesn't get defined.
}
return text;
}
function writeFile(filename: string, data: string, writeByteOrderMark: boolean) {
var diskFileName = ts.isRootedDiskPath(filename)
? filename
@@ -209,53 +268,55 @@ class ProjectRunner extends RunnerBase {
outputFiles.push({ emittedFileName: filename, code: data, fileName: diskRelativeName, writeByteOrderMark: writeByteOrderMark });
}
}
function getCurrentDirectory() {
return sys.resolvePath(testCase.projectRoot);
function compileCompileDTsFiles(compilerResult: BatchCompileProjectTestCaseResult) {
var inputDtsSourceFiles = ts.map(ts.filter(compilerResult.program.getSourceFiles(),
sourceFile => Harness.Compiler.isDTS(sourceFile.filename)),
sourceFile => {
return { emittedFileName: sourceFile.filename, code: sourceFile.text };
});
var ouputDtsFiles = ts.filter(compilerResult.outputFiles, ouputFile => Harness.Compiler.isDTS(ouputFile.emittedFileName));
var allInputFiles = inputDtsSourceFiles.concat(ouputDtsFiles);
return compileProjectFiles(compilerResult.moduleKind,getInputFiles, getSourceFileText, writeFile);
function getInputFiles() {
return ts.map(allInputFiles, outputFile => outputFile.emittedFileName);
}
function getSourceFileText(filename: string): string {
return ts.forEach(allInputFiles, inputFile => inputFile.emittedFileName === filename ? inputFile.code : undefined);
}
function createCompilerHost(): ts.CompilerHost {
return {
getSourceFile: getSourceFile,
getDefaultLibFilename: () => "lib.d.ts",
writeFile: writeFile,
getCurrentDirectory: getCurrentDirectory,
getCanonicalFileName: ts.getCanonicalFileName,
useCaseSensitiveFileNames: () => sys.useCaseSensitiveFileNames,
getNewLine:()=> sys.newLine
};
function writeFile(filename: string, data: string, writeByteOrderMark: boolean) {
}
}
var program = ts.createProgram(testCase.inputFiles, createCompilerOptions(), createCompilerHost());
var errors = program.getDiagnostics();
if (!errors.length) {
var checker = program.getTypeChecker();
errors = checker.getDiagnostics();
var emitResult = checker.emitFiles();
errors = ts.concatenate(errors, emitResult.errors);
sourceMapData = emitResult.sourceMaps;
// Clean up source map data that will be used in baselining
if (sourceMapData) {
for (var i = 0; i < sourceMapData.length; i++) {
for (var j = 0; j < sourceMapData[i].sourceMapSources.length; j++) {
sourceMapData[i].sourceMapSources[j] = cleanProjectUrl(sourceMapData[i].sourceMapSources[j]);
}
sourceMapData[i].jsSourceMappingURL = cleanProjectUrl(sourceMapData[i].jsSourceMappingURL);
sourceMapData[i].sourceMapSourceRoot = cleanProjectUrl(sourceMapData[i].sourceMapSourceRoot);
}
function getErrorsBaseline(compilerResult: CompileProjectFilesResult) {
// This is copied from tc.ts's reportError to replicate what tc does
var errors = "";
for (var i = 0; i < compilerResult.errors.length; i++) {
var error = compilerResult.errors[i];
// TODO(jfreeman): Remove assert
ts.Debug.assert(error.messageText.indexOf("{NL}") < 0);
if (error.file) {
var loc = error.file.getLineAndCharacterFromPosition(error.start);
errors += error.file.filename + "(" + loc.line + "," + loc.character + "): " + error.messageText + sys.newLine;
}
else {
errors += error.messageText + sys.newLine;
}
}
return {
moduleKind: moduleKind,
program: program,
readInputFiles: readInputFiles,
sourceMapData: sourceMapData,
outputFiles: outputFiles,
errors: errors,
nonSubfolderDiskFiles: nonSubfolderDiskFiles,
};
var inputFiles = ts.map(ts.filter(compilerResult.program.getSourceFiles(),
sourceFile => sourceFile.filename !== "lib.d.ts"),
sourceFile => {
return { unitName: sourceFile.filename, content: sourceFile.text };
});
var diagnostics = ts.map(compilerResult.errors, error => Harness.Compiler.getMinimalDiagnostic(error));
errors += sys.newLine + sys.newLine + Harness.Compiler.getErrorBaseline(inputFiles, diagnostics);
return errors;
}
describe('Compiling project for ' + testCase.scenario +': testcase ' + testCaseFileName, () => {
@@ -276,7 +337,7 @@ class ProjectRunner extends RunnerBase {
baselineCheck: testCase.baselineCheck,
runTest: testCase.runTest,
bug: testCase.bug,
resolvedInputFiles: ts.map(compilerResult.readInputFiles, inputFile => inputFile.filename),
resolvedInputFiles: ts.map(compilerResult.program.getSourceFiles(), inputFile => inputFile.filename),
emittedFiles: ts.map(compilerResult.outputFiles, outputFile => outputFile.emittedFileName)
};
@@ -284,7 +345,6 @@ class ProjectRunner extends RunnerBase {
}
it('Resolution information of (' + moduleNameToString(compilerResult.moduleKind) + '): ' + testCaseFileName, () => {
assert.equal(compilerResult.program.getSourceFiles().length, compilerResult.readInputFiles.length, "Compiler missing/has extra source files that were read during compilation");
Harness.Baseline.runBaseline('Resolution information of (' + moduleNameToString(compilerResult.moduleKind) + '): ' + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + '.json', () => {
return JSON.stringify(getCompilerResolutionInfo(), undefined, " ");
});
@@ -293,22 +353,7 @@ class ProjectRunner extends RunnerBase {
if (compilerResult.errors.length) {
it('Errors for (' + moduleNameToString(compilerResult.moduleKind) + '): ' + testCaseFileName, () => {
Harness.Baseline.runBaseline('Errors for (' + moduleNameToString(compilerResult.moduleKind) + '): ' + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + '.errors.txt', () => {
// This is copied from tc.ts's reportError to replicate what tc does
var errors = "";
for (var i = 0; i < compilerResult.errors.length; i++) {
var error = compilerResult.errors[i];
// TODO(jfreeman): Remove assert
ts.Debug.assert(error.messageText.indexOf("{NL}") < 0);
if (error.file) {
var loc = error.file.getLineAndCharacterFromPosition(error.start);
errors += error.file.filename + "(" + loc.line + "," + loc.character + "): " + error.messageText + sys.newLine;
}
else {
errors += error.messageText + sys.newLine;
}
}
return errors;
return getErrorsBaseline(compilerResult);
});
});
}
@@ -335,6 +380,18 @@ class ProjectRunner extends RunnerBase {
});
});
}
// Verify that all the generated .d.ts files compile
if (!compilerResult.errors.length && testCase.declaration) {
var dTsCompileResult = compileCompileDTsFiles(compilerResult);
if (dTsCompileResult.errors.length) {
it('Errors in generated Dts files for (' + moduleNameToString(compilerResult.moduleKind) + '): ' + testCaseFileName, () => {
Harness.Baseline.runBaseline('Errors in generated Dts files for (' + moduleNameToString(compilerResult.moduleKind) + '): ' + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + '.dts.errors.txt', () => {
return getErrorsBaseline(dTsCompileResult);
});
});
}
}
}
}
+22 -46
View File
@@ -302,13 +302,13 @@ interface String {
* Matches a string with a regular expression, and returns an array containing the results of that search.
* @param regexp A variable name or string literal containing the regular expression pattern and flags.
*/
match(regexp: string): string[];
match(regexp: string): RegExpMatchArray;
/**
* Matches a string with a regular expression, and returns an array containing the results of that search.
* @param regexp A regular expression object that contains the regular expression pattern and applicable flags.
*/
match(regexp: RegExp): string[];
match(regexp: RegExp): RegExpMatchArray;
/**
* Replaces text in a string, using a regular expression or search string.
@@ -775,38 +775,15 @@ declare var Date: {
now(): number;
}
interface RegExpExecArray {
[index: number]: string;
length: number;
index: number;
input: string;
toString(): string;
toLocaleString(): string;
concat(...items: string[][]): string[];
join(separator?: string): string;
pop(): string;
push(...items: string[]): number;
reverse(): string[];
shift(): string;
slice(start?: number, end?: number): string[];
sort(compareFn?: (a: string, b: string) => number): string[];
splice(start: number): string[];
splice(start: number, deleteCount: number, ...items: string[]): string[];
unshift(...items: string[]): number;
indexOf(searchElement: string, fromIndex?: number): number;
lastIndexOf(searchElement: string, fromIndex?: number): number;
every(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): boolean;
some(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): boolean;
forEach(callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any): void;
map(callbackfn: (value: string, index: number, array: string[]) => any, thisArg?: any): any[];
filter(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): string[];
reduce(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: string[]) => any, initialValue?: any): any;
reduceRight(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: string[]) => any, initialValue?: any): any;
interface RegExpMatchArray extends Array<string> {
index?: number;
input?: string;
}
interface RegExpExecArray extends Array<string> {
index: number;
input: string;
}
interface RegExp {
/**
@@ -964,11 +941,24 @@ declare var JSON: JSON;
/////////////////////////////
interface Array<T> {
/**
* Gets or sets the length of the array. This is a number one higher than the highest element defined in an array.
*/
length: number;
/**
* Returns a string representation of an array.
*/
toString(): string;
toLocaleString(): string;
/**
* Appends new elements to an array, and returns the new length of the array.
* @param items New elements of the Array.
*/
push(...items: T[]): number;
/**
* Removes the last element from an array and returns it.
*/
pop(): T;
/**
* Combines two or more arrays.
* @param items Additional items to add to the end of array1.
@@ -984,15 +974,6 @@ interface Array<T> {
* @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma.
*/
join(separator?: string): string;
/**
* Removes the last element from an array and returns it.
*/
pop(): T;
/**
* Appends new elements to an array, and returns the new length of the array.
* @param items New elements of the Array.
*/
push(...items: T[]): number;
/**
* Reverses the elements in an Array.
*/
@@ -1109,11 +1090,6 @@ interface Array<T> {
*/
reduceRight<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U;
/**
* Gets or sets the length of the array. This is a number one higher than the highest element defined in an array.
*/
length: number;
[n: number]: T;
}
declare var Array: {
+1 -1
View File
@@ -49,7 +49,7 @@ module TypeScript {
return isNoDefaultLibRegex.exec(comment);
}
export var tripleSlashReferenceRegExp = /^(\/\/\/\s*<reference\s+path=)('|")(.+?)\2\s*(static=('|")(.+?)\2\s*)*\/>/;
export var tripleSlashReferenceRegExp = /^(\/\/\/\s*<reference\s+path=)('|")(.+?)\2\s*(static=('|")(.+?)\5\s*)*\/>/;
function getFileReferenceFromReferencePath(fileName: string, text: ISimpleText, position: number, comment: string, diagnostics: Diagnostic[]): IFileReference {
// First, just see if they've written: /// <reference\s+
+61 -83
View File
@@ -15,95 +15,73 @@
///<reference path='references.ts' />
module TypeScript.Services {
export class OutliningElementsCollector extends TypeScript.DepthLimitedWalker {
// The maximum depth for collecting spans; this will cause us to miss deeply nested function/modules spans,
// but will guarantee performance will not be closely tied to tree depth.
private static MaximumDepth: number = 10;
private inObjectLiteralExpression: boolean = false;
module ts {
private elements: TypeScript.TextSpan[] = [];
export interface OutliningSpan {
/**
* @param textSpan The span of the document to actually collapse.
* @param hintSpan The span of the document to display when the user hovers over the
* collapsed span.
* @param bannerText The text to display in the editor for the collapsed region.
* @param autoCollapse Whether or not this region should be automatically collapsed when
* the 'Collapse to Definitions' command is invoked.
*/
textSpan: TypeScript.TextSpan;
hintSpan: TypeScript.TextSpan;
bannerText: string;
autoCollapse: boolean;
}
constructor() {
super(OutliningElementsCollector.MaximumDepth);
}
export module OutliningElementsCollector {
export function collectElements(sourceFile: SourceFile): OutliningSpan[] {
var elements: OutliningSpan[] = [];
public visitClassDeclaration(node: TypeScript.ClassDeclarationSyntax): void {
this.addOutlineRange(node, node.openBraceToken, node.closeBraceToken);
super.visitClassDeclaration(node);
}
public visitInterfaceDeclaration(node: TypeScript.InterfaceDeclarationSyntax): void {
this.addOutlineRange(node, node.body.openBraceToken, node.body.closeBraceToken);
super.visitInterfaceDeclaration(node);
}
public visitModuleDeclaration(node: TypeScript.ModuleDeclarationSyntax): void {
this.addOutlineRange(node, node.openBraceToken, node.closeBraceToken);
super.visitModuleDeclaration(node);
}
public visitEnumDeclaration(node: TypeScript.EnumDeclarationSyntax): void {
this.addOutlineRange(node, node.openBraceToken, node.closeBraceToken);
super.visitEnumDeclaration(node);
}
public visitFunctionDeclaration(node: TypeScript.FunctionDeclarationSyntax): void {
this.addOutlineRange(node, node.block, node.block);
super.visitFunctionDeclaration(node);
}
public visitFunctionExpression(node: TypeScript.FunctionExpressionSyntax): void {
this.addOutlineRange(node, node.block, node.block);
super.visitFunctionExpression(node);
}
public visitConstructorDeclaration(node: TypeScript.ConstructorDeclarationSyntax): void {
this.addOutlineRange(node, node.block, node.block);
super.visitConstructorDeclaration(node);
}
public visitMemberFunctionDeclaration(node: TypeScript.MemberFunctionDeclarationSyntax): void {
this.addOutlineRange(node, node.block, node.block);
super.visitMemberFunctionDeclaration(node);
}
public visitGetAccessor(node: TypeScript.GetAccessorSyntax): void {
if (!this.inObjectLiteralExpression) {
this.addOutlineRange(node, node.block, node.block);
function addOutlineRange(hintSpanNode: Node, startElement: Node, endElement: Node) {
if (hintSpanNode && startElement && endElement) {
var span: OutliningSpan = {
textSpan: TypeScript.TextSpan.fromBounds(startElement.pos, endElement.end),
hintSpan: TypeScript.TextSpan.fromBounds(hintSpanNode.getStart(), hintSpanNode.end),
bannerText: "...",
autoCollapse: false
};
elements.push(span);
}
}
super.visitGetAccessor(node);
}
public visitSetAccessor(node: TypeScript.SetAccessorSyntax): void {
if (!this.inObjectLiteralExpression) {
this.addOutlineRange(node, node.block, node.block);
var depth = 0;
var maxDepth = 20;
function walk(n: Node): void {
if (depth > maxDepth) {
return;
}
switch (n.kind) {
case SyntaxKind.Block:
case SyntaxKind.FunctionBlock:
case SyntaxKind.ModuleBlock:
case SyntaxKind.TryBlock:
case SyntaxKind.TryBlock:
case SyntaxKind.CatchBlock:
case SyntaxKind.FinallyBlock:
var openBrace = forEach(n.getChildren(), c => c.kind === SyntaxKind.OpenBraceToken && c);
var closeBrace = forEach(n.getChildren(), c => c.kind === SyntaxKind.CloseBraceToken && c);
addOutlineRange(n.parent, openBrace, closeBrace);
break;
case SyntaxKind.ClassDeclaration:
case SyntaxKind.InterfaceDeclaration:
case SyntaxKind.EnumDeclaration:
case SyntaxKind.ObjectLiteral:
var openBrace = forEach(n.getChildren(), c => c.kind === SyntaxKind.OpenBraceToken && c);
var closeBrace = forEach(n.getChildren(), c => c.kind === SyntaxKind.CloseBraceToken && c);
addOutlineRange(n, openBrace, closeBrace);
break;
}
depth++;
forEachChild(n, walk);
depth--;
}
super.visitSetAccessor(node);
}
public visitObjectLiteralExpression(node: TypeScript.ObjectLiteralExpressionSyntax): void {
var savedInObjectLiteralExpression = this.inObjectLiteralExpression;
this.inObjectLiteralExpression = true;
super.visitObjectLiteralExpression(node);
this.inObjectLiteralExpression = savedInObjectLiteralExpression;
}
private addOutlineRange(node: TypeScript.ISyntaxNode, startElement: TypeScript.ISyntaxNodeOrToken, endElement: TypeScript.ISyntaxNodeOrToken) {
if (startElement && endElement && !isShared(startElement) && !isShared(endElement)) {
// Compute the position
var start = TypeScript.start(startElement);
var end = TypeScript.end(endElement);
// Push the new range
this.elements.push(TypeScript.TextSpan.fromBounds(start, end));
}
}
public static collectElements(node: TypeScript.SourceUnitSyntax): TypeScript.TextSpan[] {
var collector = new OutliningElementsCollector();
visitNodeOrToken(collector, node);
return collector.elements;
walk(sourceFile);
return elements;
}
}
}
}
+83 -23
View File
@@ -416,10 +416,10 @@ module ts {
? TypeScript.Parser.parse(this.filename, text, this.languageVersion, TypeScript.isDTSFile(this.filename))
: TypeScript.IncrementalParser.parse(oldSyntaxTree, textChangeRange, text);
return SourceFileObject.createSourceFileObject(this.languageVersion, this.filename, scriptSnapshot, version, isOpen, newSyntaxTree);
return SourceFileObject.createSourceFileObject(this.filename, scriptSnapshot, this.languageVersion, version, isOpen, newSyntaxTree);
}
public static createSourceFileObject(languageVersion: ScriptTarget, filename: string, scriptSnapshot: TypeScript.IScriptSnapshot, version: number, isOpen: boolean, syntaxTree: TypeScript.SyntaxTree) {
public static createSourceFileObject(filename: string, scriptSnapshot: TypeScript.IScriptSnapshot, languageVersion: ScriptTarget, version: number, isOpen: boolean, syntaxTree?: TypeScript.SyntaxTree) {
var newSourceFile = <SourceFileObject><any>createSourceFile(filename, scriptSnapshot.getText(0, scriptSnapshot.getLength()), languageVersion, version, isOpen);
newSourceFile.scriptSnapshot = scriptSnapshot;
newSourceFile.syntaxTree = syntaxTree;
@@ -482,7 +482,7 @@ module ts {
getNavigateToItems(searchValue: string): NavigateToItem[];
getScriptLexicalStructure(fileName: string): NavigateToItem[];
getOutliningRegions(fileName: string): TypeScript.TextSpan[];
getOutliningRegions(fileName: string): OutliningSpan[];
getBraceMatchingAtPosition(fileName: string, position: number): TypeScript.TextSpan[];
getIndentationAtPosition(fileName: string, position: number, options: EditorOptions): number;
@@ -962,6 +962,7 @@ module ts {
// currently edited file.
private currentfilename: string = "";
private currentFileVersion: number = -1;
private currentSourceFile: SourceFile = null;
private currentFileSyntaxTree: TypeScript.SyntaxTree = null;
private currentFileScriptSnapshot: TypeScript.IScriptSnapshot = null;
@@ -969,32 +970,71 @@ module ts {
this.hostCache = new HostCache(host);
}
public getCurrentFileSyntaxTree(filename: string): TypeScript.SyntaxTree {
private initialize(filename: string) {
// ensure that both source file and syntax tree are either initialized or not initialized
Debug.assert(!!this.currentFileSyntaxTree === !!this.currentSourceFile);
this.hostCache = new HostCache(this.host);
var version = this.hostCache.getVersion(filename);
var syntaxTree: TypeScript.SyntaxTree = null;
var sourceFile: SourceFile;
if (this.currentFileSyntaxTree === null || this.currentfilename !== filename) {
var scriptSnapshot = this.hostCache.getScriptSnapshot(filename);
syntaxTree = this.createSyntaxTree(filename, scriptSnapshot);
sourceFile = createSourceFileFromScriptSnapshot(filename, scriptSnapshot, getDefaultCompilerOptions(), version, /*isOpen*/ true);
fixupParentReferences(sourceFile);
}
else if (this.currentFileVersion !== version) {
var scriptSnapshot = this.hostCache.getScriptSnapshot(filename);
syntaxTree = this.updateSyntaxTree(filename, scriptSnapshot, this.currentFileSyntaxTree, this.currentFileVersion);
var editRange = this.hostCache.getScriptTextChangeRangeSinceVersion(filename, this.currentFileVersion);
sourceFile = !editRange
? createSourceFileFromScriptSnapshot(filename, scriptSnapshot, getDefaultCompilerOptions(), version, /*isOpen*/ true)
: this.currentSourceFile.update(scriptSnapshot, version, /*isOpen*/ true, editRange);
fixupParentReferences(sourceFile);
}
if (syntaxTree !== null) {
Debug.assert(sourceFile);
// All done, ensure state is up to date
this.currentFileScriptSnapshot = scriptSnapshot;
this.currentFileVersion = version;
this.currentfilename = filename;
this.currentFileSyntaxTree = syntaxTree;
this.currentSourceFile = sourceFile;
}
function fixupParentReferences(sourceFile: SourceFile) {
// normally parent references are set during binding.
// however here SourceFile data is used only for syntactic features so running the whole binding process is an overhead.
// walk over the nodes and set parent references
var parent: Node = sourceFile;
function walk(n: Node): void {
n.parent = parent;
var saveParent = parent;
parent = n;
forEachChild(n, walk);
parent = saveParent;
}
forEachChild(sourceFile, walk);
}
}
public getCurrentFileSyntaxTree(filename: string): TypeScript.SyntaxTree {
this.initialize(filename);
return this.currentFileSyntaxTree;
}
public getCurrentSourceFile(filename: string): SourceFile {
this.initialize(filename);
return this.currentSourceFile;
}
public getCurrentScriptSnapshot(filename: string): TypeScript.IScriptSnapshot {
// update currentFileScriptSnapshot as a part of 'getCurrentFileSyntaxTree' call
this.getCurrentFileSyntaxTree(filename);
@@ -1093,6 +1133,10 @@ module ts {
}
}
function createSourceFileFromScriptSnapshot(filename: string, scriptSnapshot: TypeScript.IScriptSnapshot, settings: CompilerOptions, version: number, isOpen: boolean) {
return SourceFileObject.createSourceFileObject(filename, scriptSnapshot, settings.target, version, isOpen);
}
export function createDocumentRegistry(): DocumentRegistry {
var buckets: Map<Map<DocumentRegistryEntry>> = {};
@@ -1140,7 +1184,7 @@ module ts {
var bucket = getBucketForCompilationSettings(compilationSettings, /*createIfMissing*/ true);
var entry = lookUp(bucket, filename);
if (!entry) {
var sourceFile = createSourceFile(filename, scriptSnapshot.getText(0, scriptSnapshot.getLength()), compilationSettings.target, version, isOpen);
var sourceFile = createSourceFileFromScriptSnapshot(filename, scriptSnapshot, compilationSettings, version, isOpen);
bucket[filename] = entry = {
sourceFile: sourceFile,
@@ -1212,7 +1256,11 @@ module ts {
var formattingRulesProvider: TypeScript.Services.Formatting.RulesProvider;
var hostCache: HostCache; // A cache of all the information about the files on the host side.
var program: Program;
var typeChecker: TypeChecker;
// this checker is used to answer all LS questions except errors
var typeInfoResolver: TypeChecker;
// the sole purpose of this checkes is to reutrn semantic diagnostics
// creation is deferred - use getFullTypeCheckChecker to get instance
var fullTypeCheckChecker_doNotAccessDirectly: TypeChecker;
var useCaseSensitivefilenames = false;
var sourceFilesByName: Map<SourceFile> = {};
var documentRegistry = documentRegistry;
@@ -1228,6 +1276,10 @@ module ts {
return lookUp(sourceFilesByName, filename);
}
function getFullTypeCheckChecker() {
return fullTypeCheckChecker_doNotAccessDirectly || (fullTypeCheckChecker_doNotAccessDirectly = program.getTypeChecker(/*fullTypeCheck*/ true));
}
function createCompilerHost(): CompilerHost {
return {
getSourceFile: (filename, languageVersion) => {
@@ -1359,7 +1411,8 @@ module ts {
// Now create a new compiler
program = createProgram(hostfilenames, compilationSettings, createCompilerHost());
typeChecker = program.getTypeChecker();
typeInfoResolver = program.getTypeChecker(/*fullTypeCheckMode*/ false);
fullTypeCheckChecker_doNotAccessDirectly = undefined;
}
/// Clean up any semantic caches that are not needed.
@@ -1367,7 +1420,8 @@ module ts {
/// We will just dump the typeChecker and recreate a new one. this should have the effect of destroying all the semantic caches.
function cleanupSemanticCache(): void {
if (program) {
typeChecker = program.getTypeChecker();
typeInfoResolver = program.getTypeChecker(/*fullTypeCheckMode*/ false);
fullTypeCheckChecker_doNotAccessDirectly = undefined;
}
}
@@ -1392,7 +1446,7 @@ module ts {
filename = TypeScript.switchToForwardSlashes(filename)
return typeChecker.getDiagnostics(getSourceFile(filename).getSourceFile());
return getFullTypeCheckChecker().getDiagnostics(getSourceFile(filename));
}
function getCompilerOptionsDiagnostics() {
@@ -1634,12 +1688,12 @@ module ts {
entries: [],
symbols: {},
location: mappedNode,
typeChecker: typeChecker
typeChecker: typeInfoResolver
};
// Right of dot member completion list
if (isRightOfDot) {
var type: Type = typeChecker.getTypeOfExpression(mappedNode);
var type: Type = typeInfoResolver.getTypeOfExpression(mappedNode);
if (!type) {
return undefined;
}
@@ -1687,7 +1741,7 @@ module ts {
isMemberCompletion = false;
/// TODO filter meaning based on the current context
var symbolMeanings = SymbolFlags.Type | SymbolFlags.Value | SymbolFlags.Namespace;
var symbols = typeChecker.getSymbolsInScope(mappedNode, symbolMeanings);
var symbols = typeInfoResolver.getSymbolsInScope(mappedNode, symbolMeanings);
getCompletionEntriesFromSymbols(symbols, activeCompletionSession);
}
@@ -1726,7 +1780,7 @@ module ts {
kind: completionEntry.kind,
kindModifiers: completionEntry.kindModifiers,
type: session.typeChecker.typeToString(type, session.location),
fullSymbolName: typeChecker.symbolToString(symbol, session.location),
fullSymbolName: typeInfoResolver.symbolToString(symbol, session.location),
docComment: ""
};
}
@@ -1838,13 +1892,13 @@ module ts {
var node = getNodeAtPosition(sourceFile.getSourceFile(), position);
if (!node) return undefined;
var symbol = typeChecker.getSymbolInfo(node);
var type = symbol && typeChecker.getTypeOfSymbol(symbol);
var symbol = typeInfoResolver.getSymbolInfo(node);
var type = symbol && typeInfoResolver.getTypeOfSymbol(symbol);
if (type) {
return {
memberName: new TypeScript.MemberNameString(typeChecker.typeToString(type)),
memberName: new TypeScript.MemberNameString(typeInfoResolver.typeToString(type)),
docComment: "",
fullSymbolName: typeChecker.symbolToString(symbol, getContainerNode(node)),
fullSymbolName: typeInfoResolver.symbolToString(symbol, getContainerNode(node)),
kind: getSymbolKind(symbol),
minChar: node.pos,
limChar: node.end
@@ -1990,7 +2044,7 @@ module ts {
return undefined;
}
var symbol = typeChecker.getSymbolInfo(node);
var symbol = typeInfoResolver.getSymbolInfo(node);
// Could not find a symbol e.g. node is string or number keyword,
// or the symbol was an internal symbol and does not have a declaration e.g. undefined symbol
@@ -2001,10 +2055,10 @@ module ts {
var result: DefinitionInfo[] = [];
var declarations = symbol.getDeclarations();
var symbolName = typeChecker.symbolToString(symbol, node);
var symbolName = typeInfoResolver.symbolToString(symbol, node);
var symbolKind = getSymbolKind(symbol);
var containerSymbol = symbol.parent;
var containerName = containerSymbol ? typeChecker.symbolToString(containerSymbol, node) : "";
var containerName = containerSymbol ? typeInfoResolver.symbolToString(containerSymbol, node) : "";
var containerKind = containerSymbol ? getSymbolKind(symbol) : "";
if (!tryAddConstructSignature(symbol, node, symbolKind, symbolName, containerName, result) &&
@@ -2024,6 +2078,12 @@ module ts {
return syntaxTreeCache.getCurrentFileSyntaxTree(filename);
}
function getCurrentSourceFile(filename: string): SourceFile {
filename = TypeScript.switchToForwardSlashes(filename);
var currentSourceFile = syntaxTreeCache.getCurrentSourceFile(filename);
return currentSourceFile;
}
function getNameOrDottedNameSpan(filename: string, startPos: number, endPos: number): SpanInfo {
function getTypeInfoEligiblePath(filename: string, position: number, isConstructorValidPosition: boolean) {
var sourceUnit = syntaxTreeCache.getCurrentFileSyntaxTree(filename).sourceUnit();
@@ -2097,11 +2157,11 @@ module ts {
return items;
}
function getOutliningRegions(filename: string) {
function getOutliningRegions(filename: string): OutliningSpan[] {
// doesn't use compiler - no need to synchronize with host
filename = TypeScript.switchToForwardSlashes(filename);
var syntaxTree = getSyntaxTree(filename);
return TypeScript.Services.OutliningElementsCollector.collectElements(syntaxTree.sourceUnit());
var sourceFile = getCurrentSourceFile(filename);
return OutliningElementsCollector.collectElements(sourceFile);
}
function getBraceMatchingAtPosition(filename: string, position: number) {
+4 -1
View File
@@ -726,7 +726,10 @@ module ts {
"getOutliningRegions(\"" + fileName + "\")",
() => {
var items = this.languageService.getOutliningRegions(fileName);
return items;
// return just the part of data that language service v2 can understand
// language service v2 will use the entire OutliningSpan
var spans = map(items, i => i.textSpan);
return spans;
});
}
@@ -0,0 +1,8 @@
==== tests/cases/compiler/aliasInaccessibleModule.ts (1 errors) ====
module M {
module N {
}
export import X = N;
~~~~~~~~~~~~~~~~~~~~
!!! Import declaration 'X' is using private name 'N'.
}
@@ -0,0 +1,12 @@
==== tests/cases/compiler/aliasInaccessibleModule2.ts (1 errors) ====
module M {
module N {
class C {
}
}
import R = N;
~~~~~~~~~~~~~
!!! Import declaration 'R' is using private name 'N'.
export import X = R;
}
@@ -1,30 +0,0 @@
==== tests/cases/compiler/aliasUsage1_main.ts (2 errors) ====
import Backbone = require("aliasUsage1_backbone");
import moduleA = require("aliasUsage1_moduleA");
interface IHasVisualizationModel {
VisualizationModel: typeof Backbone.Model;
}
class C2 {
x: IHasVisualizationModel;
get A() {
~
!!! Accessors are only available when targeting ECMAScript 5 and higher.
return this.x;
}
set A(x) {
~
!!! Accessors are only available when targeting ECMAScript 5 and higher.
x = moduleA;
}
}
==== tests/cases/compiler/aliasUsage1_backbone.ts (0 errors) ====
export class Model {
public someData: string;
}
==== tests/cases/compiler/aliasUsage1_moduleA.ts (0 errors) ====
import Backbone = require("aliasUsage1_backbone");
export class VisualizationModel extends Backbone.Model {
// interesting stuff here
}
@@ -0,0 +1,69 @@
//// [tests/cases/compiler/aliasUsageInAccessorsOfClass.ts] ////
//// [aliasUsage1_backbone.ts]
export class Model {
public someData: string;
}
//// [aliasUsage1_moduleA.ts]
import Backbone = require("aliasUsage1_backbone");
export class VisualizationModel extends Backbone.Model {
// interesting stuff here
}
//// [aliasUsage1_main.ts]
import Backbone = require("aliasUsage1_backbone");
import moduleA = require("aliasUsage1_moduleA");
interface IHasVisualizationModel {
VisualizationModel: typeof Backbone.Model;
}
class C2 {
x: IHasVisualizationModel;
get A() {
return this.x;
}
set A(x) {
x = moduleA;
}
}
//// [aliasUsage1_backbone.js]
var Model = (function () {
function Model() {
}
return Model;
})();
exports.Model = Model;
//// [aliasUsage1_moduleA.js]
var __extends = this.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};
var Backbone = require("aliasUsage1_backbone");
var VisualizationModel = (function (_super) {
__extends(VisualizationModel, _super);
function VisualizationModel() {
_super.apply(this, arguments);
}
return VisualizationModel;
})(Backbone.Model);
exports.VisualizationModel = VisualizationModel;
//// [aliasUsage1_main.js]
var moduleA = require("aliasUsage1_moduleA");
var C2 = (function () {
function C2() {
}
Object.defineProperty(C2.prototype, "A", {
get: function () {
return this.x;
},
set: function (x) {
x = moduleA;
},
enumerable: true,
configurable: true
});
return C2;
})();
@@ -128,25 +128,25 @@
arr_any = f1; // should be an error - is
~~~~~~~
!!! Type '() => C1' is not assignable to type 'any[]':
!!! Property 'concat' is missing in type '() => C1'.
!!! Property 'push' is missing in type '() => C1'.
arr_any = o1; // should be an error - is
~~~~~~~
!!! Type '{ one: number; }' is not assignable to type 'any[]':
!!! Property 'concat' is missing in type '{ one: number; }'.
!!! Property 'length' is missing in type '{ one: number; }'.
arr_any = a1; // should be ok - is
arr_any = c1; // should be an error - is
~~~~~~~
!!! Type 'C1' is not assignable to type 'any[]':
!!! Property 'concat' is missing in type 'C1'.
!!! Property 'length' is missing in type 'C1'.
arr_any = c2; // should be an error - is
~~~~~~~
!!! Type 'C2' is not assignable to type 'any[]':
!!! Property 'concat' is missing in type 'C2'.
!!! Property 'length' is missing in type 'C2'.
arr_any = c3; // should be an error - is
~~~~~~~
!!! Type 'C3' is not assignable to type 'any[]':
!!! Property 'concat' is missing in type 'C3'.
!!! Property 'length' is missing in type 'C3'.
arr_any = i1; // should be an error - is
~~~~~~~
!!! Type 'I1' is not assignable to type 'any[]':
!!! Property 'concat' is missing in type 'I1'.
!!! Property 'length' is missing in type 'I1'.
@@ -64,30 +64,30 @@
arr_any = f1; // should be an error - is
~~~~~~~
!!! Type '() => C1' is not assignable to type 'any[]':
!!! Property 'concat' is missing in type '() => C1'.
!!! Property 'push' is missing in type '() => C1'.
arr_any = function () { return null;} // should be an error - is
~~~~~~~
!!! Type '() => any' is not assignable to type 'any[]':
!!! Property 'concat' is missing in type '() => any'.
!!! Property 'push' is missing in type '() => any'.
arr_any = o1; // should be an error - is
~~~~~~~
!!! Type '{ one: number; }' is not assignable to type 'any[]':
!!! Property 'concat' is missing in type '{ one: number; }'.
!!! Property 'length' is missing in type '{ one: number; }'.
arr_any = a1; // should be ok - is
arr_any = c1; // should be an error - is
~~~~~~~
!!! Type 'C1' is not assignable to type 'any[]':
!!! Property 'concat' is missing in type 'C1'.
!!! Property 'length' is missing in type 'C1'.
arr_any = c2; // should be an error - is
~~~~~~~
!!! Type 'C2' is not assignable to type 'any[]':
!!! Property 'concat' is missing in type 'C2'.
!!! Property 'length' is missing in type 'C2'.
arr_any = c3; // should be an error - is
~~~~~~~
!!! Type 'C3' is not assignable to type 'any[]':
!!! Property 'concat' is missing in type 'C3'.
!!! Property 'length' is missing in type 'C3'.
arr_any = i1; // should be an error - is
~~~~~~~
!!! Type 'I1' is not assignable to type 'any[]':
!!! Property 'concat' is missing in type 'I1'.
!!! Property 'length' is missing in type 'I1'.
@@ -25,9 +25,9 @@
arr_any = function () { return null;} // should be an error - is
~~~~~~~
!!! Type '() => any' is not assignable to type 'any[]':
!!! Property 'concat' is missing in type '() => any'.
!!! Property 'push' is missing in type '() => any'.
arr_any = c3; // should be an error - is
~~~~~~~
!!! Type 'C3' is not assignable to type 'any[]':
!!! Property 'concat' is missing in type 'C3'.
!!! Property 'length' is missing in type 'C3'.
@@ -30,7 +30,7 @@
!!! 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 'concat' is missing in type 'Number'.
!!! Property 'length' is missing in type 'Number'.
function isEmpty(l: { length: number }) {
return l.length === 0;
@@ -12,4 +12,4 @@
!!! 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 'concat' is missing in type 'Number'.
!!! Property 'length' is missing in type 'Number'.
@@ -12,4 +12,4 @@
!!! 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 'join' is missing in type 'String'.
!!! Property 'push' is missing in type 'String'.
@@ -12,4 +12,4 @@
!!! 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 'concat' is missing in type 'Number'.
!!! Property 'length' is missing in type 'Number'.
@@ -12,7 +12,4 @@
!!! 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[]':
!!! Types of property 'concat' are incompatible:
!!! Type '(...strings: string[]) => string' is not assignable to type '{ <U extends number[]>(...items: U[]): number[]; (...items: number[]): number[]; }':
!!! Types of parameters 'strings' and 'items' are incompatible:
!!! Type 'string' is not assignable to type 'number'.
!!! Property 'push' is missing in type 'String'.
@@ -12,4 +12,4 @@
!!! 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 'concat' is missing in type 'Number'.
!!! Property 'length' is missing in type 'Number'.
@@ -12,4 +12,4 @@
!!! 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 'join' is missing in type 'String'.
!!! Property 'push' is missing in type 'String'.
@@ -12,4 +12,4 @@
!!! 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 'concat' is missing in type 'Number'.
!!! Property 'length' is missing in type 'Number'.
@@ -12,7 +12,4 @@
!!! 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[]':
!!! Types of property 'concat' are incompatible:
!!! Type '(...strings: string[]) => string' is not assignable to type '{ <U extends boolean[]>(...items: U[]): boolean[]; (...items: boolean[]): boolean[]; }':
!!! Types of parameters 'strings' and 'items' are incompatible:
!!! Type 'string' is not assignable to type 'boolean'.
!!! Property 'push' is missing in type 'String'.
@@ -12,4 +12,4 @@
!!! 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 'concat' is missing in type 'Number'.
!!! Property 'length' is missing in type 'Number'.
@@ -12,4 +12,4 @@
!!! 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 'concat' is missing in type 'Number'.
!!! Property 'length' is missing in type 'Number'.
@@ -12,4 +12,4 @@
!!! 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 'concat' is missing in type 'Number'.
!!! Property 'length' is missing in type 'Number'.
@@ -12,4 +12,4 @@
!!! 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 'concat' is missing in type 'Number'.
!!! Property 'length' is missing in type 'Number'.
@@ -487,11 +487,11 @@ declare var i1_ncf: (b: number) => number;
declare var i1_ncr: number;
declare var i1_ncprop: number;
declare var i1_s_p: number;
declare var i1_s_f: (b: number) => number;
declare var i1_s_f: typeof c1.s2;
declare var i1_s_r: number;
declare var i1_s_prop: number;
declare var i1_s_nc_p: number;
declare var i1_s_ncf: (b: number) => number;
declare var i1_s_ncf: typeof c1.nc_s2;
declare var i1_s_ncr: number;
declare var i1_s_ncprop: number;
declare var i1_c: typeof c1;
@@ -20,3 +20,24 @@ declare module "MainModule" {
//// [cyclicModuleImport.js]
//// [cyclicModuleImport.d.ts]
declare module "SubModule" {
import MainModule = require('MainModule');
class SubModule {
static StaticVar: number;
InstanceVar: number;
main: MainModule;
constructor();
}
export = SubModule;
}
declare module "MainModule" {
import SubModule = require('SubModule');
class MainModule {
SubModule: SubModule;
constructor();
}
export = MainModule;
}
@@ -27,28 +27,12 @@ exports.x;
declare module "SubModule" {
module m {
module m3 {
interface c {
}
}
}
}
//// [declFileAmbientExternalModuleWithSingleExportedModule_1.d.ts]
/// <reference path='declFileAmbientExternalModuleWithSingleExportedModule_0.d.ts' />
import SubModule = require('SubModule');
export declare var x: SubModule.m.m3.c;
//// [DtsFileErrors]
==== tests/cases/compiler/declFileAmbientExternalModuleWithSingleExportedModule_1.d.ts (1 errors) ====
/// <reference path='declFileAmbientExternalModuleWithSingleExportedModule_0.d.ts' />
export declare var x: SubModule.m.m3.c;
~~~~~~~~~~~~~~~~
!!! Cannot find name 'SubModule'.
==== tests/cases/compiler/declFileAmbientExternalModuleWithSingleExportedModule_0.d.ts (0 errors) ====
declare module "SubModule" {
module m {
module m3 {
}
}
}
@@ -28,20 +28,5 @@ interface Foo<T> {
}
export = Foo;
//// [declFileExportAssignmentOfGenericInterface_1.d.ts]
import a = require('declFileExportAssignmentOfGenericInterface_0');
export declare var x: a<a<string>>;
//// [DtsFileErrors]
==== tests/cases/compiler/declFileExportAssignmentOfGenericInterface_1.d.ts (1 errors) ====
export declare var x: a<a<string>>;
~~~~~~~~~~~~
!!! Cannot find name 'a'.
==== tests/cases/compiler/declFileExportAssignmentOfGenericInterface_0.d.ts (0 errors) ====
interface Foo<T> {
a: string;
}
export = Foo;
@@ -74,33 +74,5 @@ export = b;
//// [declFileExportImportChain_c.d.ts]
export import b1 = require("declFileExportImportChain_b1");
//// [declFileExportImportChain_d.d.ts]
export declare var x: m1.m2.c1;
//// [DtsFileErrors]
==== tests/cases/compiler/declFileExportImportChain_d.d.ts (1 errors) ====
export declare var x: m1.m2.c1;
~~~~~~~~
!!! Cannot find name 'm1'.
==== tests/cases/compiler/declFileExportImportChain_a.d.ts (0 errors) ====
declare module m1 {
module m2 {
class c1 {
}
}
}
export = m1;
==== tests/cases/compiler/declFileExportImportChain_b.d.ts (0 errors) ====
export import a = require("declFileExportImportChain_a");
==== tests/cases/compiler/declFileExportImportChain_b1.d.ts (0 errors) ====
import b = require("declFileExportImportChain_b");
export = b;
==== tests/cases/compiler/declFileExportImportChain_c.d.ts (0 errors) ====
export import b1 = require("declFileExportImportChain_b1");
import c = require("declFileExportImportChain_c");
export declare var x: c.b1.a.m2.c1;
@@ -65,30 +65,5 @@ export = a;
//// [declFileExportImportChain2_c.d.ts]
export import b = require("declFileExportImportChain2_b");
//// [declFileExportImportChain2_d.d.ts]
export declare var x: m1.m2.c1;
//// [DtsFileErrors]
==== tests/cases/compiler/declFileExportImportChain2_d.d.ts (1 errors) ====
export declare var x: m1.m2.c1;
~~~~~~~~
!!! Cannot find name 'm1'.
==== tests/cases/compiler/declFileExportImportChain2_a.d.ts (0 errors) ====
declare module m1 {
module m2 {
class c1 {
}
}
}
export = m1;
==== tests/cases/compiler/declFileExportImportChain2_b.d.ts (0 errors) ====
import a = require("declFileExportImportChain2_a");
export = a;
==== tests/cases/compiler/declFileExportImportChain2_c.d.ts (0 errors) ====
export import b = require("declFileExportImportChain2_b");
import c = require("declFileExportImportChain2_c");
export declare var x: c.b.m2.c1;
@@ -131,10 +131,10 @@ export declare module C {
}
}
export declare var a: C.A<C.B>;
export declare var b: <T>(x: T) => C.A<C.B>;
export declare var c: <T>(x: T) => C.A<C.B>;
export declare var d: <T>(x: T) => C.A<C.B>[];
export declare var e: <T extends C.A<C.B>>(x: T) => C.A<C.B>[];
export declare var b: typeof C.F;
export declare var c: typeof C.F2;
export declare var d: typeof C.F3;
export declare var e: typeof C.F4;
export declare var x: C.A<C.B>;
export declare function f<T extends C.A<C.B>>(): void;
export declare var g: C.A<C.B>;
@@ -142,4 +142,4 @@ export declare class h extends C.A<C.B> {
}
export interface i extends C.A<C.B> {
}
export declare var j: <T extends C.A<C.B>>(x: T) => T;
export declare var j: typeof C.F6;
@@ -91,12 +91,21 @@ var templa;
//// [declFileGenericType2.d.ts]
declare module templa.mvc {
interface IModel {
}
}
declare module templa.mvc {
interface IController<ModelType extends IModel> {
}
}
declare module templa.mvc {
class AbstractController<ModelType extends IModel> implements IController<ModelType> {
}
}
declare module templa.mvc.composite {
interface ICompositeControllerModel extends IModel {
getControllers(): IController<IModel>[];
}
}
declare module templa.dom.mvc {
interface IElementController<ModelType extends templa.mvc.IModel> extends templa.mvc.IController<ModelType> {
@@ -113,45 +122,3 @@ declare module templa.dom.mvc.composite {
constructor();
}
}
//// [DtsFileErrors]
==== tests/cases/compiler/declFileGenericType2.d.ts (6 errors) ====
declare module templa.mvc {
}
declare module templa.mvc {
}
declare module templa.mvc {
}
declare module templa.mvc.composite {
}
declare module templa.dom.mvc {
interface IElementController<ModelType extends templa.mvc.IModel> extends templa.mvc.IController<ModelType> {
~~~~~~~~~~~~~~~~~
!!! Module 'templa.mvc' has no exported member 'IModel'.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! Module 'templa.mvc' has no exported member 'IController'.
}
}
declare module templa.dom.mvc {
class AbstractElementController<ModelType extends templa.mvc.IModel> extends templa.mvc.AbstractController<ModelType> implements IElementController<ModelType> {
~~~~~~~~~~~~~~~~~
!!! Module 'templa.mvc' has no exported member 'IModel'.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! Module 'templa.mvc' has no exported member 'AbstractController'.
constructor();
}
}
declare module templa.dom.mvc.composite {
class AbstractCompositeElementController<ModelType extends templa.mvc.composite.ICompositeControllerModel> extends AbstractElementController<ModelType> {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! Module 'templa.mvc.composite' has no exported member 'ICompositeControllerModel'.
_controllers: templa.mvc.IController<templa.mvc.IModel>[];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! Module 'templa.mvc' has no exported member 'IController'.
constructor();
}
}
@@ -0,0 +1,39 @@
//// [declFileImportChainInExportAssignment.ts]
module m {
export module c {
export class c {
}
}
}
import a = m.c;
import b = a;
export = b;
//// [declFileImportChainInExportAssignment.js]
var m;
(function (m) {
(function (_c) {
var c = (function () {
function c() {
}
return c;
})();
_c.c = c;
})(m.c || (m.c = {}));
var c = m.c;
})(m || (m = {}));
var a = m.c;
var b = a;
module.exports = b;
//// [declFileImportChainInExportAssignment.d.ts]
declare module m {
module c {
class c {
}
}
}
import a = m.c;
import b = a;
export = b;
@@ -52,43 +52,9 @@ declare var m2: {
};
export = m2;
//// [declFileImportModuleWithExportAssignment_1.d.ts]
import a1 = require("declFileImportModuleWithExportAssignment_0");
export declare var a: {
(): a1.connectExport;
test1: a1.connectModule;
test2(): a1.connectModule;
};
//// [DtsFileErrors]
==== tests/cases/compiler/declFileImportModuleWithExportAssignment_1.d.ts (3 errors) ====
export declare var a: {
(): a1.connectExport;
~~~~~~~~~~~~~~~~
!!! Cannot find name 'a1'.
test1: a1.connectModule;
~~~~~~~~~~~~~~~~
!!! Cannot find name 'a1'.
test2(): a1.connectModule;
~~~~~~~~~~~~~~~~
!!! Cannot find name 'a1'.
};
==== tests/cases/compiler/declFileImportModuleWithExportAssignment_0.d.ts (0 errors) ====
declare module m2 {
interface connectModule {
(res: any, req: any, next: any): void;
}
interface connectExport {
use: (mod: connectModule) => connectExport;
listen: (port: number) => void;
}
}
declare var m2: {
(): m2.connectExport;
test1: m2.connectModule;
test2(): m2.connectModule;
};
export = m2;
@@ -25,23 +25,10 @@ var List = (function () {
declare class List<T> {
}
declare module 'mod1' {
class Foo {
}
}
declare module 'moo' {
import x = require('mod1');
var p: List<x.Foo>;
}
//// [DtsFileErrors]
==== tests/cases/compiler/declFileImportedTypeUseInTypeArgPosition.d.ts (1 errors) ====
declare class List<T> {
}
declare module 'mod1' {
}
declare module 'moo' {
var p: List<x.Foo>;
~~~~~
!!! Cannot find name 'x'.
}
@@ -40,29 +40,10 @@ declare module m {
}
}
declare module m1 {
import x = m.c;
var d: x;
}
declare module m2 {
export import x = m.c;
var d: x;
}
//// [DtsFileErrors]
==== tests/cases/compiler/declFileInternalAliases.d.ts (1 errors) ====
declare module m {
class c {
}
}
declare module m1 {
var d: x;
~
!!! Cannot find name 'x'.
}
declare module m2 {
export import x = m.c;
var d: x;
}
@@ -64,39 +64,15 @@ function foo5(x) {
//// [declFileTypeofFunction.d.ts]
declare function f(n: {
(n: typeof f): string;
(n: {
(n: typeof g): number;
(n: typeof f): number;
}): string;
}): string;
declare function f(n: {
(n: typeof g): number;
(n: {
(n: typeof f): string;
(n: typeof g): string;
}): number;
}): string;
declare function g(n: {
(n: typeof g): number;
(n: {
(n: typeof f): string;
(n: typeof g): string;
}): number;
}): number;
declare function g(n: {
(n: typeof f): string;
(n: {
(n: typeof g): number;
(n: typeof f): number;
}): string;
}): number;
declare function f(n: typeof f): string;
declare function f(n: typeof g): string;
declare function g(n: typeof g): number;
declare function g(n: typeof f): number;
declare var b: any;
declare function b1(): () => typeof b1;
declare function foo(): () => typeof foo;
declare var foo1: () => typeof foo;
declare var foo2: () => typeof foo;
declare function b1(): typeof b1;
declare function foo(): typeof foo;
declare var foo1: typeof foo;
declare var foo2: typeof foo;
declare var foo3: any;
declare var x: any;
declare function foo5(x: number): (x: number) => number;
@@ -58,6 +58,8 @@ var A;
//// [declFileWithExtendsClauseThatHasItsContainerNameConflict.d.ts]
declare module A.B.C {
class B {
}
}
declare module A.B {
class EventManager {
@@ -0,0 +1,32 @@
==== tests/cases/compiler/declInput-2.ts (5 errors) ====
module M {
class C { }
export class E {}
export interface I1 {}
interface I2 {}
export class D {
private c: C; // don't generate
public m1: number;
public m2: string;
public m22: C; // don't generate
~~~~~~~~~~~~~~
!!! Public property 'm22' of exported class has or is using private name 'C'.
public m23: E;
public m24: I1;
public m25: I2; // don't generate
~~~~~~~~~~~~~~~
!!! Public property 'm25' of exported class has or is using private name 'I2'.
public m232(): E { return null;}
public m242(): I1 { return null; }
public m252(): I2 { return null; } // don't generate
~~~~
!!! Return type of public method from exported class has or is using private name 'I2'.
public m26(i:I1) {}
public m262(i:I2) {}
~~~~
!!! Parameter 'i' of public method from exported class has or is using private name 'I2'.
public m3():C { return new C(); }
~~
!!! Return type of public method from exported class has or is using private name 'C'.
}
}
-62
View File
@@ -58,65 +58,3 @@ var M;
})();
M.D = D;
})(M || (M = {}));
//// [declInput-2.d.ts]
declare module M {
class E {
}
interface I1 {
}
class D {
private c;
m1: number;
m2: string;
m22: C;
m23: E;
m24: I1;
m25: I2;
m232(): E;
m242(): I1;
m252(): I2;
m26(i: I1): void;
m262(i: I2): void;
m3(): C;
}
}
//// [DtsFileErrors]
==== tests/cases/compiler/declInput-2.d.ts (5 errors) ====
declare module M {
class E {
}
interface I1 {
}
class D {
private c;
m1: number;
m2: string;
m22: C;
~
!!! Cannot find name 'C'.
m23: E;
m24: I1;
m25: I2;
~~
!!! Cannot find name 'I2'.
m232(): E;
m242(): I1;
m252(): I2;
~~
!!! Cannot find name 'I2'.
m26(i: I1): void;
m262(i: I2): void;
~~
!!! Cannot find name 'I2'.
m3(): C;
~
!!! Cannot find name 'C'.
}
}
@@ -28,7 +28,6 @@ export module M.P {
export interface I { }
}
export import im = M.P.f;
// Bug 887180: Invalid .d.ts when an aliased entity is referenced, and a different entity is closer in scope
export var a = M.a; // emitted incorrectly as typeof f
export var b = M.b; // ok
export var c = M.c; // ok
@@ -145,6 +144,7 @@ declare module f {
}
export = f;
//// [declarationEmit_nameConflicts_0.d.ts]
import im = require('declarationEmit_nameConflicts_1');
export declare module M {
function f(): void;
class C {
@@ -169,10 +169,10 @@ export declare module M.P {
}
}
export import im = M.P.f;
var a: () => void;
var a: typeof M.f;
var b: typeof M.C;
var c: typeof M.N;
var g: () => void;
var g: typeof M.c.g;
var d: typeof M.d;
}
export declare module M.Q {
@@ -186,74 +186,10 @@ export declare module M.Q {
}
interface b extends M.C {
}
interface I extends M.N.I {
interface I extends M.c.I {
}
module c {
interface I extends M.N.I {
interface I extends M.c.I {
}
}
}
//// [DtsFileErrors]
==== tests/cases/compiler/declarationEmit_nameConflicts_0.d.ts (1 errors) ====
export declare module M {
function f(): void;
class C {
}
module N {
function g(): void;
interface I {
}
}
export import a = M.f;
export import b = M.C;
export import c = N;
export import d = im;
~~~~~~~~~~~~~~~~~~~~~
!!! Cannot find name 'im'.
}
export declare module M.P {
function f(): void;
class C {
}
module N {
function g(): void;
interface I {
}
}
export import im = M.P.f;
var a: () => void;
var b: typeof M.C;
var c: typeof M.N;
var g: () => void;
var d: typeof M.d;
}
export declare module M.Q {
function f(): void;
class C {
}
module N {
function g(): void;
interface I {
}
}
interface b extends M.C {
}
interface I extends M.N.I {
}
module c {
interface I extends M.N.I {
}
}
}
==== tests/cases/compiler/declarationEmit_nameConflicts_1.d.ts (0 errors) ====
declare module f {
class c {
}
}
export = f;
@@ -9,7 +9,6 @@ module X.Y.base {
}
module X.Y.base.Z {
// Bug 887180
export var f = X.Y.base.f; // Should be base.f
export var C = X.Y.base.C; // Should be base.C
export var M = X.Y.base.M; // Should be base.M
@@ -72,7 +71,7 @@ declare module X.Y.base {
}
}
declare module X.Y.base.Z {
var f: () => void;
var f: typeof base.f;
var C: typeof base.C;
var M: typeof base.M;
var E: typeof base.E;
@@ -20,7 +20,6 @@ module M.P {
export enum D {
f
}
// Bug 887180
export var v: M.D; // ok
export var w = M.D.f; // error, should be typeof M.D.f
export var x = M.C.f; // error, should be typeof M.C.f
@@ -111,7 +110,7 @@ declare module M.P {
f = 0,
}
var v: M.D;
var w: () => void;
var x: () => void;
var x: () => void;
var w: typeof M.D.f;
var x: typeof M.C.f;
var x: typeof M.C.f;
}
@@ -1,5 +1,4 @@
//// [declarationEmit_nameConflictsWithAlias.ts]
// Bug 887180
export module C { export interface I { } }
export import v = C;
export module M {
@@ -1,138 +1,47 @@
==== tests/cases/conformance/types/members/duplicateStringIndexers.ts (52 errors) ====
==== tests/cases/conformance/types/members/duplicateStringIndexers.ts (6 errors) ====
// it is an error to have duplicate index signatures of the same kind in a type
interface Number {
[x: string]: string;
~~~~~~~~~~~~~~~~~~~~
!!! Property 'toExponential' of type '(fractionDigits?: number) => string' is not assignable to string index type 'string'.
~~~~~~~~~~~~~~~~~~~~
!!! Property 'toFixed' of type '(fractionDigits?: number) => string' is not assignable to string index type 'string'.
~~~~~~~~~~~~~~~~~~~~
!!! Property 'toPrecision' of type '(precision?: number) => string' is not assignable to string index type 'string'.
~~~~~~~~~~~~~~~~~~~~
!!! Property 'toString' of type '(radix?: number) => string' is not assignable to string index type 'string'.
[x: string]: string;
~~~~~~~~~~~~~~~~~~~~
module test {
interface Number {
[x: string]: string;
[x: string]: string;
~~~~~~~~~~~~~~~~~~~~
!!! Duplicate string index signature.
}
}
interface String {
[x: string]: string;
~~~~~~~~~~~~~~~~~~~~
!!! Property 'charAt' of type '(pos: number) => string' is not assignable to string index type 'string'.
~~~~~~~~~~~~~~~~~~~~
!!! Property 'charCodeAt' of type '(index: number) => number' is not assignable to string index type 'string'.
~~~~~~~~~~~~~~~~~~~~
!!! Property 'concat' of type '(...strings: string[]) => string' is not assignable to string index type 'string'.
~~~~~~~~~~~~~~~~~~~~
!!! Property 'indexOf' of type '(searchString: string, position?: number) => number' is not assignable to string index type 'string'.
~~~~~~~~~~~~~~~~~~~~
!!! Property 'lastIndexOf' of type '(searchString: string, position?: number) => number' is not assignable to string index type 'string'.
~~~~~~~~~~~~~~~~~~~~
!!! Property 'length' of type 'number' is not assignable to string index type 'string'.
~~~~~~~~~~~~~~~~~~~~
!!! Property 'localeCompare' of type '(that: string) => number' is not assignable to string index type 'string'.
~~~~~~~~~~~~~~~~~~~~
!!! Property 'match' of type '{ (regexp: string): string[]; (regexp: RegExp): string[]; }' is not assignable to string index type 'string'.
~~~~~~~~~~~~~~~~~~~~
!!! Property 'replace' of type '{ (searchValue: string, replaceValue: string): string; (searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; }' is not assignable to string index type 'string'.
~~~~~~~~~~~~~~~~~~~~
!!! Property 'search' of type '{ (regexp: string): number; (regexp: RegExp): number; }' is not assignable to string index type 'string'.
~~~~~~~~~~~~~~~~~~~~
!!! Property 'slice' of type '(start?: number, end?: number) => string' is not assignable to string index type 'string'.
~~~~~~~~~~~~~~~~~~~~
!!! Property 'split' of type '{ (separator: string, limit?: number): string[]; (separator: RegExp, limit?: number): string[]; }' is not assignable to string index type 'string'.
~~~~~~~~~~~~~~~~~~~~
!!! Property 'substr' of type '(from: number, length?: number) => string' is not assignable to string index type 'string'.
~~~~~~~~~~~~~~~~~~~~
!!! Property 'substring' of type '(start: number, end?: number) => string' is not assignable to string index type 'string'.
~~~~~~~~~~~~~~~~~~~~
!!! Property 'toLocaleLowerCase' of type '() => string' is not assignable to string index type 'string'.
~~~~~~~~~~~~~~~~~~~~
!!! Property 'toLocaleUpperCase' of type '() => string' is not assignable to string index type 'string'.
~~~~~~~~~~~~~~~~~~~~
!!! Property 'toLowerCase' of type '() => string' is not assignable to string index type 'string'.
~~~~~~~~~~~~~~~~~~~~
!!! Property 'toString' of type '() => string' is not assignable to string index type 'string'.
~~~~~~~~~~~~~~~~~~~~
!!! Property 'toUpperCase' of type '() => string' is not assignable to string index type 'string'.
~~~~~~~~~~~~~~~~~~~~
!!! Property 'trim' of type '() => string' is not assignable to string index type 'string'.
[x: string]: string;
~~~~~~~~~~~~~~~~~~~~
interface String {
[x: string]: string;
[x: string]: string;
~~~~~~~~~~~~~~~~~~~~
!!! Duplicate string index signature.
}
}
interface Array<T> {
[x: string]: T;
~~~~~~~~~~~~~~~
!!! Property 'concat' of type '{ <U extends T[]>(...items: U[]): T[]; (...items: T[]): T[]; }' is not assignable to string index type 'T'.
~~~~~~~~~~~~~~~
!!! Property 'every' of type '(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any) => boolean' is not assignable to string index type 'T'.
~~~~~~~~~~~~~~~
!!! Property 'filter' of type '(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any) => T[]' is not assignable to string index type 'T'.
~~~~~~~~~~~~~~~
!!! Property 'forEach' of type '(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any) => void' is not assignable to string index type 'T'.
~~~~~~~~~~~~~~~
!!! Property 'indexOf' of type '(searchElement: T, fromIndex?: number) => number' is not assignable to string index type 'T'.
~~~~~~~~~~~~~~~
!!! Property 'join' of type '(separator?: string) => string' is not assignable to string index type 'T'.
~~~~~~~~~~~~~~~
!!! Property 'lastIndexOf' of type '(searchElement: T, fromIndex?: number) => number' is not assignable to string index type 'T'.
~~~~~~~~~~~~~~~
!!! Property 'length' of type 'number' is not assignable to string index type 'T'.
~~~~~~~~~~~~~~~
!!! Property 'map' of type '<U>(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any) => U[]' is not assignable to string index type 'T'.
~~~~~~~~~~~~~~~
!!! Property 'pop' of type '() => T' is not assignable to string index type 'T'.
~~~~~~~~~~~~~~~
!!! Property 'push' of type '(...items: T[]) => number' is not assignable to string index type 'T'.
~~~~~~~~~~~~~~~
!!! Property 'reduce' of type '{ (callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; <U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; }' is not assignable to string index type 'T'.
~~~~~~~~~~~~~~~
!!! Property 'reduceRight' of type '{ (callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; <U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; }' is not assignable to string index type 'T'.
~~~~~~~~~~~~~~~
!!! Property 'reverse' of type '() => T[]' is not assignable to string index type 'T'.
~~~~~~~~~~~~~~~
!!! Property 'shift' of type '() => T' is not assignable to string index type 'T'.
~~~~~~~~~~~~~~~
!!! Property 'slice' of type '(start?: number, end?: number) => T[]' is not assignable to string index type 'T'.
~~~~~~~~~~~~~~~
!!! Property 'some' of type '(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any) => boolean' is not assignable to string index type 'T'.
~~~~~~~~~~~~~~~
!!! Property 'sort' of type '(compareFn?: (a: T, b: T) => number) => T[]' is not assignable to string index type 'T'.
~~~~~~~~~~~~~~~
!!! Property 'splice' of type '{ (start: number): T[]; (start: number, deleteCount: number, ...items: T[]): T[]; }' is not assignable to string index type 'T'.
~~~~~~~~~~~~~~~
!!! Property 'toLocaleString' of type '() => string' is not assignable to string index type 'T'.
~~~~~~~~~~~~~~~
!!! Property 'toString' of type '() => string' is not assignable to string index type 'T'.
~~~~~~~~~~~~~~~
!!! Property 'unshift' of type '(...items: T[]) => number' is not assignable to string index type 'T'.
[x: string]: T;
~~~~~~~~~~~~~~~
interface Array<T> {
[x: string]: T;
[x: string]: T;
~~~~~~~~~~~~~~~
!!! Duplicate string index signature.
}
}
class C {
[x: string]: string;
[x: string]: string;
~~~~~~~~~~~~~~~~~~~~
class C {
[x: string]: string;
[x: string]: string;
~~~~~~~~~~~~~~~~~~~~
!!! Duplicate string index signature.
}
}
interface I {
[x: string]: string;
[x: string]: string;
~~~~~~~~~~~~~~~~~~~~
interface I {
[x: string]: string;
[x: string]: string;
~~~~~~~~~~~~~~~~~~~~
!!! Duplicate string index signature.
}
}
var a: {
[x: string]: string;
[x: string]: string;
~~~~~~~~~~~~~~~~~~~~
var a: {
[x: string]: string;
[x: string]: string;
~~~~~~~~~~~~~~~~~~~~
!!! Duplicate string index signature.
}
}
@@ -1,42 +1,46 @@
//// [duplicateStringIndexers.ts]
// it is an error to have duplicate index signatures of the same kind in a type
interface Number {
[x: string]: string;
[x: string]: string;
}
module test {
interface Number {
[x: string]: string;
[x: string]: string;
}
interface String {
[x: string]: string;
[x: string]: string;
}
interface String {
[x: string]: string;
[x: string]: string;
}
interface Array<T> {
[x: string]: T;
[x: string]: T;
}
interface Array<T> {
[x: string]: T;
[x: string]: T;
}
class C {
[x: string]: string;
[x: string]: string;
}
class C {
[x: string]: string;
[x: string]: string;
}
interface I {
[x: string]: string;
[x: string]: string;
}
interface I {
[x: string]: string;
[x: string]: string;
}
var a: {
[x: string]: string;
[x: string]: string;
var a: {
[x: string]: string;
[x: string]: string;
}
}
//// [duplicateStringIndexers.js]
var C = (function () {
function C() {
}
return C;
})();
var a;
var test;
(function (test) {
var C = (function () {
function C() {
}
return C;
})();
var a;
})(test || (test = {}));
@@ -68,7 +68,7 @@
var m: number[] = e;
~
!!! Type 'E' is not assignable to type 'number[]':
!!! Property 'concat' is missing in type 'Number'.
!!! Property 'length' is missing in type 'Number'.
var n: { foo: string } = e;
~
!!! Type 'E' is not assignable to type '{ foo: string; }':
+5
View File
@@ -14,4 +14,9 @@ declare module mAmbient {
//// [enumDecl1.d.ts]
declare module mAmbient {
enum e {
x,
y,
z,
}
}
+2 -20
View File
@@ -46,23 +46,5 @@ declare class Widget1 {
//// [exporter.d.ts]
export import w = require('./w1');
//// [consumer.d.ts]
export declare function w(): Widget1;
//// [DtsFileErrors]
==== tests/cases/compiler/consumer.d.ts (1 errors) ====
export declare function w(): Widget1;
~~~~~~~
!!! Cannot find name 'Widget1'.
==== tests/cases/compiler/w1.d.ts (0 errors) ====
export = Widget1;
declare class Widget1 {
name: string;
}
==== tests/cases/compiler/exporter.d.ts (0 errors) ====
export import w = require('./w1');
import e = require('./exporter');
export declare function w(): e.w;
@@ -38,23 +38,5 @@ interface Widget1 {
//// [exporter.d.ts]
export import w = require('./w1');
//// [consumer.d.ts]
export declare function w(): Widget1;
//// [DtsFileErrors]
==== tests/cases/compiler/consumer.d.ts (1 errors) ====
export declare function w(): Widget1;
~~~~~~~
!!! Cannot find name 'Widget1'.
==== tests/cases/compiler/w1.d.ts (0 errors) ====
export = Widget1;
interface Widget1 {
name: string;
}
==== tests/cases/compiler/exporter.d.ts (0 errors) ====
export import w = require('./w1');
import e = require('./exporter');
export declare function w(): e.w;
+10 -13
View File
@@ -134,29 +134,26 @@ var f2 = function () {
//// [funcdecl.d.ts]
declare function simpleFunc(): string;
declare var simpleFuncVar: () => string;
declare var simpleFuncVar: typeof simpleFunc;
declare function anotherFuncNoReturn(): void;
declare var anotherFuncNoReturnVar: () => void;
declare var anotherFuncNoReturnVar: typeof anotherFuncNoReturn;
declare function withReturn(): string;
declare var withReturnVar: () => string;
declare var withReturnVar: typeof withReturn;
declare function withParams(a: string): string;
declare var withparamsVar: (a: string) => string;
declare var withparamsVar: typeof withParams;
declare function withMultiParams(a: number, b: any, c: Object): number;
declare var withMultiParamsVar: (a: number, b: any, c: Object) => number;
declare var withMultiParamsVar: typeof withMultiParams;
declare function withOptionalParams(a?: string): void;
declare var withOptionalParamsVar: (a?: string) => void;
declare var withOptionalParamsVar: typeof withOptionalParams;
declare function withInitializedParams(a: string, b0: any, b?: number, c?: string): void;
declare var withInitializedParamsVar: (a: string, b0: any, b?: number, c?: string) => void;
declare var withInitializedParamsVar: typeof withInitializedParams;
declare function withOptionalInitializedParams(a: string, c?: string): void;
declare var withOptionalInitializedParamsVar: (a: string, c?: string) => void;
declare var withOptionalInitializedParamsVar: typeof withOptionalInitializedParams;
declare function withRestParams(a: string, ...myRestParameter: number[]): number[];
declare var withRestParamsVar: (a: string, ...myRestParameter: number[]) => number[];
declare var withRestParamsVar: typeof withRestParams;
declare function overload1(n: number): string;
declare function overload1(s: string): string;
declare var withOverloadSignature: {
(n: number): string;
(s: string): string;
};
declare var withOverloadSignature: typeof overload1;
declare function f(n: () => void): void;
declare module m2 {
function foo(n: () => void): void;
@@ -8,14 +8,4 @@ var x = function somefn() {
//// [functionExpressionReturningItself.d.ts]
declare var x: () => typeof somefn;
//// [DtsFileErrors]
==== tests/cases/compiler/functionExpressionReturningItself.d.ts (1 errors) ====
declare var x: () => typeof somefn;
~~~~~~
!!! Cannot find name 'somefn'.
declare var x: () => any;
@@ -10,4 +10,4 @@ function somefn() {
//// [functionReturningItself.d.ts]
declare function somefn(): () => typeof somefn;
declare function somefn(): typeof somefn;
@@ -4,7 +4,7 @@
!!! Cannot compile external modules unless the '--module' flag is provided.
~~~~~~~~~~~~~~~
!!! Class 'ObservableArray<T>' incorrectly implements interface 'T[]':
!!! Property 'join' is missing in type 'ObservableArray<T>'.
!!! Property 'length' is missing in type 'ObservableArray<T>'.
concat<U extends T[]>(...items: U[]): T[];
concat(...items: T[]): T[];
}
@@ -1,83 +0,0 @@
==== tests/cases/compiler/importDecl_1.ts (1 errors) ====
///<reference path='importDecl_require.ts'/>
///<reference path='importDecl_require1.ts'/>
///<reference path='importDecl_require2.ts'/>
///<reference path='importDecl_require3.ts'/>
///<reference path='importDecl_require4.ts'/>
import m4 = require("importDecl_require"); // Emit used
export var x4 = m4.x;
export var d4 = m4.d;
export var f4 = m4.foo();
export module m1 {
export var x2 = m4.x;
export var d2 = m4.d;
export var f2 = m4.foo();
var x3 = m4.x;
var d3 = m4.d;
var f3 = m4.foo();
}
//Emit global only usage
import glo_m4 = require("importDecl_require1");
export var useGlo_m4_x4 = glo_m4.x;
~
!!! Property 'x' does not exist on type 'typeof "tests/cases/compiler/importDecl_require1"'.
export var useGlo_m4_d4 = glo_m4.d;
export var useGlo_m4_f4 = glo_m4.foo();
//Emit even when used just in function type
import fncOnly_m4 = require("importDecl_require2");
export var useFncOnly_m4_f4 = fncOnly_m4.foo();
// only used privately no need to emit
import private_m4 = require("importDecl_require3");
export module usePrivate_m4_m1 {
var x3 = private_m4.x;
var d3 = private_m4.d;
var f3 = private_m4.foo();
}
// Do not emit unused import
import m5 = require("importDecl_require4");
export var d = m5.foo2();
// Do not emit multiple used import statements
import multiImport_m4 = require("importDecl_require"); // Emit used
export var useMultiImport_m4_x4 = multiImport_m4.x;
export var useMultiImport_m4_d4 = multiImport_m4.d;
export var useMultiImport_m4_f4 = multiImport_m4.foo();
==== tests/cases/compiler/importDecl_require.ts (0 errors) ====
export class d {
foo: string;
}
export var x: d;
export function foo(): d { return null; }
==== tests/cases/compiler/importDecl_require1.ts (0 errors) ====
export class d {
bar: string;
}
var x: d;
export function foo(): d { return null; }
==== tests/cases/compiler/importDecl_require2.ts (0 errors) ====
export class d {
baz: string;
}
export var x: d;
export function foo(): d { return null; }
==== tests/cases/compiler/importDecl_require3.ts (0 errors) ====
export class d {
bing: string;
}
export var x: d;
export function foo(): d { return null; }
==== tests/cases/compiler/importDecl_require4.ts (0 errors) ====
import m4 = require("importDecl_require");
export function foo2(): m4.d { return null; }
+54 -2
View File
@@ -55,7 +55,6 @@ export module m1 {
//Emit global only usage
import glo_m4 = require("importDecl_require1");
export var useGlo_m4_x4 = glo_m4.x;
export var useGlo_m4_d4 = glo_m4.d;
export var useGlo_m4_f4 = glo_m4.foo();
@@ -150,7 +149,6 @@ exports.f4 = m4.foo();
})(exports.m1 || (exports.m1 = {}));
var m1 = exports.m1;
var glo_m4 = require("importDecl_require1");
exports.useGlo_m4_x4 = glo_m4.x;
exports.useGlo_m4_d4 = glo_m4.d;
exports.useGlo_m4_f4 = glo_m4.foo();
var fncOnly_m4 = require("importDecl_require2");
@@ -168,3 +166,57 @@ var multiImport_m4 = require("importDecl_require");
exports.useMultiImport_m4_x4 = multiImport_m4.x;
exports.useMultiImport_m4_d4 = multiImport_m4.d;
exports.useMultiImport_m4_f4 = multiImport_m4.foo();
//// [importDecl_require.d.ts]
export declare class d {
foo: string;
}
export declare var x: d;
export declare function foo(): d;
//// [importDecl_require1.d.ts]
export declare class d {
bar: string;
}
export declare function foo(): d;
//// [importDecl_require2.d.ts]
export declare class d {
baz: string;
}
export declare var x: d;
export declare function foo(): d;
//// [importDecl_require3.d.ts]
export declare class d {
bing: string;
}
export declare var x: d;
export declare function foo(): d;
//// [importDecl_require4.d.ts]
import m4 = require("importDecl_require");
export declare function foo2(): m4.d;
//// [importDecl_1.d.ts]
/// <reference path='importDecl_require.d.ts' />
/// <reference path='importDecl_require1.d.ts' />
/// <reference path='importDecl_require2.d.ts' />
/// <reference path='importDecl_require3.d.ts' />
/// <reference path='importDecl_require4.d.ts' />
import m4 = require("importDecl_require");
export declare var x4: m4.d;
export declare var d4: typeof m4.d;
export declare var f4: m4.d;
export declare module m1 {
var x2: m4.d;
var d2: typeof m4.d;
var f2: m4.d;
}
import glo_m4 = require("importDecl_require1");
export declare var useGlo_m4_d4: typeof glo_m4.d;
export declare var useGlo_m4_f4: glo_m4.d;
import fncOnly_m4 = require("importDecl_require2");
export declare var useFncOnly_m4_f4: fncOnly_m4.d;
export declare module usePrivate_m4_m1 {
}
export declare var d: m4.d;
export declare var useMultiImport_m4_x4: m4.d;
export declare var useMultiImport_m4_d4: typeof m4.d;
export declare var useMultiImport_m4_f4: m4.d;
@@ -28,20 +28,5 @@ export declare class B {
}
//// [importDeclarationUsedAsTypeQuery_1.d.ts]
/// <reference path='importDeclarationUsedAsTypeQuery_require.d.ts' />
import a = require('importDeclarationUsedAsTypeQuery_require');
export declare var x: typeof a;
//// [DtsFileErrors]
==== tests/cases/compiler/importDeclarationUsedAsTypeQuery_1.d.ts (1 errors) ====
/// <reference path='importDeclarationUsedAsTypeQuery_require.d.ts' />
export declare var x: typeof a;
~
!!! Cannot find name 'a'.
==== tests/cases/compiler/importDeclarationUsedAsTypeQuery_require.d.ts (0 errors) ====
export declare class B {
id: number;
}
@@ -32,21 +32,6 @@ declare module a {
}
}
declare module c {
import b = a.c;
var x: b;
}
//// [DtsFileErrors]
==== tests/cases/compiler/internalAliasClass.d.ts (1 errors) ====
declare module a {
class c {
}
}
declare module c {
var x: b;
~
!!! Cannot find name 'b'.
}
@@ -47,25 +47,7 @@ export declare module x {
}
export declare module m2 {
module m3 {
import c = x.c;
var cProp: c;
}
}
//// [DtsFileErrors]
==== tests/cases/compiler/internalAliasClassInsideLocalModuleWithoutExport.d.ts (1 errors) ====
export declare module x {
class c {
foo(a: number): number;
}
}
export declare module m2 {
module m3 {
var cProp: c;
~
!!! Cannot find name 'c'.
}
}
@@ -35,19 +35,5 @@ export declare module x {
foo(a: number): number;
}
}
import xc = x.c;
export declare var cProp: xc;
//// [DtsFileErrors]
==== tests/cases/compiler/internalAliasClassInsideTopLevelModuleWithoutExport.d.ts (1 errors) ====
export declare module x {
class c {
foo(a: number): number;
}
}
export declare var cProp: xc;
~~
!!! Cannot find name 'xc'.
+1 -19
View File
@@ -39,24 +39,6 @@ declare module a {
}
}
declare module c {
import b = a.weekend;
var bVal: b;
}
//// [DtsFileErrors]
==== tests/cases/compiler/internalAliasEnum.d.ts (1 errors) ====
declare module a {
enum weekend {
Friday = 0,
Saturday = 1,
Sunday = 2,
}
}
declare module c {
var bVal: b;
~
!!! Cannot find name 'b'.
}
@@ -39,24 +39,6 @@ export declare module a {
}
}
export declare module c {
import b = a.weekend;
var bVal: b;
}
//// [DtsFileErrors]
==== tests/cases/compiler/internalAliasEnumInsideLocalModuleWithoutExport.d.ts (1 errors) ====
export declare module a {
enum weekend {
Friday = 0,
Saturday = 1,
Sunday = 2,
}
}
export declare module c {
var bVal: b;
~
!!! Cannot find name 'b'.
}
@@ -35,21 +35,5 @@ export declare module a {
Sunday = 2,
}
}
import b = a.weekend;
export declare var bVal: b;
//// [DtsFileErrors]
==== tests/cases/compiler/internalAliasEnumInsideTopLevelModuleWithoutExport.d.ts (1 errors) ====
export declare module a {
enum weekend {
Friday = 0,
Saturday = 1,
Sunday = 2,
}
}
export declare var bVal: b;
~
!!! Cannot find name 'b'.
@@ -33,6 +33,7 @@ declare module a {
function foo(x: number): number;
}
declare module c {
import b = a.foo;
var bVal: number;
var bVal2: (x: number) => number;
var bVal2: typeof b;
}
@@ -35,5 +35,5 @@ export declare module a {
export declare module c {
export import b = a.foo;
var bVal: number;
var bVal2: (x: number) => number;
var bVal2: typeof b;
}
@@ -33,5 +33,6 @@ export declare module a {
function foo(x: number): number;
}
export declare module c {
var bVal2: (x: number) => number;
import b = a.foo;
var bVal2: typeof b;
}
@@ -31,4 +31,4 @@ export declare module a {
}
export import b = a.foo;
export declare var bVal: number;
export declare var bVal2: (x: number) => number;
export declare var bVal2: typeof b;
@@ -27,5 +27,6 @@ exports.bVal2 = b;
export declare module a {
function foo(x: number): number;
}
import b = a.foo;
export declare var bVal: number;
export declare var bVal2: (x: number) => number;
export declare var bVal2: typeof b;
@@ -39,23 +39,6 @@ declare module a {
}
}
declare module c {
import b = a.b;
var x: b.c;
}
//// [DtsFileErrors]
==== tests/cases/compiler/internalAliasInitializedModule.d.ts (1 errors) ====
declare module a {
module b {
class c {
}
}
}
declare module c {
var x: b.c;
~~~
!!! Cannot find name 'b'.
}
@@ -39,23 +39,6 @@ export declare module a {
}
}
export declare module c {
import b = a.b;
var x: b.c;
}
//// [DtsFileErrors]
==== tests/cases/compiler/internalAliasInitializedModuleInsideLocalModuleWithoutExport.d.ts (1 errors) ====
export declare module a {
module b {
class c {
}
}
}
export declare module c {
var x: b.c;
~~~
!!! Cannot find name 'b'.
}
@@ -35,20 +35,5 @@ export declare module a {
}
}
}
import b = a.b;
export declare var x: b.c;
//// [DtsFileErrors]
==== tests/cases/compiler/internalAliasInitializedModuleInsideTopLevelModuleWithoutExport.d.ts (1 errors) ====
export declare module a {
module b {
class c {
}
}
}
export declare var x: b.c;
~~~
!!! Cannot find name 'b'.
@@ -23,21 +23,6 @@ declare module a {
}
}
declare module c {
import b = a.I;
var x: b;
}
//// [DtsFileErrors]
==== tests/cases/compiler/internalAliasInterface.d.ts (1 errors) ====
declare module a {
interface I {
}
}
declare module c {
var x: b;
~
!!! Cannot find name 'b'.
}
@@ -25,21 +25,6 @@ export declare module a {
}
}
export declare module c {
import b = a.I;
var x: b;
}
//// [DtsFileErrors]
==== tests/cases/compiler/internalAliasInterfaceInsideLocalModuleWithoutExport.d.ts (1 errors) ====
export declare module a {
interface I {
}
}
export declare module c {
var x: b;
~
!!! Cannot find name 'b'.
}
@@ -19,18 +19,5 @@ export declare module a {
interface I {
}
}
import b = a.I;
export declare var x: b;
//// [DtsFileErrors]
==== tests/cases/compiler/internalAliasInterfaceInsideTopLevelModuleWithoutExport.d.ts (1 errors) ====
export declare module a {
interface I {
}
}
export declare var x: b;
~
!!! Cannot find name 'b'.
@@ -30,24 +30,6 @@ declare module a {
}
}
declare module c {
import b = a.b;
var x: b.I;
}
//// [DtsFileErrors]
==== tests/cases/compiler/internalAliasUninitializedModule.d.ts (1 errors) ====
declare module a {
module b {
interface I {
foo(): any;
}
}
}
declare module c {
var x: b.I;
~~~
!!! Cannot find name 'b'.
}
@@ -30,24 +30,6 @@ export declare module a {
}
}
export declare module c {
import b = a.b;
var x: b.I;
}
//// [DtsFileErrors]
==== tests/cases/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExport.d.ts (1 errors) ====
export declare module a {
module b {
interface I {
foo(): any;
}
}
}
export declare module c {
var x: b.I;
~~~
!!! Cannot find name 'b'.
}
@@ -25,21 +25,5 @@ export declare module a {
}
}
}
import b = a.b;
export declare var x: b.I;
//// [DtsFileErrors]
==== tests/cases/compiler/internalAliasUninitializedModuleInsideTopLevelModuleWithoutExport.d.ts (1 errors) ====
export declare module a {
module b {
interface I {
foo(): any;
}
}
}
export declare var x: b.I;
~~~
!!! Cannot find name 'b'.
@@ -18,3 +18,11 @@ var a;
})(a.b || (a.b = {}));
var b = a.b;
})(a || (a = {}));
//// [internalAliasWithDottedNameEmit.d.ts]
declare module a.b.c {
var d: any;
}
declare module a.e.f {
}
@@ -44,33 +44,9 @@ declare module "SubModule" {
}
//// [missingImportAfterModuleImport_1.d.ts]
/// <reference path='missingImportAfterModuleImport_0.d.ts' />
import SubModule = require('SubModule');
declare class MainModule {
SubModule: SubModule;
constructor();
}
export = MainModule;
//// [DtsFileErrors]
==== tests/cases/compiler/missingImportAfterModuleImport_1.d.ts (1 errors) ====
/// <reference path='missingImportAfterModuleImport_0.d.ts' />
declare class MainModule {
SubModule: SubModule;
~~~~~~~~~
!!! Cannot find name 'SubModule'.
constructor();
}
export = MainModule;
==== tests/cases/compiler/missingImportAfterModuleImport_0.d.ts (0 errors) ====
declare module "SubModule" {
class SubModule {
static StaticVar: number;
InstanceVar: number;
constructor();
}
export = SubModule;
}
@@ -14,4 +14,10 @@ declare module outer {
//// [moduleOuterQualification.d.ts]
declare module outer {
interface Beta {
}
module inner {
interface Beta extends outer.Beta {
}
}
}

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