Skip to content

Commit c742d16

Browse files
committed
Merge remote-tracking branch 'origin/master' into import_completions_pr
2 parents 7261866 + db62503 commit c742d16

File tree

210 files changed

+2597
-1744
lines changed

Some content is hidden

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

210 files changed

+2597
-1744
lines changed

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: 191 additions & 123 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: 13 additions & 5 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
@@ -2867,11 +2871,7 @@
28672871
"Element implicitly has an 'any' type because index expression is not of type 'number'.": {
28682872
"category": "Error",
28692873
"code": 7015
2870-
},
2871-
"Property '{0}' implicitly has type 'any', because its 'set' accessor lacks a type annotation.": {
2872-
"category": "Error",
2873-
"code": 7016
2874-
},
2874+
},
28752875
"Index signature of object type implicitly has an 'any' type.": {
28762876
"category": "Error",
28772877
"code": 7017
@@ -2928,6 +2928,14 @@
29282928
"category": "Error",
29292929
"code": 7031
29302930
},
2931+
"Property '{0}' implicitly has type 'any', because its set accessor lacks a parameter type annotation.": {
2932+
"category": "Error",
2933+
"code": 7032
2934+
},
2935+
"Property '{0}' implicitly has type 'any', because its get accessor lacks a return type annotation.": {
2936+
"category": "Error",
2937+
"code": 7033
2938+
},
29312939
"You cannot rename this element.": {
29322940
"category": "Error",
29332941
"code": 8000

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: 40 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
@@ -5893,6 +5913,9 @@ namespace ts {
58935913
case SyntaxKind.BooleanKeyword:
58945914
case SyntaxKind.SymbolKeyword:
58955915
case SyntaxKind.VoidKeyword:
5916+
case SyntaxKind.NullKeyword:
5917+
case SyntaxKind.UndefinedKeyword:
5918+
case SyntaxKind.NeverKeyword:
58965919
return parseTokenNode<JSDocType>();
58975920
case SyntaxKind.StringLiteral:
58985921
case SyntaxKind.NumericLiteral:

src/compiler/program.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -717,8 +717,9 @@ namespace ts {
717717
const typesFile = tryReadTypesSection(packageJsonPath, candidate, state);
718718
if (typesFile) {
719719
const onlyRecordFailures = !directoryProbablyExists(getDirectoryPath(typesFile), state.host);
720-
// The package.json "typings" property must specify the file with extension, so just try that exact filename.
721-
const result = tryFile(typesFile, failedLookupLocation, onlyRecordFailures, state);
720+
// A package.json "typings" may specify an exact filename, or may choose to omit an extension.
721+
const result = tryFile(typesFile, failedLookupLocation, onlyRecordFailures, state) ||
722+
tryAddingExtensions(typesFile, extensions, failedLookupLocation, onlyRecordFailures, state);
722723
if (result) {
723724
return result;
724725
}
@@ -1097,7 +1098,7 @@ namespace ts {
10971098
// - This calls resolveModuleNames, and then calls findSourceFile for each resolved module.
10981099
// As all these operations happen - and are nested - within the createProgram call, they close over the below variables.
10991100
// The current resolution depth is tracked by incrementing/decrementing as the depth first search progresses.
1100-
const maxNodeModulesJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 2;
1101+
const maxNodeModulesJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 0;
11011102
let currentNodeModulesDepth = 0;
11021103

11031104
// 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: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,9 @@ namespace ts {
351351
JSDocPropertyTag,
352352
JSDocTypeLiteral,
353353
JSDocLiteralType,
354+
JSDocNullKeyword,
355+
JSDocUndefinedKeyword,
356+
JSDocNeverKeyword,
354357

355358
// Synthesized list
356359
SyntaxList,
@@ -383,7 +386,7 @@ namespace ts {
383386
FirstJSDocNode = JSDocTypeExpression,
384387
LastJSDocNode = JSDocLiteralType,
385388
FirstJSDocTagNode = JSDocComment,
386-
LastJSDocTagNode = JSDocLiteralType
389+
LastJSDocTagNode = JSDocNeverKeyword
387390
}
388391

389392
export const enum NodeFlags {
@@ -2264,7 +2267,7 @@ namespace ts {
22642267
Class = 1 << 15, // Class
22652268
Interface = 1 << 16, // Interface
22662269
Reference = 1 << 17, // Generic type reference
2267-
Tuple = 1 << 18, // Tuple
2270+
Tuple = 1 << 18, // Synthesized generic tuple type
22682271
Union = 1 << 19, // Union (T | U)
22692272
Intersection = 1 << 20, // Intersection (T & U)
22702273
Anonymous = 1 << 21, // Anonymous
@@ -2386,11 +2389,6 @@ namespace ts {
23862389
instantiations: Map<TypeReference>; // Generic instantiation cache
23872390
}
23882391

2389-
export interface TupleType extends ObjectType {
2390-
elementTypes: Type[]; // Element types
2391-
thisType?: Type; // This-type of tuple (only needed for tuples that are constraints of type parameters)
2392-
}
2393-
23942392
export interface UnionOrIntersectionType extends Type {
23952393
types: Type[]; // Constituent types
23962394
/* @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)