Skip to content

Commit b69622a

Browse files
committed
Merge branch 'master' into transitiveReferences
2 parents 578f8db + 0f4a615 commit b69622a

File tree

106 files changed

+3512
-1712
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

+3512
-1712
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,6 @@ to establish the new baselines as the desired behavior. This will change the fil
194194
## Localization
195195

196196
All strings the user may see are stored in [`diagnosticMessages.json`](./src/compiler/diagnosticMessages.json).
197-
If you make changes to it, run `jake generate-diagnostics` to push them to the `Diagnostic` interface in [`diagnosticInformationMap.generated.ts`](./src/compiler/diagnosticInformationMap.generated.ts).
197+
If you make changes to it, run `jake generate-diagnostics` to push them to the `Diagnostic` interface in `diagnosticInformationMap.generated.ts`.
198198

199199
See [coding guidelines on diagnostic messages](https://github.com/Microsoft/TypeScript/wiki/Coding-guidelines#diagnostic-messages).

src/compiler/checker.ts

Lines changed: 112 additions & 87 deletions
Large diffs are not rendered by default.

src/compiler/commandLineParser.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2512,11 +2512,16 @@ namespace ts {
25122512
// via wildcard, and to handle extension priority.
25132513
const wildcardFileMap = createMap<string>();
25142514

2515+
// Wildcard paths of json files (provided via the "includes" array in tsconfig.json) are stored in a
2516+
// file map with a possibly case insensitive key. We use this map to store paths matched
2517+
// via wildcard of *.json kind
2518+
const wildCardJsonFileMap = createMap<string>();
25152519
const { filesSpecs, validatedIncludeSpecs, validatedExcludeSpecs, wildcardDirectories } = spec;
25162520

25172521
// Rather than requery this for each file and filespec, we query the supported extensions
25182522
// once and store it on the expansion context.
25192523
const supportedExtensions = getSupportedExtensions(options, extraFileExtensions);
2524+
const supportedExtensionsWithJsonIfResolveJsonModule = getSuppoertedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions);
25202525

25212526
// Literal files are always included verbatim. An "include" or "exclude" specification cannot
25222527
// remove a literal file.
@@ -2527,8 +2532,25 @@ namespace ts {
25272532
}
25282533
}
25292534

