Skip to content

Commit deae9f2

Browse files
committed
Merge branch 'master' into emitNode
2 parents 21c10af + a633652 commit deae9f2

File tree

115 files changed

+2321
-444
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+2321
-444
lines changed

.travis.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ language: node_js
33
node_js:
44
- 'stable'
55
- '4'
6-
- '0.10'
76

87
sudo: false
98

@@ -12,13 +11,6 @@ env:
1211

1312
matrix:
1413
fast_finish: true
15-
include:
16-
- os: osx
17-
node_js: stable
18-
osx_image: xcode7.3
19-
env: workerCount=2
20-
allow_failures:
21-
- os: osx
2214

2315
branches:
2416
only:

src/compiler/checker.ts

Lines changed: 210 additions & 69 deletions
Large diffs are not rendered by default.

src/compiler/commandLineParser.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ namespace ts {
408408
"es2017": "lib.es2017.d.ts",
409409
// Host only
410410
"dom": "lib.dom.d.ts",
411+
"dom.iterable": "lib.dom.iterable.d.ts",
411412
"webworker": "lib.webworker.d.ts",
412413
"scripthost": "lib.scripthost.d.ts",
413414
// ES2015 Or ESNext By-feature options

src/compiler/declarationEmitter.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,6 +1142,10 @@ namespace ts {
11421142
if ((node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature) && node.parent.kind === SyntaxKind.TypeLiteral) {
11431143
emitTypeOfVariableDeclarationFromTypeLiteral(node);
11441144
}
1145+
else if (resolver.isLiteralConstDeclaration(node)) {
1146+
write(" = ");
1147+
resolver.writeLiteralConstValue(node, writer);
1148+
}
11451149
else if (!hasModifier(node, ModifierFlags.Private)) {
11461150
writeTypeOfDeclaration(node, node.type, getVariableDeclarationTypeVisibilityError);
11471151
}

src/compiler/diagnosticMessages.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,10 @@
819819
"category": "Error",
820820
"code": 1253
821821
},
822+
"A 'const' initializer in an ambient context must be a string or numeric literal.": {
823+
"category": "Error",
824+
"code": 1254
825+
},
822826
"'with' statements are not allowed in an async function block.": {
823827
"category": "Error",
824828
"code": 1300
@@ -1959,6 +1963,10 @@
19591963
"category": "Error",
19601964
"code": 2695
19611965
},
1966+
"The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?": {
1967+
"category": "Error",
1968+
"code": 2696
1969+
},
19621970

19631971
"Import declaration '{0}' is using private name '{1}'.": {
19641972
"category": "Error",

src/compiler/factory.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ namespace ts {
416416
return node;
417417
}
418418

419-
export function createObjectLiteral(properties?: ObjectLiteralElement[], location?: TextRange, multiLine?: boolean) {
419+
export function createObjectLiteral(properties?: ObjectLiteralElementLike[], location?: TextRange, multiLine?: boolean) {
420420
const node = <ObjectLiteralExpression>createNode(SyntaxKind.ObjectLiteralExpression, location);
421421
node.properties = createNodeArray(properties);
422422
if (multiLine) {
@@ -425,7 +425,7 @@ namespace ts {
425425
return node;
426426
}
427427

428-
export function updateObjectLiteral(node: ObjectLiteralExpression, properties: ObjectLiteralElement[]) {
428+
export function updateObjectLiteral(node: ObjectLiteralExpression, properties: ObjectLiteralElementLike[]) {
429429
if (node.properties !== properties) {
430430
return updateNode(createObjectLiteral(properties, node, node.multiLine), node);
431431
}
@@ -2069,7 +2069,7 @@ namespace ts {
20692069
}
20702070
}
20712071

2072-
export function createExpressionForObjectLiteralElement(node: ObjectLiteralExpression, property: ObjectLiteralElement, receiver: Expression): Expression {
2072+
export function createExpressionForObjectLiteralElementLike(node: ObjectLiteralExpression, property: ObjectLiteralElementLike, receiver: Expression): Expression {
20732073
switch (property.kind) {
20742074
case SyntaxKind.GetAccessor:
20752075
case SyntaxKind.SetAccessor:
@@ -2086,7 +2086,7 @@ namespace ts {
20862086
function createExpressionForAccessorDeclaration(properties: NodeArray<Declaration>, property: AccessorDeclaration, receiver: Expression, multiLine: boolean) {
20872087
const { firstAccessor, getAccessor, setAccessor } = getAllAccessorDeclarations(properties, property);
20882088
if (property === firstAccessor) {
2089-
const properties: ObjectLiteralElement[] = [];
2089+
const properties: ObjectLiteralElementLike[] = [];
20902090
if (getAccessor) {
20912091
const getterFunction = createFunctionExpression(
20922092
/*asteriskToken*/ undefined,

src/compiler/parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4121,7 +4121,7 @@ namespace ts {
41214121
return undefined;
41224122
}
41234123

4124-
function parseObjectLiteralElement(): ObjectLiteralElement {
4124+
function parseObjectLiteralElement(): ObjectLiteralElementLike {
41254125
const fullStart = scanner.getStartPos();
41264126
const decorators = parseDecorators();
41274127
const modifiers = parseModifiers();

src/compiler/transformers/destructuring.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,22 @@ namespace ts {
126126
context: TransformationContext,
127127
node: VariableDeclaration,
128128
value?: Expression,
129-
visitor?: (node: Node) => VisitResult<Node>) {
129+
visitor?: (node: Node) => VisitResult<Node>,
130+
recordTempVariable?: (node: Identifier) => void) {
130131
const declarations: VariableDeclaration[] = [];
131132

133+
let pendingAssignments: Expression[];
132134
flattenDestructuring(context, node, value, node, emitAssignment, emitTempVariableAssignment, visitor);
133135

134136
return declarations;
135137

136138
function emitAssignment(name: Identifier, value: Expression, location: TextRange, original: Node) {
139+
if (pendingAssignments) {
140+
pendingAssignments.push(value);
141+
value = inlineExpressions(pendingAssignments);
142+
pendingAssignments = undefined;
143+
}
144+
137145
const declaration = createVariableDeclaration(name, /*type*/ undefined, value, location);
138146
declaration.original = original;
139147

@@ -146,8 +154,19 @@ namespace ts {
146154
}
147155

148156
function emitTempVariableAssignment(value: Expression, location: TextRange) {
149-
const name = createTempVariable(/*recordTempVariable*/ undefined);
150-
emitAssignment(name, value, location, /*original*/ undefined);
157+
const name = createTempVariable(recordTempVariable);
158+
if (recordTempVariable) {
159+
const assignment = createAssignment(name, value, location);
160+
if (pendingAssignments) {
161+
pendingAssignments.push(assignment);
162+
}
163+
else {
164+
pendingAssignments = [assignment];
165+
}
166+
}
167+
else {
168+
emitAssignment(name, value, location, /*original*/ undefined);
169+
}
151170
return name;
152171
}
153172
}

0 commit comments

Comments
 (0)