Skip to content

Commit b2e72cf

Browse files
committed
Merge branch 'master' into constructor-functions-as-classes
2 parents e2f8545 + 0212e24 commit b2e72cf

File tree

44 files changed

+877
-70
lines changed

Some content is hidden

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

44 files changed

+877
-70
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 tslint 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 tslint 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/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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9345,10 +9345,10 @@ namespace ts {
93459345
return globalFunctionType;
93469346
case "Array":
93479347
case "array":
9348-
return !typeArgs || !typeArgs.length ? anyArrayType : undefined;
9348+
return (!typeArgs || !typeArgs.length) && !noImplicitAny ? anyArrayType : undefined;
93499349
case "Promise":
93509350
case "promise":
9351-
return !typeArgs || !typeArgs.length ? createPromiseType(anyType) : undefined;
9351+
return (!typeArgs || !typeArgs.length) && !noImplicitAny ? createPromiseType(anyType) : undefined;
93529352
case "Object":
93539353
if (typeArgs && typeArgs.length === 2) {
93549354
if (isJSDocIndexSignature(node)) {
@@ -9360,7 +9360,7 @@ namespace ts {
93609360
return anyType;
93619361
}
93629362
checkNoTypeArguments(node);
9363-
return anyType;
9363+
return !noImplicitAny ? anyType : undefined;
93649364
}
93659365
}
93669366
}

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/utilities.ts

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

