Skip to content

Commit b0eff90

Browse files
committed
Merge remote-tracking branch 'origin/master' into go_to_implementation_pr
2 parents 115141c + 0485bb6 commit b0eff90

122 files changed

Lines changed: 2012 additions & 499 deletions

File tree

Some content is hidden

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

Gulpfile.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ function restoreSavedNodeEnv() {
551551
process.env.NODE_ENV = savedNodeEnv;
552552
}
553553

554-
let testTimeout = 20000;
554+
let testTimeout = 40000;
555555
function runConsoleTests(defaultReporter: string, runInParallel: boolean, done: (e?: any) => void) {
556556
const lintFlag = cmdLineOptions["lint"];
557557
cleanTestDirs((err) => {

src/compiler/checker.ts

Lines changed: 178 additions & 122 deletions
Large diffs are not rendered by default.

src/compiler/commandLineParser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,7 @@ namespace ts {
885885
function convertCompilerOptionsFromJsonWorker(jsonOptions: any,
886886
basePath: string, errors: Diagnostic[], configFileName?: string): CompilerOptions {
887887

888-
const options: CompilerOptions = getBaseFileName(configFileName) === "jsconfig.json" ? { allowJs: true } : {};
888+
const options: CompilerOptions = getBaseFileName(configFileName) === "jsconfig.json" ? { allowJs: true, maxNodeModuleJsDepth: 2 } : {};
889889
convertOptionsFromJson(optionDeclarations, jsonOptions, basePath, options, Diagnostics.Unknown_compiler_option_0, errors);
890890
return options;
891891
}

src/compiler/declarationEmitter.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,8 +1132,10 @@ namespace ts {
11321132
// it if it's not a well known symbol. In that case, the text of the name will be exactly
11331133
// what we want, namely the name expression enclosed in brackets.
11341134
writeTextOfNode(currentText, node.name);
1135-
// If optional property emit ?
1136-
if ((node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature || node.kind === SyntaxKind.Parameter) && hasQuestionToken(node)) {
1135+
// If optional property emit ? but in the case of parameterProperty declaration with "?" indicating optional parameter for the constructor
1136+
// we don't want to emit property declaration with "?"
1137+
if ((node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature ||
1138+
(node.kind === SyntaxKind.Parameter && !isParameterPropertyDeclaration(node))) && hasQuestionToken(node)) {
11371139
write("?");
11381140
}
11391141
if ((node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature) && node.parent.kind === SyntaxKind.TypeLiteral) {

src/compiler/diagnosticMessages.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1955,6 +1955,10 @@
19551955
"category": "Error",
19561956
"code": 2691
19571957
},
1958+
"'{0}' is a primitive, but '{1}' is a wrapper object. Prefer using '{0}' when possible.": {
1959+
"category": "Error",
1960+
"code": 2692
1961+
},
19581962
"Import declaration '{0}' is using private name '{1}'.": {
19591963
"category": "Error",
19601964
"code": 4000

src/compiler/emitter.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1817,6 +1817,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
18171817
else if (node.parent.kind === SyntaxKind.ConditionalExpression && (<ConditionalExpression>node.parent).condition === node) {
18181818
return true;
18191819
}
1820+
else if (node.parent.kind === SyntaxKind.PrefixUnaryExpression || node.parent.kind === SyntaxKind.DeleteExpression ||
1821+
node.parent.kind === SyntaxKind.TypeOfExpression || node.parent.kind === SyntaxKind.VoidExpression) {
1822+
return true;
1823+
}
18201824

18211825
return false;
18221826
}
@@ -6583,7 +6587,7 @@ const _super = (function (geti, seti) {
65836587
// import { x, y } from "foo"
65846588
// import d, * as x from "foo"
65856589
// import d, { x, y } from "foo"
6586-
const isNakedImport = SyntaxKind.ImportDeclaration && !(<ImportDeclaration>node).importClause;
6590+
const isNakedImport = node.kind === SyntaxKind.ImportDeclaration && !(<ImportDeclaration>node).importClause;
65876591
if (!isNakedImport) {
65886592
write(varOrConst);
65896593
write(getGeneratedNameForNode(<ImportDeclaration>node));

src/compiler/parser.ts

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,7 @@ namespace ts {
912912
// Note: it is not actually necessary to save/restore the context flags here. That's
913913
// because the saving/restoring of these flags happens naturally through the recursive
914914
// descent nature of our parser. However, we still store this here just so we can
915-
// assert that that invariant holds.
915+
// assert that invariant holds.
916916
const saveContextFlags = contextFlags;
917917

918918
// If we're only looking ahead, then tell the scanner to only lookahead as well.
@@ -2339,6 +2339,7 @@ namespace ts {
23392339
token() === SyntaxKind.LessThanToken ||
23402340
token() === SyntaxKind.QuestionToken ||
23412341
token() === SyntaxKind.ColonToken ||
2342+
token() === SyntaxKind.CommaToken ||
23422343
canParseSemicolon();
23432344
}
23442345
return false;
@@ -2765,7 +2766,7 @@ namespace ts {
27652766
// Note: for ease of implementation we treat productions '2' and '3' as the same thing.
27662767
// (i.e. they're both BinaryExpressions with an assignment operator in it).
27672768

2768-
// First, do the simple check if we have a YieldExpression (production '5').
2769+
// First, do the simple check if we have a YieldExpression (production '6').
27692770
if (isYieldExpression()) {
27702771
return parseYieldExpression();
27712772
}
@@ -3373,24 +3374,40 @@ namespace ts {
33733374
}
33743375

33753376
/**
3376-
* Parse ES7 unary expression and await expression
3377+
* Parse ES7 exponential expression and await expression
3378+
*
3379+
* ES7 ExponentiationExpression:
3380+
* 1) UnaryExpression[?Yield]
3381+
* 2) UpdateExpression[?Yield] ** ExponentiationExpression[?Yield]
33773382
*
3378-
* ES7 UnaryExpression:
3379-
* 1) SimpleUnaryExpression[?yield]
3380-
* 2) IncrementExpression[?yield] ** UnaryExpression[?yield]
33813383
*/
33823384
function parseUnaryExpressionOrHigher(): UnaryExpression | BinaryExpression {
3383-
if (isAwaitExpression()) {
3384-
return parseAwaitExpression();
3385-
}
3386-
3387-
if (isIncrementExpression()) {
3385+
/**
3386+
* ES7 UpdateExpression:
3387+
* 1) LeftHandSideExpression[?Yield]
3388+
* 2) LeftHandSideExpression[?Yield][no LineTerminator here]++
3389+
* 3) LeftHandSideExpression[?Yield][no LineTerminator here]--
3390+
* 4) ++UnaryExpression[?Yield]
3391+
* 5) --UnaryExpression[?Yield]
3392+
*/
3393+
if (isUpdateExpression()) {
33883394
const incrementExpression = parseIncrementExpression();
33893395
return token() === SyntaxKind.AsteriskAsteriskToken ?
33903396
<BinaryExpression>parseBinaryExpressionRest(getBinaryOperatorPrecedence(), incrementExpression) :
33913397
incrementExpression;
33923398
}
33933399

3400+
/**
3401+
* ES7 UnaryExpression:
3402+
* 1) UpdateExpression[?yield]
3403+
* 2) delete UpdateExpression[?yield]
3404+
* 3) void UpdateExpression[?yield]
3405+
* 4) typeof UpdateExpression[?yield]
3406+
* 5) + UpdateExpression[?yield]
3407+
* 6) - UpdateExpression[?yield]
3408+
* 7) ~ UpdateExpression[?yield]
3409+
* 8) ! UpdateExpression[?yield]
3410+
*/
33943411
const unaryOperator = token();
33953412
const simpleUnaryExpression = parseSimpleUnaryExpression();
33963413
if (token() === SyntaxKind.AsteriskAsteriskToken) {
@@ -3408,8 +3425,8 @@ namespace ts {
34083425
/**
34093426
* Parse ES7 simple-unary expression or higher:
34103427
*
3411-
* ES7 SimpleUnaryExpression:
3412-
* 1) IncrementExpression[?yield]
3428+
* ES7 UnaryExpression:
3429+
* 1) UpdateExpression[?yield]
34133430
* 2) delete UnaryExpression[?yield]
34143431
* 3) void UnaryExpression[?yield]
34153432
* 4) typeof UnaryExpression[?yield]
@@ -3432,13 +3449,15 @@ namespace ts {
34323449
return parseTypeOfExpression();
34333450
case SyntaxKind.VoidKeyword:
34343451
return parseVoidExpression();
3435-
case SyntaxKind.AwaitKeyword:
3436-
return parseAwaitExpression();
34373452
case SyntaxKind.LessThanToken:
34383453
// This is modified UnaryExpression grammar in TypeScript
34393454
// UnaryExpression (modified):
34403455
// < type > UnaryExpression
34413456
return parseTypeAssertion();
3457+
case SyntaxKind.AwaitKeyword:
3458+
if (isAwaitExpression()) {
3459+
return parseAwaitExpression();
3460+
}
34423461
default:
34433462
return parseIncrementExpression();
34443463
}
@@ -3447,14 +3466,14 @@ namespace ts {
34473466
/**
34483467
* Check if the current token can possibly be an ES7 increment expression.
34493468
*
3450-
* ES7 IncrementExpression:
3469+
* ES7 UpdateExpression:
34513470
* LeftHandSideExpression[?Yield]
34523471
* LeftHandSideExpression[?Yield][no LineTerminator here]++
34533472
* LeftHandSideExpression[?Yield][no LineTerminator here]--
34543473
* ++LeftHandSideExpression[?Yield]
34553474
* --LeftHandSideExpression[?Yield]
34563475
*/
3457-
function isIncrementExpression(): boolean {
3476+
function isUpdateExpression(): boolean {
34583477
// This function is called inside parseUnaryExpression to decide
34593478
// whether to call parseSimpleUnaryExpression or call parseIncrementExpression directly
34603479
switch (token()) {
@@ -3465,6 +3484,7 @@ namespace ts {
34653484
case SyntaxKind.DeleteKeyword:
34663485
case SyntaxKind.TypeOfKeyword:
34673486
case SyntaxKind.VoidKeyword:
3487+
case SyntaxKind.AwaitKeyword:
34683488
return false;
34693489
case SyntaxKind.LessThanToken:
34703490
// If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression

src/compiler/program.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,7 @@ namespace ts {
11011101
// - This calls resolveModuleNames, and then calls findSourceFile for each resolved module.
11021102
// As all these operations happen - and are nested - within the createProgram call, they close over the below variables.
11031103
// The current resolution depth is tracked by incrementing/decrementing as the depth first search progresses.
1104-
const maxNodeModulesJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 2;
1104+
const maxNodeModulesJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 0;
11051105
let currentNodeModulesDepth = 0;
11061106

11071107
// If a module has some of its imports skipped due to being at the depth limit under node_modules, then track

src/compiler/types.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2266,7 +2266,7 @@ namespace ts {
22662266
Class = 1 << 15, // Class
22672267
Interface = 1 << 16, // Interface
22682268
Reference = 1 << 17, // Generic type reference
2269-
Tuple = 1 << 18, // Tuple
2269+
Tuple = 1 << 18, // Synthesized generic tuple type
22702270
Union = 1 << 19, // Union (T | U)
22712271
Intersection = 1 << 20, // Intersection (T & U)
22722272
Anonymous = 1 << 21, // Anonymous
@@ -2388,11 +2388,6 @@ namespace ts {
23882388
instantiations: Map<TypeReference>; // Generic instantiation cache
23892389
}
23902390

2391-
export interface TupleType extends ObjectType {
2392-
elementTypes: Type[]; // Element types
2393-
thisType?: Type; // This-type of tuple (only needed for tuples that are constraints of type parameters)
2394-
}
2395-
23962391
export interface UnionOrIntersectionType extends Type {
23972392
types: Type[]; // Constituent types
23982393
/* @internal */

src/compiler/utilities.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,10 @@ namespace ts {
301301
return node.kind >= SyntaxKind.FirstJSDocNode && node.kind <= SyntaxKind.LastJSDocNode;
302302
}
303303

304+
export function isJSDocTag(node: Node) {
305+
return node.kind >= SyntaxKind.FirstJSDocTagNode && node.kind <= SyntaxKind.LastJSDocTagNode;
306+
}
307+
304308
export function getNonDecoratorTokenPosOfNode(node: Node, sourceFile?: SourceFile): number {
305309
if (nodeIsMissing(node) || !node.decorators) {
306310
return getTokenPosOfNode(node, sourceFile);

0 commit comments

Comments
 (0)