Skip to content

Commit 05882ff

Browse files
committed
Merge branch 'useBaselinesForQuickInfoTests' into literalTypesAlways
2 parents f73b4be + 069c10c commit 05882ff

File tree

106 files changed

+39817
-8975
lines changed

Some content is hidden

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

106 files changed

+39817
-8975
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ matrix:
2323
branches:
2424
only:
2525
- master
26-
- transforms
26+
- release.2.0
2727

2828
install:
2929
- npm uninstall typescript

Jakefile.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,16 +120,27 @@ var servicesSources = [
120120
].map(function (f) {
121121
return path.join(compilerDirectory, f);
122122
}).concat([
123+
"types.ts",
124+
"utilities.ts",
123125
"breakpoints.ts",
126+
"classifier.ts",
127+
"completions.ts",
128+
"documentHighlights.ts",
129+
"findAllReferences.ts",
130+
"goToDefinition.ts",
131+
"jsDoc.ts",
132+
"jsTyping.ts",
124133
"navigateTo.ts",
125134
"navigationBar.ts",
126135
"outliningElementsCollector.ts",
127136
"patternMatcher.ts",
137+
"preProcess.ts",
138+
"rename.ts",
128139
"services.ts",
129140
"shims.ts",
130141
"signatureHelp.ts",
131-
"types.ts",
132-
"utilities.ts",
142+
"symbolDisplay.ts",
143+
"transpile.ts",
133144
"formatting/formatting.ts",
134145
"formatting/formattingContext.ts",
135146
"formatting/formattingRequestKind.ts",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
"ts-node": "latest",
7878
"tsd": "latest",
7979
"tslint": "next",
80-
"typescript": "2.1.0-dev.20160906"
80+
"typescript": "next"
8181
},
8282
"scripts": {
8383
"pretest": "jake tests",

scripts/tslint/preferConstRule.ts

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,44 +9,12 @@ export class Rule extends Lint.Rules.AbstractRule {
99
}
1010
}
1111

12-
function isBindingPattern(node: ts.Node): node is ts.BindingPattern {
13-
return !!node && (node.kind === ts.SyntaxKind.ArrayBindingPattern || node.kind === ts.SyntaxKind.ObjectBindingPattern);
14-
}
15-
16-
function walkUpBindingElementsAndPatterns(node: ts.Node): ts.Node {
17-
while (node && (node.kind === ts.SyntaxKind.BindingElement || isBindingPattern(node))) {
18-
node = node.parent;
19-
}
20-
21-
return node;
22-
}
23-
24-
function getCombinedNodeFlags(node: ts.Node): ts.NodeFlags {
25-
node = walkUpBindingElementsAndPatterns(node);
26-
27-
let flags = node.flags;
28-
if (node.kind === ts.SyntaxKind.VariableDeclaration) {
29-
node = node.parent;
30-
}
31-
32-
if (node && node.kind === ts.SyntaxKind.VariableDeclarationList) {
33-
flags |= node.flags;
34-
node = node.parent;
35-
}
36-
37-
if (node && node.kind === ts.SyntaxKind.VariableStatement) {
38-
flags |= node.flags;
39-
}
40-
41-
return flags;
42-
}
43-
4412
function isLet(node: ts.Node) {
45-
return !!(getCombinedNodeFlags(node) & ts.NodeFlags.Let);
13+
return !!(ts.getCombinedNodeFlags(node) & ts.NodeFlags.Let);
4614
}
4715

4816
function isExported(node: ts.Node) {
49-
return !!(getCombinedNodeFlags(node) & ts.NodeFlags.Export);
17+
return !!(ts.getCombinedModifierFlags(node) & ts.ModifierFlags.Export);
5018
}
5119

5220
function isAssignmentOperator(token: ts.SyntaxKind): boolean {

src/compiler/checker.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10060,6 +10060,10 @@ namespace ts {
1006010060
return isTypeAny(type) || isTypeOfKind(type, kind);
1006110061
}
1006210062

10063+
function isInfinityOrNaNString(name: string): boolean {
10064+
return name === "Infinity" || name === "-Infinity" || name === "NaN";
10065+
}
10066+
1006310067
function isNumericLiteralName(name: string) {
1006410068
// The intent of numeric names is that
1006510069
// - they are names with text in a numeric form, and that
@@ -16839,7 +16843,7 @@ namespace ts {
1683916843
}
1684016844
else {
1684116845
const text = getTextOfPropertyName(<PropertyName>member.name);
16842-
if (isNumericLiteralName(text)) {
16846+
if (isNumericLiteralName(text) && !isInfinityOrNaNString(text)) {
1684316847
error(member.name, Diagnostics.An_enum_member_cannot_have_a_numeric_name);
1684416848
}
1684516849
}

src/compiler/commandLineParser.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -858,14 +858,13 @@ namespace ts {
858858
errors.push(createCompilerDiagnostic(Diagnostics.Unknown_option_excludes_Did_you_mean_exclude));
859859
}
860860
else {
861-
// By default, exclude common package folders
861+
// By default, exclude common package folders and the outDir
862862
excludeSpecs = ["node_modules", "bower_components", "jspm_packages"];
863-
}
864863

865-
// Always exclude the output directory unless explicitly included
866-
const outDir = json["compilerOptions"] && json["compilerOptions"]["outDir"];
867-
if (outDir) {
868-
excludeSpecs.push(outDir);
864+
const outDir = json["compilerOptions"] && json["compilerOptions"]["outDir"];
865+
if (outDir) {
866+
excludeSpecs.push(outDir);
867+
}
869868
}
870869

871870
if (fileNames === undefined && includeSpecs === undefined) {

src/compiler/emitter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2030,7 +2030,7 @@ const _super = (function (geti, seti) {
20302030
emitTrailingCommentsOfPosition(commentRange.pos);
20312031
}
20322032

2033-
emitExpression(node.initializer);
2033+
emitExpression(initializer);
20342034
}
20352035

20362036
function emitShorthandPropertyAssignment(node: ShorthandPropertyAssignment) {

src/compiler/parser.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,10 @@ namespace ts {
905905
return currentToken = scanner.scanJsxToken();
906906
}
907907

908+
function scanJsxAttributeValue(): SyntaxKind {
909+
return currentToken = scanner.scanJsxAttributeValue();
910+
}
911+
908912
function speculationHelper<T>(callback: () => T, isLookAhead: boolean): T {
909913
// Keep track of the state we'll need to rollback to if lookahead fails (or if the
910914
// caller asked us to always reset our state).
@@ -3831,8 +3835,8 @@ namespace ts {
38313835
scanJsxIdentifier();
38323836
const node = <JsxAttribute>createNode(SyntaxKind.JsxAttribute);
38333837
node.name = parseIdentifierName();
3834-
if (parseOptional(SyntaxKind.EqualsToken)) {
3835-
switch (token()) {
3838+
if (token() === SyntaxKind.EqualsToken) {
3839+
switch (scanJsxAttributeValue()) {
38363840
case SyntaxKind.StringLiteral:
38373841
node.initializer = parseLiteralNode();
38383842
break;

src/compiler/scanner.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ namespace ts {
2727
reScanSlashToken(): SyntaxKind;
2828
reScanTemplateToken(): SyntaxKind;
2929
scanJsxIdentifier(): SyntaxKind;
30+
scanJsxAttributeValue(): SyntaxKind;
3031
reScanJsxToken(): SyntaxKind;
3132
scanJsxToken(): SyntaxKind;
3233
scanJSDocToken(): SyntaxKind;
@@ -817,6 +818,7 @@ namespace ts {
817818
reScanSlashToken,
818819
reScanTemplateToken,
819820
scanJsxIdentifier,
821+
scanJsxAttributeValue,
820822
reScanJsxToken,
821823
scanJsxToken,
822824
scanJSDocToken,
@@ -911,7 +913,7 @@ namespace ts {
911913
return value;
912914
}
913915

914-
function scanString(): string {
916+
function scanString(allowEscapes = true): string {
915917
const quote = text.charCodeAt(pos);
916918
pos++;
917919
let result = "";
@@ -929,7 +931,7 @@ namespace ts {
929931
pos++;
930932
break;
931933
}
932-
if (ch === CharacterCodes.backslash) {
934+
if (ch === CharacterCodes.backslash && allowEscapes) {
933935
result += text.substring(start, pos);
934936
result += scanEscapeSequence();
935937
start = pos;
@@ -1737,6 +1739,20 @@ namespace ts {
17371739
return token;
17381740
}
17391741

1742+
function scanJsxAttributeValue(): SyntaxKind {
1743+
startPos = pos;
1744+
1745+
switch (text.charCodeAt(pos)) {
1746+
case CharacterCodes.doubleQuote:
1747+
case CharacterCodes.singleQuote:
1748+
tokenValue = scanString(/*allowEscapes*/ false);
1749+
return token = SyntaxKind.StringLiteral;
1750+
default:
1751+
// If this scans anything other than `{`, it's a parse error.
1752+
return scan();
1753+
}
1754+
}
1755+
17401756
function scanJSDocToken(): SyntaxKind {
17411757
if (pos >= end) {
17421758
return token = SyntaxKind.EndOfFileToken;

src/compiler/transformers/jsx.ts

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ namespace ts {
140140
return createLiteral(true);
141141
}
142142
else if (node.kind === SyntaxKind.StringLiteral) {
143-
return node;
143+
const decoded = tryDecodeEntities((<StringLiteral>node).text);
144+
return decoded ? createLiteral(decoded, /*location*/ node) : node;
144145
}
145146
else if (node.kind === SyntaxKind.JsxExpression) {
146147
return visitJsxExpression(<JsxExpression>node);
@@ -210,19 +211,31 @@ namespace ts {
210211
}
211212

212213
/**
213-
* Decodes JSX entities.
214+
* Replace entities like "&nbsp;", "&#123;", and "&#xDEADBEEF;" with the characters they encode.
215+
* See https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references
214216
*/
215-
function decodeEntities(text: string) {
216-
return text.replace(/&(\w+);/g, function(s: any, m: string) {
217-
if (entities[m] !== undefined) {
218-
return String.fromCharCode(entities[m]);
217+
function decodeEntities(text: string): string {
218+
return text.replace(/&((#((\d+)|x([\da-fA-F]+)))|(\w+));/g, (match, _all, _number, _digits, decimal, hex, word) => {
219+
if (decimal) {
220+
return String.fromCharCode(parseInt(decimal, 10));
221+
}
222+
else if (hex) {
223+
return String.fromCharCode(parseInt(hex, 16));
219224
}
220225
else {
221-
return s;
226+
const ch = entities[word];
227+
// If this is not a valid entity, then just use `match` (replace it with itself, i.e. don't replace)
228+
return ch ? String.fromCharCode(ch) : match;
222229
}
223230
});
224231
}
225232

233+
/** Like `decodeEntities` but returns `undefined` if there were no entities to decode. */
234+
function tryDecodeEntities(text: string): string | undefined {
235+
const decoded = decodeEntities(text);
236+
return decoded === text ? undefined : decoded;
237+
}
238+
226239
function getTagName(node: JsxElement | JsxOpeningLikeElement): Expression {
227240
if (node.kind === SyntaxKind.JsxElement) {
228241
return getTagName((<JsxElement>node).openingElement);

0 commit comments

Comments
 (0)