Skip to content

Commit 3bdec69

Browse files
committed
Merge branch 'master' into tripleEquals
2 parents 3b6da51 + 2b61d18 commit 3bdec69

File tree

75 files changed

+2046
-1799
lines changed

Some content is hidden

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

75 files changed

+2046
-1799
lines changed

src/compiler/binder.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1855,7 +1855,7 @@ namespace ts {
18551855
}
18561856

18571857
function checkStrictModeNumericLiteral(node: NumericLiteral) {
1858-
if (inStrictMode && node.isOctalLiteral) {
1858+
if (inStrictMode && node.numericLiteralFlags & NumericLiteralFlags.Octal) {
18591859
file.bindDiagnostics.push(createDiagnosticForNode(node, Diagnostics.Octal_literals_are_not_allowed_in_strict_mode));
18601860
}
18611861
}
@@ -3330,6 +3330,18 @@ namespace ts {
33303330
transformFlags |= TransformFlags.AssertES2015;
33313331
break;
33323332

3333+
case SyntaxKind.StringLiteral:
3334+
if ((<StringLiteral>node).hasExtendedUnicodeEscape) {
3335+
transformFlags |= TransformFlags.AssertES2015;
3336+
}
3337+
break;
3338+
3339+
case SyntaxKind.NumericLiteral:
3340+
if ((<NumericLiteral>node).numericLiteralFlags & NumericLiteralFlags.BinaryOrOctalSpecifier) {
3341+
transformFlags |= TransformFlags.AssertES2015;
3342+
}
3343+
break;
3344+
33333345
case SyntaxKind.ForOfStatement:
33343346
// This node is either ES2015 syntax or ES2017 syntax (if it is a for-await-of).
33353347
if ((<ForOfStatement>node).awaitModifier) {

src/compiler/checker.ts

Lines changed: 280 additions & 251 deletions
Large diffs are not rendered by default.

src/compiler/commandLineParser.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -860,9 +860,9 @@ namespace ts {
860860
}
861861

862862
/**
863-
* Read tsconfig.json file
864-
* @param fileName The path to the config file
865-
*/
863+
* Read tsconfig.json file
864+
* @param fileName The path to the config file
865+
*/
866866
export function readConfigFile(fileName: string, readFile: (path: string) => string): { config?: any; error?: Diagnostic } {
867867
let text = "";
868868
try {
@@ -875,10 +875,10 @@ namespace ts {
875875
}
876876

877877
/**
878-
* Parse the text of the tsconfig.json file
879-
* @param fileName The path to the config file
880-
* @param jsonText The text of the config file
881-
*/
878+
* Parse the text of the tsconfig.json file
879+
* @param fileName The path to the config file
880+
* @param jsonText The text of the config file
881+
*/
882882
export function parseConfigFileTextToJson(fileName: string, jsonText: string, stripComments = true): { config?: any; error?: Diagnostic } {
883883
try {
884884
const jsonTextToParse = stripComments ? removeComments(jsonText) : jsonText;
@@ -1083,12 +1083,12 @@ namespace ts {
10831083
}
10841084

10851085
/**
1086-
* Parse the contents of a config file (tsconfig.json).
1087-
* @param json The contents of the config file to parse
1088-
* @param host Instance of ParseConfigHost used to enumerate files in folder.
1089-
* @param basePath A root directory to resolve relative path entries in the config
1090-
* file to. e.g. outDir
1091-
*/
1086+
* Parse the contents of a config file (tsconfig.json).
1087+
* @param json The contents of the config file to parse
1088+
* @param host Instance of ParseConfigHost used to enumerate files in folder.
1089+
* @param basePath A root directory to resolve relative path entries in the config
1090+
* file to. e.g. outDir
1091+
*/
10921092
export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions: CompilerOptions = {}, configFileName?: string, resolutionStack: Path[] = [], extraFileExtensions: JsFileExtensionInfo[] = []): ParsedCommandLine {
10931093
const errors: Diagnostic[] = [];
10941094
basePath = normalizeSlashes(basePath);

src/compiler/comments.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ namespace ts {
411411
* Determine if the given comment is a triple-slash
412412
*
413413
* @return true if the comment is a triple-slash comment else false
414-
**/
414+
*/
415415
function isTripleSlashComment(commentPos: number, commentEnd: number) {
416416
// Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text
417417
// so that we don't end up computing comment string and doing match for all // comments

src/compiler/core.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,7 +1358,7 @@ namespace ts {
13581358

13591359
/**
13601360
* Returns length of path root (i.e. length of "/", "x:/", "//server/share/, file:///user/files")
1361-
*/
1361+
*/
13621362
export function getRootLength(path: string): number {
13631363
if (path.charCodeAt(0) === CharacterCodes.slash) {
13641364
if (path.charCodeAt(1) !== CharacterCodes.slash) return 1;
@@ -1455,7 +1455,7 @@ namespace ts {
14551455
return /^\.\.?($|[\\/])/.test(moduleName);
14561456
}
14571457

1458-
export function getEmitScriptTarget(compilerOptions: CompilerOptions | PrinterOptions) {
1458+
export function getEmitScriptTarget(compilerOptions: CompilerOptions) {
14591459
return compilerOptions.target || ScriptTarget.ES3;
14601460
}
14611461

src/compiler/diagnosticMessages.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1827,6 +1827,10 @@
18271827
"category": "Error",
18281828
"code": 2549
18291829
},
1830+
"Generic type instantiation is excessively deep and possibly infinite.": {
1831+
"category": "Error",
1832+
"code": 2550
1833+
},
18301834
"JSX element attributes type '{0}' may not be a union type.": {
18311835
"category": "Error",
18321836
"code": 2600

src/compiler/emitter.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,6 @@ namespace ts {
204204
} = handlers;
205205

206206
const newLine = getNewLineCharacter(printerOptions);
207-
const languageVersion = getEmitScriptTarget(printerOptions);
208207
const comments = createCommentWriter(printerOptions, onEmitSourceMapOfPosition);
209208
const {
210209
emitNodeWithComments,
@@ -1084,7 +1083,7 @@ namespace ts {
10841083
}
10851084

10861085
const preferNewLine = node.multiLine ? ListFormat.PreferNewLine : ListFormat.None;
1087-
const allowTrailingComma = languageVersion >= ScriptTarget.ES5 ? ListFormat.AllowTrailingComma : ListFormat.None;
1086+
const allowTrailingComma = currentSourceFile.languageVersion >= ScriptTarget.ES5 ? ListFormat.AllowTrailingComma : ListFormat.None;
10881087
emitList(node, properties, ListFormat.ObjectLiteralExpressionProperties | allowTrailingComma | preferNewLine);
10891088

10901089
if (indentedFlag) {
@@ -1118,11 +1117,11 @@ namespace ts {
11181117
// 1..toString is a valid property access, emit a dot after the literal
11191118
// Also emit a dot if expression is a integer const enum value - it will appear in generated code as numeric literal
11201119
function needsDotDotForPropertyAccess(expression: Expression) {
1121-
if (expression.kind === SyntaxKind.NumericLiteral) {
1120+
expression = skipPartiallyEmittedExpressions(expression);
1121+
if (isNumericLiteral(expression)) {
11221122
// check if numeric literal is a decimal literal that was originally written with a dot
11231123
const text = getLiteralTextOfNode(<LiteralExpression>expression);
1124-
return getNumericLiteralFlags(text, /*hint*/ NumericLiteralFlags.All) === NumericLiteralFlags.None
1125-
&& !(<LiteralExpression>expression).isOctalLiteral
1124+
return !expression.numericLiteralFlags
11261125
&& text.indexOf(tokenToString(SyntaxKind.DotToken)) < 0;
11271126
}
11281127
else if (isPropertyAccessExpression(expression) || isElementAccessExpression(expression)) {
@@ -2638,7 +2637,7 @@ namespace ts {
26382637
}
26392638
}
26402639

2641-
return getLiteralText(node, currentSourceFile, languageVersion);
2640+
return getLiteralText(node, currentSourceFile);
26422641
}
26432642

26442643
/**

src/compiler/factory.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ namespace ts {
8888
export function createNumericLiteral(value: string): NumericLiteral {
8989
const node = <NumericLiteral>createSynthesizedNode(SyntaxKind.NumericLiteral);
9090
node.text = value;
91+
node.numericLiteralFlags = 0;
9192
return node;
9293
}
9394

@@ -3365,17 +3366,14 @@ namespace ts {
33653366
*/
33663367
export function parenthesizeForAccess(expression: Expression): LeftHandSideExpression {
33673368
// isLeftHandSideExpression is almost the correct criterion for when it is not necessary
3368-
// to parenthesize the expression before a dot. The known exceptions are:
3369+
// to parenthesize the expression before a dot. The known exception is:
33693370
//
33703371
// NewExpression:
33713372
// new C.x -> not the same as (new C).x
3372-
// NumericLiteral
3373-
// 1.x -> not the same as (1).x
33743373
//
33753374
const emittedExpression = skipPartiallyEmittedExpressions(expression);
33763375
if (isLeftHandSideExpression(emittedExpression)
3377-
&& (emittedExpression.kind !== SyntaxKind.NewExpression || (<NewExpression>emittedExpression).arguments)
3378-
&& emittedExpression.kind !== SyntaxKind.NumericLiteral) {
3376+
&& (emittedExpression.kind !== SyntaxKind.NewExpression || (<NewExpression>emittedExpression).arguments)) {
33793377
return <LeftHandSideExpression>expression;
33803378
}
33813379

src/compiler/moduleNameResolver.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -249,13 +249,13 @@ namespace ts {
249249
}
250250

251251
/**
252-
* Given a set of options, returns the set of type directive names
253-
* that should be included for this program automatically.
254-
* This list could either come from the config file,
255-
* or from enumerating the types root + initial secondary types lookup location.
256-
* More type directives might appear in the program later as a result of loading actual source files;
257-
* this list is only the set of defaults that are implicitly included.
258-
*/
252+
* Given a set of options, returns the set of type directive names
253+
* that should be included for this program automatically.
254+
* This list could either come from the config file,
255+
* or from enumerating the types root + initial secondary types lookup location.
256+
* More type directives might appear in the program later as a result of loading actual source files;
257+
* this list is only the set of defaults that are implicitly included.
258+
*/
259259
export function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: ModuleResolutionHost): string[] {
260260
// Use explicit type list from tsconfig.json
261261
if (options.types) {

src/compiler/parser.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2031,32 +2031,27 @@ namespace ts {
20312031
node.isUnterminated = true;
20322032
}
20332033

2034-
const tokenPos = scanner.getTokenPos();
2035-
nextToken();
2036-
finishNode(node);
2037-
20382034
// Octal literals are not allowed in strict mode or ES5
20392035
// Note that theoretically the following condition would hold true literals like 009,
20402036
// which is not octal.But because of how the scanner separates the tokens, we would
20412037
// never get a token like this. Instead, we would get 00 and 9 as two separate tokens.
20422038
// We also do not need to check for negatives because any prefix operator would be part of a
20432039
// parent unary expression.
2044-
if (node.kind === SyntaxKind.NumericLiteral
2045-
&& sourceText.charCodeAt(tokenPos) === CharacterCodes._0
2046-
&& isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) {
2047-
2048-
node.isOctalLiteral = true;
2040+
if (node.kind === SyntaxKind.NumericLiteral) {
2041+
(<NumericLiteral>node).numericLiteralFlags = scanner.getNumericLiteralFlags();
20492042
}
20502043

2044+
nextToken();
2045+
finishNode(node);
2046+
20512047
return node;
20522048
}
20532049

20542050
// TYPES
20552051

20562052
function parseTypeReference(): TypeReferenceNode {
2057-
const typeName = parseEntityName(/*allowReservedWords*/ false, Diagnostics.Type_expected);
2058-
const node = <TypeReferenceNode>createNode(SyntaxKind.TypeReference, typeName.pos);
2059-
node.typeName = typeName;
2053+
const node = <TypeReferenceNode>createNode(SyntaxKind.TypeReference);
2054+
node.typeName = parseEntityName(/*allowReservedWords*/ false, Diagnostics.Type_expected);
20602055
if (!scanner.hasPrecedingLineBreak() && token() === SyntaxKind.LessThanToken) {
20612056
node.typeArguments = parseBracketedList(ParsingContext.TypeArguments, parseType, SyntaxKind.LessThanToken, SyntaxKind.GreaterThanToken);
20622057
}

0 commit comments

Comments
 (0)