Skip to content

Commit 5f3f6cc

Browse files
committed
Merge branch 'master' of github.com:Microsoft/TypeScript into rest-param-destructuring
2 parents 5b122db + 9c9f3e3 commit 5f3f6cc

File tree

3,966 files changed

+6789
-59941
lines changed

Some content is hidden

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

3,966 files changed

+6789
-59941
lines changed

.mailmap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,3 +358,4 @@ Vyacheslav Pukhanov <[email protected]>
358358
dangoo <[email protected]> # Daniel Gooss
359359
krk <[email protected]> # Kerem Kat
360360
micnic <[email protected]> # Nicu Micleușanu
361+
rflorian <[email protected]> # @rflorian

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Design changes will not be accepted at this time. If you have a design change pr
6161

6262
You will need to complete a Contributor License Agreement (CLA). Briefly, this agreement testifies that you are granting us permission to use the submitted change according to the terms of the project's license, and that the work being submitted is under appropriate copyright.
6363

64-
Please submit a Contributor License Agreement (CLA) before submitting a pull request. You may visit https://cla.microsoft.com to sign digitally. Alternatively, download the agreement ([Microsoft Contribution License Agreement.docx](https://www.codeplex.com/Download?ProjectName=typescript&DownloadId=822190) or [Microsoft Contribution License Agreement.pdf](https://www.codeplex.com/Download?ProjectName=typescript&DownloadId=921298)), sign, scan, and email it back to <[email protected]>. Be sure to include your github user name along with the agreement. Once we have received the signed CLA, we'll review the request.
64+
Please submit a Contributor License Agreement (CLA) before submitting a pull request. You may visit https://cla.microsoft.com to sign digitally. Alternatively, download the agreement ([Microsoft Contribution License Agreement.pdf](https://opensource.microsoft.com/pdf/microsoft-contribution-license-agreement.pdf)), sign, scan, and email it back to <[email protected]>. Be sure to include your github user name along with the agreement. Once we have received the signed CLA, we'll review the request.
6565

6666
## Housekeeping
6767

