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 eb4a036

Browse filesBrowse files
committed
Merge branch 'master' into symbolic-declaration-files
2 parents 550014d + 70b7bd5 commit eb4a036
Copy full SHA for eb4a036

117 files changed

+11,687-11,414Lines changed: 11687 additions & 11414 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

‎src/compiler/checker.ts‎

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

‎src/compiler/diagnosticMessages.json‎

Copy file name to clipboardExpand all lines: src/compiler/diagnosticMessages.json
-4Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5121,10 +5121,6 @@
51215121
"category": "Error",
51225122
"code": 18004
51235123
},
5124-
"Quoted constructors have previously been interpreted as methods, which is incorrect. In TypeScript 3.6, they will be correctly parsed as constructors. In the meantime, consider using 'constructor()' to write a constructor, or '[\"constructor\"]()' to write a method.": {
5125-
"category": "Error",
5126-
"code": 18005
5127-
},
51285124
"Classes may not have a field named 'constructor'.": {
51295125
"category": "Error",
51305126
"code": 18006
Collapse file

‎src/compiler/emitter.ts‎

Copy file name to clipboardExpand all lines: src/compiler/emitter.ts
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,11 @@ namespace ts {
408408
}
409409
);
410410
if (emitOnlyDtsFiles && declarationTransform.transformed[0].kind === SyntaxKind.SourceFile) {
411-
const sourceFile = declarationTransform.transformed[0] as SourceFile;
411+
// Improved narrowing in master/3.6 makes this cast unnecessary, triggering a lint rule.
412+
// But at the same time, the LKG (3.5) necessitates it because it doesn’t narrow.
413+
// Once the LKG is updated to 3.6, this comment, the cast to `SourceFile`, and the
414+
// tslint directive can be all be removed.
415+
const sourceFile = declarationTransform.transformed[0] as SourceFile; // tslint:disable-line
412416
exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit;
413417
}
414418
}
Collapse file

‎src/compiler/factory.ts‎

Copy file name to clipboardExpand all lines: src/compiler/factory.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4706,7 +4706,7 @@ namespace ts {
47064706
}
47074707
}
47084708

