Skip to content

Commit 533cc96

Browse files
committed
Merge
2 parents 83df183 + 81f4e38 commit 533cc96

File tree

1,851 files changed

+7572
-2769
lines changed

Some content is hidden

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

1,851 files changed

+7572
-2769
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "typescript",
33
"author": "Microsoft Corp.",
44
"homepage": "http://typescriptlang.org/",
5-
"version": "2.2.0",
5+
"version": "2.3.0",
66
"license": "Apache-2.0",
77
"description": "TypeScript is a language for application scale JavaScript development",
88
"keywords": [

src/compiler/binder.ts

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1045,7 +1045,35 @@ namespace ts {
10451045
if (node.finallyBlock) {
10461046
// in finally flow is combined from pre-try/flow from try/flow from catch
10471047
// pre-flow is necessary to make sure that finally is reachable even if finally flows in both try and finally blocks are unreachable
1048-
addAntecedent(preFinallyLabel, preTryFlow);
1048+
1049+
// also for finally blocks we inject two extra edges into the flow graph.
1050+
// first -> edge that connects pre-try flow with the label at the beginning of the finally block, it has lock associated with it
1051+
// second -> edge that represents post-finally flow.
1052+
// these edges are used in following scenario:
1053+
// let a; (1)
1054+
// try { a = someOperation(); (2)}
1055+
// finally { (3) console.log(a) } (4)
1056+
// (5) a
1057+
1058+
// flow graph for this case looks roughly like this (arrows show ):
1059+
// (1-pre-try-flow) <--.. <-- (2-post-try-flow)
1060+
// ^ ^
1061+
// |*****(3-pre-finally-label) -----|
1062+
// ^
1063+
// |-- ... <-- (4-post-finally-label) <--- (5)
1064+
// In case when we walk the flow starting from inside the finally block we want to take edge '*****' into account
1065+
// since it ensures that finally is always reachable. However when we start outside the finally block and go through label (5)
1066+
// then edge '*****' should be discarded because label 4 is only reachable if post-finally label-4 is reachable
1067+
// Simply speaking code inside finally block is treated as reachable as pre-try-flow
1068+
// since we conservatively assume that any line in try block can throw or return in which case we'll enter finally.
1069+
// However code after finally is reachable only if control flow was not abrupted in try/catch or finally blocks - it should be composed from
1070+
// final flows of these blocks without taking pre-try flow into account.
1071+
//
1072+
// extra edges that we inject allows to control this behavior
1073+
// if when walking the flow we step on post-finally edge - we can mark matching pre-finally edge as locked so it will be skipped.
1074+
const preFinallyFlow: PreFinallyFlow = { flags: FlowFlags.PreFinally, antecedent: preTryFlow, lock: {} };
1075+
addAntecedent(preFinallyLabel, preFinallyFlow);
1076+
10491077
currentFlow = finishFlowLabel(preFinallyLabel);
10501078
bind(node.finallyBlock);
10511079
// if flow after finally is unreachable - keep it
@@ -1061,6 +1089,11 @@ namespace ts {
10611089
: unreachableFlow;
10621090
}
10631091
}
1092+
if (!(currentFlow.flags & FlowFlags.Unreachable)) {
1093+
const afterFinallyFlow: AfterFinallyFlow = { flags: FlowFlags.AfterFinally, antecedent: currentFlow };
1094+
preFinallyFlow.lock = afterFinallyFlow;
1095+
currentFlow = afterFinallyFlow;
1096+
}
10641097
}
10651098
else {
10661099
currentFlow = finishFlowLabel(preFinallyLabel);

src/compiler/checker.ts

Lines changed: 297 additions & 136 deletions
Large diffs are not rendered by default.

src/compiler/commandLineParser.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ namespace ts {
850850
* @param basePath A root directory to resolve relative path entries in the config
851851
* file to. e.g. outDir
852852
*/
853-
export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions: CompilerOptions = {}, configFileName?: string, resolutionStack: Path[] = [], extraFileExtensions: FileExtensionInfo[] = []): ParsedCommandLine {
853+
export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions: CompilerOptions = {}, configFileName?: string, resolutionStack: Path[] = [], extraFileExtensions: JsFileExtensionInfo[] = []): ParsedCommandLine {
854854
const errors: Diagnostic[] = [];
855855
basePath = normalizeSlashes(basePath);
856856
const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames);
@@ -1196,7 +1196,7 @@ namespace ts {
11961196
* @param host The host used to resolve files and directories.
11971197
* @param errors An array for diagnostic reporting.
11981198
*/
1199-
function matchFileNames(fileNames: string[], include: string[], exclude: string[], basePath: string, options: CompilerOptions, host: ParseConfigHost, errors: Diagnostic[], extraFileExtensions: FileExtensionInfo[]): ExpandResult {
1199+
function matchFileNames(fileNames: string[], include: string[], exclude: string[], basePath: string, options: CompilerOptions, host: ParseConfigHost, errors: Diagnostic[], extraFileExtensions: JsFileExtensionInfo[]): ExpandResult {
12001200
basePath = normalizePath(basePath);
12011201

12021202
// The exclude spec list is converted into a regular expression, which allows us to quickly
@@ -1371,7 +1371,7 @@ namespace ts {
13711371
*/
13721372
function hasFileWithHigherPriorityExtension(file: string, literalFiles: Map<string>, wildcardFiles: Map<string>, extensions: string[], keyMapper: (value: string) => string) {
13731373
const extensionPriority = getExtensionPriority(file, extensions);
1374-
const adjustedExtensionPriority = adjustExtensionPriority(extensionPriority);
1374+
const adjustedExtensionPriority = adjustExtensionPriority(extensionPriority, extensions);
13751375
for (let i = ExtensionPriority.Highest; i < adjustedExtensionPriority; i++) {
13761376
const higherPriorityExtension = extensions[i];
13771377
const higherPriorityPath = keyMapper(changeExtension(file, higherPriorityExtension));
@@ -1393,7 +1393,7 @@ namespace ts {
13931393
*/
13941394
function removeWildcardFilesWithLowerPriorityExtension(file: string, wildcardFiles: Map<string>, extensions: string[], keyMapper: (value: string) => string) {
13951395
const extensionPriority = getExtensionPriority(file, extensions);
1396-
const nextExtensionPriority = getNextLowestExtensionPriority(extensionPriority);
1396+
const nextExtensionPriority = getNextLowestExtensionPriority(extensionPriority, extensions);
13971397
for (let i = nextExtensionPriority; i < extensions.length; i++) {
13981398
const lowerPriorityExtension = extensions[i];
13991399
const lowerPriorityPath = keyMapper(changeExtension(file, lowerPriorityExtension));

src/compiler/core.ts

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace ts {
55
/** The version of the TypeScript compiler release */
6-
export const version = "2.2.0";
6+
export const version = "2.3.0";
77
}
88

99
/* @internal */
@@ -2020,14 +2020,14 @@ namespace ts {
20202020
export const supportedJavascriptExtensions = [".js", ".jsx"];
20212021
const allSupportedExtensions = supportedTypeScriptExtensions.concat(supportedJavascriptExtensions);
20222022

2023-
export function getSupportedExtensions(options?: CompilerOptions, extraFileExtensions?: FileExtensionInfo[]): string[] {
2023+
export function getSupportedExtensions(options?: CompilerOptions, extraFileExtensions?: JsFileExtensionInfo[]): string[] {
20242024
const needAllExtensions = options && options.allowJs;
2025-
if (!extraFileExtensions || extraFileExtensions.length === 0) {
2025+
if (!extraFileExtensions || extraFileExtensions.length === 0 || !needAllExtensions) {
20262026
return needAllExtensions ? allSupportedExtensions : supportedTypeScriptExtensions;
20272027
}
2028-
const extensions = (needAllExtensions ? allSupportedExtensions : supportedTypeScriptExtensions).slice(0);
2028+
const extensions = allSupportedExtensions.slice(0);
20292029
for (const extInfo of extraFileExtensions) {
2030-
if (needAllExtensions || extInfo.scriptKind === ScriptKind.TS) {
2030+
if (extensions.indexOf(extInfo.extension) === -1) {
20312031
extensions.push(extInfo.extension);
20322032
}
20332033
}
@@ -2042,7 +2042,7 @@ namespace ts {
20422042
return forEach(supportedTypeScriptExtensions, extension => fileExtensionIs(fileName, extension));
20432043
}
20442044

2045-
export function isSupportedSourceFileName(fileName: string, compilerOptions?: CompilerOptions, extraFileExtensions?: FileExtensionInfo[]) {
2045+
export function isSupportedSourceFileName(fileName: string, compilerOptions?: CompilerOptions, extraFileExtensions?: JsFileExtensionInfo[]) {
20462046
if (!fileName) { return false; }
20472047

20482048
for (const extension of getSupportedExtensions(compilerOptions, extraFileExtensions)) {
@@ -2061,7 +2061,6 @@ namespace ts {
20612061
export const enum ExtensionPriority {
20622062
TypeScriptFiles = 0,
20632063
DeclarationAndJavaScriptFiles = 2,
2064-
Limit = 5,
20652064

20662065
Highest = TypeScriptFiles,
20672066
Lowest = DeclarationAndJavaScriptFiles,
@@ -2070,7 +2069,7 @@ namespace ts {
20702069
export function getExtensionPriority(path: string, supportedExtensions: string[]): ExtensionPriority {
20712070
for (let i = supportedExtensions.length - 1; i >= 0; i--) {
20722071
if (fileExtensionIs(path, supportedExtensions[i])) {
2073-
return adjustExtensionPriority(<ExtensionPriority>i);
2072+
return adjustExtensionPriority(<ExtensionPriority>i, supportedExtensions);
20742073
}
20752074
}
20762075

@@ -2082,27 +2081,26 @@ namespace ts {
20822081
/**
20832082
* Adjusts an extension priority to be the highest priority within the same range.
20842083
*/
2085-
export function adjustExtensionPriority(extensionPriority: ExtensionPriority): ExtensionPriority {
2084+
export function adjustExtensionPriority(extensionPriority: ExtensionPriority, supportedExtensions: string[]): ExtensionPriority {
20862085
if (extensionPriority < ExtensionPriority.DeclarationAndJavaScriptFiles) {
20872086
return ExtensionPriority.TypeScriptFiles;
20882087
}
2089-
else if (extensionPriority < ExtensionPriority.Limit) {
2088+
else if (extensionPriority < supportedExtensions.length) {
20902089
return ExtensionPriority.DeclarationAndJavaScriptFiles;
20912090
}
20922091
else {
2093-
return ExtensionPriority.Limit;
2094-
}
2095-
}
2092+
return supportedExtensions.length;
2093+
} }
20962094

20972095
/**
20982096
* Gets the next lowest extension priority for a given priority.
20992097
*/
2100-
export function getNextLowestExtensionPriority(extensionPriority: ExtensionPriority): ExtensionPriority {
2098+
export function getNextLowestExtensionPriority(extensionPriority: ExtensionPriority, supportedExtensions: string[]): ExtensionPriority {
21012099
if (extensionPriority < ExtensionPriority.DeclarationAndJavaScriptFiles) {
21022100
return ExtensionPriority.DeclarationAndJavaScriptFiles;
21032101
}
21042102
else {
2105-
return ExtensionPriority.Limit;
2103+
return supportedExtensions.length;
21062104
}
21072105
}
21082106

src/compiler/declarationEmitter.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,13 +324,20 @@ namespace ts {
324324
function writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, type: TypeNode, getSymbolAccessibilityDiagnostic: GetSymbolAccessibilityDiagnostic) {
325325
writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic;
326326
write(": ");
327-
if (type) {
327+
328+
// use the checker's type, not the declared type,
329+
// for non-optional initialized parameters that aren't a parameter property
330+
const shouldUseResolverType = declaration.kind === SyntaxKind.Parameter &&
331+
resolver.isRequiredInitializedParameter(declaration as ParameterDeclaration);
332+
if (type && !shouldUseResolverType) {
328333
// Write the type
329334
emitType(type);
330335
}
331336
else {
332337
errorNameNode = declaration.name;
333-
resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, TypeFormatFlags.UseTypeOfFunction | TypeFormatFlags.UseTypeAliasValue, writer);
338+
const format = TypeFormatFlags.UseTypeOfFunction | TypeFormatFlags.UseTypeAliasValue |
339+
(shouldUseResolverType ? TypeFormatFlags.AddUndefined : 0);
340+
resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, format, writer);
334341
errorNameNode = undefined;
335342
}
336343
}

src/compiler/diagnosticMessages.json

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,10 @@
671671
"category": "Error",
672672
"code": 1215
673673
},
674+
"Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules.": {
675+
"category": "Error",
676+
"code": 1216
677+
},
674678
"Export assignment is not supported when '--module' flag is 'system'.": {
675679
"category": "Error",
676680
"code": 1218
@@ -1787,6 +1791,10 @@
17871791
"category": "Error",
17881792
"code": 2545
17891793
},
1794+
"Property '{0}' has conflicting declarations and is inaccessible in type '{1}'.": {
1795+
"category": "Error",
1796+
"code": 2546
1797+
},
17901798
"JSX element attributes type '{0}' may not be a union type.": {
17911799
"category": "Error",
17921800
"code": 2600
@@ -2047,6 +2055,10 @@
20472055
"category": "Error",
20482056
"code": 2704
20492057
},
2058+
"An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option.": {
2059+
"category": "Error",
2060+
"code": 2705
2061+
},
20502062

20512063
"Import declaration '{0}' is using private name '{1}'.": {
20522064
"category": "Error",
@@ -2801,7 +2813,7 @@
28012813
"category": "Message",
28022814
"code": 6099
28032815
},
2804-
"'package.json' does not have a 'types' or 'main' field.": {
2816+
"'package.json' does not have a '{0}' field.": {
28052817
"category": "Message",
28062818
"code": 6100
28072819
},
@@ -2949,10 +2961,6 @@
29492961
"category": "Message",
29502962
"code": 6136
29512963
},
2952-
"No types specified in 'package.json', so returning 'main' value of '{0}'": {
2953-
"category": "Message",
2954-
"code": 6137
2955-
},
29562964
"Property '{0}' is declared but never used.": {
29572965
"category": "Error",
29582966
"code": 6138

0 commit comments

Comments
 (0)