2535+
let jsonOnlyIncludeRegexes: ReadonlyArray<RegExp> | undefined;
25302536
if (validatedIncludeSpecs && validatedIncludeSpecs.length > 0) {
2531-
for (const file of host.readDirectory(basePath, supportedExtensions, validatedExcludeSpecs, validatedIncludeSpecs, /*depth*/ undefined)) {
2537+
for (const file of host.readDirectory(basePath, supportedExtensionsWithJsonIfResolveJsonModule, validatedExcludeSpecs, validatedIncludeSpecs, /*depth*/ undefined)) {
2538+
if (fileExtensionIs(file, Extension.Json)) {
2539+
// Valid only if *.json specified
2540+
if (!jsonOnlyIncludeRegexes) {
2541+
const includes = validatedIncludeSpecs.filter(s => endsWith(s, Extension.Json));
2542+
const includeFilePatterns = map(getRegularExpressionsForWildcards(includes, basePath, "files"), pattern => `^${pattern}$`);
2543+
jsonOnlyIncludeRegexes = includeFilePatterns ? includeFilePatterns.map(pattern => getRegexFromPattern(pattern, host.useCaseSensitiveFileNames)) : emptyArray;
2544+
}
2545+
const includeIndex = findIndex(jsonOnlyIncludeRegexes, re => re.test(file));
2546+
if (includeIndex !== -1) {
2547+
const key = keyMapper(file);
2548+
if (!literalFileMap.has(key) && !wildCardJsonFileMap.has(key)) {
2549+
wildCardJsonFileMap.set(key, file);
2550+
}
2551+
}
2552+
continue;
2553+
}
25322554
// If we have already included a literal or wildcard path with a
25332555
// higher priority extension, we should skip this file.
25342556
//
@@ -2556,7 +2578,7 @@ namespace ts {
25562578
const wildcardFiles = arrayFrom(wildcardFileMap.values());
25572579

25582580
return {
2559-
fileNames: literalFiles.concat(wildcardFiles),
2581+
fileNames: literalFiles.concat(wildcardFiles, arrayFrom(wildCardJsonFileMap.values())),
25602582
wildcardDirectories,
25612583
spec
25622584
};

src/compiler/core.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1602,8 +1602,9 @@ namespace ts {
16021602
return value;
16031603
}
16041604

1605-
export function assertNever(member: never, message?: string, stackCrawlMark?: AnyFunction): never {
1606-
return fail(message || `Illegal value: ${member}`, stackCrawlMark || assertNever);
1605+
export function assertNever(member: never, message = "Illegal value:", stackCrawlMark?: AnyFunction): never {
1606+
const detail = "kind" in member && "pos" in member ? "SyntaxKind: " + showSyntaxKind(member as Node) : JSON.stringify(member);
1607+
return fail(`${message} ${detail}`, stackCrawlMark || assertNever);
16071608
}
16081609

16091610
export function getFunctionName(func: AnyFunction) {

src/compiler/diagnosticMessages.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2485,10 +2485,6 @@
24852485
"category": "Error",
24862486
"code": 2732
24872487
},
2488-
"Index '{0}' is out-of-bounds in tuple of length {1}.": {
2489-
"category": "Error",
2490-
"code": 2733
2491-
},
24922488
"It is highly likely that you are missing a semicolon.": {
24932489
"category": "Error",
24942490
"code": 2734

src/compiler/emitter.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ namespace ts {
5252
else {
5353
const ownOutputFilePath = getOwnEmitOutputFilePath(sourceFile.fileName, host, getOutputExtension(sourceFile, options));
5454
// If json file emits to the same location skip writing it, if emitDeclarationOnly skip writing it
55-
const jsFilePath = options.emitDeclarationOnly ? undefined : ownOutputFilePath;
55+
const isJsonEmittedToSameLocation = isJsonSourceFile(sourceFile) &&
56+
comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === Comparison.EqualTo;
57+
const jsFilePath = options.emitDeclarationOnly || isJsonEmittedToSameLocation ? undefined : ownOutputFilePath;
5658
const sourceMapFilePath = !jsFilePath || isJsonSourceFile(sourceFile) ? undefined : getSourceMapFilePath(jsFilePath, options);
5759
// For legacy reasons (ie, we have baselines capturing the behavior), js files don't report a .d.ts output path - this would only matter if `declaration` and `allowJs` were both on, which is currently an error
5860
const isJs = isSourceFileJS(sourceFile);

src/compiler/parser.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1482,7 +1482,15 @@ namespace ts {
14821482
// which would be a candidate for improved error reporting.
14831483
return token() === SyntaxKind.OpenBracketToken || isLiteralPropertyName();
14841484
case ParsingContext.ObjectLiteralMembers:
1485-
return token() === SyntaxKind.OpenBracketToken || token() === SyntaxKind.AsteriskToken || token() === SyntaxKind.DotDotDotToken || isLiteralPropertyName();
1485+
switch (token()) {
1486+
case SyntaxKind.OpenBracketToken:
1487+
case SyntaxKind.AsteriskToken:
1488+
case SyntaxKind.DotDotDotToken:
1489+
case SyntaxKind.DotToken: // Not an object literal member, but don't want to close the object (see `tests/cases/fourslash/completionsDotInObjectLiteral.ts`)
1490+
return true;
1491+
default:
1492+
return isLiteralPropertyName();
1493+
}
14861494
case ParsingContext.RestProperties:
14871495
return isLiteralPropertyName();
14881496
case ParsingContext.ObjectBindingElements:

src/compiler/program.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ namespace ts {
630630
const programDiagnostics = createDiagnosticCollection();
631631
const currentDirectory = host.getCurrentDirectory();
632632
const supportedExtensions = getSupportedExtensions(options);
633-
const supportedExtensionsWithJsonIfResolveJsonModule = options.resolveJsonModule ? [...supportedExtensions, Extension.Json] : undefined;
633+
const supportedExtensionsWithJsonIfResolveJsonModule = getSuppoertedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions);
634634

635635
// Map storing if there is emit blocking diagnostics for given input
636636
const hasEmitBlockingDiagnostics = createMap<boolean>();
@@ -1994,7 +1994,7 @@ namespace ts {
19941994
refFile?: SourceFile): SourceFile | undefined {
19951995

19961996
if (hasExtension(fileName)) {
1997-
if (!options.allowNonTsExtensions && !forEach(supportedExtensionsWithJsonIfResolveJsonModule || supportedExtensions, extension => fileExtensionIs(host.getCanonicalFileName(fileName), extension))) {
1997+
if (!options.allowNonTsExtensions && !forEach(supportedExtensionsWithJsonIfResolveJsonModule, extension => fileExtensionIs(host.getCanonicalFileName(fileName), extension))) {
19981998
if (fail) fail(Diagnostics.File_0_has_unsupported_extension_The_only_supported_extensions_are_1, fileName, "'" + supportedExtensions.join("', '") + "'");
19991999
return undefined;
20002000
}
@@ -2060,6 +2060,7 @@ namespace ts {
20602060
redirect.resolvedPath = resolvedPath;
20612061
redirect.originalFileName = originalFileName;
20622062
redirect.redirectInfo = { redirectTarget, unredirected };
2063+
sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0);
20632064
Object.defineProperties(redirect, {
20642065
id: {
20652066
get(this: SourceFile) { return this.redirectInfo!.redirectTarget.id; },

src/compiler/sys.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,6 @@ namespace ts {
3636
Low = 250
3737
}
3838

39-
function getPriorityValues(highPriorityValue: number): [number, number, number] {
40-
const mediumPriorityValue = highPriorityValue * 2;
41-
const lowPriorityValue = mediumPriorityValue * 4;
42-
return [highPriorityValue, mediumPriorityValue, lowPriorityValue];
43-
}
44-
45-
function pollingInterval(watchPriority: PollingInterval): number {
46-
return pollingIntervalsForPriority[watchPriority];
47-
}
48-
49-
const pollingIntervalsForPriority = getPriorityValues(250);
50-
51-
/* @internal */
52-
export function watchFileUsingPriorityPollingInterval(host: System, fileName: string, callback: FileWatcherCallback, watchPriority: PollingInterval): FileWatcher {
53-
return host.watchFile!(fileName, callback, pollingInterval(watchPriority));
54-
}
55-
5639
/* @internal */
5740
export type HostWatchFile = (fileName: string, callback: FileWatcherCallback, pollingInterval: PollingInterval | undefined) => FileWatcher;
5841
/* @internal */

src/compiler/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4078,6 +4078,7 @@ namespace ts {
40784078
templateType?: Type;
40794079
modifiersType?: Type;
40804080
resolvedApparentType?: Type;
4081+
instantiating?: boolean;
40814082
}
40824083

40834084
export interface EvolvingArrayType extends ObjectType {

0 commit comments

Comments
 (0)