Skip to content

Commit ac6224d

Browse files
committed
Merge pull request #7775 from Microsoft/libraryDirectives-2
Library directives support
2 parents 8e4541e + e5e7d47 commit ac6224d

File tree

118 files changed

+2550
-332
lines changed

Some content is hidden

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

118 files changed

+2550
-332
lines changed

src/compiler/commandLineParser.ts

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,9 +317,32 @@ namespace ts {
317317
}
318318
},
319319
{
320-
name: "traceModuleResolution",
320+
name: "typesSearchPaths",
321+
type: "list",
322+
isTSConfigOnly: true,
323+
element: {
324+
name: "typesSearchPaths",
325+
type: "string",
326+
isFilePath: true
327+
}
328+
},
329+
{
330+
name: "typesRoot",
331+
type: "string"
332+
},
333+
{
334+
name: "types",
335+
type: "list",
336+
element: {
337+
name: "types",
338+
type: "string"
339+
},
340+
description: Diagnostics.Type_declaration_files_to_be_included_in_compilation
341+
},
342+
{
343+
name: "traceResolution",
321344
type: "boolean",
322-
description: Diagnostics.Enable_tracing_of_the_module_resolution_process
345+
description: Diagnostics.Enable_tracing_of_the_name_resolution_process
323346
},
324347
{
325348
name: "allowJs",
@@ -641,6 +664,7 @@ namespace ts {
641664
const compilerOptions: CompilerOptions = convertCompilerOptionsFromJsonWorker(json["compilerOptions"], basePath, errors, configFileName);
642665
const options = extend(existingOptions, compilerOptions);
643666
const typingOptions: TypingOptions = convertTypingOptionsFromJsonWorker(json["typingOptions"], basePath, errors, configFileName);
667+
options.configFilePath = configFileName;
644668

645669
const fileNames = getFileNames(errors);
646670

src/compiler/diagnosticMessages.json

Lines changed: 68 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1903,10 +1903,10 @@
19031903
"category": "Error",
19041904
"code": 2684
19051905
},
1906-
"The 'this' types of each signature are incompatible.": {
1907-
"category": "Error",
1908-
"code": 2685
1909-
},
1906+
"The 'this' types of each signature are incompatible.": {
1907+
"category": "Error",
1908+
"code": 2685
1909+
},
19101910
"Import declaration '{0}' is using private name '{1}'.": {
19111911
"category": "Error",
19121912
"code": 4000
@@ -2187,6 +2187,11 @@
21872187
"category": "Error",
21882188
"code": 4082
21892189
},
2190+
"Conflicting library definitions for '{0}' found at '{1}' and '{2}'. Copy the correct file to the 'typings' folder to resolve this conflict.": {
2191+
"category": "Message",
2192+
"code": 4090
2193+
},
2194+
21902195
"The current host does not support the '{0}' option.": {
21912196
"category": "Error",
21922197
"code": 5001
@@ -2540,7 +2545,7 @@
25402545
"category": "Message",
25412546
"code": 6084
25422547
},
2543-
"Enable tracing of the module resolution process.": {
2548+
"Enable tracing of the name resolution process.": {
25442549
"category": "Message",
25452550
"code": 6085
25462551
},
@@ -2588,7 +2593,7 @@
25882593
"category": "Message",
25892594
"code": 6096
25902595
},
2591-
"File '{0}' exist - use it as a module resolution result.": {
2596+
"File '{0}' exist - use it as a name resolution result.": {
25922597
"category": "Message",
25932598
"code": 6097
25942599
},
@@ -2600,11 +2605,11 @@
26002605
"category": "Message",
26012606
"code": 6099
26022607
},
2603-
"'package.json' does not have 'typings' field.": {
2608+
"'package.json' does not have 'types' field.": {
26042609
"category": "Message",
26052610
"code": 6100
26062611
},
2607-
"'package.json' has 'typings' field '{0}' that references '{1}'.": {
2612+
"'package.json' has '{0}' field '{1}' that references '{2}'.": {
26082613
"category": "Message",
26092614
"code": 6101
26102615
},
@@ -2620,7 +2625,7 @@
26202625
"category": "Message",
26212626
"code": 6104
26222627
},
2623-
"Expected type of 'typings' field in 'package.json' to be 'string', got '{0}'.": {
2628+
"Expected type of '{0}' field in 'package.json' to be 'string', got '{1}'.": {
26242629
"category": "Message",
26252630
"code": 6105
26262631
},
@@ -2662,8 +2667,60 @@
26622667
},
26632668
"Raise error on 'this' expressions with an implied 'any' type.": {
26642669
"category": "Message",
2665-
"code": 6115
2666-
},
2670+
"code": 6115
2671+
},
2672+
"======== Resolving type reference directive '{0}', containing file '{1}', root directory '{2}'. ========": {
2673+
"category": "Message",
2674+
"code": 6116
2675+
},
2676+
"Resolving using primary search paths...": {
2677+
"category": "Message",
2678+
"code": 6117
2679+
},
2680+
"Resolving from node_modules folder...": {
2681+
"category": "Message",
2682+
"code": 6118
2683+
},
2684+
"======== Type reference directive '{0}' was successfully resolved to '{1}', primary: {2}. ========": {
2685+
"category": "Message",
2686+
"code": 6119
2687+
},
2688+
"======== Type reference directive '{0}' was not resolved. ========": {
2689+
"category": "Message",
2690+
"code": 6120
2691+
},
2692+
"Resolving with primary search path '{0}'": {
2693+
"category": "Message",
2694+
"code": 6121
2695+
},
2696+
"Root directory cannot be determined, skipping primary search paths.": {
2697+
"category": "Message",
2698+
"code": 6122
2699+
},
2700+
"======== Resolving type reference directive '{0}', containing file '{1}', root directory not set. ========": {
2701+
"category": "Message",
2702+
"code": 6123
2703+
},
2704+
"Type declaration files to be included in compilation.": {
2705+
"category": "Message",
2706+
"code": 6124
2707+
},
2708+
"Looking up in 'node_modules' folder, initial location '{0}'": {
2709+
"category": "Message",
2710+
"code": 6125
2711+
},
2712+
"Containing file is not specified and root directory cannot be determined, skipping lookup in 'node_modules' folder.": {
2713+
"category": "Message",
2714+
"code": 6126
2715+
},
2716+
"======== Resolving type reference directive '{0}', containing file not set, root directory '{1}'. ========": {
2717+
"category": "Message",
2718+
"code": 6127
2719+
},
2720+
"======== Resolving type reference directive '{0}', containing file not set, root directory not set. ========": {
2721+
"category": "Message",
2722+
"code": 6128
2723+
},
26672724
"Variable '{0}' implicitly has an '{1}' type.": {
26682725
"category": "Error",
26692726
"code": 7005

src/compiler/parser.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5509,6 +5509,7 @@ namespace ts {
55095509
function processReferenceComments(sourceFile: SourceFile): void {
55105510
const triviaScanner = createScanner(sourceFile.languageVersion, /*skipTrivia*/false, LanguageVariant.Standard, sourceText);
55115511
const referencedFiles: FileReference[] = [];
5512+
const typeReferenceDirectives: FileReference[] = [];
55125513
const amdDependencies: { path: string; name: string }[] = [];
55135514
let amdModuleName: string;
55145515

@@ -5535,7 +5536,12 @@ namespace ts {
55355536
sourceFile.hasNoDefaultLib = referencePathMatchResult.isNoDefaultLib;
55365537
const diagnosticMessage = referencePathMatchResult.diagnosticMessage;
55375538
if (fileReference) {
5538-
referencedFiles.push(fileReference);
5539+
if (referencePathMatchResult.isTypeReferenceDirective) {
5540+
typeReferenceDirectives.push(fileReference);
5541+
}
5542+
else {
5543+
referencedFiles.push(fileReference);
5544+
}
55395545
}
55405546
if (diagnosticMessage) {
55415547
parseDiagnostics.push(createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, diagnosticMessage));
@@ -5567,6 +5573,7 @@ namespace ts {
55675573
}
55685574

55695575
sourceFile.referencedFiles = referencedFiles;
5576+
sourceFile.typeReferenceDirectives = typeReferenceDirectives;
55705577
sourceFile.amdDependencies = amdDependencies;
55715578
sourceFile.moduleName = amdModuleName;
55725579
}

0 commit comments

Comments
 (0)