src/compiler/binder.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2072,7 +2072,10 @@ namespace ts {
20722072
if (isSpecialPropertyDeclaration(node as PropertyAccessExpression)) {
20732073
bindSpecialPropertyDeclaration(node as PropertyAccessExpression);
20742074
}
2075-
if (isInJavaScriptFile(node) && isModuleExportsPropertyAccessExpression(node as PropertyAccessExpression)) {
2075+
if (isInJavaScriptFile(node) &&
2076+
file.commonJsModuleIndicator &&
2077+
isModuleExportsPropertyAccessExpression(node as PropertyAccessExpression) &&
2078+
!lookupSymbolForNameWorker(container, "module" as __String)) {
20762079
declareSymbol(container.locals!, /*parent*/ undefined, (node as PropertyAccessExpression).expression as Identifier,
20772080
SymbolFlags.FunctionScopedVariable | SymbolFlags.ModuleExports, SymbolFlags.FunctionScopedVariableExcludes);
20782081
}

src/compiler/checker.ts

Lines changed: 346 additions & 229 deletions
Large diffs are not rendered by default.

src/compiler/core.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2093,7 +2093,7 @@ namespace ts {
20932093
return arg => f(arg) || g(arg);
20942094
}
20952095

2096-
export function assertTypeIsNever(_: never): void { } // tslint:disable-line no-empty
2096+
export function assertType<T>(_: T): void { } // tslint:disable-line no-empty
20972097

20982098
export function singleElementArray<T>(t: T | undefined): T[] | undefined {
20992099
return t === undefined ? undefined : [t];

src/compiler/diagnosticMessages.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3655,6 +3655,10 @@
36553655
"category": "Message",
36563656
"code": 6204
36573657
},
3658+
"All type parameters are unused": {
3659+
"category": "Error",
3660+
"code": 6205
3661+
},
36583662

36593663
"Projects to reference": {
36603664
"category": "Message",
@@ -4208,6 +4212,14 @@
42084212
"category": "Message",
42094213
"code": 90010
42104214
},
4215+
"Remove template tag": {
4216+
"category": "Message",
4217+
"code": 90011
4218+
},
4219+
"Remove type parameters": {
4220+
"category": "Message",
4221+
"code": 90012
4222+
},
42114223
"Import '{0}' from module \"{1}\"": {
42124224
"category": "Message",
42134225
"code": 90013
@@ -4276,6 +4288,22 @@
42764288
"category": "Message",
42774289
"code": 90029
42784290
},
4291+
"Replace 'infer {0}' with 'unknown'": {
4292+
"category": "Message",
4293+
"code": 90030
4294+
},
4295+
"Replace all unused 'infer' with 'unknown'": {
4296+
"category": "Message",
4297+
"code": 90031
4298+
},
4299+
"Import default '{0}' from module \"{1}\"": {
4300+
"category": "Message",
4301+
"code": 90032
4302+
},
4303+
"Add default import '{0}' to existing import declaration from \"{1}\"": {
4304+
"category": "Message",
4305+
"code": 90033
4306+
},
42794307
"Convert function to an ES2015 class": {
42804308
"category": "Message",
42814309
"code": 95001

src/compiler/factory.ts

Lines changed: 13 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ namespace ts {
10581058
: node;
10591059
}
10601060

1061-
export function createTaggedTemplate(tag: Expression, template: TemplateLiteral): TaggedTemplateExpression;
1061+
/** @deprecated */ export function createTaggedTemplate(tag: Expression, template: TemplateLiteral): TaggedTemplateExpression;
10621062
export function createTaggedTemplate(tag: Expression, typeArguments: ReadonlyArray<TypeNode> | undefined, template: TemplateLiteral): TaggedTemplateExpression;
10631063
/** @internal */
10641064
export function createTaggedTemplate(tag: Expression, typeArgumentsOrTemplate: ReadonlyArray<TypeNode> | TemplateLiteral | undefined, template?: TemplateLiteral): TaggedTemplateExpression;
@@ -1076,7 +1076,7 @@ namespace ts {
10761076
return node;
10771077
}
10781078

1079-
export function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, template: TemplateLiteral): TaggedTemplateExpression;
1079+
/** @deprecated */ export function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, template: TemplateLiteral): TaggedTemplateExpression;
10801080
export function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, typeArguments: ReadonlyArray<TypeNode> | undefined, template: TemplateLiteral): TaggedTemplateExpression;
10811081
export function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, typeArgumentsOrTemplate: ReadonlyArray<TypeNode> | TemplateLiteral | undefined, template?: TemplateLiteral) {
10821082
return node.tag !== tag
@@ -1168,43 +1168,15 @@ namespace ts {
11681168
node.body = parenthesizeConciseBody(body);
11691169
return node;
11701170
}
1171-
1172-
/** @deprecated */ export function updateArrowFunction(
1173-
node: ArrowFunction,
1174-
modifiers: ReadonlyArray<Modifier> | undefined,
1175-
typeParameters: ReadonlyArray<TypeParameterDeclaration> | undefined,
1176-
parameters: ReadonlyArray<ParameterDeclaration>,
1177-
type: TypeNode | undefined,
1178-
body: ConciseBody): ArrowFunction;
11791171
export function updateArrowFunction(
11801172
node: ArrowFunction,
11811173
modifiers: ReadonlyArray<Modifier> | undefined,
11821174
typeParameters: ReadonlyArray<TypeParameterDeclaration> | undefined,
11831175
parameters: ReadonlyArray<ParameterDeclaration>,
11841176
type: TypeNode | undefined,
11851177
equalsGreaterThanToken: Token<SyntaxKind.EqualsGreaterThanToken>,
1186-
body: ConciseBody): ArrowFunction;
1187-
export function updateArrowFunction(
1188-
node: ArrowFunction,
1189-
modifiers: ReadonlyArray<Modifier> | undefined,
1190-
typeParameters: ReadonlyArray<TypeParameterDeclaration> | undefined,
1191-
parameters: ReadonlyArray<ParameterDeclaration>,
1192-
type: TypeNode | undefined,
1193-
equalsGreaterThanTokenOrBody: Token<SyntaxKind.EqualsGreaterThanToken> | ConciseBody,
1194-
bodyOrUndefined?: ConciseBody,
1178+
body: ConciseBody
11951179
): ArrowFunction {
1196-
let equalsGreaterThanToken: Token<SyntaxKind.EqualsGreaterThanToken>;
1197-
let body: ConciseBody;
1198-
if (bodyOrUndefined === undefined) {
1199-
equalsGreaterThanToken = node.equalsGreaterThanToken;
1200-
body = cast(equalsGreaterThanTokenOrBody, isConciseBody);
1201-
}
1202-
else {
1203-
equalsGreaterThanToken = cast(equalsGreaterThanTokenOrBody, (n): n is Token<SyntaxKind.EqualsGreaterThanToken> =>
1204-
n.kind === SyntaxKind.EqualsGreaterThanToken);
1205-
body = bodyOrUndefined;
1206-
}
1207-
12081180
return node.modifiers !== modifiers
12091181
|| node.typeParameters !== typeParameters
12101182
|| node.parameters !== parameters
@@ -1306,7 +1278,7 @@ namespace ts {
13061278
: node;
13071279
}
13081280

1309-
export function createConditional(condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression;
1281+
/** @deprecated */ export function createConditional(condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression;
13101282
export function createConditional(condition: Expression, questionToken: QuestionToken, whenTrue: Expression, colonToken: ColonToken, whenFalse: Expression): ConditionalExpression;
13111283
export function createConditional(condition: Expression, questionTokenOrWhenTrue: QuestionToken | Expression, whenTrueOrWhenFalse: Expression, colonToken?: ColonToken, whenFalse?: Expression) {
13121284
const node = <ConditionalExpression>createSynthesizedNode(SyntaxKind.ConditionalExpression);
@@ -1317,26 +1289,14 @@ namespace ts {
13171289
node.whenFalse = parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenFalse : whenTrueOrWhenFalse);
13181290
return node;
13191291
}
1320-
1321-
/** @deprecated */ export function updateConditional(
1322-
node: ConditionalExpression,
1323-
condition: Expression,
1324-
whenTrue: Expression,
1325-
whenFalse: Expression): ConditionalExpression;
13261292
export function updateConditional(
13271293
node: ConditionalExpression,
13281294
condition: Expression,
13291295
questionToken: Token<SyntaxKind.QuestionToken>,
13301296
whenTrue: Expression,
13311297
colonToken: Token<SyntaxKind.ColonToken>,
1332-
whenFalse: Expression): ConditionalExpression;
1333-
export function updateConditional(node: ConditionalExpression, condition: Expression, ...args: any[]) {
1334-
if (args.length === 2) {
1335-
const [whenTrue, whenFalse] = args;
1336-
return updateConditional(node, condition, node.questionToken, whenTrue, node.colonToken, whenFalse);
1337-
}
1338-
Debug.assert(args.length === 4);
1339-
const [questionToken, whenTrue, colonToken, whenFalse] = args;
1298+
whenFalse: Expression
1299+
): ConditionalExpression {
13401300
return node.condition !== condition
13411301
|| node.questionToken !== questionToken
13421302
|| node.whenTrue !== whenTrue
@@ -2231,7 +2191,7 @@ namespace ts {
22312191
export function createJsxSelfClosingElement(tagName: JsxTagNameExpression, typeArguments: ReadonlyArray<TypeNode> | undefined, attributes: JsxAttributes) {
22322192
const node = <JsxSelfClosingElement>createSynthesizedNode(SyntaxKind.JsxSelfClosingElement);
22332193
node.tagName = tagName;
2234-
node.typeArguments = typeArguments && createNodeArray(typeArguments);
2194+
node.typeArguments = asNodeArray(typeArguments);
22352195
node.attributes = attributes;
22362196
return node;
22372197
}
@@ -2247,7 +2207,7 @@ namespace ts {
22472207
export function createJsxOpeningElement(tagName: JsxTagNameExpression, typeArguments: ReadonlyArray<TypeNode> | undefined, attributes: JsxAttributes) {
22482208
const node = <JsxOpeningElement>createSynthesizedNode(SyntaxKind.JsxOpeningElement);
22492209
node.tagName = tagName;
2250-
node.typeArguments = typeArguments && createNodeArray(typeArguments);
2210+
node.typeArguments = asNodeArray(typeArguments);
22512211
node.attributes = attributes;
22522212
return node;
22532213
}
@@ -4024,6 +3984,11 @@ namespace ts {
40243984
const binaryOperatorPrecedence = getOperatorPrecedence(SyntaxKind.BinaryExpression, binaryOperator);
40253985
const binaryOperatorAssociativity = getOperatorAssociativity(SyntaxKind.BinaryExpression, binaryOperator);
40263986
const emittedOperand = skipPartiallyEmittedExpressions(operand);
3987+
if (!isLeftSideOfBinary && operand.kind === SyntaxKind.ArrowFunction && binaryOperatorPrecedence > 4) {
3988+
// We need to parenthesize arrow functions on the right side to avoid it being
3989+
// parsed as parenthesized expression: `a && (() => {})`
3990+
return true;
3991+
}
40273992
const operandPrecedence = getExpressionPrecedence(emittedOperand);
40283993
switch (compareValues(operandPrecedence, binaryOperatorPrecedence)) {
40293994
case Comparison.LessThan:

0 commit comments

Comments
 (0)