Merge branch 'master' into jsTypingForAcquireDts

This commit is contained in:
Jason Ramsay
2016-02-22 19:01:09 -08:00
30 changed files with 640 additions and 49 deletions

View File

@@ -6524,6 +6524,7 @@ namespace ts {
let targetStack: Type[];
let depth = 0;
let inferiority = 0;
const visited: Map<boolean> = {};
inferFromTypes(source, target);
function isInProcess(source: Type, target: Type) {
@@ -6653,6 +6654,12 @@ namespace ts {
return;
}
const key = source.id + "," + target.id;
if (hasProperty(visited, key)) {
return;
}
visited[key] = true;
if (depth === 0) {
sourceStack = [];
targetStack = [];
@@ -12051,6 +12058,9 @@ namespace ts {
if (((node.flags & NodeFlags.AccessibilityModifier) !== (otherAccessor.flags & NodeFlags.AccessibilityModifier))) {
error(node.name, Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility);
}
if (((node.flags & NodeFlags.Abstract) !== (otherAccessor.flags & NodeFlags.Abstract))) {
error(node.name, Diagnostics.Accessors_must_both_be_abstract_or_non_abstract);
}
const currentAccessorType = getAnnotatedAccessorType(node);
const otherAccessorType = getAnnotatedAccessorType(otherAccessor);
@@ -12196,7 +12206,7 @@ namespace ts {
forEach(overloads, o => {
const deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags;
if (deviation & NodeFlags.Export) {
error(o.name, Diagnostics.Overload_signatures_must_all_be_exported_or_not_exported);
error(o.name, Diagnostics.Overload_signatures_must_all_be_exported_or_non_exported);
}
else if (deviation & NodeFlags.Ambient) {
error(o.name, Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient);
@@ -12205,7 +12215,7 @@ namespace ts {
error(o.name || o, Diagnostics.Overload_signatures_must_all_be_public_private_or_protected);
}
else if (deviation & NodeFlags.Abstract) {
error(o.name, Diagnostics.Overload_signatures_must_all_be_abstract_or_not_abstract);
error(o.name, Diagnostics.Overload_signatures_must_all_be_abstract_or_non_abstract);
}
});
}
@@ -12250,7 +12260,7 @@ namespace ts {
seen = c === node;
}
});
// We may be here because of some extra junk between overloads that could not be parsed into a valid node.
// We may be here because of some extra nodes between overloads that could not be parsed into a valid node.
// In this case the subsequent node is not really consecutive (.pos !== node.end), and we must ignore it here.
if (subsequentNode && subsequentNode.pos === node.end) {
if (subsequentNode.kind === node.kind) {
@@ -16498,8 +16508,11 @@ namespace ts {
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "abstract");
}
if (node.kind !== SyntaxKind.ClassDeclaration) {
if (node.kind !== SyntaxKind.MethodDeclaration) {
return grammarErrorOnNode(modifier, Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration);
if (node.kind !== SyntaxKind.MethodDeclaration &&
node.kind !== SyntaxKind.PropertyDeclaration &&
node.kind !== SyntaxKind.GetAccessor &&
node.kind !== SyntaxKind.SetAccessor) {
return grammarErrorOnNode(modifier, Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration);
}
if (!(node.parent.kind === SyntaxKind.ClassDeclaration && node.parent.flags & NodeFlags.Abstract)) {
return grammarErrorOnNode(modifier, Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class);
@@ -16993,7 +17006,7 @@ namespace ts {
else if (isInAmbientContext(accessor)) {
return grammarErrorOnNode(accessor.name, Diagnostics.An_accessor_cannot_be_declared_in_an_ambient_context);
}
else if (accessor.body === undefined) {
else if (accessor.body === undefined && !(accessor.flags & NodeFlags.Abstract)) {
return grammarErrorAtPos(getSourceFileOfNode(accessor), accessor.end - 1, ";".length, Diagnostics._0_expected, "{");
}
else if (accessor.typeParameters) {

View File

@@ -779,7 +779,7 @@
"category": "Error",
"code": 1241
},
"'abstract' modifier can only appear on a class or method declaration.": {
"'abstract' modifier can only appear on a class, method, or property declaration.": {
"category": "Error",
"code": 1242
},
@@ -1151,7 +1151,7 @@
"category": "Error",
"code": 2382
},
"Overload signatures must all be exported or not exported.": {
"Overload signatures must all be exported or non-exported.": {
"category": "Error",
"code": 2383
},
@@ -1635,7 +1635,7 @@
"category": "Error",
"code": 2511
},
"Overload signatures must all be abstract or not abstract.": {
"Overload signatures must all be abstract or non-abstract.": {
"category": "Error",
"code": 2512
},
@@ -1843,6 +1843,10 @@
"category": "Error",
"code": 2675
},
"Accessors must both be abstract or non-abstract.": {
"category": "Error",
"code": 2676
},
"Import declaration '{0}' is using private name '{1}'.": {
"category": "Error",
"code": 4000

View File

@@ -710,16 +710,19 @@ namespace ts {
else {
const compilerOptions = extend(options, defaultInitCompilerOptions);
const configurations: any = {
compilerOptions: serializeCompilerOptions(compilerOptions)
compilerOptions: serializeCompilerOptions(compilerOptions)
};
if (fileNames && fileNames.length) {
// only set the files property if we have at least one file
configurations.files = fileNames;
}
else {
configurations.exclude = ["node_modules"];
}
else {
configurations.exclude = ["node_modules"];
if (compilerOptions.outDir) {
configurations.exclude.push(compilerOptions.outDir);
}
}
sys.writeFile(file, JSON.stringify(configurations, undefined, 4));
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Successfully_created_a_tsconfig_json_file), /* compilerHost */ undefined);

View File

@@ -2838,7 +2838,7 @@ namespace ts {
if (oldSourceFile) {
// We already had a source file for this file name. Go to the registry to
// ensure that we get the right up to date version of it. We need this to
// address the following 'race'. Specifically, say we have the following:
// address the following race-condition. Specifically, say we have the following:
//
// LS1
// \