merge with master

This commit is contained in:
Vladimir Matveev
2015-07-30 14:03:48 -07:00
105 changed files with 2975 additions and 1386 deletions
+9 -9
View File
@@ -218,7 +218,7 @@ var compilerFilename = "tsc.js";
function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOutFile, generateDeclarations, outDir, preserveConstEnums, keepComments, noResolve, stripInternal, callback) {
file(outFile, prereqs, function() {
var dir = useBuiltCompiler ? builtLocalDirectory : LKGDirectory;
var options = "--module commonjs -noImplicitAny";
var options = "--module commonjs --noImplicitAny --noEmitOnError";
// Keep comments when specifically requested
// or when in debug mode.
@@ -339,10 +339,10 @@ file(diagnosticInfoMapTs, [processDiagnosticMessagesJs, diagnosticMessagesJson],
complete();
});
ex.run();
}, {async: true});
}, {async: true});
desc("Generates a diagnostic file in TypeScript based on an input JSON file");
task("generate-diagnostics", [diagnosticInfoMapTs]);
task("generate-diagnostics", [diagnosticInfoMapTs]);
// Publish nightly
@@ -479,11 +479,11 @@ file(specMd, [word2mdJs, specWord], function () {
child_process.exec(cmd, function () {
complete();
});
}, {async: true});
}, {async: true});
desc("Generates a Markdown version of the Language Specification");
task("generate-spec", [specMd]);
task("generate-spec", [specMd]);
// Makes a new LKG. This target does not build anything, but errors if not all the outputs are present in the built/local directory
@@ -615,7 +615,7 @@ task("runtests", ["tests", builtLocalDirectory], function() {
exec(cmd, deleteTemporaryProjectOutput);
}, {async: true});
desc("Generates code coverage data via instanbul");
desc("Generates code coverage data via instanbul");
task("generate-code-coverage", ["tests", builtLocalDirectory], function () {
var cmd = 'istanbul cover node_modules/mocha/bin/_mocha -- -R min -t ' + testTimeout + ' ' + run;
console.log(cmd);
@@ -658,7 +658,7 @@ task("runtests-browser", ["tests", "browserify", builtLocalDirectory], function(
function getDiffTool() {
var program = process.env['DIFF']
if (!program) {
fail("Add the 'DIFF' environment variable to the path of the program you want to use.");
fail("Add the 'DIFF' environment variable to the path of the program you want to use.");
}
return program;
}
@@ -667,14 +667,14 @@ function getDiffTool() {
desc("Diffs the compiler baselines using the diff tool specified by the 'DIFF' environment variable");
task('diff', function () {
var cmd = '"' + getDiffTool() + '" ' + refBaseline + ' ' + localBaseline;
console.log(cmd);
console.log(cmd);
exec(cmd);
}, {async: true});
desc("Diffs the RWC baselines using the diff tool specified by the 'DIFF' environment variable");
task('diff-rwc', function () {
var cmd = '"' + getDiffTool() + '" ' + refRwcBaseline + ' ' + localRwcBaseline;
console.log(cmd);
console.log(cmd);
exec(cmd);
}, {async: true});
Binary file not shown.
Binary file not shown.
+1621 -1165
View File
File diff suppressed because it is too large Load Diff
-1
View File
@@ -19,7 +19,6 @@
"type": "git",
"url": "https://github.com/Microsoft/TypeScript.git"
},
"preferGlobal": true,
"main": "./lib/typescript.js",
"bin": {
"tsc": "./bin/tsc",
+29 -6
View File
@@ -1,8 +1,16 @@
// word2md - Word to Markdown conversion tool
//
// word2md converts a Microsoft Word document to Markdown formatted text. The tool uses the
// Word Automation APIs to start an instance of Word and access the contents of the document
// being converted. The tool must be run using the cscript.exe script host and requires Word
// to be installed on the target machine. The name of the document to convert must be specified
// as a command line argument and the resulting Markdown is written to standard output. The
// tool recognizes the specific Word styles used in the TypeScript Language Specification.
var sys = (function () {
var fileStream = new ActiveXObject("ADODB.Stream");
fileStream.Type = 2;
fileStream.Type = 2 /*text*/;
var binaryStream = new ActiveXObject("ADODB.Stream");
binaryStream.Type = 1;
binaryStream.Type = 1 /*binary*/;
var args = [];
for (var i = 0; i < WScript.Arguments.length; i++) {
args[i] = WScript.Arguments.Item(i);
@@ -17,11 +25,13 @@ var sys = (function () {
fileStream.Open();
binaryStream.Open();
try {
// Write characters in UTF-8 encoding
fileStream.Charset = "utf-8";
fileStream.WriteText(data);
// We don't want the BOM, skip it by setting the starting location to 3 (size of BOM).
fileStream.Position = 3;
fileStream.CopyTo(binaryStream);
binaryStream.SaveToFile(fileName, 2);
binaryStream.SaveToFile(fileName, 2 /*overwrite*/);
}
finally {
binaryStream.Close();
@@ -59,6 +69,17 @@ function convertDocumentToMarkdown(doc) {
setProperties(replace, replaceOptions);
find.execute(findText, false, false, false, false, false, true, 0, true, replaceText, 2);
}
function fixHyperlinks() {
var count = doc.hyperlinks.count;
for (var i = 0; i < count; i++) {
var hyperlink = doc.hyperlinks.item(i + 1);
var address = hyperlink.address;
if (address && address.length > 0) {
var textToDisplay = hyperlink.textToDisplay;
hyperlink.textToDisplay = "[" + textToDisplay + "](" + address + ")";
}
}
}
function write(s) {
result += s;
}
@@ -184,14 +205,15 @@ function convertDocumentToMarkdown(doc) {
findReplace("&lt;", { style: "Code Fragment" }, "<", {});
findReplace("&lt;", { style: "Terminal" }, "<", {});
findReplace("", { font: { subscript: true } }, "<sub>^&</sub>", { font: { subscript: false } });
findReplace("", { style: "Code Fragment" }, "`^&`", { style: -66 });
findReplace("", { style: "Production" }, "*^&*", { style: -66 });
findReplace("", { style: "Terminal" }, "`^&`", { style: -66 });
findReplace("", { style: "Code Fragment" }, "`^&`", { style: -66 /* default font */ });
findReplace("", { style: "Production" }, "*^&*", { style: -66 /* default font */ });
findReplace("", { style: "Terminal" }, "`^&`", { style: -66 /* default font */ });
findReplace("", { font: { bold: true, italic: true } }, "***^&***", { font: { bold: false, italic: false } });
findReplace("", { font: { italic: true } }, "*^&*", { font: { italic: false } });
doc.fields.toggleShowCodes();
findReplace("^19 REF", {}, "[^&](#^&)", {});
doc.fields.toggleShowCodes();
fixHyperlinks();
writeDocument();
result = result.replace(/\x85/g, "\u2026");
result = result.replace(/\x96/g, "\u2013");
@@ -210,3 +232,4 @@ function main(args) {
app.quit();
}
main(sys.args);
//# sourceMappingURL=file:///c:/ts/scripts/word2md.js.map
+24
View File
@@ -100,9 +100,19 @@ module Word {
toggleShowCodes(): void;
}
export interface Hyperlink {
address: string;
textToDisplay: string;
range: Range;
}
export interface Hyperlinks extends Collection<Hyperlink> {
}
export interface Document {
fields: Fields;
paragraphs: Paragraphs;
hyperlinks: Hyperlinks;
builtInDocumentProperties: Collection<any>;
close(saveChanges: boolean): void;
range(): Range;
@@ -195,6 +205,18 @@ function convertDocumentToMarkdown(doc: Word.Document): string {
find.execute(findText, false, false, false, false, false, true, 0, true, replaceText, 2);
}
function fixHyperlinks() {
var count = doc.hyperlinks.count;
for (var i = 0; i < count; i++) {
var hyperlink = doc.hyperlinks.item(i + 1);
var address = hyperlink.address;
if (address && address.length > 0) {
var textToDisplay = hyperlink.textToDisplay;
hyperlink.textToDisplay = "[" + textToDisplay + "](" + address + ")";
}
}
}
function write(s: string) {
result += s;
}
@@ -347,6 +369,8 @@ function convertDocumentToMarkdown(doc: Word.Document): string {
findReplace("^19 REF", {}, "[^&](#^&)", {});
doc.fields.toggleShowCodes();
fixHyperlinks();
writeDocument();
result = result.replace(/\x85/g, "\u2026");
+109 -60
View File
@@ -91,7 +91,8 @@ namespace ts {
getExportsOfModule: getExportsOfModuleAsArray,
getJsxElementAttributesType,
getJsxIntrinsicTagNames
getJsxIntrinsicTagNames,
isOptionalParameter
};
let unknownSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "unknown");
@@ -113,6 +114,10 @@ namespace ts {
emptyGenericType.instantiations = {};
let anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
// The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated
// in getPropagatingFlagsOfTypes, and it is checked in inferFromTypes.
anyFunctionType.flags |= TypeFlags.ContainsAnyFunctionType;
let noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
let anySignature = createSignature(undefined, undefined, emptyArray, anyType, undefined, 0, false, false);
@@ -587,7 +592,19 @@ namespace ts {
declarationNameToString(propertyName), typeof nameArg === "string" ? nameArg : declarationNameToString(nameArg));
return undefined;
}
if (result.flags & SymbolFlags.BlockScopedVariable) {
// Only check for block-scoped variable if we are looking for the
// name with variable meaning
// For example,
// declare module foo {
// interface bar {}
// }
// let foo/*1*/: foo/*2*/.bar;
// The foo at /*1*/ and /*2*/ will share same symbol with two meaning
// block - scope variable and namespace module. However, only when we
// try to resolve name in /*1*/ which is used in variable position,
// we want to check for block- scoped
if (meaning & SymbolFlags.BlockScopedVariable && result.flags & SymbolFlags.BlockScopedVariable) {
checkResolvedBlockScopedVariable(result, errorLocation);
}
}
@@ -1994,15 +2011,15 @@ namespace ts {
}
return _displayBuilder || (_displayBuilder = {
buildSymbolDisplay: buildSymbolDisplay,
buildTypeDisplay: buildTypeDisplay,
buildTypeParameterDisplay: buildTypeParameterDisplay,
buildParameterDisplay: buildParameterDisplay,
buildDisplayForParametersAndDelimiters: buildDisplayForParametersAndDelimiters,
buildDisplayForTypeParametersAndDelimiters: buildDisplayForTypeParametersAndDelimiters,
buildTypeParameterDisplayFromSymbol: buildTypeParameterDisplayFromSymbol,
buildSignatureDisplay: buildSignatureDisplay,
buildReturnTypeDisplay: buildReturnTypeDisplay
buildSymbolDisplay,
buildTypeDisplay,
buildTypeParameterDisplay,
buildParameterDisplay,
buildDisplayForParametersAndDelimiters,
buildDisplayForTypeParametersAndDelimiters,
buildTypeParameterDisplayFromSymbol,
buildSignatureDisplay,
buildReturnTypeDisplay
});
}
@@ -3517,7 +3534,19 @@ namespace ts {
}
function isOptionalParameter(node: ParameterDeclaration) {
return hasQuestionToken(node) || !!node.initializer;
if (hasQuestionToken(node)) {
return true;
}
if (node.initializer) {
let signatureDeclaration = <SignatureDeclaration>node.parent;
let signature = getSignatureFromDeclaration(signatureDeclaration);
let parameterIndex = signatureDeclaration.parameters.indexOf(node);
Debug.assert(parameterIndex >= 0);
return parameterIndex >= signature.minArgumentCount;
}
return false;
}
function getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature {
@@ -3535,11 +3564,16 @@ namespace ts {
if (param.type && param.type.kind === SyntaxKind.StringLiteral) {
hasStringLiterals = true;
}
if (minArgumentCount < 0) {
if (param.initializer || param.questionToken || param.dotDotDotToken) {
if (param.initializer || param.questionToken || param.dotDotDotToken) {
if (minArgumentCount < 0) {
minArgumentCount = i;
}
}
else {
// If we see any required parameters, it means the prior ones were not in fact optional.
minArgumentCount = -1;
}
}
if (minArgumentCount < 0) {
@@ -3757,22 +3791,23 @@ namespace ts {
}
}
// This function is used to propagate widening flags when creating new object types references and union types.
// It is only necessary to do so if a constituent type might be the undefined type, the null type, or the type
// of an object literal (since those types have widening related information we need to track).
function getWideningFlagsOfTypes(types: Type[]): TypeFlags {
// This function is used to propagate certain flags when creating new object type references and union types.
// It is only necessary to do so if a constituent type might be the undefined type, the null type, the type
// of an object literal or the anyFunctionType. This is because there are operations in the type checker
// that care about the presence of such types at arbitrary depth in a containing type.
function getPropagatingFlagsOfTypes(types: Type[]): TypeFlags {
let result: TypeFlags = 0;
for (let type of types) {
result |= type.flags;
}
return result & TypeFlags.RequiresWidening;
return result & TypeFlags.PropagatingFlags;
}
function createTypeReference(target: GenericType, typeArguments: Type[]): TypeReference {
let id = getTypeListId(typeArguments);
let type = target.instantiations[id];
if (!type) {
let flags = TypeFlags.Reference | getWideningFlagsOfTypes(typeArguments);
let flags = TypeFlags.Reference | getPropagatingFlagsOfTypes(typeArguments);
type = target.instantiations[id] = <TypeReference>createObjectType(flags, target.symbol);
type.target = target;
type.typeArguments = typeArguments;
@@ -4026,7 +4061,7 @@ namespace ts {
let id = getTypeListId(elementTypes);
let type = tupleTypes[id];
if (!type) {
type = tupleTypes[id] = <TupleType>createObjectType(TypeFlags.Tuple | getWideningFlagsOfTypes(elementTypes));
type = tupleTypes[id] = <TupleType>createObjectType(TypeFlags.Tuple | getPropagatingFlagsOfTypes(elementTypes));
type.elementTypes = elementTypes;
}
return type;
@@ -4175,7 +4210,7 @@ namespace ts {
let id = getTypeListId(typeSet);
let type = unionTypes[id];
if (!type) {
type = unionTypes[id] = <UnionType>createObjectType(TypeFlags.Union | getWideningFlagsOfTypes(typeSet));
type = unionTypes[id] = <UnionType>createObjectType(TypeFlags.Union | getPropagatingFlagsOfTypes(typeSet));
type.types = typeSet;
}
return type;
@@ -4209,7 +4244,7 @@ namespace ts {
let id = getTypeListId(typeSet);
let type = intersectionTypes[id];
if (!type) {
type = intersectionTypes[id] = <IntersectionType>createObjectType(TypeFlags.Intersection | getWideningFlagsOfTypes(typeSet));
type = intersectionTypes[id] = <IntersectionType>createObjectType(TypeFlags.Intersection | getPropagatingFlagsOfTypes(typeSet));
type.types = typeSet;
}
return type;
@@ -5216,7 +5251,7 @@ namespace ts {
return indexTypesIdenticalTo(IndexKind.String, source, target);
}
let targetType = getIndexTypeOfType(target, IndexKind.String);
if (targetType) {
if (targetType && !(targetType.flags & TypeFlags.Any)) {
let sourceType = getIndexTypeOfType(source, IndexKind.String);
if (!sourceType) {
if (reportErrors) {
@@ -5241,7 +5276,7 @@ namespace ts {
return indexTypesIdenticalTo(IndexKind.Number, source, target);
}
let targetType = getIndexTypeOfType(target, IndexKind.Number);
if (targetType) {
if (targetType && !(targetType.flags & TypeFlags.Any)) {
let sourceStringType = getIndexTypeOfType(source, IndexKind.String);
let sourceNumberType = getIndexTypeOfType(source, IndexKind.Number);
if (!(sourceStringType || sourceNumberType)) {
@@ -5656,11 +5691,17 @@ namespace ts {
}
function inferFromTypes(source: Type, target: Type) {
if (source === anyFunctionType) {
return;
}
if (target.flags & TypeFlags.TypeParameter) {
// If target is a type parameter, make an inference
// If target is a type parameter, make an inference, unless the source type contains
// the anyFunctionType (the wildcard type that's used to avoid contextually typing functions).
// Because the anyFunctionType is internal, it should not be exposed to the user by adding
// it as an inference candidate. Hopefully, a better candidate will come along that does
// not contain anyFunctionType when we come back to this argument for its second round
// of inference.
if (source.flags & TypeFlags.ContainsAnyFunctionType) {
return;
}
let typeParameters = context.typeParameters;
for (let i = 0; i < typeParameters.length; i++) {
if (target === typeParameters[i]) {
@@ -7093,7 +7134,7 @@ namespace ts {
let stringIndexType = getIndexType(IndexKind.String);
let numberIndexType = getIndexType(IndexKind.Number);
let result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType);
result.flags |= TypeFlags.ObjectLiteral | TypeFlags.FreshObjectLiteral | TypeFlags.ContainsObjectLiteral | (typeFlags & TypeFlags.ContainsUndefinedOrNull);
result.flags |= TypeFlags.ObjectLiteral | TypeFlags.FreshObjectLiteral | TypeFlags.ContainsObjectLiteral | (typeFlags & TypeFlags.PropagatingFlags);
return result;
function getIndexType(kind: IndexKind) {
@@ -12767,28 +12808,7 @@ namespace ts {
}
let initializer = member.initializer;
if (initializer) {
autoValue = getConstantValueForEnumMemberInitializer(initializer);
if (autoValue === undefined) {
if (enumIsConst) {
error(initializer, Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression);
}
else if (!ambient) {
// Only here do we need to check that the initializer is assignable to the enum type.
// If it is a constant value (not undefined), it is syntactically constrained to be a number.
// Also, we do not need to check this for ambients because there is already
// a syntax error if it is not a constant.
checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, /*headMessage*/ undefined);
}
}
else if (enumIsConst) {
if (isNaN(autoValue)) {
error(initializer, Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN);
}
else if (!isFinite(autoValue)) {
error(initializer, Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value);
}
}
autoValue = computeConstantValueForEnumMemberInitializer(initializer, enumType, enumIsConst, ambient);
}
else if (ambient && !enumIsConst) {
autoValue = undefined;
@@ -12802,8 +12822,36 @@ namespace ts {
nodeLinks.flags |= NodeCheckFlags.EnumValuesComputed;
}
function getConstantValueForEnumMemberInitializer(initializer: Expression): number {
return evalConstant(initializer);
function computeConstantValueForEnumMemberInitializer(initializer: Expression, enumType: Type, enumIsConst: boolean, ambient: boolean): number {
// Controls if error should be reported after evaluation of constant value is completed
// Can be false if another more precise error was already reported during evaluation.
let reportError = true;
let value = evalConstant(initializer);
if (reportError) {
if (value === undefined) {
if (enumIsConst) {
error(initializer, Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression);
}
else if (!ambient) {
// Only here do we need to check that the initializer is assignable to the enum type.
// If it is a constant value (not undefined), it is syntactically constrained to be a number.
// Also, we do not need to check this for ambients because there is already
// a syntax error if it is not a constant.
checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, /*headMessage*/ undefined);
}
}
else if (enumIsConst) {
if (isNaN(value)) {
error(initializer, Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN);
}
else if (!isFinite(value)) {
error(initializer, Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value);
}
}
}
return value;
function evalConstant(e: Node): number {
switch (e.kind) {
@@ -12912,6 +12960,8 @@ namespace ts {
// illegal case: forward reference
if (!isDefinedBefore(propertyDecl, member)) {
reportError = false;
error(e, Diagnostics.A_member_initializer_in_a_const_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_const_enums);
return undefined;
}
@@ -14393,6 +14443,7 @@ namespace ts {
getBlockScopedVariableId,
getReferencedValueDeclaration,
getTypeReferenceSerializationKind,
isOptionalParameter
};
}
@@ -14788,17 +14839,15 @@ namespace ts {
return grammarErrorOnNode(parameter.name, Diagnostics.A_rest_parameter_cannot_have_an_initializer);
}
}
else if (parameter.questionToken || parameter.initializer) {
else if (parameter.questionToken) {
seenOptionalParameter = true;
if (parameter.questionToken && parameter.initializer) {
if (parameter.initializer) {
return grammarErrorOnNode(parameter.name, Diagnostics.Parameter_cannot_have_question_mark_and_initializer);
}
}
else {
if (seenOptionalParameter) {
return grammarErrorOnNode(parameter.name, Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter);
}
else if (seenOptionalParameter && !parameter.initializer) {
return grammarErrorOnNode(parameter.name, Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter);
}
}
}
+4 -1
View File
@@ -422,10 +422,13 @@ namespace ts {
if (json["files"] instanceof Array) {
fileNames = map(<string[]>json["files"], s => combinePaths(basePath, s));
}
else {
errors.push(createCompilerDiagnostic(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, 'files', 'Array'));
}
}
else {
let exclude = json["exclude"] instanceof Array ? map(<string[]>json["exclude"], normalizeSlashes) : undefined;
let sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude));
let sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude));
for (let i = 0; i < sysFiles.length; i++) {
let name = sysFiles[i];
if (fileExtensionIs(name, ".d.ts")) {
+1 -1
View File
@@ -1371,7 +1371,7 @@ namespace ts {
else {
writeTextOfNode(currentSourceFile, node.name);
}
if (node.initializer || hasQuestionToken(node)) {
if (resolver.isOptionalParameter(node)) {
write("?");
}
decreaseIndent();
@@ -425,7 +425,8 @@ namespace ts {
JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: DiagnosticCategory.Error, key: "JSX element class does not support attributes because it does not have a '{0}' property" },
The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: DiagnosticCategory.Error, key: "The global type 'JSX.{0}' may not have more than one property" },
Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" },
Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2651, category: DiagnosticCategory.Error, key: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." },
A_member_initializer_in_a_const_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_const_enums: { code: 2651, category: DiagnosticCategory.Error, key: "A member initializer in a 'const' enum declaration cannot reference members declared after it, including members defined in other 'const' enums." },
Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: DiagnosticCategory.Error, key: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." },
Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." },
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." },
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." },
+5 -1
View File
@@ -1689,9 +1689,13 @@
"category": "Error",
"code": 2650
},
"Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead.": {
"A member initializer in a 'const' enum declaration cannot reference members declared after it, including members defined in other 'const' enums.": {
"category": "Error",
"code": 2651
},
"Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead.": {
"category": "Error",
"code": 2652
},
"Import declaration '{0}' is using private name '{1}'.": {
"category": "Error",
+7 -1
View File
@@ -1425,6 +1425,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
case SyntaxKind.IfStatement:
case SyntaxKind.JsxSelfClosingElement:
case SyntaxKind.JsxOpeningElement:
case SyntaxKind.JsxSpreadAttribute:
case SyntaxKind.JsxExpression:
case SyntaxKind.NewExpression:
case SyntaxKind.ParenthesizedExpression:
@@ -4866,6 +4867,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
}
function emitSerializedTypeNode(node: TypeNode) {
if(!node) {
return; //don't write anything on the stream when type is not defined
}
switch (node.kind) {
case SyntaxKind.VoidKeyword:
write("void 0");
@@ -5032,7 +5038,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
/** Serializes the return type of function. Used by the __metadata decorator for a method. */
function emitSerializedReturnTypeOfNode(node: Node): string | string[] {
if (node && isFunctionLike(node)) {
if (node && isFunctionLike(node) && (<FunctionLikeDeclaration>node).type) {
emitSerializedTypeNode((<FunctionLikeDeclaration>node).type);
return;
}
+9 -3
View File
@@ -1431,6 +1431,7 @@ namespace ts {
getJsxElementAttributesType(elementNode: JsxOpeningLikeElement): Type;
getJsxIntrinsicTagNames(): Symbol[];
isOptionalParameter(node: ParameterDeclaration): boolean;
// Should not be called directly. Should only be accessed through the Program instance.
/* @internal */ getDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
@@ -1574,7 +1575,8 @@ namespace ts {
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
getBlockScopedVariableId(node: Identifier): number;
getReferencedValueDeclaration(reference: Identifier): Declaration;
getTypeReferenceSerializationKind(node: TypeReferenceNode): TypeReferenceSerializationKind;
getTypeReferenceSerializationKind(node: TypeReferenceNode): TypeReferenceSerializationKind;
isOptionalParameter(node: ParameterDeclaration): boolean;
}
export const enum SymbolFlags {
@@ -1768,7 +1770,9 @@ namespace ts {
ContainsUndefinedOrNull = 0x00200000, // Type is or contains Undefined or Null type
/* @internal */
ContainsObjectLiteral = 0x00400000, // Type is or contains object literal type
ESSymbol = 0x00800000, // Type of symbol primitive introduced in ES6
/* @internal */
ContainsAnyFunctionType = 0x00800000, // Type is or contains object literal type
ESSymbol = 0x01000000, // Type of symbol primitive introduced in ES6
/* @internal */
Intrinsic = Any | String | Number | Boolean | ESSymbol | Void | Undefined | Null,
@@ -1779,8 +1783,10 @@ namespace ts {
ObjectType = Class | Interface | Reference | Tuple | Anonymous,
UnionOrIntersection = Union | Intersection,
StructuredType = ObjectType | Union | Intersection,
/* @internal */
RequiresWidening = ContainsUndefinedOrNull | ContainsObjectLiteral,
/* @internal */
RequiresWidening = ContainsUndefinedOrNull | ContainsObjectLiteral
PropagatingFlags = ContainsUndefinedOrNull | ContainsObjectLiteral | ContainsAnyFunctionType
}
// Properties common to all types
+1 -3
View File
@@ -988,15 +988,13 @@ namespace ts {
if (node) {
switch (node.kind) {
case SyntaxKind.Parameter:
return (<ParameterDeclaration>node).questionToken !== undefined;
case SyntaxKind.MethodDeclaration:
case SyntaxKind.MethodSignature:
return (<MethodDeclaration>node).questionToken !== undefined;
case SyntaxKind.ShorthandPropertyAssignment:
case SyntaxKind.PropertyAssignment:
case SyntaxKind.PropertyDeclaration:
case SyntaxKind.PropertySignature:
return (<PropertyDeclaration>node).questionToken !== undefined;
return (<ParameterDeclaration | MethodDeclaration | PropertyDeclaration>node).questionToken !== undefined;
}
}
+28
View File
@@ -2476,6 +2476,17 @@ module FourSlash {
}
}
// @Filename is the only directive that can be used in a test that contains tsconfig.json file.
if (containTSConfigJson(files)) {
let directive = getNonFileNameOptionInFileList(files);
if (!directive) {
directive = getNonFileNameOptionInObject(globalOptions);
}
if (directive) {
throw Error("It is not allowed to use tsconfig.json along with directive '" + directive + "'");
}
}
return {
markerPositions,
markers,
@@ -2485,6 +2496,23 @@ module FourSlash {
};
}
function containTSConfigJson(files: FourSlashFile[]): boolean {
return ts.forEach(files, f => f.fileOptions['Filename'] === 'tsconfig.json');
}
function getNonFileNameOptionInFileList(files: FourSlashFile[]): string {
return ts.forEach(files, f => getNonFileNameOptionInObject(f.fileOptions));
}
function getNonFileNameOptionInObject(optionObject: { [s: string]: string }): string {
for (let option in optionObject) {
if (option !== metadataOptionNames.fileName) {
return option;
}
}
return undefined;
}
const enum State {
none,
inSlashStarMarker,
+2 -2
View File
@@ -493,7 +493,7 @@ module Harness {
export let readFile: typeof IO.readFile = ts.sys.readFile;
export let writeFile: typeof IO.writeFile = ts.sys.writeFile;
export let fileExists: typeof IO.fileExists = fs.existsSync;
export let log: typeof IO.log = console.log;
export let log: typeof IO.log = s => console.log(s);
export function createDirectory(path: string) {
if (!directoryExists(path)) {
@@ -673,7 +673,7 @@ module Harness {
};
export let listFiles = Utils.memoize(_listFilesImpl);
export let log = console.log;
export let log = (s: string) => console.log(s);
export function readFile(file: string) {
let response = Http.getFileFromServerSync(serverRoot + file);
+2 -4
View File
@@ -803,9 +803,6 @@ namespace ts.server {
} else {
this.log("no config file");
}
if (configFileName) {
configFileName = getAbsolutePath(configFileName, searchPath);
}
if (configFileName && (!this.configProjectIsActive(configFileName))) {
var configResult = this.openConfigFile(configFileName, fileName);
if (!configResult.success) {
@@ -910,7 +907,8 @@ namespace ts.server {
configFilename = ts.normalizePath(configFilename);
// file references will be relative to dirPath (or absolute)
var dirPath = ts.getDirectoryPath(configFilename);
var rawConfig: { config?: ProjectOptions; error?: Diagnostic; } = ts.readConfigFile(configFilename);
var contents = this.host.readFile(configFilename)
var rawConfig: { config?: ProjectOptions; error?: Diagnostic; } = ts.parseConfigFileText(configFilename, contents);
if (rawConfig.error) {
return rawConfig.error;
}
+1 -3
View File
@@ -611,13 +611,11 @@ namespace ts.SignatureHelp {
let displayParts = mapToDisplayParts(writer =>
typeChecker.getSymbolDisplayBuilder().buildParameterDisplay(parameter, writer, invocation));
let isOptional = hasQuestionToken(parameter.valueDeclaration);
return {
name: parameter.name,
documentation: parameter.getDocumentationComment(),
displayParts,
isOptional
isOptional: typeChecker.isOptionalParameter(<ParameterDeclaration>parameter.valueDeclaration)
};
}
@@ -1,18 +1,21 @@
tests/cases/compiler/assignmentCompat1.ts(4,1): error TS2322: Type '{ [index: string]: any; }' is not assignable to type '{ one: number; }'.
Property 'one' is missing in type '{ [index: string]: any; }'.
tests/cases/compiler/assignmentCompat1.ts(5,1): error TS2322: Type '{ one: number; }' is not assignable to type '{ [index: string]: any; }'.
Index signature is missing in type '{ one: number; }'.
tests/cases/compiler/assignmentCompat1.ts(6,1): error TS2322: Type '{ [index: number]: any; }' is not assignable to type '{ one: number; }'.
Property 'one' is missing in type '{ [index: number]: any; }'.
==== tests/cases/compiler/assignmentCompat1.ts (2 errors) ====
var x = {one: 1};
var y: {[index:string]: any};
x = y;
var x = { one: 1 };
var y: { [index: string]: any };
var z: { [index: number]: any };
x = y; // Error
~
!!! error TS2322: Type '{ [index: string]: any; }' is not assignable to type '{ one: number; }'.
!!! error TS2322: Property 'one' is missing in type '{ [index: string]: any; }'.
y = x;
y = x; // Ok because index signature type is any
x = z; // Error
~
!!! error TS2322: Type '{ one: number; }' is not assignable to type '{ [index: string]: any; }'.
!!! error TS2322: Index signature is missing in type '{ one: number; }'.
!!! error TS2322: Type '{ [index: number]: any; }' is not assignable to type '{ one: number; }'.
!!! error TS2322: Property 'one' is missing in type '{ [index: number]: any; }'.
z = x; // Ok because index signature type is any
+13 -7
View File
@@ -1,12 +1,18 @@
//// [assignmentCompat1.ts]
var x = {one: 1};
var y: {[index:string]: any};
x = y;
y = x;
var x = { one: 1 };
var y: { [index: string]: any };
var z: { [index: number]: any };
x = y; // Error
y = x; // Ok because index signature type is any
x = z; // Error
z = x; // Ok because index signature type is any
//// [assignmentCompat1.js]
var x = { one: 1 };
var y;
x = y;
y = x;
var z;
x = y; // Error
y = x; // Ok because index signature type is any
x = z; // Error
z = x; // Ok because index signature type is any
@@ -1,17 +0,0 @@
tests/cases/compiler/assignmentCompatability36.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ [index: string]: any; }'.
Index signature is missing in type 'interfaceWithPublicAndOptional<number, string>'.
==== tests/cases/compiler/assignmentCompatability36.ts (1 errors) ====
module __test1__ {
export interface interfaceWithPublicAndOptional<T,U> { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional<number,string> = { one: 1 };;
export var __val__obj4 = obj4;
}
module __test2__ {
export var aa:{[index:string]:any;};;
export var __val__aa = aa;
}
__test2__.__val__aa = __test1__.__val__obj4
~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '{ [index: string]: any; }'.
!!! error TS2322: Index signature is missing in type 'interfaceWithPublicAndOptional<number, string>'.
@@ -0,0 +1,39 @@
=== tests/cases/compiler/assignmentCompatability36.ts ===
module __test1__ {
>__test1__ : Symbol(__test1__, Decl(assignmentCompatability36.ts, 0, 0))
export interface interfaceWithPublicAndOptional<T,U> { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional<number,string> = { one: 1 };;
>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability36.ts, 0, 18))
>T : Symbol(T, Decl(assignmentCompatability36.ts, 1, 52))
>U : Symbol(U, Decl(assignmentCompatability36.ts, 1, 54))
>one : Symbol(one, Decl(assignmentCompatability36.ts, 1, 58))
>T : Symbol(T, Decl(assignmentCompatability36.ts, 1, 52))
>two : Symbol(two, Decl(assignmentCompatability36.ts, 1, 66))
>U : Symbol(U, Decl(assignmentCompatability36.ts, 1, 54))
>obj4 : Symbol(obj4, Decl(assignmentCompatability36.ts, 1, 83))
>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability36.ts, 0, 18))
>one : Symbol(one, Decl(assignmentCompatability36.ts, 1, 139))
export var __val__obj4 = obj4;
>__val__obj4 : Symbol(__val__obj4, Decl(assignmentCompatability36.ts, 2, 14))
>obj4 : Symbol(obj4, Decl(assignmentCompatability36.ts, 1, 83))
}
module __test2__ {
>__test2__ : Symbol(__test2__, Decl(assignmentCompatability36.ts, 3, 1))
export var aa:{[index:string]:any;};;
>aa : Symbol(aa, Decl(assignmentCompatability36.ts, 5, 14))
>index : Symbol(index, Decl(assignmentCompatability36.ts, 5, 20))
export var __val__aa = aa;
>__val__aa : Symbol(__val__aa, Decl(assignmentCompatability36.ts, 6, 14))
>aa : Symbol(aa, Decl(assignmentCompatability36.ts, 5, 14))
}
__test2__.__val__aa = __test1__.__val__obj4
>__test2__.__val__aa : Symbol(__test2__.__val__aa, Decl(assignmentCompatability36.ts, 6, 14))
>__test2__ : Symbol(__test2__, Decl(assignmentCompatability36.ts, 3, 1))
>__val__aa : Symbol(__test2__.__val__aa, Decl(assignmentCompatability36.ts, 6, 14))
>__test1__.__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability36.ts, 2, 14))
>__test1__ : Symbol(__test1__, Decl(assignmentCompatability36.ts, 0, 0))
>__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability36.ts, 2, 14))
@@ -0,0 +1,42 @@
=== tests/cases/compiler/assignmentCompatability36.ts ===
module __test1__ {
>__test1__ : typeof __test1__
export interface interfaceWithPublicAndOptional<T,U> { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional<number,string> = { one: 1 };;
>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional<T, U>
>T : T
>U : U
>one : T
>T : T
>two : U
>U : U
>obj4 : interfaceWithPublicAndOptional<number, string>
>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional<T, U>
>{ one: 1 } : { one: number; }
>one : number
>1 : number
export var __val__obj4 = obj4;
>__val__obj4 : interfaceWithPublicAndOptional<number, string>
>obj4 : interfaceWithPublicAndOptional<number, string>
}
module __test2__ {
>__test2__ : typeof __test2__
export var aa:{[index:string]:any;};;
>aa : { [index: string]: any; }
>index : string
export var __val__aa = aa;
>__val__aa : { [index: string]: any; }
>aa : { [index: string]: any; }
}
__test2__.__val__aa = __test1__.__val__obj4
>__test2__.__val__aa = __test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional<number, string>
>__test2__.__val__aa : { [index: string]: any; }
>__test2__ : typeof __test2__
>__val__aa : { [index: string]: any; }
>__test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional<number, string>
>__test1__ : typeof __test1__
>__val__obj4 : __test1__.interfaceWithPublicAndOptional<number, string>
@@ -1,6 +1,6 @@
tests/cases/compiler/constEnumErrors.ts(1,12): error TS2300: Duplicate identifier 'E'.
tests/cases/compiler/constEnumErrors.ts(5,8): error TS2300: Duplicate identifier 'E'.
tests/cases/compiler/constEnumErrors.ts(12,9): error TS2474: In 'const' enum declarations member initializer must be constant expression.
tests/cases/compiler/constEnumErrors.ts(12,9): error TS2651: A member initializer in a 'const' enum declaration cannot reference members declared after it, including members defined in other 'const' enums.
tests/cases/compiler/constEnumErrors.ts(14,9): error TS2474: In 'const' enum declarations member initializer must be constant expression.
tests/cases/compiler/constEnumErrors.ts(15,10): error TS2474: In 'const' enum declarations member initializer must be constant expression.
tests/cases/compiler/constEnumErrors.ts(22,13): error TS2476: A const enum member can only be accessed using a string literal.
@@ -31,7 +31,7 @@ tests/cases/compiler/constEnumErrors.ts(42,9): error TS2478: 'const' enum member
// forward reference to the element of the same enum
X = Y,
~
!!! error TS2474: In 'const' enum declarations member initializer must be constant expression.
!!! error TS2651: A member initializer in a 'const' enum declaration cannot reference members declared after it, including members defined in other 'const' enums.
// forward reference to the element of the same enum
Y = E1.Z,
~~~~
@@ -1,5 +1,5 @@
tests/cases/conformance/es6/modules/m1.ts(2,25): error TS2651: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead.
tests/cases/conformance/es6/modules/m1.ts(11,18): error TS2651: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead.
tests/cases/conformance/es6/modules/m1.ts(2,25): error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead.
tests/cases/conformance/es6/modules/m1.ts(11,18): error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead.
tests/cases/conformance/es6/modules/m2.ts(5,8): error TS2304: Cannot find name 'Entity'.
tests/cases/conformance/es6/modules/m2.ts(6,8): error TS2503: Cannot find namespace 'Entity'.
tests/cases/conformance/es6/modules/m2.ts(8,8): error TS2339: Property 'x' does not exist on type '() => number'.
@@ -10,7 +10,7 @@ tests/cases/conformance/es6/modules/m2.ts(9,8): error TS2339: Property 'y' does
export default function Decl() {
~~~~
!!! error TS2651: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead.
!!! error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead.
return 0;
}
@@ -21,7 +21,7 @@ tests/cases/conformance/es6/modules/m2.ts(9,8): error TS2339: Property 'y' does
export namespace Decl {
~~~~
!!! error TS2651: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead.
!!! error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead.
export var x = 10;
export var y = 20;
@@ -1,5 +1,5 @@
tests/cases/conformance/es6/modules/m1.ts(2,22): error TS2651: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead.
tests/cases/conformance/es6/modules/m1.ts(5,18): error TS2651: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead.
tests/cases/conformance/es6/modules/m1.ts(2,22): error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead.
tests/cases/conformance/es6/modules/m1.ts(5,18): error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead.
tests/cases/conformance/es6/modules/m2.ts(3,1): error TS2348: Value of type 'typeof Decl' is not callable. Did you mean to include 'new'?
tests/cases/conformance/es6/modules/m2.ts(6,8): error TS2503: Cannot find namespace 'Entity'.
tests/cases/conformance/es6/modules/m2.ts(8,13): error TS2339: Property 'p1' does not exist on type 'Decl'.
@@ -10,12 +10,12 @@ tests/cases/conformance/es6/modules/m2.ts(8,20): error TS2339: Property 'p2' doe
export default class Decl {
~~~~
!!! error TS2651: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead.
!!! error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead.
}
export interface Decl {
~~~~
!!! error TS2651: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead.
!!! error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead.
p1: number;
p2: number;
}
@@ -1,6 +1,6 @@
tests/cases/conformance/es6/modules/m1.ts(2,22): error TS2651: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead.
tests/cases/conformance/es6/modules/m1.ts(2,22): error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead.
tests/cases/conformance/es6/modules/m1.ts(5,11): error TS2518: Only an ambient class can be merged with an interface.
tests/cases/conformance/es6/modules/m1.ts(5,11): error TS2651: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead.
tests/cases/conformance/es6/modules/m1.ts(5,11): error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead.
tests/cases/conformance/es6/modules/m2.ts(3,1): error TS2348: Value of type 'typeof Decl' is not callable. Did you mean to include 'new'?
tests/cases/conformance/es6/modules/m2.ts(6,8): error TS2503: Cannot find namespace 'Entity'.
tests/cases/conformance/es6/modules/m2.ts(8,13): error TS2339: Property 'p1' does not exist on type 'Decl'.
@@ -11,14 +11,14 @@ tests/cases/conformance/es6/modules/m2.ts(8,20): error TS2339: Property 'p2' doe
export default class Decl {
~~~~
!!! error TS2651: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead.
!!! error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead.
}
interface Decl {
~~~~
!!! error TS2518: Only an ambient class can be merged with an interface.
~~~~
!!! error TS2651: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead.
!!! error TS2652: Merged declaration 'Decl' cannot include a default export declaration. Consider adding a separate 'export default Decl' declaration instead.
p1: number;
p2: number;
}
@@ -1,5 +1,5 @@
tests/cases/conformance/es6/modules/defaultExportsCannotMerge04.ts(2,25): error TS2651: Merged declaration 'Foo' cannot include a default export declaration. Consider adding a separate 'export default Foo' declaration instead.
tests/cases/conformance/es6/modules/defaultExportsCannotMerge04.ts(5,11): error TS2651: Merged declaration 'Foo' cannot include a default export declaration. Consider adding a separate 'export default Foo' declaration instead.
tests/cases/conformance/es6/modules/defaultExportsCannotMerge04.ts(2,25): error TS2652: Merged declaration 'Foo' cannot include a default export declaration. Consider adding a separate 'export default Foo' declaration instead.
tests/cases/conformance/es6/modules/defaultExportsCannotMerge04.ts(5,11): error TS2652: Merged declaration 'Foo' cannot include a default export declaration. Consider adding a separate 'export default Foo' declaration instead.
tests/cases/conformance/es6/modules/defaultExportsCannotMerge04.ts(9,11): error TS2395: Individual declarations in merged declaration 'Foo' must be all exported or all local.
tests/cases/conformance/es6/modules/defaultExportsCannotMerge04.ts(12,18): error TS2395: Individual declarations in merged declaration 'Foo' must be all exported or all local.
@@ -8,12 +8,12 @@ tests/cases/conformance/es6/modules/defaultExportsCannotMerge04.ts(12,18): error
export default function Foo() {
~~~
!!! error TS2651: Merged declaration 'Foo' cannot include a default export declaration. Consider adding a separate 'export default Foo' declaration instead.
!!! error TS2652: Merged declaration 'Foo' cannot include a default export declaration. Consider adding a separate 'export default Foo' declaration instead.
}
namespace Foo {
~~~
!!! error TS2651: Merged declaration 'Foo' cannot include a default export declaration. Consider adding a separate 'export default Foo' declaration instead.
!!! error TS2652: Merged declaration 'Foo' cannot include a default export declaration. Consider adding a separate 'export default Foo' declaration instead.
export var x;
}
@@ -0,0 +1,31 @@
//// [emitVoid0ReturnType.ts]
declare var decorator: any;
class MyClass {
constructor(test: string, test2: number) {
}
@decorator
doSomething() {
}
}
//// [emitVoid0ReturnType.js]
var MyClass = (function () {
function MyClass(test, test2) {
}
MyClass.prototype.doSomething = function () {
};
Object.defineProperty(MyClass.prototype, "doSomething",
__decorate([
decorator,
__metadata('design:type', Function),
__metadata('design:paramtypes', []),
__metadata('design:returntype', void 0)
], MyClass.prototype, "doSomething", Object.getOwnPropertyDescriptor(MyClass.prototype, "doSomething")));
return MyClass;
})();
@@ -0,0 +1,23 @@
=== tests/cases/compiler/emitVoid0ReturnType.ts ===
declare var decorator: any;
>decorator : Symbol(decorator, Decl(emitVoid0ReturnType.ts, 1, 11))
class MyClass {
>MyClass : Symbol(MyClass, Decl(emitVoid0ReturnType.ts, 1, 27))
constructor(test: string, test2: number) {
>test : Symbol(test, Decl(emitVoid0ReturnType.ts, 4, 16))
>test2 : Symbol(test2, Decl(emitVoid0ReturnType.ts, 4, 29))
}
@decorator
>decorator : Symbol(decorator, Decl(emitVoid0ReturnType.ts, 1, 11))
doSomething() {
>doSomething : Symbol(doSomething, Decl(emitVoid0ReturnType.ts, 6, 5))
}
}
@@ -0,0 +1,23 @@
=== tests/cases/compiler/emitVoid0ReturnType.ts ===
declare var decorator: any;
>decorator : any
class MyClass {
>MyClass : MyClass
constructor(test: string, test2: number) {
>test : string
>test2 : number
}
@decorator
>decorator : any
doSomething() {
>doSomething : () => void
}
}
@@ -1,10 +1,9 @@
tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors1.ts(1,9): error TS1016: A required parameter cannot follow an optional parameter.
tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors1.ts(2,8): error TS1047: A rest parameter cannot be optional.
tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors1.ts(4,5): error TS1048: A rest parameter cannot have an initializer.
tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors1.ts(7,12): error TS1016: A required parameter cannot follow an optional parameter.
==== tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors1.ts (4 errors) ====
==== tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors1.ts (3 errors) ====
(arg1?, arg2) => 101;
~~~~
!!! error TS1016: A required parameter cannot follow an optional parameter.
@@ -16,7 +15,5 @@ tests/cases/compiler/fatarrowfunctionsOptionalArgsErrors1.ts(7,12): error TS1016
~~~
!!! error TS1048: A rest parameter cannot have an initializer.
// Non optional parameter following an optional one
(arg1 = 1, arg2) => 1;
~~~~
!!! error TS1016: A required parameter cannot follow an optional parameter.
// Uninitialized parameter makes the initialized one required
(arg1 = 1, arg2) => 1;
@@ -4,7 +4,7 @@
(...arg) => 103;
(...arg:number [] = []) => 104;
// Non optional parameter following an optional one
// Uninitialized parameter makes the initialized one required
(arg1 = 1, arg2) => 1;
//// [fatarrowfunctionsOptionalArgsErrors1.js]
@@ -30,7 +30,7 @@
}
return 104;
});
// Non optional parameter following an optional one
// Uninitialized parameter makes the initialized one required
(function (arg1, arg2) {
if (arg1 === void 0) { arg1 = 1; }
return 1;
@@ -1,14 +1,13 @@
tests/cases/compiler/indexTypeCheck.ts(2,2): error TS1021: An index signature must have a type annotation.
tests/cases/compiler/indexTypeCheck.ts(3,2): error TS1021: An index signature must have a type annotation.
tests/cases/compiler/indexTypeCheck.ts(17,2): error TS2413: Numeric index type 'number' is not assignable to string index type 'string'.
tests/cases/compiler/indexTypeCheck.ts(22,2): error TS2413: Numeric index type 'Orange' is not assignable to string index type 'Yellow'.
tests/cases/compiler/indexTypeCheck.ts(27,2): error TS2413: Numeric index type 'number' is not assignable to string index type 'string'.
tests/cases/compiler/indexTypeCheck.ts(32,3): error TS1096: An index signature must have exactly one parameter.
tests/cases/compiler/indexTypeCheck.ts(36,3): error TS1023: An index signature parameter type must be 'string' or 'number'.
tests/cases/compiler/indexTypeCheck.ts(51,1): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'.
==== tests/cases/compiler/indexTypeCheck.ts (8 errors) ====
==== tests/cases/compiler/indexTypeCheck.ts (7 errors) ====
interface Red {
[n:number]; // ok
~~~~~~~~~~~
@@ -37,8 +36,6 @@ tests/cases/compiler/indexTypeCheck.ts(51,1): error TS2342: An index expression
interface Green {
[n:number]: Orange; // error
~~~~~~~~~~~~~~~~~~~
!!! error TS2413: Numeric index type 'Orange' is not assignable to string index type 'Yellow'.
[s:string]: Yellow; // ok
}
@@ -13,7 +13,7 @@ function foo<T extends { m(p: string): number }>(x: T): T {
}
foo({ m(x) { return x.length } });
>foo({ m(x) { return x.length } }) : { }
>foo({ m(x) { return x.length } }) : { m(x: string): number; }
>foo : <T extends { m(p: string): number; }>(x: T) => T
>{ m(x) { return x.length } } : { m(x: string): number; }
>m : (x: string) => number
@@ -0,0 +1,12 @@
//// [inferringAnyFunctionType1.ts]
function f<T extends { "0": (p1: number) => number }>(p: T): T {
return p;
}
var v = f([x => x]);
//// [inferringAnyFunctionType1.js]
function f(p) {
return p;
}
var v = f([function (x) { return x; }]);
@@ -0,0 +1,19 @@
=== tests/cases/compiler/inferringAnyFunctionType1.ts ===
function f<T extends { "0": (p1: number) => number }>(p: T): T {
>f : Symbol(f, Decl(inferringAnyFunctionType1.ts, 0, 0))
>T : Symbol(T, Decl(inferringAnyFunctionType1.ts, 0, 11))
>p1 : Symbol(p1, Decl(inferringAnyFunctionType1.ts, 0, 29))
>p : Symbol(p, Decl(inferringAnyFunctionType1.ts, 0, 54))
>T : Symbol(T, Decl(inferringAnyFunctionType1.ts, 0, 11))
>T : Symbol(T, Decl(inferringAnyFunctionType1.ts, 0, 11))
return p;
>p : Symbol(p, Decl(inferringAnyFunctionType1.ts, 0, 54))
}
var v = f([x => x]);
>v : Symbol(v, Decl(inferringAnyFunctionType1.ts, 4, 3))
>f : Symbol(f, Decl(inferringAnyFunctionType1.ts, 0, 0))
>x : Symbol(x, Decl(inferringAnyFunctionType1.ts, 4, 11))
>x : Symbol(x, Decl(inferringAnyFunctionType1.ts, 4, 11))
@@ -0,0 +1,22 @@
=== tests/cases/compiler/inferringAnyFunctionType1.ts ===
function f<T extends { "0": (p1: number) => number }>(p: T): T {
>f : <T extends { "0": (p1: number) => number; }>(p: T) => T
>T : T
>p1 : number
>p : T
>T : T
>T : T
return p;
>p : T
}
var v = f([x => x]);
>v : [(x: number) => number]
>f([x => x]) : [(x: number) => number]
>f : <T extends { "0": (p1: number) => number; }>(p: T) => T
>[x => x] : [(x: number) => number]
>x => x : (x: number) => number
>x : number
>x : number
@@ -0,0 +1,12 @@
//// [inferringAnyFunctionType2.ts]
function f<T extends [(p1: number) => number]>(p: T): T {
return p;
}
var v = f([x => x]);
//// [inferringAnyFunctionType2.js]
function f(p) {
return p;
}
var v = f([function (x) { return x; }]);
@@ -0,0 +1,19 @@
=== tests/cases/compiler/inferringAnyFunctionType2.ts ===
function f<T extends [(p1: number) => number]>(p: T): T {
>f : Symbol(f, Decl(inferringAnyFunctionType2.ts, 0, 0))
>T : Symbol(T, Decl(inferringAnyFunctionType2.ts, 0, 11))
>p1 : Symbol(p1, Decl(inferringAnyFunctionType2.ts, 0, 23))
>p : Symbol(p, Decl(inferringAnyFunctionType2.ts, 0, 47))
>T : Symbol(T, Decl(inferringAnyFunctionType2.ts, 0, 11))
>T : Symbol(T, Decl(inferringAnyFunctionType2.ts, 0, 11))
return p;
>p : Symbol(p, Decl(inferringAnyFunctionType2.ts, 0, 47))
}
var v = f([x => x]);
>v : Symbol(v, Decl(inferringAnyFunctionType2.ts, 4, 3))
>f : Symbol(f, Decl(inferringAnyFunctionType2.ts, 0, 0))
>x : Symbol(x, Decl(inferringAnyFunctionType2.ts, 4, 11))
>x : Symbol(x, Decl(inferringAnyFunctionType2.ts, 4, 11))
@@ -0,0 +1,22 @@
=== tests/cases/compiler/inferringAnyFunctionType2.ts ===
function f<T extends [(p1: number) => number]>(p: T): T {
>f : <T extends [(p1: number) => number]>(p: T) => T
>T : T
>p1 : number
>p : T
>T : T
>T : T
return p;
>p : T
}
var v = f([x => x]);
>v : [(x: number) => number]
>f([x => x]) : [(x: number) => number]
>f : <T extends [(p1: number) => number]>(p: T) => T
>[x => x] : [(x: number) => number]
>x => x : (x: number) => number
>x : number
>x : number
@@ -0,0 +1,12 @@
//// [inferringAnyFunctionType3.ts]
function f<T extends ((p1: number) => number)[]>(p: T): T {
return p;
}
var v = f([x => x]);
//// [inferringAnyFunctionType3.js]
function f(p) {
return p;
}
var v = f([function (x) { return x; }]);
@@ -0,0 +1,19 @@
=== tests/cases/compiler/inferringAnyFunctionType3.ts ===
function f<T extends ((p1: number) => number)[]>(p: T): T {
>f : Symbol(f, Decl(inferringAnyFunctionType3.ts, 0, 0))
>T : Symbol(T, Decl(inferringAnyFunctionType3.ts, 0, 11))
>p1 : Symbol(p1, Decl(inferringAnyFunctionType3.ts, 0, 23))
>p : Symbol(p, Decl(inferringAnyFunctionType3.ts, 0, 49))
>T : Symbol(T, Decl(inferringAnyFunctionType3.ts, 0, 11))
>T : Symbol(T, Decl(inferringAnyFunctionType3.ts, 0, 11))
return p;
>p : Symbol(p, Decl(inferringAnyFunctionType3.ts, 0, 49))
}
var v = f([x => x]);
>v : Symbol(v, Decl(inferringAnyFunctionType3.ts, 4, 3))
>f : Symbol(f, Decl(inferringAnyFunctionType3.ts, 0, 0))
>x : Symbol(x, Decl(inferringAnyFunctionType3.ts, 4, 11))
>x : Symbol(x, Decl(inferringAnyFunctionType3.ts, 4, 11))
@@ -0,0 +1,22 @@
=== tests/cases/compiler/inferringAnyFunctionType3.ts ===
function f<T extends ((p1: number) => number)[]>(p: T): T {
>f : <T extends ((p1: number) => number)[]>(p: T) => T
>T : T
>p1 : number
>p : T
>T : T
>T : T
return p;
>p : T
}
var v = f([x => x]);
>v : ((x: number) => number)[]
>f([x => x]) : ((x: number) => number)[]
>f : <T extends ((p1: number) => number)[]>(p: T) => T
>[x => x] : ((x: number) => number)[]
>x => x : (x: number) => number
>x : number
>x : number
@@ -0,0 +1,12 @@
//// [inferringAnyFunctionType4.ts]
function f<T extends (p1: number) => number>(p: T): T {
return p;
}
var v = f(x => x);
//// [inferringAnyFunctionType4.js]
function f(p) {
return p;
}
var v = f(function (x) { return x; });
@@ -0,0 +1,19 @@
=== tests/cases/compiler/inferringAnyFunctionType4.ts ===
function f<T extends (p1: number) => number>(p: T): T {
>f : Symbol(f, Decl(inferringAnyFunctionType4.ts, 0, 0))
>T : Symbol(T, Decl(inferringAnyFunctionType4.ts, 0, 11))
>p1 : Symbol(p1, Decl(inferringAnyFunctionType4.ts, 0, 22))
>p : Symbol(p, Decl(inferringAnyFunctionType4.ts, 0, 45))
>T : Symbol(T, Decl(inferringAnyFunctionType4.ts, 0, 11))
>T : Symbol(T, Decl(inferringAnyFunctionType4.ts, 0, 11))
return p;
>p : Symbol(p, Decl(inferringAnyFunctionType4.ts, 0, 45))
}
var v = f(x => x);
>v : Symbol(v, Decl(inferringAnyFunctionType4.ts, 4, 3))
>f : Symbol(f, Decl(inferringAnyFunctionType4.ts, 0, 0))
>x : Symbol(x, Decl(inferringAnyFunctionType4.ts, 4, 10))
>x : Symbol(x, Decl(inferringAnyFunctionType4.ts, 4, 10))
@@ -0,0 +1,21 @@
=== tests/cases/compiler/inferringAnyFunctionType4.ts ===
function f<T extends (p1: number) => number>(p: T): T {
>f : <T extends (p1: number) => number>(p: T) => T
>T : T
>p1 : number
>p : T
>T : T
>T : T
return p;
>p : T
}
var v = f(x => x);
>v : (x: number) => number
>f(x => x) : (x: number) => number
>f : <T extends (p1: number) => number>(p: T) => T
>x => x : (x: number) => number
>x : number
>x : number
@@ -0,0 +1,12 @@
//// [inferringAnyFunctionType5.ts]
function f<T extends { q: (p1: number) => number }>(p: T): T {
return p;
}
var v = f({ q: x => x });
//// [inferringAnyFunctionType5.js]
function f(p) {
return p;
}
var v = f({ q: function (x) { return x; } });
@@ -0,0 +1,21 @@
=== tests/cases/compiler/inferringAnyFunctionType5.ts ===
function f<T extends { q: (p1: number) => number }>(p: T): T {
>f : Symbol(f, Decl(inferringAnyFunctionType5.ts, 0, 0))
>T : Symbol(T, Decl(inferringAnyFunctionType5.ts, 0, 11))
>q : Symbol(q, Decl(inferringAnyFunctionType5.ts, 0, 22))
>p1 : Symbol(p1, Decl(inferringAnyFunctionType5.ts, 0, 27))
>p : Symbol(p, Decl(inferringAnyFunctionType5.ts, 0, 52))
>T : Symbol(T, Decl(inferringAnyFunctionType5.ts, 0, 11))
>T : Symbol(T, Decl(inferringAnyFunctionType5.ts, 0, 11))
return p;
>p : Symbol(p, Decl(inferringAnyFunctionType5.ts, 0, 52))
}
var v = f({ q: x => x });
>v : Symbol(v, Decl(inferringAnyFunctionType5.ts, 4, 3))
>f : Symbol(f, Decl(inferringAnyFunctionType5.ts, 0, 0))
>q : Symbol(q, Decl(inferringAnyFunctionType5.ts, 4, 11))
>x : Symbol(x, Decl(inferringAnyFunctionType5.ts, 4, 14))
>x : Symbol(x, Decl(inferringAnyFunctionType5.ts, 4, 14))
@@ -0,0 +1,24 @@
=== tests/cases/compiler/inferringAnyFunctionType5.ts ===
function f<T extends { q: (p1: number) => number }>(p: T): T {
>f : <T extends { q: (p1: number) => number; }>(p: T) => T
>T : T
>q : (p1: number) => number
>p1 : number
>p : T
>T : T
>T : T
return p;
>p : T
}
var v = f({ q: x => x });
>v : { q: (x: number) => number; }
>f({ q: x => x }) : { q: (x: number) => number; }
>f : <T extends { q: (p1: number) => number; }>(p: T) => T
>{ q: x => x } : { q: (x: number) => number; }
>q : (x: number) => number
>x => x : (x: number) => number
>x : number
>x : number
@@ -29,15 +29,7 @@ tests/cases/compiler/intTypeCheck.ts(134,5): error TS2322: Type 'boolean' is not
tests/cases/compiler/intTypeCheck.ts(134,21): error TS1109: Expression expected.
tests/cases/compiler/intTypeCheck.ts(134,22): error TS2304: Cannot find name 'i3'.
tests/cases/compiler/intTypeCheck.ts(135,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
tests/cases/compiler/intTypeCheck.ts(141,5): error TS2322: Type 'Object' is not assignable to type 'i4'.
Index signature is missing in type 'Object'.
tests/cases/compiler/intTypeCheck.ts(142,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
tests/cases/compiler/intTypeCheck.ts(143,5): error TS2322: Type 'Base' is not assignable to type 'i4'.
Index signature is missing in type 'Base'.
tests/cases/compiler/intTypeCheck.ts(145,5): error TS2322: Type '() => void' is not assignable to type 'i4'.
Index signature is missing in type '() => void'.
tests/cases/compiler/intTypeCheck.ts(148,5): error TS2322: Type 'boolean' is not assignable to type 'i4'.
Index signature is missing in type 'Boolean'.
tests/cases/compiler/intTypeCheck.ts(148,21): error TS1109: Expression expected.
tests/cases/compiler/intTypeCheck.ts(148,22): error TS2304: Cannot find name 'i4'.
tests/cases/compiler/intTypeCheck.ts(149,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
@@ -73,21 +65,13 @@ tests/cases/compiler/intTypeCheck.ts(190,5): error TS2322: Type 'boolean' is not
tests/cases/compiler/intTypeCheck.ts(190,21): error TS1109: Expression expected.
tests/cases/compiler/intTypeCheck.ts(190,22): error TS2304: Cannot find name 'i7'.
tests/cases/compiler/intTypeCheck.ts(191,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
tests/cases/compiler/intTypeCheck.ts(197,5): error TS2322: Type 'Object' is not assignable to type 'i8'.
Index signature is missing in type 'Object'.
tests/cases/compiler/intTypeCheck.ts(198,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
tests/cases/compiler/intTypeCheck.ts(199,5): error TS2322: Type 'Base' is not assignable to type 'i8'.
Index signature is missing in type 'Base'.
tests/cases/compiler/intTypeCheck.ts(201,5): error TS2322: Type '() => void' is not assignable to type 'i8'.
Index signature is missing in type '() => void'.
tests/cases/compiler/intTypeCheck.ts(204,5): error TS2322: Type 'boolean' is not assignable to type 'i8'.
Index signature is missing in type 'Boolean'.
tests/cases/compiler/intTypeCheck.ts(204,21): error TS1109: Expression expected.
tests/cases/compiler/intTypeCheck.ts(204,22): error TS2304: Cannot find name 'i8'.
tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
==== tests/cases/compiler/intTypeCheck.ts (69 errors) ====
==== tests/cases/compiler/intTypeCheck.ts (61 errors) ====
interface i1 {
//Property Signatures
p;
@@ -287,27 +271,15 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit
var obj33: i4;
var obj34: i4 = {};
var obj35: i4 = new Object();
~~~~~
!!! error TS2322: Type 'Object' is not assignable to type 'i4'.
!!! error TS2322: Index signature is missing in type 'Object'.
var obj36: i4 = new obj33;
~~~~~~~~~
!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
var obj37: i4 = new Base;
~~~~~
!!! error TS2322: Type 'Base' is not assignable to type 'i4'.
!!! error TS2322: Index signature is missing in type 'Base'.
var obj38: i4 = null;
var obj39: i4 = function () { };
~~~~~
!!! error TS2322: Type '() => void' is not assignable to type 'i4'.
!!! error TS2322: Index signature is missing in type '() => void'.
//var obj40: i4 = function foo() { };
var obj41: i4 = <i4> anyVar;
var obj42: i4 = new <i4> anyVar;
~~~~~
!!! error TS2322: Type 'boolean' is not assignable to type 'i4'.
!!! error TS2322: Index signature is missing in type 'Boolean'.
~
!!! error TS1109: Expression expected.
~~
@@ -421,27 +393,15 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit
var obj77: i8;
var obj78: i8 = {};
var obj79: i8 = new Object();
~~~~~
!!! error TS2322: Type 'Object' is not assignable to type 'i8'.
!!! error TS2322: Index signature is missing in type 'Object'.
var obj80: i8 = new obj77;
~~~~~~~~~
!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
var obj81: i8 = new Base;
~~~~~
!!! error TS2322: Type 'Base' is not assignable to type 'i8'.
!!! error TS2322: Index signature is missing in type 'Base'.
var obj82: i8 = null;
var obj83: i8 = function () { };
~~~~~
!!! error TS2322: Type '() => void' is not assignable to type 'i8'.
!!! error TS2322: Index signature is missing in type '() => void'.
//var obj84: i8 = function foo() { };
var obj85: i8 = <i8> anyVar;
var obj86: i8 = new <i8> anyVar;
~~~~~
!!! error TS2322: Type 'boolean' is not assignable to type 'i8'.
!!! error TS2322: Index signature is missing in type 'Boolean'.
~
!!! error TS1109: Expression expected.
~~
@@ -1,6 +1,6 @@
tests/cases/compiler/optionalParamArgsTest.ts(31,12): error TS2393: Duplicate function implementation.
tests/cases/compiler/optionalParamArgsTest.ts(35,12): error TS2393: Duplicate function implementation.
tests/cases/compiler/optionalParamArgsTest.ts(35,47): error TS1016: A required parameter cannot follow an optional parameter.
tests/cases/compiler/optionalParamArgsTest.ts(34,12): error TS2393: Duplicate function implementation.
tests/cases/compiler/optionalParamArgsTest.ts(98,1): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/compiler/optionalParamArgsTest.ts(99,1): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/compiler/optionalParamArgsTest.ts(100,1): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/compiler/optionalParamArgsTest.ts(101,1): error TS2346: Supplied parameters do not match any signature of call target.
@@ -20,10 +20,9 @@ tests/cases/compiler/optionalParamArgsTest.ts(114,1): error TS2346: Supplied par
tests/cases/compiler/optionalParamArgsTest.ts(115,1): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/compiler/optionalParamArgsTest.ts(116,1): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/compiler/optionalParamArgsTest.ts(117,1): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/compiler/optionalParamArgsTest.ts(118,1): error TS2346: Supplied parameters do not match any signature of call target.
==== tests/cases/compiler/optionalParamArgsTest.ts (23 errors) ====
==== tests/cases/compiler/optionalParamArgsTest.ts (22 errors) ====
// Optional parameter and default argument tests
// Key:
@@ -58,13 +57,10 @@ tests/cases/compiler/optionalParamArgsTest.ts(118,1): error TS2346: Supplied par
~~~~
!!! error TS2393: Duplicate function implementation.
// Negative test
// "Optional parameters may only be followed by other optional parameters"
// Uninitialized parameter makes the initialized one required
public C1M5(C1M5A1:number,C1M5A2:number=0,C1M5A3:number) { return C1M5A1 + C1M5A2; }
~~~~
!!! error TS2393: Duplicate function implementation.
~~~~~~
!!! error TS1016: A required parameter cannot follow an optional parameter.
}
class C2 extends C1 {
@@ -31,8 +31,7 @@ class C1 {
public C1M5(C1M5A1:number,C1M5A2:number=0,C1M5A3?:number) { return C1M5A1 + C1M5A2; }
// Negative test
// "Optional parameters may only be followed by other optional parameters"
// Uninitialized parameter makes the initialized one required
public C1M5(C1M5A1:number,C1M5A2:number=0,C1M5A3:number) { return C1M5A1 + C1M5A2; }
}
@@ -152,8 +151,7 @@ var C1 = (function () {
if (C1M5A2 === void 0) { C1M5A2 = 0; }
return C1M5A1 + C1M5A2;
};
// Negative test
// "Optional parameters may only be followed by other optional parameters"
// Uninitialized parameter makes the initialized one required
C1.prototype.C1M5 = function (C1M5A1, C1M5A2, C1M5A3) {
if (C1M5A2 === void 0) { C1M5A2 = 0; }
return C1M5A1 + C1M5A2;
@@ -0,0 +1,28 @@
tests/cases/compiler/requiredInitializedParameter1.ts(11,1): error TS2346: Supplied parameters do not match any signature of call target.
tests/cases/compiler/requiredInitializedParameter1.ts(16,1): error TS2346: Supplied parameters do not match any signature of call target.
==== tests/cases/compiler/requiredInitializedParameter1.ts (2 errors) ====
function f1(a, b = 0, c) { }
function f2(a, b = 0, c = 0) { }
function f3(a, b = 0, c?) { }
function f4(a, b = 0, ...c) { }
f1(0, 1, 2);
f2(0, 1, 2);
f3(0, 1, 2);
f4(0, 1, 2);
f1(0, 1);
~~~~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
f2(0, 1);
f3(0, 1);
f4(0, 1);
f1(0);
~~~~~
!!! error TS2346: Supplied parameters do not match any signature of call target.
f2(0);
f3(0);
f4(0);
@@ -0,0 +1,51 @@
//// [requiredInitializedParameter1.ts]
function f1(a, b = 0, c) { }
function f2(a, b = 0, c = 0) { }
function f3(a, b = 0, c?) { }
function f4(a, b = 0, ...c) { }
f1(0, 1, 2);
f2(0, 1, 2);
f3(0, 1, 2);
f4(0, 1, 2);
f1(0, 1);
f2(0, 1);
f3(0, 1);
f4(0, 1);
f1(0);
f2(0);
f3(0);
f4(0);
//// [requiredInitializedParameter1.js]
function f1(a, b, c) {
if (b === void 0) { b = 0; }
}
function f2(a, b, c) {
if (b === void 0) { b = 0; }
if (c === void 0) { c = 0; }
}
function f3(a, b, c) {
if (b === void 0) { b = 0; }
}
function f4(a, b) {
if (b === void 0) { b = 0; }
var c = [];
for (var _i = 2; _i < arguments.length; _i++) {
c[_i - 2] = arguments[_i];
}
}
f1(0, 1, 2);
f2(0, 1, 2);
f3(0, 1, 2);
f4(0, 1, 2);
f1(0, 1);
f2(0, 1);
f3(0, 1);
f4(0, 1);
f1(0);
f2(0);
f3(0);
f4(0);
@@ -0,0 +1,17 @@
tests/cases/compiler/requiredInitializedParameter2.ts(5,7): error TS2420: Class 'C1' incorrectly implements interface 'I1'.
Types of property 'method' are incompatible.
Type '(a: number, b: any) => void' is not assignable to type '() => any'.
==== tests/cases/compiler/requiredInitializedParameter2.ts (1 errors) ====
interface I1 {
method();
}
class C1 implements I1 {
~~
!!! error TS2420: Class 'C1' incorrectly implements interface 'I1'.
!!! error TS2420: Types of property 'method' are incompatible.
!!! error TS2420: Type '(a: number, b: any) => void' is not assignable to type '() => any'.
method(a = 0, b) { }
}
@@ -0,0 +1,18 @@
//// [requiredInitializedParameter2.ts]
interface I1 {
method();
}
class C1 implements I1 {
method(a = 0, b) { }
}
//// [requiredInitializedParameter2.js]
var C1 = (function () {
function C1() {
}
C1.prototype.method = function (a, b) {
if (a === void 0) { a = 0; }
};
return C1;
})();
@@ -0,0 +1,27 @@
//// [requiredInitializedParameter3.ts]
interface I1 {
method();
}
class C1 implements I1 {
method(a = 0, b?) { }
}
//// [requiredInitializedParameter3.js]
var C1 = (function () {
function C1() {
}
C1.prototype.method = function (a, b) {
if (a === void 0) { a = 0; }
};
return C1;
})();
//// [requiredInitializedParameter3.d.ts]
interface I1 {
method(): any;
}
declare class C1 implements I1 {
method(a?: number, b?: any): void;
}
@@ -0,0 +1,17 @@
=== tests/cases/compiler/requiredInitializedParameter3.ts ===
interface I1 {
>I1 : Symbol(I1, Decl(requiredInitializedParameter3.ts, 0, 0))
method();
>method : Symbol(method, Decl(requiredInitializedParameter3.ts, 0, 14))
}
class C1 implements I1 {
>C1 : Symbol(C1, Decl(requiredInitializedParameter3.ts, 2, 1))
>I1 : Symbol(I1, Decl(requiredInitializedParameter3.ts, 0, 0))
method(a = 0, b?) { }
>method : Symbol(method, Decl(requiredInitializedParameter3.ts, 4, 24))
>a : Symbol(a, Decl(requiredInitializedParameter3.ts, 5, 11))
>b : Symbol(b, Decl(requiredInitializedParameter3.ts, 5, 17))
}
@@ -0,0 +1,18 @@
=== tests/cases/compiler/requiredInitializedParameter3.ts ===
interface I1 {
>I1 : I1
method();
>method : () => any
}
class C1 implements I1 {
>C1 : C1
>I1 : I1
method(a = 0, b?) { }
>method : (a?: number, b?: any) => void
>a : number
>0 : number
>b : any
}
@@ -0,0 +1,20 @@
//// [requiredInitializedParameter4.ts]
class C1 {
method(a = 0, b) { }
}
//// [requiredInitializedParameter4.js]
var C1 = (function () {
function C1() {
}
C1.prototype.method = function (a, b) {
if (a === void 0) { a = 0; }
};
return C1;
})();
//// [requiredInitializedParameter4.d.ts]
declare class C1 {
method(a: number, b: any): void;
}
@@ -0,0 +1,9 @@
=== tests/cases/compiler/requiredInitializedParameter4.ts ===
class C1 {
>C1 : Symbol(C1, Decl(requiredInitializedParameter4.ts, 0, 0))
method(a = 0, b) { }
>method : Symbol(method, Decl(requiredInitializedParameter4.ts, 0, 10))
>a : Symbol(a, Decl(requiredInitializedParameter4.ts, 1, 11))
>b : Symbol(b, Decl(requiredInitializedParameter4.ts, 1, 17))
}
@@ -0,0 +1,10 @@
=== tests/cases/compiler/requiredInitializedParameter4.ts ===
class C1 {
>C1 : C1
method(a = 0, b) { }
>method : (a: number, b: any) => void
>a : number
>0 : number
>b : any
}
@@ -0,0 +1,7 @@
//// [resolveInterfaceNameWithSameLetDeclarationName1.ts]
interface bar { }
let bar: bar;
//// [resolveInterfaceNameWithSameLetDeclarationName1.js]
var bar;
@@ -0,0 +1,8 @@
=== tests/cases/compiler/resolveInterfaceNameWithSameLetDeclarationName1.ts ===
interface bar { }
>bar : Symbol(bar, Decl(resolveInterfaceNameWithSameLetDeclarationName1.ts, 0, 0), Decl(resolveInterfaceNameWithSameLetDeclarationName1.ts, 1, 3))
let bar: bar;
>bar : Symbol(bar, Decl(resolveInterfaceNameWithSameLetDeclarationName1.ts, 0, 0), Decl(resolveInterfaceNameWithSameLetDeclarationName1.ts, 1, 3))
>bar : Symbol(bar, Decl(resolveInterfaceNameWithSameLetDeclarationName1.ts, 0, 0), Decl(resolveInterfaceNameWithSameLetDeclarationName1.ts, 1, 3))
@@ -0,0 +1,8 @@
=== tests/cases/compiler/resolveInterfaceNameWithSameLetDeclarationName1.ts ===
interface bar { }
>bar : bar
let bar: bar;
>bar : bar
>bar : bar
@@ -0,0 +1,9 @@
//// [resolveInterfaceNameWithSameLetDeclarationName2.ts]
interface foo { }
interface bar { }
let bar: bar | foo;
let foo: bar | foo;
//// [resolveInterfaceNameWithSameLetDeclarationName2.js]
var bar;
var foo;
@@ -0,0 +1,17 @@
=== tests/cases/compiler/resolveInterfaceNameWithSameLetDeclarationName2.ts ===
interface foo { }
>foo : Symbol(foo, Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 0, 0), Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 3, 3))
interface bar { }
>bar : Symbol(bar, Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 0, 17), Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 2, 3))
let bar: bar | foo;
>bar : Symbol(bar, Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 0, 17), Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 2, 3))
>bar : Symbol(bar, Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 0, 17), Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 2, 3))
>foo : Symbol(foo, Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 0, 0), Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 3, 3))
let foo: bar | foo;
>foo : Symbol(foo, Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 0, 0), Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 3, 3))
>bar : Symbol(bar, Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 0, 17), Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 2, 3))
>foo : Symbol(foo, Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 0, 0), Decl(resolveInterfaceNameWithSameLetDeclarationName2.ts, 3, 3))
@@ -0,0 +1,17 @@
=== tests/cases/compiler/resolveInterfaceNameWithSameLetDeclarationName2.ts ===
interface foo { }
>foo : foo
interface bar { }
>bar : bar
let bar: bar | foo;
>bar : bar | foo
>bar : bar
>foo : foo
let foo: bar | foo;
>foo : bar | foo
>bar : bar
>foo : foo
@@ -0,0 +1,12 @@
//// [resolveModuleNameWithSameLetDeclarationName1.ts]
declare module foo {
interface Bar {
}
}
let foo: foo.Bar;
//// [resolveModuleNameWithSameLetDeclarationName1.js]
var foo;
@@ -0,0 +1,15 @@
=== tests/cases/compiler/resolveModuleNameWithSameLetDeclarationName1.ts ===
declare module foo {
>foo : Symbol(foo, Decl(resolveModuleNameWithSameLetDeclarationName1.ts, 0, 0), Decl(resolveModuleNameWithSameLetDeclarationName1.ts, 7, 3))
interface Bar {
>Bar : Symbol(Bar, Decl(resolveModuleNameWithSameLetDeclarationName1.ts, 0, 20))
}
}
let foo: foo.Bar;
>foo : Symbol(foo, Decl(resolveModuleNameWithSameLetDeclarationName1.ts, 0, 0), Decl(resolveModuleNameWithSameLetDeclarationName1.ts, 7, 3))
>foo : Symbol(foo, Decl(resolveModuleNameWithSameLetDeclarationName1.ts, 0, 0), Decl(resolveModuleNameWithSameLetDeclarationName1.ts, 7, 3))
>Bar : Symbol(foo.Bar, Decl(resolveModuleNameWithSameLetDeclarationName1.ts, 0, 20))
@@ -0,0 +1,15 @@
=== tests/cases/compiler/resolveModuleNameWithSameLetDeclarationName1.ts ===
declare module foo {
>foo : Bar
interface Bar {
>Bar : Bar
}
}
let foo: foo.Bar;
>foo : foo.Bar
>foo : any
>Bar : foo.Bar
@@ -0,0 +1,11 @@
//// [resolveModuleNameWithSameLetDeclarationName2.ts]
declare module "punycode" {
interface ucs2 {
decode(string: string): string;
encode(codePoints: number[]): string;
}
export let ucs2: ucs2;
}
//// [resolveModuleNameWithSameLetDeclarationName2.js]
@@ -0,0 +1,18 @@
=== tests/cases/compiler/resolveModuleNameWithSameLetDeclarationName2.ts ===
declare module "punycode" {
interface ucs2 {
>ucs2 : Symbol(ucs2, Decl(resolveModuleNameWithSameLetDeclarationName2.ts, 0, 27), Decl(resolveModuleNameWithSameLetDeclarationName2.ts, 6, 14))
decode(string: string): string;
>decode : Symbol(decode, Decl(resolveModuleNameWithSameLetDeclarationName2.ts, 1, 20))
>string : Symbol(string, Decl(resolveModuleNameWithSameLetDeclarationName2.ts, 2, 15))
encode(codePoints: number[]): string;
>encode : Symbol(encode, Decl(resolveModuleNameWithSameLetDeclarationName2.ts, 2, 39))
>codePoints : Symbol(codePoints, Decl(resolveModuleNameWithSameLetDeclarationName2.ts, 3, 15))
}
export let ucs2: ucs2;
>ucs2 : Symbol(ucs2, Decl(resolveModuleNameWithSameLetDeclarationName2.ts, 0, 27), Decl(resolveModuleNameWithSameLetDeclarationName2.ts, 6, 14))
>ucs2 : Symbol(ucs2, Decl(resolveModuleNameWithSameLetDeclarationName2.ts, 0, 27), Decl(resolveModuleNameWithSameLetDeclarationName2.ts, 6, 14))
}
@@ -0,0 +1,18 @@
=== tests/cases/compiler/resolveModuleNameWithSameLetDeclarationName2.ts ===
declare module "punycode" {
interface ucs2 {
>ucs2 : ucs2
decode(string: string): string;
>decode : (string: string) => string
>string : string
encode(codePoints: number[]): string;
>encode : (codePoints: number[]) => string
>codePoints : number[]
}
export let ucs2: ucs2;
>ucs2 : ucs2
>ucs2 : ucs2
}
@@ -0,0 +1,13 @@
//// [resolveTypeAliasWithSameLetDeclarationName1.ts]
class C { }
type baz = C;
let baz: baz;
//// [resolveTypeAliasWithSameLetDeclarationName1.js]
var C = (function () {
function C() {
}
return C;
})();
var baz;
@@ -0,0 +1,12 @@
=== tests/cases/compiler/resolveTypeAliasWithSameLetDeclarationName1.ts ===
class C { }
>C : Symbol(C, Decl(resolveTypeAliasWithSameLetDeclarationName1.ts, 0, 0))
type baz = C;
>baz : Symbol(baz, Decl(resolveTypeAliasWithSameLetDeclarationName1.ts, 0, 11), Decl(resolveTypeAliasWithSameLetDeclarationName1.ts, 2, 3))
>C : Symbol(C, Decl(resolveTypeAliasWithSameLetDeclarationName1.ts, 0, 0))
let baz: baz;
>baz : Symbol(baz, Decl(resolveTypeAliasWithSameLetDeclarationName1.ts, 0, 11), Decl(resolveTypeAliasWithSameLetDeclarationName1.ts, 2, 3))
>baz : Symbol(baz, Decl(resolveTypeAliasWithSameLetDeclarationName1.ts, 0, 11), Decl(resolveTypeAliasWithSameLetDeclarationName1.ts, 2, 3))
@@ -0,0 +1,12 @@
=== tests/cases/compiler/resolveTypeAliasWithSameLetDeclarationName1.ts ===
class C { }
>C : C
type baz = C;
>baz : C
>C : C
let baz: baz;
>baz : C
>baz : C
@@ -0,0 +1,25 @@
//// [tests/cases/conformance/jsx/tsxExternalModuleEmit2.tsx] ////
//// [modules.d.ts]
declare module 'mod' {
var y: any;
export default y;
}
//// [app.tsx]
import Main from 'mod';
declare var Foo, React;
// Should see mod_1['default'] in emit here
<Foo handler={Main}></Foo>;
// Should see mod_1['default'] in emit here
<Foo {...Main}></Foo>;
//// [app.js]
var mod_1 = require('mod');
// Should see mod_1['default'] in emit here
React.createElement(Foo, {"handler": mod_1["default"]});
// Should see mod_1['default'] in emit here
React.createElement(Foo, React.__spread({}, mod_1["default"]));
@@ -0,0 +1,28 @@
=== tests/cases/conformance/jsx/modules.d.ts ===
declare module 'mod' {
var y: any;
>y : Symbol(y, Decl(modules.d.ts, 2, 5))
export default y;
>y : Symbol(y, Decl(modules.d.ts, 2, 5))
}
=== tests/cases/conformance/jsx/app.tsx ===
import Main from 'mod';
>Main : Symbol(Main, Decl(app.tsx, 0, 6))
declare var Foo, React;
>Foo : Symbol(Foo, Decl(app.tsx, 1, 11))
>React : Symbol(React, Decl(app.tsx, 1, 16))
// Should see mod_1['default'] in emit here
<Foo handler={Main}></Foo>;
>Foo : Symbol(Foo, Decl(app.tsx, 1, 11))
>handler : Symbol(unknown)
// Should see mod_1['default'] in emit here
<Foo {...Main}></Foo>;
>Foo : Symbol(Foo, Decl(app.tsx, 1, 11))
@@ -0,0 +1,34 @@
=== tests/cases/conformance/jsx/modules.d.ts ===
declare module 'mod' {
var y: any;
>y : any
export default y;
>y : any
}
=== tests/cases/conformance/jsx/app.tsx ===
import Main from 'mod';
>Main : any
declare var Foo, React;
>Foo : any
>React : any
// Should see mod_1['default'] in emit here
<Foo handler={Main}></Foo>;
><Foo handler={Main}></Foo> : any
>Foo : any
>handler : any
>Main : any
>Foo : any
// Should see mod_1['default'] in emit here
<Foo {...Main}></Foo>;
><Foo {...Main}></Foo> : any
>Foo : any
>Main : any
>Foo : any
+7 -5
View File
@@ -1,5 +1,7 @@
var x = {one: 1};
var y: {[index:string]: any};
x = y;
y = x;
var x = { one: 1 };
var y: { [index: string]: any };
var z: { [index: number]: any };
x = y; // Error
y = x; // Ok because index signature type is any
x = z; // Error
z = x; // Ok because index signature type is any
@@ -0,0 +1,17 @@
// @noemithelpers: true
// @experimentaldecorators: true
// @emitdecoratormetadata: true
// @target: es5
declare var decorator: any;
class MyClass {
constructor(test: string, test2: number) {
}
@decorator
doSomething() {
}
}
@@ -3,5 +3,5 @@
(...arg) => 103;
(...arg:number [] = []) => 104;
// Non optional parameter following an optional one
// Uninitialized parameter makes the initialized one required
(arg1 = 1, arg2) => 1;
@@ -0,0 +1,5 @@
function f<T extends { "0": (p1: number) => number }>(p: T): T {
return p;
}
var v = f([x => x]);
@@ -0,0 +1,5 @@
function f<T extends [(p1: number) => number]>(p: T): T {
return p;
}
var v = f([x => x]);
@@ -0,0 +1,5 @@
function f<T extends ((p1: number) => number)[]>(p: T): T {
return p;
}
var v = f([x => x]);
@@ -0,0 +1,5 @@
function f<T extends (p1: number) => number>(p: T): T {
return p;
}
var v = f(x => x);
@@ -0,0 +1,5 @@
function f<T extends { q: (p1: number) => number }>(p: T): T {
return p;
}
var v = f({ q: x => x });
@@ -30,8 +30,7 @@ class C1 {
public C1M5(C1M5A1:number,C1M5A2:number=0,C1M5A3?:number) { return C1M5A1 + C1M5A2; }
// Negative test
// "Optional parameters may only be followed by other optional parameters"
// Uninitialized parameter makes the initialized one required
public C1M5(C1M5A1:number,C1M5A2:number=0,C1M5A3:number) { return C1M5A1 + C1M5A2; }
}
@@ -0,0 +1,19 @@
function f1(a, b = 0, c) { }
function f2(a, b = 0, c = 0) { }
function f3(a, b = 0, c?) { }
function f4(a, b = 0, ...c) { }
f1(0, 1, 2);
f2(0, 1, 2);
f3(0, 1, 2);
f4(0, 1, 2);
f1(0, 1);
f2(0, 1);
f3(0, 1);
f4(0, 1);
f1(0);
f2(0);
f3(0);
f4(0);
@@ -0,0 +1,7 @@
interface I1 {
method();
}
class C1 implements I1 {
method(a = 0, b) { }
}
@@ -0,0 +1,8 @@
//@declaration: true
interface I1 {
method();
}
class C1 implements I1 {
method(a = 0, b?) { }
}
@@ -0,0 +1,4 @@
//@declaration: true
class C1 {
method(a = 0, b) { }
}
@@ -0,0 +1,2 @@
interface bar { }
let bar: bar;
@@ -0,0 +1,4 @@
interface foo { }
interface bar { }
let bar: bar | foo;
let foo: bar | foo;
@@ -0,0 +1,8 @@
declare module foo {
interface Bar {
}
}
let foo: foo.Bar;

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