Skip to content

Commit 13b63c5

Browse files
author
Andy Hanson
committed
Merge branch 'master' into multi_map_add
2 parents 949c517 + 8038eb9 commit 13b63c5

File tree

236 files changed

+3595
-2288
lines changed

Some content is hidden

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

236 files changed

+3595
-2288
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) => {

Jakefile.js

Lines changed: 164 additions & 153 deletions
Large diffs are not rendered by default.

src/compiler/checker.ts

Lines changed: 198 additions & 132 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/core.ts

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,20 +1515,39 @@ namespace ts {
15151515
}
15161516
}
15171517

1518-
export function copyListRemovingItem<T>(item: T, list: T[]) {
1519-
const copiedList: T[] = [];
1520-
for (const e of list) {
1521-
if (e !== item) {
1522-
copiedList.push(e);
1518+
/** Remove an item from an array, moving everything to its right one space left. */
1519+
export function orderedRemoveItemAt<T>(array: T[], index: number): void {
1520+
// This seems to be faster than either `array.splice(i, 1)` or `array.copyWithin(i, i+ 1)`.
1521+
for (let i = index; i < array.length - 1; i++) {
1522+
array[i] = array[i + 1];
1523+
}
1524+
array.pop();
1525+
}
1526+
1527+
export function unorderedRemoveItemAt<T>(array: T[], index: number): void {
1528+
// Fill in the "hole" left at `index`.
1529+
array[index] = array[array.length - 1];
1530+
array.pop();
1531+
}
1532+
1533+
/** Remove the *first* occurrence of `item` from the array. */
1534+
export function unorderedRemoveItem<T>(array: T[], item: T): void {
1535+
unorderedRemoveFirstItemWhere(array, element => element === item);
1536+
}
1537+
1538+
/** Remove the *first* element satisfying `predicate`. */
1539+
function unorderedRemoveFirstItemWhere<T>(array: T[], predicate: (element: T) => boolean): void {
1540+
for (let i = 0; i < array.length; i++) {
1541+
if (predicate(array[i])) {
1542+
unorderedRemoveItemAt(array, i);
1543+
break;
15231544
}
15241545
}
1525-
return copiedList;
15261546
}
15271547

1528-
export function createGetCanonicalFileName(useCaseSensitivefileNames: boolean): (fileName: string) => string {
1529-
return useCaseSensitivefileNames
1548+
export function createGetCanonicalFileName(useCaseSensitiveFileNames: boolean): (fileName: string) => string {
1549+
return useCaseSensitiveFileNames
15301550
? ((fileName) => fileName)
15311551
: ((fileName) => fileName.toLowerCase());
15321552
}
1533-
15341553
}

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
@@ -720,8 +720,9 @@ namespace ts {
720720
const typesFile = tryReadTypesSection(packageJsonPath, candidate, state);
721721
if (typesFile) {
722722
const onlyRecordFailures = !directoryProbablyExists(getDirectoryPath(typesFile), state.host);
723-
// The package.json "typings" property must specify the file with extension, so just try that exact filename.
724-
const result = tryFile(typesFile, failedLookupLocation, onlyRecordFailures, state);
723+
// A package.json "typings" may specify an exact filename, or may choose to omit an extension.
724+
const result = tryFile(typesFile, failedLookupLocation, onlyRecordFailures, state) ||
725+
tryAddingExtensions(typesFile, extensions, failedLookupLocation, onlyRecordFailures, state);
725726
if (result) {
726727
return result;
727728
}
@@ -1100,7 +1101,7 @@ namespace ts {
11001101
// - This calls resolveModuleNames, and then calls findSourceFile for each resolved module.
11011102
// As all these operations happen - and are nested - within the createProgram call, they close over the below variables.
11021103
// The current resolution depth is tracked by incrementing/decrementing as the depth first search progresses.
1103-
const maxNodeModulesJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 2;
1104+
const maxNodeModulesJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 0;
11041105
let currentNodeModulesDepth = 0;
11051106

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

0 commit comments

Comments
 (0)