Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b59e4c5

Browse filesBrowse files
committed
Merge branch 'master' into logical_assignment
2 parents 6f393e9 + 5f597e6 commit b59e4c5
Copy full SHA for b59e4c5

108 files changed

+4,093-1,009Lines changed: 4093 additions & 1009 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎CONTRIBUTING.md‎

Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+203-216Lines changed: 203 additions & 216 deletions
  • Display the source diff
  • Display the rich diff
Large diffs are not rendered by default.
Collapse file

‎src/compiler/binder.ts‎

Copy file name to clipboardExpand all lines: src/compiler/binder.ts
+8-2Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,7 @@ namespace ts {
988988
return initFlowNode({ flags: FlowFlags.SwitchClause, antecedent, switchStatement, clauseStart, clauseEnd });
989989
}
990990

991-
function createFlowMutation(flags: FlowFlags, antecedent: FlowNode, node: Node): FlowNode {
991+
function createFlowMutation(flags: FlowFlags, antecedent: FlowNode, node: Expression | VariableDeclaration | ArrayBindingElement): FlowNode {
992992
setFlowNodeReferenced(antecedent);
993993
const result = initFlowNode({ flags, antecedent, node });
994994
if (currentExceptionTarget) {
@@ -1350,7 +1350,7 @@ namespace ts {
13501350
// is potentially an assertion and is therefore included in the control flow.
13511351
if (node.expression.kind === SyntaxKind.CallExpression) {
13521352
const call = <CallExpression>node.expression;
1353-
if (isDottedName(call.expression)) {
1353+
if (isDottedName(call.expression) && call.expression.kind !== SyntaxKind.SuperKeyword) {
13541354
currentFlow = createFlowCall(currentFlow, call);
13551355
}
13561356
}
@@ -1767,6 +1767,9 @@ namespace ts {
17671767
}
17681768
else {
17691769
bindEachChild(node);
1770+
if (node.expression.kind === SyntaxKind.SuperKeyword) {
1771+
currentFlow = createFlowCall(currentFlow, node);
1772+
}
17701773
}
17711774
}
17721775
if (node.expression.kind === SyntaxKind.PropertyAccessExpression) {
@@ -2484,6 +2487,9 @@ namespace ts {
24842487
node.flowNode = currentFlow;
24852488
}
24862489
return checkStrictModeIdentifier(<Identifier>node);
2490+
case SyntaxKind.SuperKeyword:
2491+
node.flowNode = currentFlow;
2492+
break;
24872493
case SyntaxKind.PrivateIdentifier:
24882494
return checkPrivateIdentifier(node as PrivateIdentifier);
24892495
case SyntaxKind.PropertyAccessExpression:
Collapse file

‎src/compiler/checker.ts‎

Copy file name to clipboardExpand all lines: src/compiler/checker.ts
+251-105Lines changed: 251 additions & 105 deletions
Large diffs are not rendered by default.
Collapse file

‎src/compiler/core.ts‎

Copy file name to clipboardExpand all lines: src/compiler/core.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ namespace ts {
150150
* returns a falsey value, then returns false.
151151
* If no such value is found, the callback is applied to each element of array and `true` is returned.
152152
*/
153-
export function every<T>(array: readonly T[], callback: (element: T, index: number) => boolean): boolean {
153+
export function every<T>(array: readonly T[] | undefined, callback: (element: T, index: number) => boolean): boolean {
154154
if (array) {
155155
for (let i = 0; i < array.length; i++) {
156156
if (!callback(array[i], i)) {
Collapse file

‎src/compiler/diagnosticMessages.json‎

Copy file name to clipboardExpand all lines: src/compiler/diagnosticMessages.json
+24Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3517,6 +3517,22 @@
35173517
"category": "Error",
35183518
"code": 5083
35193519
},
3520+
"Tuple members must all have names or all not have names.": {
3521+
"category": "Error",
3522+
"code": 5084
3523+
},
3524+
"A tuple member cannot be both optional and rest.": {
3525+
"category": "Error",
3526+
"code": 5085
3527+
},
3528+
"A labeled tuple element is declared as optional with a question mark after the name and before the colon, rather than after the type.": {
3529+
"category": "Error",
3530+
"code": 5086
3531+
},
3532+
"A labeled tuple element is declared as rest with a `...` before the name, rather than before the type.": {
3533+
"category": "Error",
3534+
"code": 5087
3535+
},
35203536

35213537
"Generates a sourcemap for each corresponding '.d.ts' file.": {
35223538
"category": "Message",
@@ -5677,6 +5693,14 @@
56775693
"category": "Message",
56785694
"code": 95116
56795695
},
5696+
"Move labeled tuple element modifiers to labels": {
5697+
"category": "Message",
5698+
"code": 95117
5699+
},
5700+
"Convert overload list to single signature": {
5701+
"category": "Message",
5702+
"code": 95118
5703+
},
56805704

56815705
"No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer.": {
56825706
"category": "Error",
Collapse file

‎src/compiler/emitter.ts‎

Copy file name to clipboardExpand all lines: src/compiler/emitter.ts
+16-4Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,6 +1370,8 @@ namespace ts {
13701370
case SyntaxKind.RestType:
13711371
case SyntaxKind.JSDocVariadicType:
13721372
return emitRestOrJSDocVariadicType(node as RestTypeNode | JSDocVariadicType);
1373+
case SyntaxKind.NamedTupleMember:
1374+
return emitNamedTupleMember(node as NamedTupleMember);
13731375

13741376
// Binding patterns
13751377
case SyntaxKind.ObjectBindingPattern:
@@ -2099,9 +2101,19 @@ namespace ts {
20992101
}
21002102

21012103
function emitTupleType(node: TupleTypeNode) {
2102-
writePunctuation("[");
2103-
emitList(node, node.elementTypes, ListFormat.TupleTypeElements);
2104-
writePunctuation("]");
2104+
emitTokenWithComment(SyntaxKind.OpenBracketToken, node.pos, writePunctuation, node);
2105+
const flags = getEmitFlags(node) & EmitFlags.SingleLine ? ListFormat.SingleLineTupleTypeElements : ListFormat.MultiLineTupleTypeElements;
2106+
emitList(node, node.elements, flags | ListFormat.NoSpaceIfEmpty);
2107+
emitTokenWithComment(SyntaxKind.CloseBracketToken, node.elements.end, writePunctuation, node);
2108+
}
2109+
2110+
function emitNamedTupleMember(node: NamedTupleMember) {
2111+
emit(node.dotDotDotToken);
2112+
emit(node.name);
2113+
emit(node.questionToken);
2114+
emitTokenWithComment(SyntaxKind.ColonToken, node.name.end, writePunctuation, node);
2115+
writeSpace();
2116+
emit(node.type);
21052117
}
21062118

21072119
function emitOptionalType(node: OptionalTypeNode) {
@@ -4968,7 +4980,7 @@ namespace ts {
49684980
}
49694981

49704982
function emitLeadingSynthesizedComment(comment: SynthesizedComment) {
4971-
if (comment.kind === SyntaxKind.SingleLineCommentTrivia) {
4983+
if (comment.hasLeadingNewline || comment.kind === SyntaxKind.SingleLineCommentTrivia) {
49724984
writer.writeLine();
49734985
}
49744986
writeSynthesizedComment(comment);
Collapse file

‎src/compiler/factoryPublic.ts‎

Copy file name to clipboardExpand all lines: src/compiler/factoryPublic.ts
+38-5Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -810,15 +810,15 @@ namespace ts {
810810
: node;
811811
}
812812

813-
export function createTupleTypeNode(elementTypes: readonly TypeNode[]) {
813+
export function createTupleTypeNode(elements: readonly (TypeNode | NamedTupleMember)[]) {
814814
const node = createSynthesizedNode(SyntaxKind.TupleType) as TupleTypeNode;
815-
node.elementTypes = createNodeArray(elementTypes);
815+
node.elements = createNodeArray(elements);
816816
return node;
817817
}
818818

819-
export function updateTupleTypeNode(node: TupleTypeNode, elementTypes: readonly TypeNode[]) {
820-
return node.elementTypes !== elementTypes
821-
? updateNode(createTupleTypeNode(elementTypes), node)
819+
export function updateTupleTypeNode(node: TupleTypeNode, elements: readonly (TypeNode | NamedTupleMember)[]) {
820+
return node.elements !== elements
821+
? updateNode(createTupleTypeNode(elements), node)
822822
: node;
823823
}
824824

@@ -934,6 +934,24 @@ namespace ts {
934934
: node;
935935
}
936936

937+
export function createNamedTupleMember(dotDotDotToken: Token<SyntaxKind.DotDotDotToken> | undefined, name: Identifier, questionToken: Token<SyntaxKind.QuestionToken> | undefined, type: TypeNode) {
938+
const node = <NamedTupleMember>createSynthesizedNode(SyntaxKind.NamedTupleMember);
939+
node.dotDotDotToken = dotDotDotToken;
940+
node.name = name;
941+
node.questionToken = questionToken;
942+
node.type = type;
943+
return node;
944+
}
945+
946+
export function updateNamedTupleMember(node: NamedTupleMember, dotDotDotToken: Token<SyntaxKind.DotDotDotToken> | undefined, name: Identifier, questionToken: Token<SyntaxKind.QuestionToken> | undefined, type: TypeNode) {
947+
return node.dotDotDotToken !== dotDotDotToken
948+
|| node.name !== name
949+
|| node.questionToken !== questionToken
950+
|| node.type !== type
951+
? updateNode(createNamedTupleMember(dotDotDotToken, name, questionToken, type), node)
952+
: node;
953+
}
954+
937955
export function createThisTypeNode() {
938956
return <ThisTypeNode>createSynthesizedNode(SyntaxKind.ThisType);
939957
}
@@ -2616,6 +2634,21 @@ namespace ts {
26162634
return node;
26172635
}
26182636

2637+
2638+
/* @internal */
2639+
export function createJSDocVariadicType(type: TypeNode): JSDocVariadicType {
2640+
const node = createSynthesizedNode(SyntaxKind.JSDocVariadicType) as JSDocVariadicType;
2641+
node.type = type;
2642+
return node;
2643+
}
2644+
2645+
/* @internal */
2646+
export function updateJSDocVariadicType(node: JSDocVariadicType, type: TypeNode): JSDocVariadicType {
2647+
return node.type !== type
2648+
? updateNode(createJSDocVariadicType(type), node)
2649+
: node;
2650+
}
2651+
26192652
// JSX
26202653

26212654
export function createJsxElement(openingElement: JsxOpeningElement, children: readonly JsxChild[], closingElement: JsxClosingElement) {
Collapse file

‎src/compiler/parser.ts‎

Copy file name to clipboardExpand all lines: src/compiler/parser.ts
+31-2Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ namespace ts {
179179
case SyntaxKind.ArrayType:
180180
return visitNode(cbNode, (<ArrayTypeNode>node).elementType);
181181
case SyntaxKind.TupleType:
182-
return visitNodes(cbNode, cbNodes, (<TupleTypeNode>node).elementTypes);
182+
return visitNodes(cbNode, cbNodes, (<TupleTypeNode>node).elements);
183183
case SyntaxKind.UnionType:
184184
case SyntaxKind.IntersectionType:
185185
return visitNodes(cbNode, cbNodes, (<UnionOrIntersectionTypeNode>node).types);
@@ -207,6 +207,11 @@ namespace ts {
207207
visitNode(cbNode, (<MappedTypeNode>node).type);
208208
case SyntaxKind.LiteralType:
209209
return visitNode(cbNode, (<LiteralTypeNode>node).literal);
210+
case SyntaxKind.NamedTupleMember:
211+
return visitNode(cbNode, (<NamedTupleMember>node).dotDotDotToken) ||
212+
visitNode(cbNode, (<NamedTupleMember>node).name) ||
213+
visitNode(cbNode, (<NamedTupleMember>node).questionToken) ||
214+
visitNode(cbNode, (<NamedTupleMember>node).type);
210215
case SyntaxKind.ObjectBindingPattern:
211216
case SyntaxKind.ArrayBindingPattern:
212217
return visitNodes(cbNode, cbNodes, (<BindingPattern>node).elements);
@@ -3056,9 +3061,33 @@ namespace ts {
30563061
return type;
30573062
}
30583063

3064+
function isNextTokenColonOrQuestionColon() {
3065+
return nextToken() === SyntaxKind.ColonToken || (token() === SyntaxKind.QuestionToken && nextToken() === SyntaxKind.ColonToken);
3066+
}
3067+
3068+
function isTupleElementName() {
3069+
if (token() === SyntaxKind.DotDotDotToken) {
3070+
return tokenIsIdentifierOrKeyword(nextToken()) && isNextTokenColonOrQuestionColon();
3071+
}
3072+
return tokenIsIdentifierOrKeyword(token()) && isNextTokenColonOrQuestionColon();
3073+
}
3074+
3075+
function parseTupleElementNameOrTupleElementType() {
3076+
if (lookAhead(isTupleElementName)) {
3077+
const node = <NamedTupleMember>createNode(SyntaxKind.NamedTupleMember);
3078+
node.dotDotDotToken = parseOptionalToken(SyntaxKind.DotDotDotToken);
3079+
node.name = parseIdentifierName();
3080+
node.questionToken = parseOptionalToken(SyntaxKind.QuestionToken);
3081+
parseExpected(SyntaxKind.ColonToken);
3082+
node.type = parseTupleElementType();
3083+
return addJSDocComment(finishNode(node));
3084+
}
3085+
return parseTupleElementType();
3086+
}
3087+
30593088
function parseTupleType(): TupleTypeNode {
30603089
const node = <TupleTypeNode>createNode(SyntaxKind.TupleType);
3061-
node.elementTypes = parseBracketedList(ParsingContext.TupleElementTypes, parseTupleElementType, SyntaxKind.OpenBracketToken, SyntaxKind.CloseBracketToken);
3090+
node.elements = parseBracketedList(ParsingContext.TupleElementTypes, parseTupleElementNameOrTupleElementType, SyntaxKind.OpenBracketToken, SyntaxKind.CloseBracketToken);
30623091
return finishNode(node);
30633092
}
30643093

Collapse file

‎src/compiler/transformers/declarations.ts‎

Copy file name to clipboardExpand all lines: src/compiler/transformers/declarations.ts
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,6 +1018,10 @@ namespace ts {
10181018
}
10191019
}
10201020

1021+
if (isTupleTypeNode(input) && (getLineAndCharacterOfPosition(currentSourceFile, input.pos).line === getLineAndCharacterOfPosition(currentSourceFile, input.end).line)) {
1022+
setEmitFlags(input, EmitFlags.SingleLine);
1023+
}
1024+
10211025
return cleanup(visitEachChild(input, visitDeclarationSubtree, context));
10221026

10231027
function cleanup<T extends Node>(returnValue: T | undefined): T | undefined {
Collapse file

‎src/compiler/transformers/taggedTemplate.ts‎

Copy file name to clipboardExpand all lines: src/compiler/transformers/taggedTemplate.ts
+11-8Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,21 @@ namespace ts {
7373
*
7474
* @param node The ES6 template literal.
7575
*/
76-
function getRawLiteral(node: LiteralLikeNode, currentSourceFile: SourceFile) {
76+
function getRawLiteral(node: TemplateLiteralLikeNode, currentSourceFile: SourceFile) {
7777
// Find original source text, since we need to emit the raw strings of the tagged template.
7878
// The raw strings contain the (escaped) strings of what the user wrote.
7979
// Examples: `\n` is converted to "\\n", a template string with a newline to "\n".
80-
let text = getSourceTextOfNodeFromSourceFile(currentSourceFile, node);
80+
let text = node.rawText;
81+
if (text === undefined) {
82+
text = getSourceTextOfNodeFromSourceFile(currentSourceFile, node);
8183

82-
// text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"),
83-
// thus we need to remove those characters.
84-
// First template piece starts with "`", others with "}"
85-
// Last template piece ends with "`", others with "${"
86-
const isLast = node.kind === SyntaxKind.NoSubstitutionTemplateLiteral || node.kind === SyntaxKind.TemplateTail;
87-
text = text.substring(1, text.length - (isLast ? 1 : 2));
84+
// text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"),
85+
// thus we need to remove those characters.
86+
// First template piece starts with "`", others with "}"
87+
// Last template piece ends with "`", others with "${"
88+
const isLast = node.kind === SyntaxKind.NoSubstitutionTemplateLiteral || node.kind === SyntaxKind.TemplateTail;
89+
text = text.substring(1, text.length - (isLast ? 1 : 2));
90+
}
8891

8992
// Newline normalization:
9093
// ES6 Spec 11.8.6.1 - Static Semantics of TV's and TRV's

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.