Emit the types in declaration file

This commit is contained in:
Sheetal Nandi 2014-07-11 16:36:06 -07:00
parent c777d5c68a
commit 574c075dba
1100 changed files with 6344 additions and 6134 deletions

View File

@ -596,98 +596,136 @@ module ts {
return symbol.name;
}
function typeToString(type: Type, printArrayAsGenericType: boolean): string {
function createSingleLineTextWriter() {
var result = "";
return {
write(s: string) { result += s; },
writeLine() { result += " "; },
increaseIndent() { },
decreaseIndent() { },
getText() { return result; }
};
}
function typeToString(type: Type, flags?: TypeFormatFlags): string {
var stringWriter = createSingleLineTextWriter();
// TODO(shkamat): typeToString should take enclosingDeclaration as input, once we have implemented enclosingDeclaration
writeTypeToTextWriter(type, /*enclosingDeclaration*/ null, flags, stringWriter);
return stringWriter.getText();
}
function writeTypeToTextWriter(type: Type, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: TextWriter) {
// TODO(shkamat): usage of enclosingDeclaration
var typeStack: Type[];
return typeToString(type);
return writeType(type);
function typeToString(type: Type): string {
function writeType(type: Type) {
if (type.flags & TypeFlags.Intrinsic) {
return (<IntrinsicType>type).intrinsicName;
writer.write((<IntrinsicType>type).intrinsicName);
}
if (type.flags & TypeFlags.Reference) {
return typeReferenceToString(<TypeReference>type);
else if (type.flags & TypeFlags.Reference) {
writeTypeReference(<TypeReference>type);
}
if (type.flags & (TypeFlags.Class | TypeFlags.Interface | TypeFlags.Enum | TypeFlags.TypeParameter)) {
return symbolToString(type.symbol);
else if (type.flags & (TypeFlags.Class | TypeFlags.Interface | TypeFlags.Enum | TypeFlags.TypeParameter)) {
writer.write(symbolToString(type.symbol));
}
if (type.flags & TypeFlags.Anonymous) {
return anonymousTypeToString(<ObjectType>type);
else if (type.flags & TypeFlags.Anonymous) {
writeAnonymousType(<ObjectType>type);
}
if (type.flags & TypeFlags.StringLiteral) {
return (<StringLiteralType>type).text;
else if (type.flags & TypeFlags.StringLiteral) {
writer.write((<StringLiteralType>type).text);
}
else {
// Should never get here
writer.write("{ ... }");
}
// Should never get here
return "{ ... }";
}
function typeReferenceToString(type: TypeReference): string {
if (type.target === globalArrayType && !printArrayAsGenericType) {
return typeToString(type.typeArguments[0]) + "[]";
function writeTypeReference(type: TypeReference) {
if (type.target === globalArrayType && !(flags & TypeFormatFlags.WriteArrayAsGenericType)) {
writeType(type.typeArguments[0]);
writer.write("[]");
}
var result = symbolToString(type.target.symbol);
result += "<";
for (var i = 0; i < type.typeArguments.length; i++) {
if (i > 0) result += ", ";
result += typeToString(type.typeArguments[i]);
else {
writer.write(symbolToString(type.target.symbol));
writer.write("<");
for (var i = 0; i < type.typeArguments.length; i++) {
if (i > 0) {
writer.write(", ");
}
writeType(type.typeArguments[i]);
}
writer.write(">");
}
result += ">";
return result;
}
function anonymousTypeToString(type: ObjectType): string {
function writeAnonymousType(type: ObjectType) {
// Always use 'typeof T' for type of class, enum, and module objects
if (type.symbol && type.symbol.flags & (SymbolFlags.Class | SymbolFlags.Enum | SymbolFlags.ValueModule)) {
return symbolTypeToString(type);
writeTypeofSymbol(type);
}
// Use 'typeof T' for types of functions and methods that circularly reference themselves
if (type.symbol && type.symbol.flags & (SymbolFlags.Function | SymbolFlags.Method)) {
if (typeStack && contains(typeStack, type)) {
return symbolTypeToString(type);
}
else if (type.symbol && type.symbol.flags & (SymbolFlags.Function | SymbolFlags.Method) && typeStack && contains(typeStack, type)) {
writeTypeofSymbol(type);
}
else {
if (!typeStack) {
typeStack = [];
}
typeStack.push(type);
writeLiteralType(type);
typeStack.pop();
}
if (!typeStack) typeStack = [];
typeStack.push(type);
var result = literalTypeToString(type);
typeStack.pop();
return result;
}
function symbolTypeToString(type: ObjectType): string {
return "typeof " + symbolToString(type.symbol);
function writeTypeofSymbol(type: ObjectType) {
writer.write("typeof ");
writer.write(symbolToString(type.symbol));
}
function literalTypeToString(type: ObjectType): string {
function writeLiteralType(type: ObjectType) {
var resolved = resolveObjectTypeMembers(type);
if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) {
if (!resolved.callSignatures.length && !resolved.constructSignatures.length) {
return "{}";
writer.write("{}");
return;
}
if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) {
return signatureToString(resolved.callSignatures[0], /*arrowStyle*/ true);
writeSignature(resolved.callSignatures[0], /*arrowStyle*/ true);
return;
}
if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) {
return "new " + signatureToString(resolved.constructSignatures[0], /*arrowStyle*/ true);
writer.write("new ");
writeSignature(resolved.constructSignatures[0], /*arrowStyle*/ true);
return;
}
}
var result = "{ ";
writer.write("{");
writer.writeLine();
writer.increaseIndent();
for (var i = 0; i < resolved.callSignatures.length; i++) {
result += signatureToString(resolved.callSignatures[i]);
result += "; ";
writeSignature(resolved.callSignatures[i]);
writer.write(";");
writer.writeLine();
}
for (var i = 0; i < resolved.constructSignatures.length; i++) {
result += "new ";
result += signatureToString(resolved.constructSignatures[i]);
result += "; ";
writer.write("new ");
writeSignature(resolved.constructSignatures[i]);
writer.write(";");
writer.writeLine();
}
if (resolved.stringIndexType) {
result += "[x: string]: ";
result += typeToString(resolved.stringIndexType);
result += "; ";
writer.write("[x: string]: ");
writeType(resolved.stringIndexType);
writer.write(";");
writer.writeLine();
}
if (resolved.numberIndexType) {
result += "[x: number]: ";
result += typeToString(resolved.numberIndexType);
result += "; ";
writer.write("[x: number]: ");
writeType(resolved.numberIndexType);
writer.write(";");
writer.writeLine();
}
for (var i = 0; i < resolved.properties.length; i++) {
var p = resolved.properties[i];
@ -695,61 +733,65 @@ module ts {
if (p.flags & (SymbolFlags.Function | SymbolFlags.Method) && !getPropertiesOfType(t).length) {
var signatures = getSignaturesOfType(t, SignatureKind.Call);
for (var j = 0; j < signatures.length; j++) {
result += symbolToString(p);
writer.write(symbolToString(p));
if (isOptionalProperty(p)) {
result += "?";
writer.write("?");
}
result += signatureToString(signatures[j]);
result += "; ";
writeSignature(signatures[j]);
writer.write(";");
writer.writeLine();
}
}
else {
result += symbolToString(p);
writer.write(symbolToString(p));
if (isOptionalProperty(p)) {
result += "?";
writer.write("?");
}
result += ": ";
result += typeToString(t);
result += "; ";
writer.write(": ");
writeType(t);
writer.write(";");
writer.writeLine();
}
}
result += "}";
return result;
writer.decreaseIndent();
writer.write("}");
}
function signatureToString(signature: Signature, arrowStyle?: boolean): string {
var result = "";
function writeSignature(signature: Signature, arrowStyle?: boolean) {
if (signature.typeParameters) {
result += "<";
writer.write("<");
for (var i = 0; i < signature.typeParameters.length; i++) {
if (i > 0) result += ", ";
if (i > 0) {
writer.write(", ");
}
var tp = signature.typeParameters[i];
result += symbolToString(tp.symbol);
writer.write(symbolToString(tp.symbol));
var constraint = getConstraintOfTypeParameter(tp);
if (constraint) {
result += " extends ";
result += typeToString(constraint);
writer.write(" extends ");
writeType(constraint);
}
}
result += ">";
writer.write(">");
}
result += "(";
writer.write("(");
for (var i = 0; i < signature.parameters.length; i++) {
if (i > 0) result += ", ";
if (i > 0) {
writer.write(", ");
}
var p = signature.parameters[i];
if (getDeclarationFlagsFromSymbol(p) & NodeFlags.Rest) {
result += "...";
writer.write("...");
}
result += symbolToString(p);
writer.write(symbolToString(p));
if (p.valueDeclaration.flags & NodeFlags.QuestionMark || (<VariableDeclaration>p.valueDeclaration).initializer) {
result += "?";
writer.write("?");
}
result += ": ";
result += typeToString(getTypeOfSymbol(p));
writer.write(": ");
writeType(getTypeOfSymbol(p));
}
result += arrowStyle ? ") => " : "): ";
result += typeToString(getReturnTypeOfSignature(signature));
return result;
writer.write(arrowStyle ? ") => " : "): ");
writeType(getReturnTypeOfSignature(signature));
}
}
@ -846,7 +888,7 @@ module ts {
function reportNoImplicitAnyOnVariableOrParameterOrProperty(declaration: VariableDeclaration, type: Type): void {
var varName = identifierToString(declaration.name);
var typeName = typeToString(type, /* printArrayAsGeneric */ false);
var typeName = typeToString(type);
switch (declaration.kind) {
case SyntaxKind.VariableDeclaration:
@ -1080,7 +1122,7 @@ module ts {
type.baseTypes.push(baseType);
}
else {
error(declaration, Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*printArrayAsGenericType*/ false));
error(declaration, Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, TypeFormatFlags.WriteArrayAsGenericType));
}
}
else {
@ -1121,7 +1163,7 @@ module ts {
type.baseTypes.push(baseType);
}
else {
error(declaration, Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*printArrayAsGenericType*/ false));
error(declaration, Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, TypeFormatFlags.WriteArrayAsGenericType));
}
}
else {
@ -1688,13 +1730,13 @@ module ts {
type = createTypeReference(<GenericType>type, map(node.typeArguments, t => getTypeFromTypeNode(t)));
}
else {
error(node, Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, /*printArrayAsGenericType*/ true), typeParameters.length);
error(node, Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, TypeFormatFlags.WriteArrayAsGenericType), typeParameters.length);
type = undefined;
}
}
else {
if (node.typeArguments) {
error(node, Diagnostics.Type_0_is_not_generic, typeToString(type, /*printArrayAsGenericType*/ false));
error(node, Diagnostics.Type_0_is_not_generic, typeToString(type));
type = undefined;
}
}
@ -2068,11 +2110,11 @@ module ts {
if (isInheritedProperty && !isPropertyIdenticalTo(existing.prop, prop)) {
ok = false;
var typeName1 = typeToString(existing.containingType, /*printArrayAsGenericType*/ false);
var typeName2 = typeToString(base, /*printArrayAsGenericType*/ false);
var typeName1 = typeToString(existing.containingType);
var typeName2 = typeToString(base);
var errorInfo = chainDiagnosticMessages(undefined, Diagnostics.Named_properties_0_of_types_1_and_2_are_not_identical, prop.name, typeName1, typeName2);
errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Interface_0_cannot_simultaneously_extend_types_1_and_2_Colon, typeToString(type, /*printArrayAsGenericType*/ false), typeName1, typeName2);
errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Interface_0_cannot_simultaneously_extend_types_1_and_2_Colon, typeToString(type), typeName1, typeName2);
addDiagnostic(createDiagnosticForNodeFromMessageChain(typeNode, errorInfo));
}
}
@ -2117,7 +2159,7 @@ module ts {
var result = isRelatedToWithCustomErrors(source, target, errorNode !== undefined, chainedMessage, terminalMessage);
if (overflow) {
error(errorNode, Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source, /*printArrayAsGenericType*/ false), typeToString(target, /*printArrayAsGenericType*/ false));
error(errorNode, Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target));
}
else if (errorInfo) {
addDiagnostic(createDiagnosticForNodeFromMessageChain(errorNode, errorInfo));
@ -2183,7 +2225,7 @@ module ts {
terminalMessage = terminalMessage || Diagnostics.Type_0_is_not_assignable_to_type_1;
var diagnosticKey = errorInfo ? chainedMessage : terminalMessage;
Debug.assert(diagnosticKey);
reportError(diagnosticKey, typeToString(source, /*printArrayAsGenericType*/ false), typeToString(target, /*printArrayAsGenericType*/ false));
reportError(diagnosticKey, typeToString(source), typeToString(target));
}
return false;
}
@ -2332,7 +2374,7 @@ module ts {
if (!sourceProp) {
if (!targetPropIsOptional) {
if (reportErrors) {
reportError(Diagnostics.Property_0_is_missing_in_type_1, symbolToString(targetProp), typeToString(source, /*printArrayAsGenericType*/ false));
reportError(Diagnostics.Property_0_is_missing_in_type_1, symbolToString(targetProp), typeToString(source));
}
return false;
}
@ -2363,7 +2405,7 @@ module ts {
// (M - property in T)
// (N - property in S)
if (reportErrors) {
reportError(Diagnostics.Required_property_0_cannot_be_reimplemented_with_optional_property_in_1, targetProp.name, typeToString(source, /*printArrayAsGenericType*/ false));
reportError(Diagnostics.Required_property_0_cannot_be_reimplemented_with_optional_property_in_1, targetProp.name, typeToString(source));
}
return false;
}
@ -2535,7 +2577,7 @@ module ts {
var sourceType = getIndexTypeOfType(source, IndexKind.String);
if (!sourceType) {
if (reportErrors) {
reportError(Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source, /*printArrayAsGenericType*/ false));
reportError(Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source));
}
return false;
}
@ -2561,7 +2603,7 @@ module ts {
var sourceNumberType = getIndexTypeOfType(source, IndexKind.Number);
if (!(sourceStringType || sourceNumberType)) {
if (reportErrors) {
reportError(Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source, /*printArrayAsGenericType*/ false));
reportError(Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source));
}
return false;
}
@ -2618,7 +2660,7 @@ module ts {
propTypeWasWidened = true;
if (program.getCompilerOptions().noImplicitAny && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) {
error(p.valueDeclaration, Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(widenedType, /* printArrayAsGeneric */ false));
error(p.valueDeclaration, Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(widenedType));
}
}
widenedTypes.push(widenedType);
@ -3224,7 +3266,7 @@ module ts {
var prop = getPropertyOfApparentType(apparentType, node.right.text);
if (!prop) {
if (node.right.text) {
error(node.right, Diagnostics.Property_0_does_not_exist_on_type_1, identifierToString(node.right), typeToString(type, /*printArrayAsGenericType*/ false));
error(node.right, Diagnostics.Property_0_does_not_exist_on_type_1, identifierToString(node.right), typeToString(type));
}
return unknownType;
}
@ -3500,7 +3542,7 @@ module ts {
// with multiple call signatures.
if (!signatures.length) {
if (constructSignatures.length) {
error(node, Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType, /*printArrayAsGenericType*/ false));
error(node, Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType));
}
else {
error(node, Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature);
@ -3625,7 +3667,7 @@ module ts {
var widenedType = getWidenedType(unwidenedType);
if (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, /* printArrayAsGeneric */ false));
error(func, Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeToString(widenedType));
}
return widenedType;
@ -3649,7 +3691,7 @@ module ts {
// 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) {
var typeName = typeToString(widenedType, /* printArrayAsGeneric */ false);
var typeName = typeToString(widenedType);
if (func.name) {
error(func, Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type, identifierToString(func.name), typeName);
@ -3978,7 +4020,7 @@ module ts {
}
function reportOperatorError() {
error(node, Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, tokenToString(node.operator), typeToString(leftType, /*printArrayAsGenericType*/ false), typeToString(rightType, /*printArrayAsGenericType*/ false));
error(node, Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, tokenToString(node.operator), typeToString(leftType), typeToString(rightType));
}
}
@ -3990,10 +4032,10 @@ module ts {
if (!resultType) {
if (contextualType && !isInferentialContext(contextualMapper)) {
error(node, Diagnostics.No_best_common_type_exists_between_0_1_and_2, typeToString(contextualType, /*printArrayAsGenericType*/ false), typeToString(type1, /*printArrayAsGenericType*/ false), typeToString(type2, /*printArrayAsGenericType*/ false));
error(node, Diagnostics.No_best_common_type_exists_between_0_1_and_2, typeToString(contextualType), typeToString(type1), typeToString(type2));
}
else {
error(node, Diagnostics.No_best_common_type_exists_between_0_and_1, typeToString(type1, /*printArrayAsGenericType*/ false), typeToString(type2, /*printArrayAsGenericType*/ false));
error(node, Diagnostics.No_best_common_type_exists_between_0_and_1, typeToString(type1), typeToString(type2));
}
resultType = emptyObjectType;
@ -4564,7 +4606,7 @@ module ts {
// 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)) {
var typeName = typeToString(anyType, /* printArrayAsGeneric */ false);
var typeName = typeToString(anyType);
if (node.name) {
error(node, Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type, identifierToString(node.name), typeName);
@ -4735,7 +4777,7 @@ module ts {
// 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, /*printArrayAsGenericType*/ false), typeToString(type, /*printArrayAsGenericType*/ false));
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));
}
}
}
@ -4933,7 +4975,7 @@ module ts {
indexKind === IndexKind.String
? Diagnostics.Property_0_of_type_1_is_not_assignable_to_string_index_type_2
: Diagnostics.Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2;
error(errorNode, errorMessage, symbolToString(prop), typeToString(propertyType, /*printArrayAsGenericType*/ false), typeToString(indexType, /*printArrayAsGenericType*/ false));
error(errorNode, errorMessage, symbolToString(prop), typeToString(propertyType), typeToString(indexType));
}
}
@ -4963,7 +5005,7 @@ module ts {
if (errorNode && !isTypeAssignableTo(numberIndexType, stringIndexType)) {
error(errorNode, Diagnostics.Numeric_index_type_0_is_not_assignable_to_string_index_type_1,
typeToString(numberIndexType, /*printArrayAsGenericType*/ false), typeToString(stringIndexType, /*printArrayAsGenericType*/ false));
typeToString(numberIndexType), typeToString(stringIndexType));
}
}
@ -5014,7 +5056,7 @@ module ts {
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, /*printArrayAsGenericType*/ false));
error(node.baseType, Diagnostics.Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0, typeToString(baseType));
}
// Check that base type can be evaluated as expression
@ -5113,7 +5155,7 @@ module ts {
errorMessage = Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function;
}
error(derived.valueDeclaration.name, errorMessage, typeToString(baseType, /* printArrayAsGenericType*/ false), symbolToString(base), typeToString(type, /* printArrayAsGenericType*/ false));
error(derived.valueDeclaration.name, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type));
}
}
}
@ -5738,6 +5780,19 @@ module ts {
return getNodeLinks(node).enumMemberValue;
}
function writeTypeAtLocation(location: Node, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: TextWriter) {
// Get type of the symbol if this is the valid symbol otherwise get type at location
var symbol = getSymbolOfNode(location);
var type = symbol && !(symbol.flags & SymbolFlags.TypeLiteral) ? getTypeOfSymbol(symbol) : getTypeFromTypeNode(location);
writeTypeToTextWriter(type, enclosingDeclaration, flags, writer);
}
function writeReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: TextWriter) {
var signature = getSignatureFromDeclaration(signatureDeclaration);
writeTypeToTextWriter(getReturnTypeOfSignature(signature), enclosingDeclaration, flags , writer);
}
function invokeEmitter() {
var resolver: EmitResolver = {
getProgram: () => program,
@ -5751,7 +5806,9 @@ module ts {
isTopLevelValueImportedViaEntityName: isTopLevelValueImportedViaEntityName,
shouldEmitDeclarations: shouldEmitDeclarations,
isReferencedInExportAssignment: isReferencedInExportAssignment,
isImplementationOfOverload: isImplementationOfOverload
isImplementationOfOverload: isImplementationOfOverload,
writeTypeAtLocation: writeTypeAtLocation,
writeReturnTypeOfSignatureDeclaration: writeReturnTypeOfSignatureDeclaration
};
checkProgram();
return emitFiles(resolver);

View File

@ -94,19 +94,14 @@ module ts {
return sourceMapDataList;
}
interface TextWriter {
write(s: string): void;
interface EmitTextWriter extends TextWriter {
writeLiteral(s: string): void;
writeLine(): void;
increaseIndent(): void;
decreaseIndent(): void;
getTextPos(): number;
getLine(): number;
getColumn(): number;
getText(): string;
}
function createTextWriter(): TextWriter {
function createTextWriter(): EmitTextWriter {
var output = "";
var indent = 0;
var lineStart = true;
@ -1851,6 +1846,7 @@ module ts {
var increaseIndent = writer.increaseIndent;
var decreaseIndent = writer.decreaseIndent;
var enclosingDeclaration: Node;
function emitLines(nodes: Node[]) {
for (var i = 0, n = nodes.length; i < n; i++) {
emitNode(nodes[i]);
@ -1874,6 +1870,7 @@ module ts {
function emitSourceFile(node: SourceFile) {
currentSourceFile = node;
enclosingDeclaration = node;
emitLines(node.statements);
}
@ -1969,6 +1966,8 @@ module ts {
write(".");
emitSourceTextOfNode(node.name);
}
var prevEnclosingDeclaration = enclosingDeclaration;
enclosingDeclaration = node;
write(" {");
writeLine();
increaseIndent();
@ -1976,6 +1975,7 @@ module ts {
decreaseIndent();
write("}");
writeLine();
enclosingDeclaration = prevEnclosingDeclaration;
}
}
@ -2010,9 +2010,8 @@ module ts {
emitSourceTextOfNode(node.name);
if (node.constraint) {
write(" extends ");
// TODO(shkamat): emit constraint using type
emitSourceTextOfNode(node.constraint);
}
resolver.writeTypeAtLocation(node.constraint, enclosingDeclaration, TypeFormatFlags.None, writer);
}
}
if (typeParameters) {
@ -2023,10 +2022,13 @@ module ts {
}
function emitHeritageClause(typeReferences: TypeReferenceNode[], isImplementsList: boolean) {
function emitTypeOfTypeReference(node: Node) {
resolver.writeTypeAtLocation(node, enclosingDeclaration, TypeFormatFlags.WriteArrayAsGenericType, writer);
}
if (typeReferences) {
write(isImplementsList ? " implments " : " extends ");
// TODO(shkamat): get the symbol name in the scope for this node
emitCommaList(typeReferences, emitSourceTextOfNode);
emitCommaList(typeReferences, emitTypeOfTypeReference);
}
}
@ -2045,6 +2047,8 @@ module ts {
emitDeclarationFlags(node);
write("class ");
emitSourceTextOfNode(node.name);
var prevEnclosingDeclaration = enclosingDeclaration;
enclosingDeclaration = node;
emitTypeParameters(node.typeParameters);
if (node.baseType) {
emitHeritageClause([node.baseType], /*isImplementsList*/ false);
@ -2058,6 +2062,7 @@ module ts {
decreaseIndent();
write("}");
writeLine();
enclosingDeclaration = prevEnclosingDeclaration;
}
}
@ -2066,6 +2071,8 @@ module ts {
emitDeclarationFlags(node);
write("interface ");
emitSourceTextOfNode(node.name);
var prevEnclosingDeclaration = enclosingDeclaration;
enclosingDeclaration = node;
emitTypeParameters(node.typeParameters);
emitHeritageClause(node.baseTypes, /*isImplementsList*/ false);
write(" {");
@ -2075,6 +2082,7 @@ module ts {
decreaseIndent();
write("}");
writeLine();
enclosingDeclaration = prevEnclosingDeclaration;
}
}
@ -2094,7 +2102,8 @@ module ts {
write("?");
}
if (!(node.flags & NodeFlags.Private)) {
// TODO(shkamat): emit type of the node in given scope
write(": ");
resolver.writeTypeAtLocation(node, enclosingDeclaration, TypeFormatFlags.None, writer);
}
}
}
@ -2116,8 +2125,8 @@ module ts {
emitDeclarationFlags(node);
emitSourceTextOfNode(node.name);
if (!(node.flags & NodeFlags.Private)) {
// TODO(shkamat): emit type of the node in given scope
// If get accessor -> return type of getAccessor otherwise parameter type of setAccessor
write(": ");
resolver.writeTypeAtLocation(node, enclosingDeclaration, TypeFormatFlags.None, writer);
}
write(";");
writeLine();
@ -2134,7 +2143,7 @@ module ts {
emitSourceTextOfNode(node.name);
}
else if (node.kind === SyntaxKind.Constructor) {
write("constructor ");
write("constructor");
}
else {
emitSourceTextOfNode(node.name);
@ -2170,8 +2179,10 @@ module ts {
write(")");
}
if (!(node.flags & NodeFlags.Private)) {
// TODO(shkamat): emit return type of the signature
// 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);
}
write(";");
writeLine();
@ -2187,7 +2198,8 @@ module ts {
}
if (!(node.parent.flags & NodeFlags.Private)) {
// TODO(shkamat): emitType of the parameter if the method is not private
write(": ");
resolver.writeTypeAtLocation(node, enclosingDeclaration, TypeFormatFlags.None, writer);
}
}

View File

@ -590,6 +590,21 @@ module ts {
getSymbolOfIdentifier(identifier: Identifier): Symbol;
}
export interface TextWriter {
write(s: string): void;
writeLine(): void;
increaseIndent(): void;
decreaseIndent(): void;
getText(): string;
}
export enum TypeFormatFlags {
None = 0x00000000,
/** writes Array<T> instead T[] */
WriteArrayAsGenericType = 0x00000001, // Declarations
}
export interface EmitResolver {
getProgram(): Program;
getModuleObjectName(node: ModuleDeclaration): string;
@ -603,6 +618,8 @@ module ts {
shouldEmitDeclarations(): boolean;
isReferencedInExportAssignment(node: Declaration): boolean;
isImplementationOfOverload(node: FunctionDeclaration): boolean;
writeTypeAtLocation(location: Node, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: TextWriter): void;
writeReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: TextWriter): void;
}
export enum SymbolFlags {

View File

@ -120,38 +120,38 @@ var i8_c = c8;
//// [commentsClass.d.ts]
declare class c2 {
}
declare var i2;
declare var i2_c;
declare var i2: c2;
declare var i2_c: typeof c2;
declare class c3 {
constructor ();
constructor();
}
declare var i3;
declare var i3_c;
declare var i3: c3;
declare var i3_c: typeof c3;
declare class c4 {
constructor ();
constructor();
}
declare var i4;
declare var i4_c;
declare var i4: c4;
declare var i4_c: typeof c4;
declare class c5 {
static s1;
static s1: number;
}
declare var i5;
declare var i5_c;
declare var i5: c5;
declare var i5_c: typeof c5;
declare class c6 {
static s1;
constructor ();
static s1: number;
constructor();
}
declare var i6;
declare var i6_c;
declare var i6: c6;
declare var i6_c: typeof c6;
declare class c7 {
static s1;
constructor ();
static s1: number;
constructor();
}
declare var i7;
declare var i7_c;
declare var i7: c7;
declare var i7_c: typeof c7;
declare class c8 {
static s1;
constructor ();
static s1: number;
constructor();
}
declare var i8;
declare var i8_c;
declare var i8: c8;
declare var i8_c: typeof c8;

View File

@ -439,67 +439,67 @@ cProperties_i.nc_p2 = cProperties_i.nc_p1;
//// [commentsClassMembers.d.ts]
declare class c1 {
p1;
p2(b);
p3;
p1: number;
p2(b: number): number;
p3: number;
private pp1;
private pp2(b);
private pp3;
constructor ();
static s1;
static s2(b);
static s3;
nc_p1;
nc_p2(b);
nc_p3;
constructor();
static s1: number;
static s2(b: number): number;
static s3: number;
nc_p1: number;
nc_p2(b: number): number;
nc_p3: number;
private nc_pp1;
private nc_pp2(b);
private nc_pp3;
static nc_s1;
static nc_s2(b);
static nc_s3;
a_p1;
a_p2(b);
a_p3;
static nc_s1: number;
static nc_s2(b: number): number;
static nc_s3: number;
a_p1: number;
a_p2(b: number): number;
a_p3: number;
private a_pp1;
private a_pp2(b);
private a_pp3;
static a_s1;
static a_s2(b);
static a_s3;
b_p1;
b_p2(b);
b_p3;
static a_s1: number;
static a_s2(b: number): number;
static a_s3: number;
b_p1: number;
b_p2(b: number): number;
b_p3: number;
private b_pp1;
private b_pp2(b);
private b_pp3;
static b_s1;
static b_s2(b);
static b_s3;
static b_s1: number;
static b_s2(b: number): number;
static b_s3: number;
}
declare var i1;
declare var i1_p;
declare var i1_f;
declare var i1_r;
declare var i1_prop;
declare var i1_nc_p;
declare var i1_ncf;
declare var i1_ncr;
declare var i1_ncprop;
declare var i1_s_p;
declare var i1_s_f;
declare var i1_s_r;
declare var i1_s_prop;
declare var i1_s_nc_p;
declare var i1_s_ncf;
declare var i1_s_ncr;
declare var i1_s_ncprop;
declare var i1_c;
declare var i1: c1;
declare var i1_p: number;
declare var i1_f: (b: number) => number;
declare var i1_r: number;
declare var i1_prop: number;
declare var i1_nc_p: number;
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_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_ncr: number;
declare var i1_s_ncprop: number;
declare var i1_c: typeof c1;
declare class cProperties {
private val;
p1;
nc_p1;
p2;
nc_p2;
p1: number;
nc_p1: number;
p2: number;
nc_p2: number;
}
declare var cProperties_i;
declare var cProperties_i: cProperties;

View File

@ -224,27 +224,27 @@ var NoQuickInfoClass = (function () {
//// [commentsCommentParsing.d.ts]
declare function simple();
declare function multiLine();
declare function jsDocSingleLine();
declare function jsDocMultiLine();
declare function jsDocMultiLineMerge();
declare function jsDocMixedComments1();
declare function jsDocMixedComments2();
declare function jsDocMixedComments3();
declare function jsDocMixedComments4();
declare function jsDocMixedComments5();
declare function jsDocMixedComments6();
declare function noHelpComment1();
declare function noHelpComment2();
declare function noHelpComment3();
declare function sum(a, b);
declare function multiply(a, b, c?, d?, e?);
declare function f1(a);
declare function f1(b);
declare function subtract(a, b, c?, d?, e?, f?);
declare function square(a);
declare function divide(a, b);
declare function jsDocParamTest(a, b, c, d);
declare function simple(): void;
declare function multiLine(): void;
declare function jsDocSingleLine(): void;
declare function jsDocMultiLine(): void;
declare function jsDocMultiLineMerge(): void;
declare function jsDocMixedComments1(): void;
declare function jsDocMixedComments2(): void;
declare function jsDocMixedComments3(): void;
declare function jsDocMixedComments4(): void;
declare function jsDocMixedComments5(): void;
declare function jsDocMixedComments6(): void;
declare function noHelpComment1(): void;
declare function noHelpComment2(): void;
declare function noHelpComment3(): void;
declare function sum(a: number, b: number): number;
declare function multiply(a: number, b: number, c?: number, d?: any, e?: any): void;
declare function f1(a: number): any;
declare function f1(b: string): any;
declare function subtract(a: number, b: number, c?: () => string, d?: () => string, e?: () => string, f?: () => string): void;
declare function square(a: number): number;
declare function divide(a: number, b: number): void;
declare function jsDocParamTest(a: number, b: number, c: number, d: number): number;
declare class NoQuickInfoClass {
}

View File

@ -27,4 +27,4 @@ declare enum Colors {
Cornflower = 0,
FancyPink = 1,
}
declare var x;
declare var x: Colors;

View File

@ -123,21 +123,21 @@ define(["require", "exports", "commentsExternalModules_0"], function (require, e
//// [commentsExternalModules_0.d.ts]
export declare module m1 {
var b;
var b: number;
module m2 {
class c {
}
var i;
var i: c;
}
function fooExport();
function fooExport(): number;
}
export declare module m4 {
var b;
var b: number;
module m2 {
class c {
}
var i;
var i: c;
}
function fooExport();
function fooExport(): number;
}
//// [commentsExternalModules_1.d.ts]

View File

@ -42,8 +42,8 @@ lambddaNoVarComment(10, 20);
//// [commentsFunction.d.ts]
declare function foo();
declare function fooWithParameters(a, b);
declare var fooFunc;
declare var lambdaFoo;
declare var lambddaNoVarComment;
declare function foo(): void;
declare function fooWithParameters(a: string, b: number): void;
declare var fooFunc: (b: string) => string;
declare var lambdaFoo: (a: number, b: number) => number;
declare var lambddaNoVarComment: (a: number, b: number) => number;

View File

@ -259,85 +259,85 @@ i2_i = i3_i;
//// [commentsInheritance.d.ts]
interface i1 {
i1_p1;
i1_f1();
i1_l1;
i1_nc_p1;
i1_nc_f1();
i1_nc_l1;
p1;
f1();
l1;
nc_p1;
nc_f1();
nc_l1;
i1_p1: number;
i1_f1(): void;
i1_l1: () => void;
i1_nc_p1: number;
i1_nc_f1(): void;
i1_nc_l1: () => void;
p1: number;
f1(): void;
l1: () => void;
nc_p1: number;
nc_f1(): void;
nc_l1: () => void;
}
declare class c1 implments i1 {
i1_p1;
i1_f1();
i1_l1;
i1_nc_p1;
i1_nc_f1();
i1_nc_l1;
p1;
f1();
l1;
nc_p1;
nc_f1();
nc_l1;
i1_p1: number;
i1_f1(): void;
i1_l1: () => void;
i1_nc_p1: number;
i1_nc_f1(): void;
i1_nc_l1: () => void;
p1: number;
f1(): void;
l1: () => void;
nc_p1: number;
nc_f1(): void;
nc_l1: () => void;
}
declare var i1_i;
declare var c1_i;
declare var i1_i: i1;
declare var c1_i: c1;
declare class c2 {
c2_p1;
c2_f1();
c2_prop;
c2_nc_p1;
c2_nc_f1();
c2_nc_prop;
p1;
f1();
prop;
nc_p1;
nc_f1();
nc_prop;
constructor (a);
c2_p1: number;
c2_f1(): void;
c2_prop: number;
c2_nc_p1: number;
c2_nc_f1(): void;
c2_nc_prop: number;
p1: number;
f1(): void;
prop: number;
nc_p1: number;
nc_f1(): void;
nc_prop: number;
constructor(a: number);
}
declare class c3 extends c2 {
constructor ();
p1;
f1();
prop;
nc_p1;
nc_f1();
nc_prop;
constructor();
p1: number;
f1(): void;
prop: number;
nc_p1: number;
nc_f1(): void;
nc_prop: number;
}
declare var c2_i;
declare var c3_i;
declare var c2_i: c2;
declare var c3_i: c3;
declare class c4 extends c2 {
}
declare var c4_i;
declare var c4_i: c4;
interface i2 {
i2_p1;
i2_f1();
i2_l1;
i2_nc_p1;
i2_nc_f1();
i2_nc_l1;
p1;
f1();
l1;
nc_p1;
nc_f1();
nc_l1;
i2_p1: number;
i2_f1(): void;
i2_l1: () => void;
i2_nc_p1: number;
i2_nc_f1(): void;
i2_nc_l1: () => void;
p1: number;
f1(): void;
l1: () => void;
nc_p1: number;
nc_f1(): void;
nc_l1: () => void;
}
interface i3 extends i2 {
p1;
f1();
l1;
nc_p1;
nc_f1();
nc_l1;
p1: number;
f1(): void;
l1: () => void;
nc_p1: number;
nc_f1(): void;
nc_l1: () => void;
}
declare var i2_i;
declare var i3_i;
declare var i2_i: i2;
declare var i3_i: i3;

View File

@ -105,44 +105,44 @@ i3_i.nc_l(10);
//// [commentsInterface.d.ts]
interface i1 {
}
declare var i1_i;
declare var i1_i: i1;
interface nc_i1 {
}
declare var nc_i1_i;
declare var nc_i1_i: nc_i1;
interface i2 {
x;
foo;
[i];
new (i);
nc_x;
nc_foo;
[i];
(a, b);
fnfoo(b);
nc_fnfoo(b);
nc_y;
x: number;
foo: (b: number) => string;
[i: string]: any;
new (i: i1): any;
nc_x: number;
nc_foo: (b: number) => string;
[i: number]: number;
(a: number, b: number): number;
fnfoo(b: number): string;
nc_fnfoo(b: number): string;
nc_y: number;
}
declare var i2_i;
declare var i2_i_x;
declare var i2_i_foo;
declare var i2_i_foo_r;
declare var i2_i_i2_si;
declare var i2_i_i2_ii;
declare var i2_i_n;
declare var i2_i_nc_x;
declare var i2_i_nc_foo;
declare var i2_i_nc_foo_r;
declare var i2_i_r;
declare var i2_i_fnfoo;
declare var i2_i_fnfoo_r;
declare var i2_i_nc_fnfoo;
declare var i2_i_nc_fnfoo_r;
declare var i2_i: i2;
declare var i2_i_x: number;
declare var i2_i_foo: (b: number) => string;
declare var i2_i_foo_r: string;
declare var i2_i_i2_si: any;
declare var i2_i_i2_ii: number;
declare var i2_i_n: any;
declare var i2_i_nc_x: number;
declare var i2_i_nc_foo: (b: number) => string;
declare var i2_i_nc_foo_r: string;
declare var i2_i_r: number;
declare var i2_i_fnfoo: (b: number) => string;
declare var i2_i_fnfoo_r: string;
declare var i2_i_nc_fnfoo: (b: number) => string;
declare var i2_i_nc_fnfoo_r: string;
interface i3 {
x;
f(a);
l;
nc_x;
nc_f(a);
nc_l;
x: number;
f(a: number): string;
l: (b: number) => string;
nc_x: number;
nc_f(a: number): string;
nc_l: (b: number) => string;
}
declare var i3_i;
declare var i3_i: i3;

View File

@ -244,17 +244,17 @@ new m7.m8.m9.c();
//// [commentsModules.d.ts]
declare module m1 {
var b;
var b: number;
module m2 {
class c {
}
var i;
var i: c;
}
function fooExport();
function foo2Export(a);
function foo3Export();
function fooExport(): number;
function foo2Export(a: string): void;
function foo3Export(): void;
}
declare var myvar;
declare var myvar: c;
declare module m2.m3 {
class c {
}

View File

@ -257,92 +257,92 @@ var c5_i_2 = new c5("hello");
//// [commentsOverloads.d.ts]
declare function f1(a);
declare function f1(b);
declare function f2(a);
declare function f2(b);
declare function f3(a);
declare function f3(b);
declare function f4(a);
declare function f4(b);
declare function f1(a: number): number;
declare function f1(b: string): number;
declare function f2(a: number): number;
declare function f2(b: string): number;
declare function f3(a: number): number;
declare function f3(b: string): number;
declare function f4(a: number): number;
declare function f4(b: string): number;
interface i1 {
(a);
(b);
foo(a);
foo(b);
foo(arr);
foo(arr);
foo2(a);
foo2(b);
foo3(a);
foo3(b);
foo4(a);
foo4(b);
foo4(c);
new (a);
new (b);
(a: number): number;
(b: string): number;
foo(a: number): number;
foo(b: string): number;
foo(arr: number[]): number;
foo(arr: string[]): number;
foo2(a: number): number;
foo2(b: string): number;
foo3(a: number): number;
foo3(b: string): number;
foo4(a: number): number;
foo4(b: string): number;
foo4(c: any): any;
new (a: string): any;
new (b: number): any;
}
declare var i1_i;
declare var i1_i: i1;
interface i2 {
new (a);
new (b);
(a);
(b);
new (a: string): any;
new (b: number): any;
(a: number): number;
(b: string): number;
}
declare var i2_i;
declare var i2_i: i2;
interface i3 {
new (a);
new (b);
(a);
(b);
new (a: string): any;
new (b: number): any;
(a: number): number;
(b: string): number;
}
declare var i3_i;
declare var i3_i: i3;
interface i4 {
new (a);
new (b);
(a);
(b);
new (a: string): any;
new (b: number): any;
(a: number): number;
(b: string): number;
}
declare class c {
prop1(a);
prop1(b);
prop2(a);
prop2(b);
prop3(a);
prop3(b);
prop4(a);
prop4(b);
prop5(a);
prop5(b);
prop1(a: number): number;
prop1(b: string): number;
prop2(a: number): number;
prop2(b: string): number;
prop3(a: number): number;
prop3(b: string): number;
prop4(a: number): number;
prop4(b: string): number;
prop5(a: number): number;
prop5(b: string): number;
}
declare class c1 {
constructor (a);
constructor (b);
constructor(a: number);
constructor(b: string);
}
declare class c2 {
constructor (a);
constructor (b);
constructor(a: number);
constructor(b: string);
}
declare class c3 {
constructor (a);
constructor (b);
constructor(a: number);
constructor(b: string);
}
declare class c4 {
constructor (a);
constructor (b);
constructor(a: number);
constructor(b: string);
}
declare class c5 {
constructor (a);
constructor (b);
constructor(a: number);
constructor(b: string);
}
declare var c_i;
declare var c1_i_1;
declare var c1_i_2;
declare var c2_i_1;
declare var c2_i_2;
declare var c3_i_1;
declare var c3_i_2;
declare var c4_i_1;
declare var c4_i_2;
declare var c5_i_1;
declare var c5_i_2;
declare var c_i: c;
declare var c1_i_1: c1;
declare var c1_i_2: c1;
declare var c2_i_1: c2;
declare var c2_i_2: c2;
declare var c3_i_1: c3;
declare var c3_i_2: c3;
declare var c4_i_1: c4;
declare var c4_i_2: c4;
declare var c5_i_1: c5;
declare var c5_i_2: c5;

View File

@ -61,15 +61,15 @@ n4 = z2;
//// [commentsVarDecl.d.ts]
declare var myVariable;
declare var anotherVariable;
declare var aVar;
declare var anotherAnotherVariable;
declare var x;
declare var n;
declare var y;
declare var yy;
declare var z;
declare var z2;
declare var x2;
declare var n4;
declare var myVariable: number;
declare var anotherVariable: number;
declare var aVar: string;
declare var anotherAnotherVariable: number;
declare var x: number;
declare var n: number;
declare var y: number;
declare var yy: number;
declare var z: (x: number, y: number) => number;
declare var z2: (x: number) => string;
declare var x2: (x: number) => string;
declare var n4: (x: number) => string;

View File

@ -8,4 +8,4 @@ var v = 1;
//// [commentsVariableStatement1.d.ts]
declare var v;
declare var v: number;

View File

@ -132,32 +132,32 @@ var m1;
//// [commentsdoNotEmitComments.d.ts]
declare var myVariable;
declare function foo(p);
declare var fooVar;
declare var myVariable: number;
declare function foo(p: number): void;
declare var fooVar: () => void;
declare class c {
constructor ();
b;
myFoo();
prop1;
foo1(a);
foo1(b);
constructor();
b: number;
myFoo(): number;
prop1: number;
foo1(a: number): string;
foo1(b: string): string;
}
declare var i;
declare var i: c;
interface i1 {
(a);
new (b);
[a];
myFoo(a);
prop;
(a: number): number;
new (b: string): any;
[a: number]: string;
myFoo(a: number): string;
prop: string;
}
declare var i1_i;
declare var i1_i: i1;
declare module m1 {
class b {
x;
constructor (x);
x: number;
constructor(x: number);
}
module m2 {
}
}
declare var x;
declare var x: any;

View File

@ -132,32 +132,32 @@ var m1;
//// [commentsemitComments.d.ts]
declare var myVariable;
declare function foo(p);
declare var fooVar;
declare var myVariable: number;
declare function foo(p: number): void;
declare var fooVar: () => void;
declare class c {
constructor ();
b;
myFoo();
prop1;
foo1(a);
foo1(b);
constructor();
b: number;
myFoo(): number;
prop1: number;
foo1(a: number): string;
foo1(b: string): string;
}
declare var i;
declare var i: c;
interface i1 {
(a);
new (b);
[a];
myFoo(a);
prop;
(a: number): number;
new (b: string): any;
[a: number]: string;
myFoo(a: number): string;
prop: string;
}
declare var i1_i;
declare var i1_i: i1;
declare module m1 {
class b {
x;
constructor (x);
x: number;
constructor(x: number);
}
module m2 {
}
}
declare var x;
declare var x: any;

View File

@ -12,6 +12,6 @@ var anotherVar;
//// [constructorTypeWithTypeParameters.d.ts]
declare var X;
declare var Y;
declare var anotherVar;
declare var X: new <T>() => number;
declare var Y: new () => number;
declare var anotherVar: new <T>() => number;

View File

@ -252,23 +252,23 @@ var c2 = (function () {
//// [declFileAccessors_0.d.ts]
export declare class c1 {
p3;
p3: number;
private pp3;
static s3;
nc_p3;
static s3: number;
nc_p3: number;
private nc_pp3;
static nc_s3;
onlyGetter;
onlySetter;
static nc_s3: string;
onlyGetter: number;
onlySetter: number;
}
//// [declFileAccessors_1.d.ts]
declare class c2 {
p3;
p3: number;
private pp3;
static s3;
nc_p3;
static s3: number;
nc_p3: number;
private nc_pp3;
static nc_s3;
onlyGetter;
onlySetter;
static nc_s3: string;
onlyGetter: number;
onlySetter: number;
}

View File

@ -32,4 +32,4 @@ declare module "SubModule" {
}
//// [declFileAmbientExternalModuleWithSingleExportedModule_1.d.ts]
/// <reference path='declFileAmbientExternalModuleWithSingleExportedModule_0.d.ts' />
export declare var x;
export declare var x: c;

View File

@ -71,41 +71,41 @@ interface IGlobalCallSignatureWithOwnTypeParametes {
//// [declFileCallSignatures_0.d.ts]
export interface ICallSignature {
();
(): string;
}
export interface ICallSignatureWithParameters {
(a, b);
(a: string, b: number): void;
}
export interface ICallSignatureWithRestParameters {
(a, ...rests);
(a: string, ...rests: string[]): string;
}
export interface ICallSignatureWithOverloads {
(a);
(a);
(a: string): string;
(a: number): number;
}
export interface ICallSignatureWithTypeParameters<T> {
(a);
(a: T): string;
}
export interface ICallSignatureWithOwnTypeParametes {
<T extends ICallSignature>(a);
<T extends ICallSignature>(a: T): string;
}
//// [declFileCallSignatures_1.d.ts]
interface IGlobalCallSignature {
();
(): string;
}
interface IGlobalCallSignatureWithParameters {
(a, b);
(a: string, b: number): void;
}
interface IGlobalCallSignatureWithRestParameters {
(a, ...rests);
(a: string, ...rests: string[]): string;
}
interface IGlobalCallSignatureWithOverloads {
(a);
(a);
(a: string): string;
(a: number): number;
}
interface IGlobalCallSignatureWithTypeParameters<T> {
(a);
(a: T): string;
}
interface IGlobalCallSignatureWithOwnTypeParametes {
<T extends IGlobalCallSignature>(a);
<T extends IGlobalCallSignature>(a: T): string;
}

View File

@ -14,5 +14,5 @@ var BlockIntrinsics = (function () {
//// [declFileClassWithIndexSignature.d.ts]
declare class BlockIntrinsics {
[s];
[s: string]: string;
}

View File

@ -20,5 +20,5 @@ exports.Enhancement = Enhancement;
//// [declFileClassWithStaticMethodReturningConstructor.d.ts]
export declare class Enhancement {
static getType();
static getType(): typeof Enhancement;
}

View File

@ -71,41 +71,41 @@ interface IGlobalConstructSignatureWithOwnTypeParametes {
//// [declFileConstructSignatures_0.d.ts]
export interface IConstructSignature {
new ();
new (): string;
}
export interface IConstructSignatureWithParameters {
new (a, b);
new (a: string, b: number): any;
}
export interface IConstructSignatureWithRestParameters {
new (a, ...rests);
new (a: string, ...rests: string[]): string;
}
export interface IConstructSignatureWithOverloads {
new (a);
new (a);
new (a: string): string;
new (a: number): number;
}
export interface IConstructSignatureWithTypeParameters<T> {
new (a);
new (a: T): T;
}
export interface IConstructSignatureWithOwnTypeParametes {
new <T extends IConstructSignature>(a);
new <T extends IConstructSignature>(a: T): T;
}
//// [declFileConstructSignatures_1.d.ts]
interface IGlobalConstructSignature {
new ();
new (): string;
}
interface IGlobalConstructSignatureWithParameters {
new (a, b);
new (a: string, b: number): any;
}
interface IGlobalConstructSignatureWithRestParameters {
new (a, ...rests);
new (a: string, ...rests: string[]): string;
}
interface IGlobalConstructSignatureWithOverloads {
new (a);
new (a);
new (a: string): string;
new (a: number): number;
}
interface IGlobalConstructSignatureWithTypeParameters<T> {
new (a);
new (a: T): T;
}
interface IGlobalConstructSignatureWithOwnTypeParametes {
new <T extends IGlobalConstructSignature>(a);
new <T extends IGlobalConstructSignature>(a: T): T;
}

View File

@ -213,61 +213,61 @@ var GlobalConstructorWithParameterInitializer = (function () {
//// [declFileConstructors_0.d.ts]
export declare class SimpleConstructor {
constructor ();
constructor();
}
export declare class ConstructorWithParameters {
constructor (a, b);
constructor(a: string, b: number);
}
export declare class ConstructorWithRestParamters {
constructor (a, ...rests);
constructor(a: string, ...rests: string[]);
}
export declare class ConstructorWithOverloads {
constructor (a);
constructor (a);
constructor(a: string);
constructor(a: number);
}
export declare class ConstructorWithPublicParameterProperty {
x;
constructor (x);
x: string;
constructor(x: string);
}
export declare class ConstructorWithPrivateParameterProperty {
private x;
constructor (x);
constructor(x: string);
}
export declare class ConstructorWithOptionalParameterProperty {
x;
constructor (x?);
x: string;
constructor(x?: string);
}
export declare class ConstructorWithParameterInitializer {
x;
constructor (x?);
x: string;
constructor(x?: string);
}
//// [declFileConstructors_1.d.ts]
declare class GlobalSimpleConstructor {
constructor ();
constructor();
}
declare class GlobalConstructorWithParameters {
constructor (a, b);
constructor(a: string, b: number);
}
declare class GlobalConstructorWithRestParamters {
constructor (a, ...rests);
constructor(a: string, ...rests: string[]);
}
declare class GlobalConstructorWithOverloads {
constructor (a);
constructor (a);
constructor(a: string);
constructor(a: number);
}
declare class GlobalConstructorWithPublicParameterProperty {
x;
constructor (x);
x: string;
constructor(x: string);
}
declare class GlobalConstructorWithPrivateParameterProperty {
private x;
constructor (x);
constructor(x: string);
}
declare class GlobalConstructorWithOptionalParameterProperty {
x;
constructor (x?);
x: string;
constructor(x?: string);
}
declare class GlobalConstructorWithParameterInitializer {
x;
constructor (x?);
x: string;
constructor(x?: string);
}

View File

@ -23,4 +23,4 @@ declare enum e {
b = 1,
c = 2,
}
declare var x;
declare var x: typeof e;

View File

@ -24,8 +24,8 @@ define(["require", "exports"], function (require, exports) {
//// [declFileExportAssignmentOfGenericInterface_0.d.ts]
interface Foo<T> {
a;
a: string;
}
export = Foo;
//// [declFileExportAssignmentOfGenericInterface_1.d.ts]
export declare var x;
export declare var x: Foo<Foo<string>>;

View File

@ -74,4 +74,4 @@ export = b;
//// [declFileExportImportChain_c.d.ts]
export import b1 = require("declFileExportImportChain_b1");
//// [declFileExportImportChain_d.d.ts]
export declare var x;
export declare var x: c1;

View File

@ -65,4 +65,4 @@ export = a;
//// [declFileExportImportChain2_c.d.ts]
export import b = require("declFileExportImportChain2_b");
//// [declFileExportImportChain2_d.d.ts]
export declare var x;
export declare var x: c1;

View File

@ -59,22 +59,22 @@ var D = (function () {
//// [declFileForClassWithMultipleBaseClasses.d.ts]
declare class A {
foo();
foo(): void;
}
declare class B {
bar();
bar(): void;
}
interface I {
baz();
baz(): any;
}
interface J {
bat();
bat(): any;
}
declare class D implments I, J {
baz();
bat();
foo();
bar();
baz(): void;
bat(): void;
foo(): void;
bar(): void;
}
interface I extends A, B {
}

View File

@ -21,7 +21,7 @@ var z = exports.b.x;
//// [declFileForExportedImport_0.d.ts]
export declare var x;
export declare var x: number;
//// [declFileForExportedImport_1.d.ts]
/// <reference path='declFileForExportedImport_0.d.ts' />
export import a = require('declFileForExportedImport_0');

View File

@ -10,6 +10,6 @@ interface I {
//// [declFileForInterfaceWithOptionalFunction.d.ts]
interface I {
foo?(x?);
foo2?(x?);
foo?(x?: any): any;
foo2?(x?: number): number;
}

View File

@ -11,7 +11,7 @@ interface I {
//// [declFileForInterfaceWithRestParams.d.ts]
interface I {
foo(...x);
foo2(a, ...x);
foo3(b, ...x);
foo(...x: any[]): any[];
foo2(a: number, ...x: any[]): any[];
foo3(b: string, ...x: string[]): string[];
}

View File

@ -20,6 +20,6 @@ var C = (function () {
//// [declFileForTypeParameters.d.ts]
declare class C<T> {
x;
foo(a);
x: T;
foo(a: T): T;
}

View File

@ -9,5 +9,5 @@ var x1 = 1, y2 = 2, z2 = 3;
//// [declFileForVarList.d.ts]
declare var x, y, z;
declare var x1, y2, z2;
declare var x: any, y: any, z: number;
declare var x1: number, y2: number, z2: number;

View File

@ -113,14 +113,14 @@ function globalfooWithOverloads(a) {
//// [declFileFunctions_0.d.ts]
export declare function foo();
export declare function fooWithParameters(a, b);
export declare function fooWithRestParameters(a, ...rests);
export declare function fooWithOverloads(a);
export declare function fooWithOverloads(a);
export declare function foo(): void;
export declare function fooWithParameters(a: string, b: number): void;
export declare function fooWithRestParameters(a: string, ...rests: string[]): string;
export declare function fooWithOverloads(a: string): string;
export declare function fooWithOverloads(a: number): number;
//// [declFileFunctions_1.d.ts]
declare function globalfoo();
declare function globalfooWithParameters(a, b);
declare function globalfooWithRestParameters(a, ...rests);
declare function globalfooWithOverloads(a);
declare function globalfooWithOverloads(a);
declare function globalfoo(): void;
declare function globalfooWithParameters(a: string, b: number): void;
declare function globalfooWithRestParameters(a: string, ...rests: string[]): string;
declare function globalfooWithOverloads(a: string): string;
declare function globalfooWithOverloads(a: number): number;

View File

@ -40,15 +40,15 @@ var Baz = (function () {
//// [declFileGenericClassWithGenericExtendedClass.d.ts]
interface IFoo {
baz;
baz: Baz;
}
declare class Base<T> {
}
declare class Derived<T> extends Base<T> {
}
interface IBar<T> {
derived;
derived: Derived<T>;
}
declare class Baz implments IBar<Baz> {
derived;
derived: Derived<Baz>;
}

View File

@ -119,27 +119,27 @@ export declare module C {
}
class B {
}
function F<T>(x);
function F2<T>(x);
function F3<T>(x);
function F4<T extends A<B>>(x);
function F5<T>();
function F6<T extends A<B>>(x);
function F<T>(x: T): A<B>;
function F2<T>(x: T): A<B>;
function F3<T>(x: T): A<B>[];
function F4<T extends A<B>>(x: T): A<B>[];
function F5<T>(): T;
function F6<T extends A<B>>(x: T): T;
class D<T> {
val;
constructor (val);
val: T;
constructor(val: T);
}
}
export declare var a;
export declare var b;
export declare var c;
export declare var d;
export declare var e;
export declare var x;
export declare function f<T extends C.A<C.B>>();
export declare var g;
export declare class h extends C.A<C.B> {
export declare var a: A<B>;
export declare var b: <T>(x: T) => A<B>;
export declare var c: <T>(x: T) => A<B>;
export declare var d: <T>(x: T) => A<B>[];
export declare var e: <T extends A<B>>(x: T) => A<B>[];
export declare var x: A<B>;
export declare function f<T extends A<B>>(): void;
export declare var g: A<B>;
export declare class h extends A<B> {
}
export interface i extends C.A<C.B> {
export interface i extends A<B> {
}
export declare var j;
export declare var j: <T extends A<B>>(x: T) => T;

View File

@ -99,17 +99,17 @@ 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> {
interface IElementController<ModelType extends IModel> extends IController<ModelType> {
}
}
declare module templa.dom.mvc {
class AbstractElementController<ModelType extends templa.mvc.IModel> extends templa.mvc.AbstractController<ModelType> implments IElementController<ModelType> {
constructor ();
class AbstractElementController<ModelType extends IModel> extends AbstractController<ModelType> implments IElementController<ModelType> {
constructor();
}
}
declare module templa.dom.mvc.composite {
class AbstractCompositeElementController<ModelType extends templa.mvc.composite.ICompositeControllerModel> extends templa.dom.mvc.AbstractElementController<ModelType> {
_controllers;
constructor ();
class AbstractCompositeElementController<ModelType extends ICompositeControllerModel> extends AbstractElementController<ModelType> {
_controllers: IController<IModel>[];
constructor();
}
}

View File

@ -38,14 +38,22 @@ exports.a.test1(null, null, null);
//// [declFileImportModuleWithExportAssignment_0.d.ts]
declare module m2 {
interface connectModule {
(res, req, next);
(res: any, req: any, next: any): void;
}
interface connectExport {
use;
listen;
use: (mod: connectModule) => connectExport;
listen: (port: number) => void;
}
}
declare var m2;
declare var m2: {
(): connectExport;
test1: connectModule;
test2(): connectModule;
};
export = m2;
//// [declFileImportModuleWithExportAssignment_1.d.ts]
export declare var a;
export declare var a: {
(): connectExport;
test1: connectModule;
test2(): connectModule;
};

View File

@ -27,5 +27,5 @@ declare class List<T> {
declare module 'mod1' {
}
declare module 'moo' {
var p;
var p: List<Foo>;
}

View File

@ -41,29 +41,29 @@ interface IGlobalIndexSignatureWithTypeParameter<T> {
//// [declFileIndexSignatures_0.d.ts]
export interface IStringIndexSignature {
[s];
[s: string]: string;
}
export interface INumberIndexSignature {
[n];
[n: number]: number;
}
export interface IBothIndexSignature {
[s];
[n];
[s: string]: any;
[n: number]: number;
}
export interface IIndexSignatureWithTypeParameter<T> {
[a];
[a: string]: T;
}
//// [declFileIndexSignatures_1.d.ts]
interface IGlobalStringIndexSignature {
[s];
[s: string]: string;
}
interface IGlobalNumberIndexSignature {
[n];
[n: number]: number;
}
interface IGlobalBothIndexSignature {
[s];
[n];
[s: string]: any;
[n: number]: number;
}
interface IGlobalIndexSignatureWithTypeParameter<T> {
[a];
[a: string]: T;
}

View File

@ -40,9 +40,9 @@ declare module m {
}
}
declare module m1 {
var d;
var d: c;
}
declare module m2 {
export import x = m.c;
var d;
var d: c;
}

View File

@ -327,21 +327,21 @@ var c2 = (function () {
//// [declFileMethods_0.d.ts]
export declare class c1 {
foo();
fooWithParameters(a, b);
fooWithRestParameters(a, ...rests);
fooWithOverloads(a);
fooWithOverloads(a);
foo(): void;
fooWithParameters(a: string, b: number): void;
fooWithRestParameters(a: string, ...rests: string[]): string;
fooWithOverloads(a: string): string;
fooWithOverloads(a: number): number;
private privateFoo();
private privateFooWithParameters(a, b);
private privateFooWithRestParameters(a, ...rests);
private privateFooWithOverloads(a);
private privateFooWithOverloads(a);
static staticFoo();
static staticFooWithParameters(a, b);
static staticFooWithRestParameters(a, ...rests);
static staticFooWithOverloads(a);
static staticFooWithOverloads(a);
static staticFoo(): void;
static staticFooWithParameters(a: string, b: number): void;
static staticFooWithRestParameters(a: string, ...rests: string[]): string;
static staticFooWithOverloads(a: string): string;
static staticFooWithOverloads(a: number): number;
private static privateStaticFoo();
private static privateStaticFooWithParameters(a, b);
private static privateStaticFooWithRestParameters(a, ...rests);
@ -349,29 +349,29 @@ export declare class c1 {
private static privateStaticFooWithOverloads(a);
}
export interface I1 {
foo();
fooWithParameters(a, b);
fooWithRestParameters(a, ...rests);
fooWithOverloads(a);
fooWithOverloads(a);
foo(): string;
fooWithParameters(a: string, b: number): void;
fooWithRestParameters(a: string, ...rests: string[]): string;
fooWithOverloads(a: string): string;
fooWithOverloads(a: number): number;
}
//// [declFileMethods_1.d.ts]
declare class c2 {
foo();
fooWithParameters(a, b);
fooWithRestParameters(a, ...rests);
fooWithOverloads(a);
fooWithOverloads(a);
foo(): void;
fooWithParameters(a: string, b: number): void;
fooWithRestParameters(a: string, ...rests: string[]): string;
fooWithOverloads(a: string): string;
fooWithOverloads(a: number): number;
private privateFoo();
private privateFooWithParameters(a, b);
private privateFooWithRestParameters(a, ...rests);
private privateFooWithOverloads(a);
private privateFooWithOverloads(a);
static staticFoo();
static staticFooWithParameters(a, b);
static staticFooWithRestParameters(a, ...rests);
static staticFooWithOverloads(a);
static staticFooWithOverloads(a);
static staticFoo(): void;
static staticFooWithParameters(a: string, b: number): void;
static staticFooWithRestParameters(a: string, ...rests: string[]): string;
static staticFooWithOverloads(a: string): string;
static staticFooWithOverloads(a: number): number;
private static privateStaticFoo();
private static privateStaticFooWithParameters(a, b);
private static privateStaticFooWithRestParameters(a, ...rests);
@ -379,9 +379,9 @@ declare class c2 {
private static privateStaticFooWithOverloads(a);
}
interface I2 {
foo();
fooWithParameters(a, b);
fooWithRestParameters(a, ...rests);
fooWithOverloads(a);
fooWithOverloads(a);
foo(): string;
fooWithParameters(a: string, b: number): void;
fooWithRestParameters(a: string, ...rests: string[]): string;
fooWithOverloads(a: string): string;
fooWithOverloads(a: number): number;
}

View File

@ -30,4 +30,11 @@ declare module m1 {
class c {
}
}
declare var d;
declare var d: {
m1: {
m: typeof m1;
};
m2: {
c: typeof c;
};
};

View File

@ -33,6 +33,6 @@ declare module A.C {
}
}
declare module A.B.C {
class W implments A.C.Z {
class W implments Z {
}
}

View File

@ -24,5 +24,5 @@ var m;
declare module m {
class c {
}
var a;
var a: typeof m;
}

View File

@ -9,5 +9,5 @@ interface X {
//// [declFileOptionalInterfaceMethod.d.ts]
interface X {
f?<T>();
f?<T>(): any;
}

View File

@ -11,4 +11,9 @@ var n = { w: null, x: '', y: function () {
//// [declFileRegressionTests.d.ts]
declare var n;
declare var n: {
w: any;
x: string;
y: () => void;
z: number;
};

View File

@ -31,9 +31,9 @@ var f6 = function () {
//// [declFileRestParametersOfFunctionAndFunctionType.d.ts]
declare function f1(...args);
declare function f2(x);
declare function f3(x);
declare function f4<T extends (...args) => void>();
declare function f5<T extends { (...args): void }>();
declare var f6;
declare function f1(...args: any[]): void;
declare function f2(x: (...args: any[]) => void): void;
declare function f3(x: (...args: any[]) => void): void;
declare function f4<T extends (...args: any[]) => void>(): void;
declare function f5<T extends (...args: any[]) => void>(): void;
declare var f6: () => any[];

View File

@ -35,14 +35,14 @@ var genericX = genericC;
//// [declFileTypeofClass.d.ts]
declare class c {
static x;
static x: string;
private static y;
private x3;
y3;
y3: number;
}
declare var x;
declare var y;
declare var z;
declare var x: c;
declare var y: typeof c;
declare var z: typeof c;
declare class genericC<T> {
}
declare var genericX;
declare var genericX: typeof genericC;

View File

@ -40,6 +40,6 @@ declare enum days {
saturday = 5,
sunday = 6,
}
declare var weekendDay;
declare var daysOfMonth;
declare var daysOfYear;
declare var weekendDay: days;
declare var daysOfMonth: typeof days;
declare var daysOfYear: typeof days;

View File

@ -64,15 +64,39 @@ function foo5(x) {
//// [declFileTypeofFunction.d.ts]
declare function f(n);
declare function f(n);
declare function g(n);
declare function g(n);
declare var b;
declare function b1();
declare function foo();
declare var foo1;
declare var foo2;
declare var foo3;
declare var x;
declare function foo5(x);
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 var b: any;
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;

View File

@ -62,7 +62,25 @@ declare module m1 {
holiday = 2,
}
}
declare var a;
declare var b;
declare var c;
declare var d;
declare var a: {
c: c;
};
declare var b: {
c: typeof c;
m1: typeof m1;
};
declare var c: {
m1: typeof m1;
};
declare var d: {
m: {
mod: typeof m1;
};
mc: {
cl: typeof c;
};
me: {
en: typeof e;
};
mh: e;
};

View File

@ -30,12 +30,12 @@ var m2_2;
//// [declFileTypeofModule.d.ts]
declare module m1 {
var c;
var c: string;
}
declare var m1_1;
declare var m1_2;
declare var m1_1: typeof m1;
declare var m1_2: typeof m1;
declare module m2 {
var d;
var d: typeof m2;
}
declare var m2_1;
declare var m2_2;
declare var m2_1: typeof m2;
declare var m2_2: typeof m2;

View File

@ -69,16 +69,16 @@ var X;
//// [declFileWithClassNameConflictingWithClassReferredByExtendsClause.d.ts]
declare module A.B.Base {
class W {
id;
id: number;
}
}
declare module X.Y.base {
class W extends A.B.Base.W {
name;
class W extends W {
name: string;
}
}
declare module X.Y.base.Z {
class W<TValue> extends X.Y.base.W {
value;
class W<TValue> extends W {
value: boolean;
}
}

View File

@ -61,11 +61,11 @@ declare module A.B.C {
}
declare module A.B {
class EventManager {
id;
id: number;
}
}
declare module A.B.C {
class ContextMenu extends EventManager {
name;
name: string;
}
}

View File

@ -38,6 +38,6 @@ declare module X.A.C {
}
}
declare module X.A.B.C {
class W implments X.A.C.Z {
class W implments Z {
}
}

View File

@ -41,7 +41,7 @@ declare module X.A.C {
}
}
declare module X.A.B.C {
class W implments A.C.Z {
class W implments Z {
}
}
declare module X.A.B.C {

View File

@ -41,7 +41,7 @@ declare module X.A.C {
}
}
declare module X.A.B.C {
class W implments X.A.C.Z {
class W implments Z {
}
}
declare module X.A.B.C {

View File

@ -68,17 +68,17 @@ declare module M {
}
class D {
private c;
m1;
m2;
m22;
m23;
m24;
m25;
m232();
m242();
m252();
m26(i);
m262(i);
m3();
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;
}
}

View File

@ -34,7 +34,11 @@ var bar = (function () {
interface bar2 {
}
declare class bar {
f();
g();
h(x?, y?, z?);
f(): string;
g(): {
a: bar;
b: any;
c: any;
};
h(x?: number, y?: any, z?: string): void;
}

View File

@ -53,12 +53,12 @@ declare module M {
interface I1 {
}
class D {
m1;
m2;
m23;
m24;
m232();
m242();
m26(i);
m1: number;
m2: string;
m23: E;
m24: I1;
m232(): E;
m242(): I1;
m26(i: I1): void;
}
}

View File

@ -62,18 +62,18 @@ var X;
//// [declarationEmit_nameConflicts2.d.ts]
declare module X.Y.base {
function f();
function f(): void;
class C {
}
module M {
var v;
var v: any;
}
enum E {
}
}
declare module X.Y.base.Z {
var f;
var C;
var M;
var E;
var f: () => void;
var C: typeof C;
var M: typeof M;
var E: typeof E;
}

View File

@ -92,26 +92,26 @@ declare module M {
interface D {
}
module D {
function f();
function f(): void;
}
module C {
function f();
function f(): void;
}
module E {
function f();
function f(): void;
}
}
declare module M.P {
class C {
static f();
static f(): void;
}
class E extends C {
}
enum D {
f = 0,
}
var v;
var w;
var x;
var x;
var v: D;
var w: () => void;
var x: () => void;
var x: () => void;
}

View File

@ -26,12 +26,16 @@ module.exports = m2;
//// [declareFileExportAssignment.d.ts]
declare module m2 {
interface connectModule {
(res, req, next);
(res: any, req: any, next: any): void;
}
interface connectExport {
use;
listen;
use: (mod: connectModule) => connectExport;
listen: (port: number) => void;
}
}
declare var m2;
declare var m2: {
(): connectExport;
test1: connectModule;
test2(): connectModule;
};
export = m2;

View File

@ -26,12 +26,16 @@ module.exports = m2;
//// [declareFileExportAssignmentWithVarFromVariableStatement.d.ts]
declare module m2 {
interface connectModule {
(res, req, next);
(res: any, req: any, next: any): void;
}
interface connectExport {
use;
listen;
use: (mod: connectModule) => connectExport;
listen: (port: number) => void;
}
}
declare var m2;
declare var m2: {
(): connectExport;
test1: connectModule;
test2(): connectModule;
};
export = m2;

View File

@ -26,6 +26,6 @@ var A = (function () {
//// [es3-amd.d.ts]
declare class A {
constructor ();
B();
constructor();
B(): number;
}

View File

@ -26,6 +26,6 @@ var A = (function () {
//// [es3-declaration-amd.d.ts]
declare class A {
constructor ();
B();
constructor();
B(): number;
}

View File

@ -26,6 +26,6 @@ var A = (function () {
//// [es5-amd.d.ts]
declare class A {
constructor ();
B();
constructor();
B(): number;
}

View File

@ -26,6 +26,6 @@ var A = (function () {
//// [es5-declaration-amd.d.ts]
declare class A {
constructor ();
B();
constructor();
B(): number;
}

View File

@ -41,9 +41,9 @@ define(["require", "exports", './exporter'], function (require, exports, e) {
//// [w1.d.ts]
export = Widget1;
declare class Widget1 {
name;
name: string;
}
//// [exporter.d.ts]
export import w = require('./w1');
//// [consumer.d.ts]
export declare function w();
export declare function w(): Widget1;

View File

@ -33,9 +33,9 @@ define(["require", "exports"], function (require, exports) {
//// [w1.d.ts]
export = Widget1;
interface Widget1 {
name;
name: string;
}
//// [exporter.d.ts]
export import w = require('./w1');
//// [consumer.d.ts]
export declare function w();
export declare function w(): Widget1;

View File

@ -133,32 +133,35 @@ var f2 = function () {
//// [funcdecl.d.ts]
declare function simpleFunc();
declare var simpleFuncVar;
declare function anotherFuncNoReturn();
declare var anotherFuncNoReturnVar;
declare function withReturn();
declare var withReturnVar;
declare function withParams(a);
declare var withparamsVar;
declare function withMultiParams(a, b, c);
declare var withMultiParamsVar;
declare function withOptionalParams(a?);
declare var withOptionalParamsVar;
declare function withInitializedParams(a, b0, b?, c?);
declare var withInitializedParamsVar;
declare function withOptionalInitializedParams(a, c?);
declare var withOptionalInitializedParamsVar;
declare function withRestParams(a, ...myRestParameter);
declare var withRestParamsVar;
declare function overload1(n);
declare function overload1(s);
declare var withOverloadSignature;
declare function f(n);
declare function simpleFunc(): string;
declare var simpleFuncVar: () => string;
declare function anotherFuncNoReturn(): void;
declare var anotherFuncNoReturnVar: () => void;
declare function withReturn(): string;
declare var withReturnVar: () => string;
declare function withParams(a: string): string;
declare var withparamsVar: (a: string) => string;
declare function withMultiParams(a: number, b: any, c: Object): number;
declare var withMultiParamsVar: (a: number, b: any, c: Object) => number;
declare function withOptionalParams(a?: string): void;
declare var withOptionalParamsVar: (a?: string) => void;
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 function withOptionalInitializedParams(a: string, c?: string): void;
declare var withOptionalInitializedParamsVar: (a: string, c?: string) => void;
declare function withRestParams(a: string, ...myRestParameter: number[]): number[];
declare var withRestParamsVar: (a: string, ...myRestParameter: number[]) => number[];
declare function overload1(n: number): string;
declare function overload1(s: string): string;
declare var withOverloadSignature: {
(n: number): string;
(s: string): string;
};
declare function f(n: () => void): void;
declare module m2 {
function foo(n);
function foo(n: () => void): void;
}
declare function fooAmbient(n);
declare function overloadAmbient(n);
declare function overloadAmbient(s);
declare var f2;
declare function fooAmbient(n: number): string;
declare function overloadAmbient(n: number): string;
declare function overloadAmbient(s: string): string;
declare var f2: () => string;

View File

@ -11,4 +11,4 @@ function foo(args) {
//// [functionDeclarationWithArgumentOfTypeFunctionTypeArray.d.ts]
declare function foo(args);
declare function foo(args: (x: any) => number[]): number;

View File

@ -8,4 +8,4 @@ var x = function somefn() {
//// [functionExpressionReturningItself.d.ts]
declare var x;
declare var x: () => typeof somefn;

View File

@ -10,4 +10,4 @@ function somefn() {
//// [functionReturningItself.d.ts]
declare function somefn();
declare function somefn(): () => typeof somefn;

View File

@ -20,6 +20,6 @@ function map() {
//// [genericArray0.d.ts]
declare var x;
declare var y;
declare function map<U>();
declare var x: number[];
declare var y: number[];
declare function map<U>(): void;

View File

@ -19,4 +19,4 @@ var lengths = ["a", "b", "c"].map(function (x) { return x.length; });
//// [genericArray1.d.ts]
declare var lengths;
declare var lengths: number[];

View File

@ -25,6 +25,6 @@ declare module foo {
}
}
declare module bar {
class Foo<T> implments foo.IFoo<T> {
class Foo<T> implments IFoo<T> {
}
}

View File

@ -19,7 +19,7 @@ var y = v1.x;
//// [genericClasses0.d.ts]
declare class C<T> {
x;
x: T;
}
declare var v1;
declare var y;
declare var v1: C<string>;
declare var y: string;

View File

@ -19,7 +19,7 @@ var y = v1.x;
//// [genericClasses1.d.ts]
declare class C<T> {
x;
x: T;
}
declare var v1;
declare var y;
declare var v1: C<string>;
declare var y: string;

View File

@ -29,14 +29,14 @@ var z = v1.z.a;
//// [genericClasses2.d.ts]
interface Foo<T> {
a;
a: T;
}
declare class C<T> {
x;
y;
z;
x: T;
y: Foo<T>;
z: Foo<number>;
}
declare var v1;
declare var y;
declare var w;
declare var z;
declare var v1: C<string>;
declare var y: string;
declare var w: string;
declare var z: number;

View File

@ -44,13 +44,13 @@ var z = v2.b;
//// [genericClasses3.d.ts]
declare class B<T> {
a;
b;
a: T;
b: T;
}
declare class C<T> extends B<T> {
x;
x: T;
}
declare var v2;
declare var y;
declare var u;
declare var z;
declare var v2: C<string>;
declare var y: string;
declare var u: string;
declare var z: string;

View File

@ -35,4 +35,4 @@ declare module Foo {
class A {
}
}
declare var a;
declare var a: B<A>;

View File

@ -21,5 +21,5 @@ var List = (function () {
//// [genericConstraintDeclaration.d.ts]
declare class List<T extends {}> {
static empty<T extends {}>();
static empty<T extends {}>(): List<T>;
}

View File

@ -11,5 +11,5 @@ var x = foo(5);
//// [genericFunctions0.d.ts]
declare function foo<T>(x);
declare var x;
declare function foo<T>(x: T): T;
declare var x: number;

View File

@ -11,5 +11,5 @@ var x = foo(5);
//// [genericFunctions1.d.ts]
declare function foo<T>(x);
declare var x;
declare function foo<T>(x: T): T;
declare var x: number;

View File

@ -12,6 +12,6 @@ var lengths = map(myItems, function (x) { return x.length; });
//// [genericFunctions2.d.ts]
declare function map<T, U>(items, f);
declare var myItems;
declare var lengths;
declare function map<T, U>(items: T[], f: (x: T) => U): U[];
declare var myItems: string[];
declare var lengths: number[];

View File

@ -14,7 +14,7 @@ var z = v2.x;
//// [generics0.d.ts]
interface G<T> {
x;
x: T;
}
declare var v2;
declare var z;
declare var v2: G<string>;
declare var z: string;

View File

@ -18,18 +18,20 @@ var v4;
//// [generics1NoError.d.ts]
interface A {
a;
a: string;
}
interface B extends A {
b;
b: string;
}
interface C extends B {
c;
c: string;
}
interface G<T, U extends B> {
x;
y;
x: T;
y: U;
}
declare var v1;
declare var v2;
declare var v4;
declare var v1: G<A, C>;
declare var v2: G<{
a: string;
}, C>;
declare var v4: G<G<A, B>, C>;

View File

@ -25,18 +25,29 @@ var v4;
//// [generics2NoError.d.ts]
interface A {
a;
a: string;
}
interface B extends A {
b;
b: string;
}
interface C extends B {
c;
c: string;
}
interface G<T, U extends B> {
x;
y;
x: T;
y: U;
}
declare var v1;
declare var v2;
declare var v4;
declare var v1: {
x: {
a: string;
};
y: {
a: string;
b: string;
c: string;
};
};
declare var v2: G<{
a: string;
}, C>;
declare var v4: G<G<A, B>, C>;

View File

@ -23,10 +23,10 @@ declare class C<T> {
private x;
}
interface X {
f();
f(): string;
}
interface Y {
f();
f(): string;
}
declare var a;
declare var b;
declare var a: C<X>;
declare var b: C<Y>;

View File

@ -21,10 +21,10 @@ declare class C<T> {
private x;
}
interface X {
f();
f(): string;
}
interface Y {
f();
f(): boolean;
}
declare var a;
declare var b;
declare var a: C<X>;
declare var b: C<Y>;

View File

@ -43,9 +43,9 @@ var C = (function () {
//// [implicitAnyAnyReturningFunction.d.ts]
declare function A();
declare function B();
declare function A(): any;
declare function B(): any;
declare class C {
A();
B();
A(): any;
B(): any;
}

View File

@ -32,6 +32,6 @@ function fn3() {
//// [implicitAnyDeclareFunctionWithoutFormalType2.d.ts]
declare function fn1();
declare function fn2();
declare function fn3();
declare function fn1(): number;
declare function fn2(): any;
declare function fn3(): any;

View File

@ -24,8 +24,8 @@ exports.x;
//// [importDeclarationUsedAsTypeQuery_require.d.ts]
export declare class B {
id;
id: number;
}
//// [importDeclarationUsedAsTypeQuery_1.d.ts]
/// <reference path='importDeclarationUsedAsTypeQuery_require.d.ts' />
export declare var x;
export declare var x: typeof "tests/cases/compiler/importDeclarationUsedAsTypeQuery_require";

View File

@ -9,6 +9,6 @@ interface foo {
//// [interfaceOnly.d.ts]
interface foo {
foo();
f2(f);
foo(): any;
f2(f: () => void): any;
}

View File

@ -9,5 +9,5 @@ interface I {
//// [interfaceWithOptionalProperty.d.ts]
interface I {
x?;
x?: number;
}

View File

@ -57,27 +57,27 @@ var instance2 = new c1();
//// [interfacedecl.d.ts]
interface a0 {
();
(a, b, c?);
new ();
new (s);
[n];
[s];
p1;
p2;
p3?;
p4?;
p5;
f1();
f2?();
f3(a);
f4?(s);
(): string;
(a: any, b: any, c?: string): number;
new (): string;
new (s: string): any;
[n: number]: () => string;
[s: string]: any;
p1: any;
p2: string;
p3?: any;
p4?: number;
p5: (s: number) => string;
f1(): any;
f2?(): any;
f3(a: string): number;
f4?(s: number): string;
}
interface a1 {
[n];
[n: number]: number;
}
interface a2 {
[s];
[s: string]: number;
}
interface a {
}
@ -89,4 +89,4 @@ interface d extends a {
}
declare class c1 implments a {
}
declare var instance2;
declare var instance2: c1;

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