Skip to content

Commit 317f5e2

Browse files
committed
Merge branch 'master' into jsTypingForAcquireDts
2 parents 5b06edb + e2c9555 commit 317f5e2

30 files changed

Lines changed: 640 additions & 49 deletions

src/compiler/checker.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6524,6 +6524,7 @@ namespace ts {
65246524
let targetStack: Type[];
65256525
let depth = 0;
65266526
let inferiority = 0;
6527+
const visited: Map<boolean> = {};
65276528
inferFromTypes(source, target);
65286529

65296530
function isInProcess(source: Type, target: Type) {
@@ -6653,6 +6654,12 @@ namespace ts {
66536654
return;
66546655
}
66556656

6657+
const key = source.id + "," + target.id;
6658+
if (hasProperty(visited, key)) {
6659+
return;
6660+
}
6661+
visited[key] = true;
6662+
66566663
if (depth === 0) {
66576664
sourceStack = [];
66586665
targetStack = [];
@@ -12051,6 +12058,9 @@ namespace ts {
1205112058
if (((node.flags & NodeFlags.AccessibilityModifier) !== (otherAccessor.flags & NodeFlags.AccessibilityModifier))) {
1205212059
error(node.name, Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility);
1205312060
}
12061+
if (((node.flags & NodeFlags.Abstract) !== (otherAccessor.flags & NodeFlags.Abstract))) {
12062+
error(node.name, Diagnostics.Accessors_must_both_be_abstract_or_non_abstract);
12063+
}
1205412064

1205512065
const currentAccessorType = getAnnotatedAccessorType(node);
1205612066
const otherAccessorType = getAnnotatedAccessorType(otherAccessor);
@@ -12196,7 +12206,7 @@ namespace ts {
1219612206
forEach(overloads, o => {
1219712207
const deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags;
1219812208
if (deviation & NodeFlags.Export) {
12199-
error(o.name, Diagnostics.Overload_signatures_must_all_be_exported_or_not_exported);
12209+
error(o.name, Diagnostics.Overload_signatures_must_all_be_exported_or_non_exported);
1220012210
}
1220112211
else if (deviation & NodeFlags.Ambient) {
1220212212
error(o.name, Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient);
@@ -12205,7 +12215,7 @@ namespace ts {
1220512215
error(o.name || o, Diagnostics.Overload_signatures_must_all_be_public_private_or_protected);
1220612216
}
1220712217
else if (deviation & NodeFlags.Abstract) {
12208-
error(o.name, Diagnostics.Overload_signatures_must_all_be_abstract_or_not_abstract);
12218+
error(o.name, Diagnostics.Overload_signatures_must_all_be_abstract_or_non_abstract);
1220912219
}
1221012220
});
1221112221
}
@@ -12250,7 +12260,7 @@ namespace ts {
1225012260
seen = c === node;
1225112261
}
1225212262
});
12253-
// We may be here because of some extra junk between overloads that could not be parsed into a valid node.
12263+
// We may be here because of some extra nodes between overloads that could not be parsed into a valid node.
1225412264
// In this case the subsequent node is not really consecutive (.pos !== node.end), and we must ignore it here.
1225512265
if (subsequentNode && subsequentNode.pos === node.end) {
1225612266
if (subsequentNode.kind === node.kind) {
@@ -16498,8 +16508,11 @@ namespace ts {
1649816508
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "abstract");
1649916509
}
1650016510
if (node.kind !== SyntaxKind.ClassDeclaration) {
16501-
if (node.kind !== SyntaxKind.MethodDeclaration) {
16502-
return grammarErrorOnNode(modifier, Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration);
16511+
if (node.kind !== SyntaxKind.MethodDeclaration &&
16512+
node.kind !== SyntaxKind.PropertyDeclaration &&
16513+
node.kind !== SyntaxKind.GetAccessor &&
16514+
node.kind !== SyntaxKind.SetAccessor) {
16515+
return grammarErrorOnNode(modifier, Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration);
1650316516
}
1650416517
if (!(node.parent.kind === SyntaxKind.ClassDeclaration && node.parent.flags & NodeFlags.Abstract)) {
1650516518
return grammarErrorOnNode(modifier, Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class);
@@ -16993,7 +17006,7 @@ namespace ts {
1699317006
else if (isInAmbientContext(accessor)) {
1699417007
return grammarErrorOnNode(accessor.name, Diagnostics.An_accessor_cannot_be_declared_in_an_ambient_context);
1699517008
}
16996-
else if (accessor.body === undefined) {
17009+
else if (accessor.body === undefined && !(accessor.flags & NodeFlags.Abstract)) {
1699717010
return grammarErrorAtPos(getSourceFileOfNode(accessor), accessor.end - 1, ";".length, Diagnostics._0_expected, "{");
1699817011
}
1699917012
else if (accessor.typeParameters) {

src/compiler/diagnosticMessages.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@
779779
"category": "Error",
780780
"code": 1241
781781
},
782-
"'abstract' modifier can only appear on a class or method declaration.": {
782+
"'abstract' modifier can only appear on a class, method, or property declaration.": {
783783
"category": "Error",
784784
"code": 1242
785785
},
@@ -1151,7 +1151,7 @@
11511151
"category": "Error",
11521152
"code": 2382
11531153
},
1154-
"Overload signatures must all be exported or not exported.": {
1154+
"Overload signatures must all be exported or non-exported.": {
11551155
"category": "Error",
11561156
"code": 2383
11571157
},
@@ -1635,7 +1635,7 @@
16351635
"category": "Error",
16361636
"code": 2511
16371637
},
1638-
"Overload signatures must all be abstract or not abstract.": {
1638+
"Overload signatures must all be abstract or non-abstract.": {
16391639
"category": "Error",
16401640
"code": 2512
16411641
},
@@ -1843,6 +1843,10 @@
18431843
"category": "Error",
18441844
"code": 2675
18451845
},
1846+
"Accessors must both be abstract or non-abstract.": {
1847+
"category": "Error",
1848+
"code": 2676
1849+
},
18461850
"Import declaration '{0}' is using private name '{1}'.": {
18471851
"category": "Error",
18481852
"code": 4000

src/compiler/tsc.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -710,16 +710,19 @@ namespace ts {
710710
else {
711711
const compilerOptions = extend(options, defaultInitCompilerOptions);
712712
const configurations: any = {
713-
compilerOptions: serializeCompilerOptions(compilerOptions)
713+
compilerOptions: serializeCompilerOptions(compilerOptions)
714714
};
715715

716716
if (fileNames && fileNames.length) {
717717
// only set the files property if we have at least one file
718718
configurations.files = fileNames;
719719
}
720-
else {
721-
configurations.exclude = ["node_modules"];
722-
}
720+
else {
721+
configurations.exclude = ["node_modules"];
722+
if (compilerOptions.outDir) {
723+
configurations.exclude.push(compilerOptions.outDir);
724+
}
725+
}
723726

724727
sys.writeFile(file, JSON.stringify(configurations, undefined, 4));
725728
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Successfully_created_a_tsconfig_json_file), /* compilerHost */ undefined);

src/services/services.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2838,7 +2838,7 @@ namespace ts {
28382838
if (oldSourceFile) {
28392839
// We already had a source file for this file name. Go to the registry to
28402840
// ensure that we get the right up to date version of it. We need this to
2841-
// address the following 'race'. Specifically, say we have the following:
2841+
// address the following race-condition. Specifically, say we have the following:
28422842
//
28432843
// LS1
28442844
// \
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//// [VariableDeclaration12_es6.ts]
2+
3+
let
4+
x
5+
6+
//// [VariableDeclaration12_es6.js]
7+
let x;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
=== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration12_es6.ts ===
2+
3+
let
4+
x
5+
>x : Symbol(x, Decl(VariableDeclaration12_es6.ts, 1, 3))
6+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
=== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration12_es6.ts ===
2+
3+
let
4+
x
5+
>x : any
6+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
tests/cases/conformance/es6/variableDeclarations/VariableDeclaration13_es6.ts(5,5): error TS1181: Array element destructuring pattern expected.
2+
tests/cases/conformance/es6/variableDeclarations/VariableDeclaration13_es6.ts(5,6): error TS1005: ',' expected.
3+
tests/cases/conformance/es6/variableDeclarations/VariableDeclaration13_es6.ts(5,8): error TS1134: Variable declaration expected.
4+
tests/cases/conformance/es6/variableDeclarations/VariableDeclaration13_es6.ts(5,10): error TS1134: Variable declaration expected.
5+
6+
7+
==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration13_es6.ts (4 errors) ====
8+
9+
// An ExpressionStatement cannot start with the two token sequence `let [` because
10+
// that would make it ambiguous with a `let` LexicalDeclaration whose first LexicalBinding was an ArrayBindingPattern.
11+
var let: any;
12+
let[0] = 100;
13+
~
14+
!!! error TS1181: Array element destructuring pattern expected.
15+
~
16+
!!! error TS1005: ',' expected.
17+
~
18+
!!! error TS1134: Variable declaration expected.
19+
~~~
20+
!!! error TS1134: Variable declaration expected.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//// [VariableDeclaration13_es6.ts]
2+
3+
// An ExpressionStatement cannot start with the two token sequence `let [` because
4+
// that would make it ambiguous with a `let` LexicalDeclaration whose first LexicalBinding was an ArrayBindingPattern.
5+
var let: any;
6+
let[0] = 100;
7+
8+
//// [VariableDeclaration13_es6.js]
9+
// An ExpressionStatement cannot start with the two token sequence `let [` because
10+
// that would make it ambiguous with a `let` LexicalDeclaration whose first LexicalBinding was an ArrayBindingPattern.
11+
var let;
12+
let [] = 0;
13+
100;
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
//// [abstractProperty.ts]
2+
interface A {
3+
prop: string;
4+
raw: string;
5+
m(): void;
6+
}
7+
abstract class B implements A {
8+
abstract prop: string;
9+
abstract raw: string;
10+
abstract readonly ro: string;
11+
abstract get readonlyProp(): string;
12+
abstract set readonlyProp(val: string);
13+
abstract m(): void;
14+
}
15+
class C extends B {
16+
get prop() { return "foo"; }
17+
set prop(v) { }
18+
raw = "edge";
19+
readonly ro = "readonly please";
20+
readonlyProp: string; // don't have to give a value, in fact
21+
m() { }
22+
}
23+
24+
//// [abstractProperty.js]
25+
var __extends = (this && this.__extends) || function (d, b) {
26+
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
27+
function __() { this.constructor = d; }
28+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
29+
};
30+
var B = (function () {
31+
function B() {
32+
}
33+
Object.defineProperty(B.prototype, "readonlyProp", {
34+
get: function () { },
35+
set: function (val) { },
36+
enumerable: true,
37+
configurable: true
38+
});
39+
return B;
40+
}());
41+
var C = (function (_super) {
42+
__extends(C, _super);
43+
function C() {
44+
_super.apply(this, arguments);
45+
this.raw = "edge";
46+
this.ro = "readonly please";
47+
}
48+
Object.defineProperty(C.prototype, "prop", {
49+
get: function () { return "foo"; },
50+
set: function (v) { },
51+
enumerable: true,
52+
configurable: true
53+
});
54+
C.prototype.m = function () { };
55+
return C;
56+
}(B));

0 commit comments

Comments
 (0)