4709-
function getLeftmostExpression(node: Expression, stopAtCallExpressions: boolean) {
4709+
export function getLeftmostExpression(node: Expression, stopAtCallExpressions: boolean) {
47104710
while (true) {
47114711
switch (node.kind) {
47124712
case SyntaxKind.PostfixUnaryExpression:
Collapse file

‎src/compiler/parser.ts‎

Copy file name to clipboardExpand all lines: src/compiler/parser.ts
+26-8Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5656,12 +5656,27 @@ namespace ts {
56565656
return finishNode(node);
56575657
}
56585658

5659-
function parseConstructorDeclaration(node: ConstructorDeclaration): ConstructorDeclaration {
5660-
node.kind = SyntaxKind.Constructor;
5661-
parseExpected(SyntaxKind.ConstructorKeyword);
5662-
fillSignature(SyntaxKind.ColonToken, SignatureFlags.None, node);
5663-
node.body = parseFunctionBlockOrSemicolon(SignatureFlags.None, Diagnostics.or_expected);
5664-
return finishNode(node);
5659+
function parseConstructorName() {
5660+
if (token() === SyntaxKind.ConstructorKeyword) {
5661+
return parseExpected(SyntaxKind.ConstructorKeyword);
5662+
}
5663+
if (token() === SyntaxKind.StringLiteral && lookAhead(nextToken) === SyntaxKind.OpenParenToken) {
5664+
return tryParse(() => {
5665+
const literalNode = parseLiteralNode();
5666+
return literalNode.text === "constructor" ? literalNode : undefined;
5667+
});
5668+
}
5669+
}
5670+
5671+
function tryParseConstructorDeclaration(node: ConstructorDeclaration): ConstructorDeclaration | undefined {
5672+
return tryParse(() => {
5673+
if (parseConstructorName()) {
5674+
node.kind = SyntaxKind.Constructor;
5675+
fillSignature(SyntaxKind.ColonToken, SignatureFlags.None, node);
5676+
node.body = parseFunctionBlockOrSemicolon(SignatureFlags.None, Diagnostics.or_expected);
5677+
return finishNode(node);
5678+
}
5679+
});
56655680
}
56665681

56675682
function parseMethodDeclaration(node: MethodDeclaration, asteriskToken: AsteriskToken, diagnosticMessage?: DiagnosticMessage): MethodDeclaration {
@@ -5867,8 +5882,11 @@ namespace ts {
58675882
return parseAccessorDeclaration(<AccessorDeclaration>node, SyntaxKind.SetAccessor);
58685883
}
58695884

5870-
if (token() === SyntaxKind.ConstructorKeyword) {
5871-
return parseConstructorDeclaration(<ConstructorDeclaration>node);
5885+
if (token() === SyntaxKind.ConstructorKeyword || token() === SyntaxKind.StringLiteral) {
5886+
const constructorDeclaration = tryParseConstructorDeclaration(<ConstructorDeclaration>node);
5887+
if (constructorDeclaration) {
5888+
return constructorDeclaration;
5889+
}
58725890
}
58735891

58745892
if (isIndexSignature()) {
Collapse file

‎src/compiler/scanner.ts‎

Copy file name to clipboardExpand all lines: src/compiler/scanner.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ namespace ts {
197197
"|=": SyntaxKind.BarEqualsToken,
198198
"^=": SyntaxKind.CaretEqualsToken,
199199
"@": SyntaxKind.AtToken,
200+
"`": SyntaxKind.BacktickToken
200201
});
201202

202203
/*
@@ -298,7 +299,6 @@ namespace ts {
298299
}
299300

300301
const tokenStrings = makeReverseMap(textToToken);
301-
302302
export function tokenToString(t: SyntaxKind): string | undefined {
303303
return tokenStrings[t];
304304
}
Collapse file

‎src/compiler/types.ts‎

Copy file name to clipboardExpand all lines: src/compiler/types.ts
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1882,6 +1882,7 @@ namespace ts {
18821882
}
18831883

18841884
export interface JsxAttributes extends ObjectLiteralExpressionBase<JsxAttributeLike> {
1885+
kind: SyntaxKind.JsxAttributes;
18851886
parent: JsxOpeningLikeElement;
18861887
}
18871888

@@ -4767,7 +4768,7 @@ namespace ts {
47674768
UMD = 3,
47684769
System = 4,
47694770
ES2015 = 5,
4770-
ESNext = 6
4771+
ESNext = 99
47714772
}
47724773

47734774
export const enum JsxEmit {
@@ -4815,7 +4816,7 @@ namespace ts {
48154816
ES2018 = 5,
48164817
ES2019 = 6,
48174818
ES2020 = 7,
4818-
ESNext = 8,
4819+
ESNext = 99,
48194820
JSON = 100,
48204821
Latest = ESNext,
48214822
}
Collapse file

‎src/compiler/utilities.ts‎

Copy file name to clipboardExpand all lines: src/compiler/utilities.ts
+18-1Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3173,6 +3173,23 @@ namespace ts {
31733173
return s.replace(escapedCharsRegExp, getReplacement);
31743174
}
31753175

3176+
/**
3177+
* Strip off existed single quotes or double quotes from a given string
3178+
*
3179+
* @return non-quoted string
3180+
*/
3181+
export function stripQuotes(name: string) {
3182+
const length = name.length;
3183+
if (length >= 2 && name.charCodeAt(0) === name.charCodeAt(length - 1) && startsWithQuote(name)) {
3184+
return name.substring(1, length - 1);
3185+
}
3186+
return name;
3187+
}
3188+
3189+
export function startsWithQuote(name: string): boolean {
3190+
return isSingleOrDoubleQuote(name.charCodeAt(0));
3191+
}
3192+
31763193
function getReplacement(c: string, offset: number, input: string) {
31773194
if (c.charCodeAt(0) === CharacterCodes.nullCharacter) {
31783195
const lookAhead = input.charCodeAt(offset + c.length);
@@ -7529,7 +7546,7 @@ namespace ts {
75297546
export function getDirectoryPath(path: Path): Path;
75307547
/**
75317548
* Returns the path except for its basename. Semantics align with NodeJS's `path.dirname`
7532-
* except that we support URLs as well.
7549+
* except that we support URL's as well.
75337550
*
75347551
* ```ts
75357552
* getDirectoryPath("/path/to/file.ext") === "/path/to"

0 commit comments

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