Skip to content

Commit 52fbf9e

Browse files
committed
Merge branch 'master' into compute-common-source-dir
2 parents 5bcf861 + e3a845a commit 52fbf9e

47 files changed

Lines changed: 579 additions & 29 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.

AUTHORS.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ TypeScript is authored by:
88
* Basarat Ali Syed
99
* Ben Duffield
1010
* Bill Ticehurst
11+
* Brett Mayen
1112
* Bryan Forbes
1213
* Caitlin Potter
1314
* Chris Bubernak
@@ -17,11 +18,14 @@ TypeScript is authored by:
1718
* Dan Quirk
1819
* Daniel Rosenwasser
1920
* David Li
20-
* Dick van den Brink
21-
* Dirk Bäumer
21+
* Denis Nedelyaev
22+
* Dick van den Brink
23+
* Dirk Bäumer
24+
* Eyas Sharaiha
2225
* Frank Wallis
2326
* Gabriel Isenberg
2427
* Gilad Peleg
28+
* Graeme Wicksted
2529
* Guillaume Salles
2630
* Harald Niesche
2731
* Ingvar Stepanyan
@@ -31,30 +35,39 @@ TypeScript is authored by:
3135
* Jason Ramsay
3236
* Jed Mao
3337
* Johannes Rieken
38+
* John Vilk
3439
* Jonathan Bond-Caron
3540
* Jonathan Park
3641
* Jonathan Turner
3742
* Josh Kalderimis
43+
* Julian Williams
3844
* Kagami Sascha Rosylight
3945
* Keith Mashinter
46+
* Ken Howard
4047
* Kenji Imamula
4148
* Lorant Pinter
49+
* Martin Všetička
4250
* Masahiro Wakame
4351
* Max Deepfield
4452
* Micah Zoltu
4553
* Mohamed Hegazy
54+
* Nathan Shively-Sanders
4655
* Oleg Mihailik
4756
* Oleksandr Chekhovskyi
4857
* Paul van Brenk
4958
* Pedro Maltez
5059
* Philip Bulley
5160
* piloopin
61+
* @progre
62+
* Punya Biswal
5263
* Ron Buckton
5364
* Ryan Cavanaugh
65+
* Ryohei Ikegami
66+
* Sébastien Arod
5467
* Sheetal Nandi
5568
* Shengping Zhong
5669
* Shyyko Serhiy
57-
* Simon Hürlimann
70+
* Simon Hürlimann
5871
* Solal Pirelli
5972
* Stan Thomas
6073
* Steve Lucco
@@ -63,8 +76,10 @@ TypeScript is authored by:
6376
* togru
6477
* Tomas Grubliauskas
6578
* TruongSinh Tran-Nguyen
79+
* Viliv Vane
6680
* Vladimir Matveev
6781
* Wesley Wigham
82+
* York Yao
6883
* Yui Tanglertsampan
6984
* Zev Spitz
70-
* Zhengbo Li
85+
* Zhengbo Li

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[![Build Status](https://travis-ci.org/Microsoft/TypeScript.svg?branch=master)](https://travis-ci.org/Microsoft/TypeScript)
2-
[![npm version](https://badge.fury.io/js/typescript.svg)](http://badge.fury.io/js/typescript)
3-
[![Downloads](http://img.shields.io/npm/dm/TypeScript.svg)](https://npmjs.org/package/typescript)
2+
[![npm version](https://badge.fury.io/js/typescript.svg)](https://www.npmjs.com/package/typescript)
3+
[![Downloads](https://img.shields.io/npm/dm/TypeScript.svg)](https://www.npmjs.com/package/typescript)
44

55
# TypeScript
66

src/compiler/checker.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12886,13 +12886,13 @@ namespace ts {
1288612886
// In a 'switch' statement, each 'case' expression must be of a type that is assignable to or from the type of the 'switch' expression.
1288712887
const caseType = checkExpression(caseClause.expression);
1288812888

12889-
// Permit 'number[] | "foo"' to be asserted to 'string'.
12890-
if (expressionTypeIsStringLike && someConstituentTypeHasKind(caseType, TypeFlags.StringLike)) {
12891-
return;
12892-
}
12889+
const expressionTypeIsAssignableToCaseType =
12890+
// Permit 'number[] | "foo"' to be asserted to 'string'.
12891+
(expressionTypeIsStringLike && someConstituentTypeHasKind(caseType, TypeFlags.StringLike)) ||
12892+
isTypeAssignableTo(expressionType, caseType);
1289312893

12894-
if (!isTypeAssignableTo(expressionType, caseType)) {
12895-
// check 'expressionType isAssignableTo caseType' failed, try the reversed check and report errors if it fails
12894+
if (!expressionTypeIsAssignableToCaseType) {
12895+
// 'expressionType is not assignable to caseType', try the reversed check and report errors if it fails
1289612896
checkTypeAssignableTo(caseType, expressionType, caseClause.expression, /*headMessage*/ undefined);
1289712897
}
1289812898
}

src/compiler/emitter.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,13 +1592,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
15921592
/// these emit into an object literal property name, we don't need to be worried
15931593
/// about keywords, just non-identifier characters
15941594
function emitAttributeName(name: Identifier) {
1595-
if (/[A-Za-z_]+[\w*]/.test(name.text)) {
1596-
write("\"");
1595+
if (/^[A-Za-z_]\w*$/.test(name.text)) {
15971596
emit(name);
1598-
write("\"");
15991597
}
16001598
else {
1599+
write("\"");
16011600
emit(name);
1601+
write("\"");
16021602
}
16031603
}
16041604

src/compiler/program.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -997,16 +997,15 @@ namespace ts {
997997
if (options.mapRoot) {
998998
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap"));
999999
}
1000-
if (options.sourceRoot) {
1001-
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceRoot", "inlineSourceMap"));
1002-
}
10031000
}
10041001

1005-
10061002
if (options.inlineSources) {
10071003
if (!options.sourceMap && !options.inlineSourceMap) {
10081004
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided));
10091005
}
1006+
if (options.sourceRoot) {
1007+
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceRoot", "inlineSources"));
1008+
}
10101009
}
10111010

10121011
if (options.out && options.outFile) {
@@ -1018,10 +1017,9 @@ namespace ts {
10181017
if (options.mapRoot) {
10191018
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "mapRoot", "sourceMap"));
10201019
}
1021-
if (options.sourceRoot) {
1020+
if (options.sourceRoot && !options.inlineSourceMap) {
10221021
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "sourceRoot", "sourceMap"));
10231022
}
1024-
return;
10251023
}
10261024

10271025
const languageVersion = options.target || ScriptTarget.ES3;

src/services/services.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2847,8 +2847,11 @@ namespace ts {
28472847
}
28482848

28492849
function sourceFileUpToDate(sourceFile: SourceFile): boolean {
2850+
if (!sourceFile) {
2851+
return false;
2852+
}
28502853
let path = sourceFile.path || toPath(sourceFile.fileName, currentDirectory, getCanonicalFileName);
2851-
return sourceFile && sourceFile.version === hostCache.getVersion(path);
2854+
return sourceFile.version === hostCache.getVersion(path);
28522855
}
28532856

28542857
function programUpToDate(): boolean {
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//// [checkSwitchStatementIfCaseTypeIsString.ts]
2+
declare function use(a: any): void;
3+
4+
class A {
5+
doIt(x: Array<string>): void {
6+
x.forEach((v) => {
7+
switch(v) {
8+
case "test": use(this);
9+
}
10+
});
11+
}
12+
}
13+
14+
//// [checkSwitchStatementIfCaseTypeIsString.js]
15+
var A = (function () {
16+
function A() {
17+
}
18+
A.prototype.doIt = function (x) {
19+
var _this = this;
20+
x.forEach(function (v) {
21+
switch (v) {
22+
case "test": use(_this);
23+
}
24+
});
25+
};
26+
return A;
27+
})();
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
=== tests/cases/compiler/checkSwitchStatementIfCaseTypeIsString.ts ===
2+
declare function use(a: any): void;
3+
>use : Symbol(use, Decl(checkSwitchStatementIfCaseTypeIsString.ts, 0, 0))
4+
>a : Symbol(a, Decl(checkSwitchStatementIfCaseTypeIsString.ts, 0, 21))
5+
6+
class A {
7+
>A : Symbol(A, Decl(checkSwitchStatementIfCaseTypeIsString.ts, 0, 35))
8+
9+
doIt(x: Array<string>): void {
10+
>doIt : Symbol(doIt, Decl(checkSwitchStatementIfCaseTypeIsString.ts, 2, 9))
11+
>x : Symbol(x, Decl(checkSwitchStatementIfCaseTypeIsString.ts, 3, 9))
12+
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
13+
14+
x.forEach((v) => {
15+
>x.forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --))
16+
>x : Symbol(x, Decl(checkSwitchStatementIfCaseTypeIsString.ts, 3, 9))
17+
>forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --))
18+
>v : Symbol(v, Decl(checkSwitchStatementIfCaseTypeIsString.ts, 4, 19))
19+
20+
switch(v) {
21+
>v : Symbol(v, Decl(checkSwitchStatementIfCaseTypeIsString.ts, 4, 19))
22+
23+
case "test": use(this);
24+
>use : Symbol(use, Decl(checkSwitchStatementIfCaseTypeIsString.ts, 0, 0))
25+
>this : Symbol(A, Decl(checkSwitchStatementIfCaseTypeIsString.ts, 0, 35))
26+
}
27+
});
28+
}
29+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
=== tests/cases/compiler/checkSwitchStatementIfCaseTypeIsString.ts ===
2+
declare function use(a: any): void;
3+
>use : (a: any) => void
4+
>a : any
5+
6+
class A {
7+
>A : A
8+
9+
doIt(x: Array<string>): void {
10+
>doIt : (x: string[]) => void
11+
>x : string[]
12+
>Array : T[]
13+
14+
x.forEach((v) => {
15+
>x.forEach((v) => { switch(v) { case "test": use(this); } }) : void
16+
>x.forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void
17+
>x : string[]
18+
>forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void
19+
>(v) => { switch(v) { case "test": use(this); } } : (v: string) => void
20+
>v : string
21+
22+
switch(v) {
23+
>v : string
24+
25+
case "test": use(this);
26+
>"test" : string
27+
>use(this) : void
28+
>use : (a: any) => void
29+
>this : this
30+
}
31+
});
32+
}
33+
}

tests/baselines/reference/getEmitOutputTsxFile_React.baseline

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ declare class Bar {
1717

1818
EmitSkipped: false
1919
FileName : tests/cases/fourslash/inputFile2.js.map
20-
{"version":3,"file":"inputFile2.js","sourceRoot":"","sources":["inputFile2.tsx"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,QAAQ,CAAC;AACjB,IAAI,CAAC,GAAG,qBAAC,GAAG,KAAC,IAAI,GAAG,CAAE,EAAG,CAAA"}FileName : tests/cases/fourslash/inputFile2.js
20+
{"version":3,"file":"inputFile2.js","sourceRoot":"","sources":["inputFile2.tsx"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,QAAQ,CAAC;AACjB,IAAI,CAAC,GAAG,qBAAC,GAAG,IAAC,IAAI,EAAG,CAAE,EAAG,CAAA"}FileName : tests/cases/fourslash/inputFile2.js
2121
var y = "my div";
22-
var x = React.createElement("div", {"name": y});
22+
var x = React.createElement("div", {name: y});
2323
//# sourceMappingURL=inputFile2.js.mapFileName : tests/cases/fourslash/inputFile2.d.ts
2424
declare var y: string;
2525
declare var x: any;

0 commit comments

Comments
 (0)