Skip to content

Commit a7f4162

Browse files
committed
Merge branch 'master' of https://github.com/Microsoft/TypeScript into feature/eslint
2 parents b6d981a + b57b5fe commit a7f4162

File tree

59 files changed

+1216
-311
lines changed

Some content is hidden

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

59 files changed

+1216
-311
lines changed

README.md

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11

22
# TypeScript
33

4-
[![Join the chat at https://gitter.im/Microsoft/TypeScript](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Microsoft/TypeScript?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
5-
[![Build Status](https://travis-ci.org/microsoft/TypeScript.svg?branch=master)](https://travis-ci.org/Microsoft/TypeScript)
4+
[![Join the chat at https://gitter.im/microsoft/TypeScript](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/microsoft/TypeScript?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
5+
[![Build Status](https://travis-ci.org/microsoft/TypeScript.svg?branch=master)](https://travis-ci.org/microsoft/TypeScript)
66
[![VSTS Build Status](https://dev.azure.com/typescript/TypeScript/_apis/build/status/Typescript/node10)](https://dev.azure.com/typescript/TypeScript/_build/latest?definitionId=4&view=logs)
77
[![npm version](https://badge.fury.io/js/typescript.svg)](https://www.npmjs.com/package/typescript)
88
[![Downloads](https://img.shields.io/npm/dm/typescript.svg)](https://www.npmjs.com/package/typescript)
@@ -27,14 +27,14 @@ npm install -g typescript@next
2727

2828
## Contribute
2929

30-
There are many ways to [contribute](https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md) to TypeScript.
31-
* [Submit bugs](https://github.com/Microsoft/TypeScript/issues) and help us verify fixes as they are checked in.
32-
* Review the [source code changes](https://github.com/Microsoft/TypeScript/pulls).
30+
There are many ways to [contribute](https://github.com/microsoft/TypeScript/blob/master/CONTRIBUTING.md) to TypeScript.
31+
* [Submit bugs](https://github.com/microsoft/TypeScript/issues) and help us verify fixes as they are checked in.
32+
* Review the [source code changes](https://github.com/microsoft/TypeScript/pulls).
3333
* Engage with other TypeScript users and developers on [StackOverflow](https://stackoverflow.com/questions/tagged/typescript).
3434
* Join the [#typescript](https://twitter.com/search?q=%23TypeScript) discussion on Twitter.
35-
* [Contribute bug fixes](https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md).
36-
* Read the language specification ([docx](https://github.com/Microsoft/TypeScript/blob/master/doc/TypeScript%20Language%20Specification.docx?raw=true),
37-
[pdf](https://github.com/Microsoft/TypeScript/blob/master/doc/TypeScript%20Language%20Specification.pdf?raw=true), [md](https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md)).
35+
* [Contribute bug fixes](https://github.com/microsoft/TypeScript/blob/master/CONTRIBUTING.md).
36+
* Read the language specification ([docx](https://github.com/microsoft/TypeScript/blob/master/doc/TypeScript%20Language%20Specification.docx?raw=true),
37+
[pdf](https://github.com/microsoft/TypeScript/blob/master/doc/TypeScript%20Language%20Specification.pdf?raw=true), [md](https://github.com/microsoft/TypeScript/blob/master/doc/spec.md)).
3838

3939
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see
4040
the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [[email protected]](mailto:[email protected])
@@ -44,7 +44,7 @@ with any additional questions or comments.
4444

4545
* [Quick tutorial](https://www.typescriptlang.org/docs/tutorial.html)
4646
* [Programming handbook](https://www.typescriptlang.org/docs/handbook/basic-types.html)
47-
* [Language specification](https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md)
47+
* [Language specification](https://github.com/microsoft/TypeScript/blob/master/doc/spec.md)
4848
* [Homepage](https://www.typescriptlang.org/)
4949

5050
## Building
@@ -54,7 +54,7 @@ In order to build the TypeScript compiler, ensure that you have [Git](https://gi
5454
Clone a copy of the repo:
5555

5656
```bash
57-
git clone https://github.com/Microsoft/TypeScript.git
57+
git clone https://github.com/microsoft/TypeScript.git
5858
```
5959

6060
Change to the TypeScript directory:
@@ -73,17 +73,25 @@ npm install
7373
Use one of the following to build and test:
7474

7575
```
76-
gulp local # Build the compiler into built/local
77-
gulp clean # Delete the built compiler
78-
gulp LKG # Replace the last known good with the built one.
79-
# Bootstrapping step to be executed when the built compiler reaches a stable state.
80-
gulp tests # Build the test infrastructure using the built compiler.
81-
gulp runtests # Run tests using the built compiler and test infrastructure.
82-
# You can override the host or specify a test for this command.
83-
# Use --host=<hostName> or --tests=<testPath>.
84-
gulp baseline-accept # This replaces the baseline test results with the results obtained from gulp runtests.
85-
gulp lint # Runs eslint on the TypeScript source.
86-
gulp help # List the above commands.
76+
gulp local # Build the compiler into built/local.
77+
gulp clean # Delete the built compiler.
78+
gulp LKG # Replace the last known good with the built one.
79+
# Bootstrapping step to be executed when the built compiler reaches a stable state.
80+
gulp tests # Build the test infrastructure using the built compiler.
81+
gulp runtests # Run tests using the built compiler and test infrastructure.
82+
# Some low-value tests are skipped when not on a CI machine - you can use the
83+
# --skipPercent=0 command to override this behavior and run all tests locally.
84+
# You can override the specific suite runner used or specify a test for this command.
85+
# Use --tests=<testPath> for a specific test and/or --runner=<runnerName> for a specific suite.
86+
# Valid runners include conformance, compiler, fourslash, project, user, and docker
87+
# The user and docker runners are extended test suite runners - the user runner
88+
# works on disk in the tests/cases/user directory, while the docker runner works in containers.
89+
# You'll need to have the docker executable in your system path for the docker runner to work.
90+
gulp runtests-parallel # Like runtests, but split across multiple threads. Uses a number of threads equal to the system
91+
# core count by default. Use --workers=<number> to adjust this.
92+
gulp baseline-accept # This replaces the baseline test results with the results obtained from gulp runtests.
93+
gulp lint # Runs eslint on the TypeScript source.
94+
gulp help # List the above commands.
8795
```
8896

8997

@@ -96,4 +104,4 @@ node built/local/tsc.js hello.ts
96104

97105
## Roadmap
98106

99-
For details on our planned features and future direction please refer to our [roadmap](https://github.com/Microsoft/TypeScript/wiki/Roadmap).
107+
For details on our planned features and future direction please refer to our [roadmap](https://github.com/microsoft/TypeScript/wiki/Roadmap).

scripts/build/options.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ module.exports = minimist(process.argv.slice(2), {
1515
"r": "reporter",
1616
"c": "colors", "color": "colors",
1717
"skip-percent": "skipPercent",
18+
"skippercent": "skipPercent",
1819
"w": "workers",
1920
"f": "fix"
2021
},

scripts/open-cherry-pick-pr.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const userName = process.env.GH_USERNAME;
1111
const reviewers = process.env.REQUESTING_USER ? [process.env.REQUESTING_USER] : ["weswigham", "RyanCavanaugh"];
1212
const branchName = `pick/${process.env.SOURCE_ISSUE}/${process.env.TARGET_BRANCH}`;
1313
const remoteUrl = `https://${process.argv[2]}@github.com/${userName}/TypeScript.git`;
14+
const produceLKG = !!process.env.PRODUCE_LKG;
1415

1516
async function main() {
1617
if (!process.env.TARGET_BRANCH) {
@@ -52,7 +53,16 @@ ${logText.trim()}`;
5253
runSequence([
5354
["git", ["checkout", process.env.TARGET_BRANCH]], // checkout the target branch
5455
["git", ["checkout", "-b", branchName]], // create a new branch
55-
["git", ["cherry-pick", squashSha.trim()]], //
56+
["git", ["cherry-pick", squashSha.trim()]],
57+
]);
58+
if (produceLKG) {
59+
runSequence([
60+
["gulp", ["LKG"]],
61+
["git", ["add", "lib"]],
62+
["git", ["commit", "-m", `"Update LKG"`]]
63+
]);
64+
}
65+
runSequence([
5666
["git", ["remote", "add", "fork", remoteUrl]], // Add the remote fork
5767
["git", ["push", "--set-upstream", "fork", branchName, "-f"]] // push the branch
5868
]);
@@ -71,7 +81,7 @@ ${logText.trim()}`;
7181
base: process.env.TARGET_BRANCH,
7282
body:
7383
`This cherry-pick was triggerd by a request on https://github.com/Microsoft/TypeScript/pull/${process.env.SOURCE_ISSUE}
74-
Please review the diff and merge if no changes are unexpected.
84+
Please review the diff and merge if no changes are unexpected.${produceLKG ? ` An LKG update commit is included seperately from the base change.` : ""}
7585
You can view the cherry-pick log [here](https://typescript.visualstudio.com/TypeScript/_build/index?buildId=${process.env.BUILD_BUILDID}&_a=summary).
7686
7787
cc ${reviewers.map(r => "@" + r).join(" ")}`,

src/compiler/checker.ts

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9332,10 +9332,10 @@ namespace ts {
93329332
return globalFunctionType;
93339333
case "Array":
93349334
case "array":
9335-
return !typeArgs || !typeArgs.length ? anyArrayType : undefined;
9335+
return (!typeArgs || !typeArgs.length) && !noImplicitAny ? anyArrayType : undefined;
93369336
case "Promise":
93379337
case "promise":
9338-
return !typeArgs || !typeArgs.length ? createPromiseType(anyType) : undefined;
9338+
return (!typeArgs || !typeArgs.length) && !noImplicitAny ? createPromiseType(anyType) : undefined;
93399339
case "Object":
93409340
if (typeArgs && typeArgs.length === 2) {
93419341
if (isJSDocIndexSignature(node)) {
@@ -9347,7 +9347,7 @@ namespace ts {
93479347
return anyType;
93489348
}
93499349
checkNoTypeArguments(node);
9350-
return anyType;
9350+
return !noImplicitAny ? anyType : undefined;
93519351
}
93529352
}
93539353
}
@@ -15484,8 +15484,7 @@ namespace ts {
1548415484
let visited: Map<number>;
1548515485
let bivariant = false;
1548615486
let propagationType: Type;
15487-
let inferenceMatch = false;
15488-
let inferenceIncomplete = false;
15487+
let inferencePriority = InferencePriority.MaxValue;
1548915488
let allowComplexConstraintInference = true;
1549015489
inferFromTypes(originalSource, originalTarget);
1549115490

@@ -15598,7 +15597,7 @@ namespace ts {
1559815597
clearCachedInferences(inferences);
1559915598
}
1560015599
}
15601-
inferenceMatch = true;
15600+
inferencePriority = Math.min(inferencePriority, priority);
1560215601
return;
1560315602
}
1560415603
else {
@@ -15692,19 +15691,15 @@ namespace ts {
1569215691
const key = source.id + "," + target.id;
1569315692
const status = visited && visited.get(key);
1569415693
if (status !== undefined) {
15695-
if (status & 1) inferenceMatch = true;
15696-
if (status & 2) inferenceIncomplete = true;
15694+
inferencePriority = Math.min(inferencePriority, status);
1569715695
return;
1569815696
}
15699-
(visited || (visited = createMap<number>())).set(key, 0);
15700-
const saveInferenceMatch = inferenceMatch;
15701-
const saveInferenceIncomplete = inferenceIncomplete;
15702-
inferenceMatch = false;
15703-
inferenceIncomplete = false;
15697+
(visited || (visited = createMap<number>())).set(key, InferencePriority.Circularity);
15698+
const saveInferencePriority = inferencePriority;
15699+
inferencePriority = InferencePriority.MaxValue;
1570415700
action(source, target);
15705-
visited.set(key, (inferenceMatch ? 1 : 0) | (inferenceIncomplete ? 2 : 0));
15706-
inferenceMatch = inferenceMatch || saveInferenceMatch;
15707-
inferenceIncomplete = inferenceIncomplete || saveInferenceIncomplete;
15701+
visited.set(key, inferencePriority);
15702+
inferencePriority = Math.min(inferencePriority, saveInferencePriority);
1570815703
}
1570915704

1571015705
function inferFromMatchingType(source: Type, targets: Type[], matches: (s: Type, t: Type) => boolean) {
@@ -15776,31 +15771,32 @@ namespace ts {
1577615771
let nakedTypeVariable: Type | undefined;
1577715772
const sources = source.flags & TypeFlags.Union ? (<UnionType>source).types : [source];
1577815773
const matched = new Array<boolean>(sources.length);
15779-
const saveInferenceIncomplete = inferenceIncomplete;
15780-
inferenceIncomplete = false;
15774+
let inferenceCircularity = false;
1578115775
// First infer to types that are not naked type variables. For each source type we
15782-
// track whether inferences were made from that particular type to some target.
15776+
// track whether inferences were made from that particular type to some target with
15777+
// equal priority (i.e. of equal quality) to what we would infer for a naked type
15778+
// parameter.
1578315779
for (const t of targets) {
1578415780
if (getInferenceInfoForType(t)) {
1578515781
nakedTypeVariable = t;
1578615782
typeVariableCount++;
1578715783
}
1578815784
else {
1578915785
for (let i = 0; i < sources.length; i++) {
15790-
const saveInferenceMatch = inferenceMatch;
15791-
inferenceMatch = false;
15786+
const saveInferencePriority = inferencePriority;
15787+
inferencePriority = InferencePriority.MaxValue;
1579215788
inferFromTypes(sources[i], t);
15793-
if (inferenceMatch) matched[i] = true;
15794-
inferenceMatch = inferenceMatch || saveInferenceMatch;
15789+
if (inferencePriority === priority) matched[i] = true;
15790+
inferenceCircularity = inferenceCircularity || inferencePriority === InferencePriority.Circularity;
15791+
inferencePriority = Math.min(inferencePriority, saveInferencePriority);
1579515792
}
1579615793
}
1579715794
}
15798-
const inferenceComplete = !inferenceIncomplete;
15799-
inferenceIncomplete = inferenceIncomplete || saveInferenceIncomplete;
15800-
// If the target has a single naked type variable and inference completed (meaning we
15801-
// explored the types fully), create a union of the source types from which no inferences
15802-
// have been made so far and infer from that union to the naked type variable.
15803-
if (typeVariableCount === 1 && inferenceComplete) {
15795+
// If the target has a single naked type variable and no inference circularities were
15796+
// encountered above (meaning we explored the types fully), create a union of the source
15797+
// types from which no inferences have been made so far and infer from that union to the
15798+
// naked type variable.
15799+
if (typeVariableCount === 1 && !inferenceCircularity) {
1580415800
const unmatched = flatMap(sources, (s, i) => matched[i] ? undefined : s);
1580515801
if (unmatched.length) {
1580615802
inferFromTypes(getUnionType(unmatched), nakedTypeVariable!);
@@ -15903,7 +15899,7 @@ namespace ts {
1590315899
const symbol = isNonConstructorObject ? target.symbol : undefined;
1590415900
if (symbol) {
1590515901
if (contains(symbolStack, symbol)) {
15906-
inferenceIncomplete = true;
15902+
inferencePriority = InferencePriority.Circularity;
1590715903
return;
1590815904
}
1590915905
(symbolStack || (symbolStack = [])).push(symbol);

src/compiler/diagnosticMessages.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5112,6 +5112,10 @@
51125112
"category": "Message",
51135113
"code": 95087
51145114
},
5115+
"Enable the '--jsx' flag in your configuration file": {
5116+
"category": "Message",
5117+
"code": 95088
5118+
},
51155119

51165120
"No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer.": {
51175121
"category": "Error",

src/compiler/scanner.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,7 +1484,7 @@ namespace ts {
14841484

14851485
function scan(): SyntaxKind {
14861486
startPos = pos;
1487-
tokenFlags = 0;
1487+
tokenFlags = TokenFlags.None;
14881488
let asteriskSeen = false;
14891489
while (true) {
14901490
tokenPos = pos;
@@ -2116,7 +2116,7 @@ namespace ts {
21162116

21172117
function scanJsDocToken(): JSDocSyntaxKind {
21182118
startPos = tokenPos = pos;
2119-
tokenFlags = 0;
2119+
tokenFlags = TokenFlags.None;
21202120
if (pos >= end) {
21212121
return token = SyntaxKind.EndOfFileToken;
21222122
}
@@ -2277,7 +2277,7 @@ namespace ts {
22772277
tokenPos = textPos;
22782278
token = SyntaxKind.Unknown;
22792279
tokenValue = undefined!;
2280-
tokenFlags = 0;
2280+
tokenFlags = TokenFlags.None;
22812281
}
22822282

22832283
function setInJSDocType(inType: boolean) {

src/compiler/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4524,8 +4524,10 @@ namespace ts {
45244524
LiteralKeyof = 1 << 5, // Inference made from a string literal to a keyof T
45254525
NoConstraints = 1 << 6, // Don't infer from constraints of instantiable types
45264526
AlwaysStrict = 1 << 7, // Always use strict rules for contravariant inferences
4527+
MaxValue = 1 << 8, // Seed for inference priority tracking
45274528

45284529
PriorityImpliesCombination = ReturnType | MappedTypeConstraint | LiteralKeyof, // These priorities imply that the resulting type should be a combination of all candidates
4530+
Circularity = -1, // Inference circularity (value less than all other priorities)
45294531
}
45304532

45314533
/* @internal */

src/compiler/utilities.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2345,7 +2345,7 @@ namespace ts {
23452345
export function getTypeParameterFromJsDoc(node: TypeParameterDeclaration & { parent: JSDocTemplateTag }): TypeParameterDeclaration | undefined {
23462346
const name = node.name.escapedText;
23472347
const { typeParameters } = (node.parent.parent.parent as SignatureDeclaration | InterfaceDeclaration | ClassDeclaration);
2348-
return find(typeParameters!, p => p.name.escapedText === name);
2348+
return typeParameters && find(typeParameters, p => p.name.escapedText === name);
23492349
}
23502350

23512351
export function hasRestParameter(s: SignatureDeclaration | JSDocSignature): boolean {

0 commit comments

Comments
 (0)