23492349
export function hasRestParameter(s: SignatureDeclaration | JSDocSignature): boolean {
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/* @internal */
2+
namespace ts.codefix {
3+
const fixID = "fixEnableJsxFlag";
4+
const errorCodes = [Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided.code];
5+
registerCodeFix({
6+
errorCodes,
7+
getCodeActions: context => {
8+
const { configFile } = context.program.getCompilerOptions();
9+
if (configFile === undefined) {
10+
return undefined;
11+
}
12+
13+
const changes = textChanges.ChangeTracker.with(context, changeTracker =>
14+
doChange(changeTracker, configFile)
15+
);
16+
return [
17+
createCodeFixActionNoFixId(fixID, changes, Diagnostics.Enable_the_jsx_flag_in_your_configuration_file)
18+
];
19+
},
20+
fixIds: [fixID],
21+
getAllCodeActions: context =>
22+
codeFixAll(context, errorCodes, changes => {
23+
const { configFile } = context.program.getCompilerOptions();
24+
if (configFile === undefined) {
25+
return undefined;
26+
}
27+
28+
doChange(changes, configFile);
29+
})
30+
});
31+
32+
function doChange(changeTracker: textChanges.ChangeTracker, configFile: TsConfigSourceFile) {
33+
setJsonCompilerOptionValue(changeTracker, configFile, "jsx", createStringLiteral("react"));
34+
}
35+
}

src/services/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
"codefixes/fixClassSuperMustPrecedeThisAccess.ts",
6666
"codefixes/fixConstructorForDerivedNeedSuperCall.ts",
6767
"codefixes/fixEnableExperimentalDecorators.ts",
68+
"codefixes/fixEnableJsxFlag.ts",
6869
"codefixes/fixExtendsInterfaceBecomesImplements.ts",
6970
"codefixes/fixForgottenThisPropertyAccess.ts",
7071
"codefixes/fixUnusedIdentifier.ts",

src/testRunner/externalCompileRunner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ abstract class ExternalCompileRunnerBase extends RunnerBase {
5252
const submoduleDir = path.join(cwd, directoryName);
5353
exec("git", ["reset", "HEAD", "--hard"], { cwd: submoduleDir });
5454
exec("git", ["clean", "-f"], { cwd: submoduleDir });
55-
exec("git", ["submodule", "update", "--init", "--remote", "."], { cwd: submoduleDir });
55+
exec("git", ["submodule", "update", "--init", "--remote", "."], { cwd: originalCwd });
5656

5757
const config = JSON.parse(fs.readFileSync(path.join(cwd, "test.json"), { encoding: "utf8" })) as UserConfig;
5858
ts.Debug.assert(!!config.types, "Bad format from test.json: Types field must be present.");

tests/baselines/reference/docker/azure-sdk.log

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ Exit Code: 1
22
Standard output:
33

44
Rush Multi-Project Build Tool 5.X.X - https://rushjs.io
5-
Node.js version is 12.8.0 (pre-LTS)
5+
Node.js version is 12.8.1 (pre-LTS)
66
Starting "rush rebuild"
77
Executing a maximum of ?simultaneous processes...
8+
XX of XX: [@azure/abort-controller] completed successfully in ? seconds
89
XX of XX: [@azure/identity] completed successfully in ? seconds
910
XX of XX: [@azure/event-processor-host] completed successfully in ? seconds
10-
XX of XX: [@azure/abort-controller] completed successfully in ? seconds
1111
XX of XX: [@azure/core-arm] completed successfully in ? seconds
1212
XX of XX: [@azure/core-asynciterator-polyfill] completed successfully in ? seconds
1313
XX of XX: [@azure/core-auth] completed successfully in ? seconds
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
=== tests/cases/compiler/jsdocArrayObjectPromiseImplicitAny.js ===
2+
/** @type {Array} */
3+
var anyArray = [5];
4+
>anyArray : Symbol(anyArray, Decl(jsdocArrayObjectPromiseImplicitAny.js, 1, 3))
5+
6+
/** @type {Array<number>} */
7+
var numberArray = [5];
8+
>numberArray : Symbol(numberArray, Decl(jsdocArrayObjectPromiseImplicitAny.js, 4, 3))
9+
10+
/**
11+
* @param {Array} arr
12+
* @return {Array}
13+
*/
14+
function returnAnyArray(arr) {
15+
>returnAnyArray : Symbol(returnAnyArray, Decl(jsdocArrayObjectPromiseImplicitAny.js, 4, 22))
16+
>arr : Symbol(arr, Decl(jsdocArrayObjectPromiseImplicitAny.js, 10, 24))
17+
18+
return arr;
19+
>arr : Symbol(arr, Decl(jsdocArrayObjectPromiseImplicitAny.js, 10, 24))
20+
}
21+
22+
/** @type {Promise} */
23+
var anyPromise = Promise.resolve(5);
24+
>anyPromise : Symbol(anyPromise, Decl(jsdocArrayObjectPromiseImplicitAny.js, 15, 3))
25+
>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
26+
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
27+
>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
28+
29+
/** @type {Promise<number>} */
30+
var numberPromise = Promise.resolve(5);
31+
>numberPromise : Symbol(numberPromise, Decl(jsdocArrayObjectPromiseImplicitAny.js, 18, 3))
32+
>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
33+
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
34+
>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
35+
36+
/**
37+
* @param {Promise} pr
38+
* @return {Promise}
39+
*/
40+
function returnAnyPromise(pr) {
41+
>returnAnyPromise : Symbol(returnAnyPromise, Decl(jsdocArrayObjectPromiseImplicitAny.js, 18, 39))
42+
>pr : Symbol(pr, Decl(jsdocArrayObjectPromiseImplicitAny.js, 24, 26))
43+
44+
return pr;
45+
>pr : Symbol(pr, Decl(jsdocArrayObjectPromiseImplicitAny.js, 24, 26))
46+
}
47+
48+
/** @type {Object} */
49+
var anyObject = {valueOf: 1}; // not an error since assigning to any.
50+
>anyObject : Symbol(anyObject, Decl(jsdocArrayObjectPromiseImplicitAny.js, 29, 3))
51+
>valueOf : Symbol(valueOf, Decl(jsdocArrayObjectPromiseImplicitAny.js, 29, 17))
52+
53+
/** @type {Object<string, number>} */
54+
var paramedObject = {valueOf: 1};
55+
>paramedObject : Symbol(paramedObject, Decl(jsdocArrayObjectPromiseImplicitAny.js, 32, 3))
56+
>valueOf : Symbol(valueOf, Decl(jsdocArrayObjectPromiseImplicitAny.js, 32, 21))
57+
58+
/**
59+
* @param {Object} obj
60+
* @return {Object}
61+
*/
62+
function returnAnyObject(obj) {
63+
>returnAnyObject : Symbol(returnAnyObject, Decl(jsdocArrayObjectPromiseImplicitAny.js, 32, 33))
64+
>obj : Symbol(obj, Decl(jsdocArrayObjectPromiseImplicitAny.js, 38, 25))
65+
66+
return obj;
67+
>obj : Symbol(obj, Decl(jsdocArrayObjectPromiseImplicitAny.js, 38, 25))
68+
}
69+
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
=== tests/cases/compiler/jsdocArrayObjectPromiseImplicitAny.js ===
2+
/** @type {Array} */
3+
var anyArray = [5];
4+
>anyArray : any[]
5+
>[5] : number[]
6+
>5 : 5
7+
8+
/** @type {Array<number>} */
9+
var numberArray = [5];
10+
>numberArray : number[]
11+
>[5] : number[]
12+
>5 : 5
13+
14+
/**
15+
* @param {Array} arr
16+
* @return {Array}
17+
*/
18+
function returnAnyArray(arr) {
19+
>returnAnyArray : (arr: any[]) => any[]
20+
>arr : any[]
21+
22+
return arr;
23+
>arr : any[]
24+
}
25+
26+
/** @type {Promise} */
27+
var anyPromise = Promise.resolve(5);
28+
>anyPromise : Promise<any>
29+
>Promise.resolve(5) : Promise<number>
30+
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
31+
>Promise : PromiseConstructor
32+
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
33+
>5 : 5
34+
35+
/** @type {Promise<number>} */
36+
var numberPromise = Promise.resolve(5);
37+
>numberPromise : Promise<number>
38+
>Promise.resolve(5) : Promise<number>
39+
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
40+
>Promise : PromiseConstructor
41+
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
42+
>5 : 5
43+
44+
/**
45+
* @param {Promise} pr
46+
* @return {Promise}
47+
*/
48+
function returnAnyPromise(pr) {
49+
>returnAnyPromise : (pr: Promise<any>) => Promise<any>
50+
>pr : Promise<any>
51+
52+
return pr;
53+
>pr : Promise<any>
54+
}
55+
56+
/** @type {Object} */
57+
var anyObject = {valueOf: 1}; // not an error since assigning to any.
58+
>anyObject : any
59+
>{valueOf: 1} : { valueOf: number; }
60+
>valueOf : number
61+
>1 : 1
62+
63+
/** @type {Object<string, number>} */
64+
var paramedObject = {valueOf: 1};
65+
>paramedObject : { [x: string]: number; }
66+
>{valueOf: 1} : { valueOf: number; }
67+
>valueOf : number
68+
>1 : 1
69+
70+
/**
71+
* @param {Object} obj
72+
* @return {Object}
73+
*/
74+
function returnAnyObject(obj) {
75+
>returnAnyObject : (obj: any) => any
76+
>obj : any
77+
78+
return obj;
79+
>obj : any
80+
}
81+

0 commit comments

Comments
 (0)