Skip to content

Commit dedf4a7

Browse files
committed
Merge branch 'master' into asyncGenerators
2 parents 3e427f4 + 58b8a54 commit dedf4a7

File tree

1,687 files changed

+5584
-1718
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,687 files changed

+5584
-1718
lines changed

src/compiler/checker.ts

Lines changed: 223 additions & 120 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
@@ -847,7 +847,7 @@ namespace ts {
847847
* @param basePath A root directory to resolve relative path entries in the config
848848
* file to. e.g. outDir
849849
*/
850-
export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions: CompilerOptions = {}, configFileName?: string, resolutionStack: Path[] = [], extraFileExtensions: FileExtensionInfo[] = []): ParsedCommandLine {
850+
export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions: CompilerOptions = {}, configFileName?: string, resolutionStack: Path[] = [], extraFileExtensions: JsFileExtensionInfo[] = []): ParsedCommandLine {
851851
const errors: Diagnostic[] = [];
852852
basePath = normalizeSlashes(basePath);
853853
const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames);
@@ -1193,7 +1193,7 @@ namespace ts {
11931193
* @param host The host used to resolve files and directories.
11941194
* @param errors An array for diagnostic reporting.
11951195
*/
1196-
function matchFileNames(fileNames: string[], include: string[], exclude: string[], basePath: string, options: CompilerOptions, host: ParseConfigHost, errors: Diagnostic[], extraFileExtensions: FileExtensionInfo[]): ExpandResult {
1196+
function matchFileNames(fileNames: string[], include: string[], exclude: string[], basePath: string, options: CompilerOptions, host: ParseConfigHost, errors: Diagnostic[], extraFileExtensions: JsFileExtensionInfo[]): ExpandResult {
11971197
basePath = normalizePath(basePath);
11981198

11991199
// The exclude spec list is converted into a regular expression, which allows us to quickly
@@ -1368,7 +1368,7 @@ namespace ts {
13681368
*/
13691369
function hasFileWithHigherPriorityExtension(file: string, literalFiles: Map<string>, wildcardFiles: Map<string>, extensions: string[], keyMapper: (value: string) => string) {
13701370
const extensionPriority = getExtensionPriority(file, extensions);
1371-
const adjustedExtensionPriority = adjustExtensionPriority(extensionPriority);
1371+
const adjustedExtensionPriority = adjustExtensionPriority(extensionPriority, extensions);
13721372
for (let i = ExtensionPriority.Highest; i < adjustedExtensionPriority; i++) {
13731373
const higherPriorityExtension = extensions[i];
13741374
const higherPriorityPath = keyMapper(changeExtension(file, higherPriorityExtension));
@@ -1390,7 +1390,7 @@ namespace ts {
13901390
*/
13911391
function removeWildcardFilesWithLowerPriorityExtension(file: string, wildcardFiles: Map<string>, extensions: string[], keyMapper: (value: string) => string) {
13921392
const extensionPriority = getExtensionPriority(file, extensions);
1393-
const nextExtensionPriority = getNextLowestExtensionPriority(extensionPriority);
1393+
const nextExtensionPriority = getNextLowestExtensionPriority(extensionPriority, extensions);
13941394
for (let i = nextExtensionPriority; i < extensions.length; i++) {
13951395
const lowerPriorityExtension = extensions[i];
13961396
const lowerPriorityPath = keyMapper(changeExtension(file, lowerPriorityExtension));

src/compiler/core.ts

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -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: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,10 @@
675675
"category": "Error",
676676
"code": 1215
677677
},
678+
"Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules.": {
679+
"category": "Error",
680+
"code": 1216
681+
},
678682
"Export assignment is not supported when '--module' flag is 'system'.": {
679683
"category": "Error",
680684
"code": 1218
@@ -1799,18 +1803,22 @@
17991803
"category": "Error",
18001804
"code": 2545
18011805
},
1802-
"The type returned by the 'next()' method of an async iterator must be a promise for a type with a 'value' property.": {
1806+
"Property '{0}' has conflicting declarations and is inaccessible in type '{1}'.": {
18031807
"category": "Error",
18041808
"code": 2546
18051809
},
1806-
"Type '{0}' is not an array type or does not have a '[Symbol.iterator]()' method that returns an iterator.": {
1810+
"The type returned by the 'next()' method of an async iterator must be a promise for a type with a 'value' property.": {
18071811
"category": "Error",
18081812
"code": 2547
18091813
},
1810-
"Type '{0}' is not an array type or a string type or does not have a '[Symbol.iterator]()' method that returns an iterator.": {
1814+
"Type '{0}' is not an array type or does not have a '[Symbol.iterator]()' method that returns an iterator.": {
18111815
"category": "Error",
18121816
"code": 2548
18131817
},
1818+
"Type '{0}' is not an array type or a string type or does not have a '[Symbol.iterator]()' method that returns an iterator.": {
1819+
"category": "Error",
1820+
"code": 2549
1821+
},
18141822
"JSX element attributes type '{0}' may not be a union type.": {
18151823
"category": "Error",
18161824
"code": 2600
@@ -2825,7 +2833,7 @@
28252833
"category": "Message",
28262834
"code": 6099
28272835
},
2828-
"'package.json' does not have a 'types' or 'main' field.": {
2836+
"'package.json' does not have a '{0}' field.": {
28292837
"category": "Message",
28302838
"code": 6100
28312839
},
@@ -2973,10 +2981,6 @@
29732981
"category": "Message",
29742982
"code": 6136
29752983
},
2976-
"No types specified in 'package.json', so returning 'main' value of '{0}'": {
2977-
"category": "Message",
2978-
"code": 6137
2979-
},
29802984
"Property '{0}' is declared but never used.": {
29812985
"category": "Error",
29822986
"code": 6138

0 commit comments

Comments
 (0)