| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -248,6 +248,13 @@ namespace ts { | |||
| 248 | 248 | category: Diagnostics.Basic_Options, | |
| 249 | 249 | description: Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, | |
| 250 | 250 | }, | |
| 251 | + { | ||
| 252 | + name: "composite", | ||
| 253 | + type: "boolean", | ||
| 254 | + isTSConfigOnly: true, | ||
| 255 | + category: Diagnostics.Basic_Options, | ||
| 256 | + description: Diagnostics.Enable_project_compilation, | ||
| 257 | + }, | ||
| 251 | 258 | { | |
| 252 | 259 | name: "removeComments", | |
| 253 | 260 | type: "boolean", | |
@@ -827,12 +834,14 @@ namespace ts { | |||
| 827 | 834 | export function parseCommandLine(commandLine: ReadonlyArray<string>, readFile?: (path: string) => string | undefined): ParsedCommandLine { | |
| 828 | 835 | const options: CompilerOptions = {}; | |
| 829 | 836 | const fileNames: string[] = []; | |
| 837 | + const projectReferences: ProjectReference[] | undefined = undefined; | ||
| 830 | 838 | const errors: Diagnostic[] = []; | |
| 831 | 839 | ||
| 832 | 840 | parseStrings(commandLine); | |
| 833 | 841 | return { | |
| 834 | 842 | options, | |
| 835 | 843 | fileNames, | |
| 844 | + projectReferences, | ||
| 836 | 845 | errors | |
| 837 | 846 | }; | |
| 838 | 847 | ||
@@ -946,6 +955,49 @@ namespace ts { | |||
| 946 | 955 | return optionNameMap.get(optionName); | |
| 947 | 956 | } | |
| 948 | 957 | ||
| 958 | + | ||
| 959 | + export type DiagnosticReporter = (diagnostic: Diagnostic) => void; | ||
| 960 | + /** | ||
| 961 | + * Reports config file diagnostics | ||
| 962 | + */ | ||
| 963 | + export interface ConfigFileDiagnosticsReporter { | ||
| 964 | + /** | ||
| 965 | + * Reports unrecoverable error when parsing config file | ||
| 966 | + */ | ||
| 967 | + onUnRecoverableConfigFileDiagnostic: DiagnosticReporter; | ||
| 968 | + } | ||
| 969 | + | ||
| 970 | + /** | ||
| 971 | + * Interface extending ParseConfigHost to support ParseConfigFile that reads config file and reports errors | ||
| 972 | + */ | ||
| 973 | + export interface ParseConfigFileHost extends ParseConfigHost, ConfigFileDiagnosticsReporter { | ||
| 974 | + getCurrentDirectory(): string; | ||
| 975 | + } | ||
| 976 | + | ||
| 977 | + /** | ||
| 978 | + * Reads the config file, reports errors if any and exits if the config file cannot be found | ||
| 979 | + */ | ||
| 980 | + export function getParsedCommandLineOfConfigFile(configFileName: string, optionsToExtend: CompilerOptions, host: ParseConfigFileHost): ParsedCommandLine | undefined { | ||
| 981 | + let configFileText: string; | ||
| 982 | + try { | ||
| 983 | + configFileText = host.readFile(configFileName); | ||
| 984 | + } | ||
| 985 | + catch (e) { | ||
| 986 | + const error = createCompilerDiagnostic(Diagnostics.Cannot_read_file_0_Colon_1, configFileName, e.message); | ||
| 987 | + host.onUnRecoverableConfigFileDiagnostic(error); | ||
| 988 | + return undefined; | ||
| 989 | + } | ||
| 990 | + if (!configFileText) { | ||
| 991 | + const error = createCompilerDiagnostic(Diagnostics.File_0_not_found, configFileName); | ||
| 992 | + host.onUnRecoverableConfigFileDiagnostic(error); | ||
| 993 | + return undefined; | ||
| 994 | + } | ||
| 995 | + | ||
| 996 | + const result = parseJsonText(configFileName, configFileText); | ||
| 997 | + const cwd = host.getCurrentDirectory(); | ||
| 998 | + return parseJsonSourceFileConfigFileContent(result, host, getNormalizedAbsolutePath(getDirectoryPath(configFileName), cwd), optionsToExtend, getNormalizedAbsolutePath(configFileName, cwd)); | ||
| 999 | + } | ||
| 1000 | + | ||
| 949 | 1001 | /** | |
| 950 | 1002 | * Read tsconfig.json file | |
| 951 | 1003 | * @param fileName The path to the config file | |
@@ -1021,6 +1073,14 @@ namespace ts { | |||
| 1021 | 1073 | name: "extends", | |
| 1022 | 1074 | type: "string" | |
| 1023 | 1075 | }, | |
| 1076 | + { | ||
| 1077 | + name: "references", | ||
| 1078 | + type: "list", | ||
| 1079 | + element: { | ||
| 1080 | + name: "references", | ||
| 1081 | + type: "object" | ||
| 1082 | + } | ||
| 1083 | + }, | ||
| 1024 | 1084 | { | |
| 1025 | 1085 | name: "files", | |
| 1026 | 1086 | type: "list", | |
@@ -1428,7 +1488,7 @@ namespace ts { | |||
| 1428 | 1488 | for (let i = 0; i < nameColumn.length; i++) { | |
| 1429 | 1489 | const optionName = nameColumn[i]; | |
| 1430 | 1490 | const description = descriptionColumn[i]; | |
| 1431 | - result.push(optionName && `${tab}${tab}${optionName}${ description && (makePadding(marginLength - optionName.length + 2) + description)}`); | ||
| 1491 | + result.push(optionName && `${tab}${tab}${optionName}${description && (makePadding(marginLength - optionName.length + 2) + description)}`); | ||
| 1432 | 1492 | } | |
| 1433 | 1493 | if (fileNames.length) { | |
| 1434 | 1494 | result.push(`${tab}},`); | |
@@ -1512,12 +1572,13 @@ namespace ts { | |||
| 1512 | 1572 | const parsedConfig = parseConfig(json, sourceFile, host, basePath, configFileName, resolutionStack, errors); | |
| 1513 | 1573 | const { raw } = parsedConfig; | |
| 1514 | 1574 | const options = extend(existingOptions, parsedConfig.options || {}); | |
| 1515 | - options.configFilePath = configFileName; | ||
| 1575 | + options.configFilePath = configFileName && normalizeSlashes(configFileName); | ||
| 1516 | 1576 | setConfigFileInOptions(options, sourceFile); | |
| 1517 | - const { fileNames, wildcardDirectories, spec } = getFileNames(); | ||
| 1577 | + const { fileNames, wildcardDirectories, spec, projectReferences } = getFileNames(); | ||
| 1518 | 1578 | return { | |
| 1519 | 1579 | options, | |
| 1520 | 1580 | fileNames, | |
| 1581 | + projectReferences, | ||
| 1521 | 1582 | typeAcquisition: parsedConfig.typeAcquisition || getDefaultTypeAcquisition(), | |
| 1522 | 1583 | raw, | |
| 1523 | 1584 | errors, | |
@@ -1571,10 +1632,33 @@ namespace ts { | |||
| 1571 | 1632 | } | |
| 1572 | 1633 | ||
| 1573 | 1634 | const result = matchFileNames(filesSpecs, includeSpecs, excludeSpecs, configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath, options, host, errors, extraFileExtensions, sourceFile); | |
| 1574 | - if (result.fileNames.length === 0 && !hasProperty(raw, "files") && resolutionStack.length === 0) { | ||
| 1635 | + if (result.fileNames.length === 0 && !hasProperty(raw, "files") && resolutionStack.length === 0 && !hasProperty(raw, "references")) { | ||
| 1575 | 1636 | errors.push(getErrorForNoInputFiles(result.spec, configFileName)); | |
| 1576 | 1637 | } | |
| 1577 | 1638 | ||
| 1639 | + if (hasProperty(raw, "references") && !isNullOrUndefined(raw.references)) { | ||
| 1640 | + if (isArray(raw.references)) { | ||
| 1641 | + const references: ProjectReference[] = []; | ||
| 1642 | + for (const ref of raw.references) { | ||
| 1643 | + if (typeof ref.path !== "string") { | ||
| 1644 | + createCompilerDiagnosticOnlyIfJson(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "reference.path", "string"); | ||
| 1645 | + } | ||
| 1646 | + else { | ||
| 1647 | + references.push({ | ||
| 1648 | + path: getNormalizedAbsolutePath(ref.path, basePath), | ||
| 1649 | + originalPath: ref.path, | ||
| 1650 | + prepend: ref.prepend, | ||
| 1651 | + circular: ref.circular | ||
| 1652 | + }); | ||
| 1653 | + } | ||
| 1654 | + } | ||
| 1655 | + result.projectReferences = references; | ||
| 1656 | + } | ||
| 1657 | + else { | ||
| 1658 | + createCompilerDiagnosticOnlyIfJson(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "references", "Array"); | ||
| 1659 | + } | ||
| 1660 | + } | ||
| 1661 | + | ||
| 1578 | 1662 | return result; | |
| 1579 | 1663 | } | |
| 1580 | 1664 | ||
@@ -1863,6 +1947,9 @@ namespace ts { | |||
| 1863 | 1947 | ||
| 1864 | 1948 | const options = getDefaultCompilerOptions(configFileName); | |
| 1865 | 1949 | convertOptionsFromJson(optionDeclarations, jsonOptions, basePath, options, Diagnostics.Unknown_compiler_option_0, errors); | |
| 1950 | + if (configFileName) { | ||
| 1951 | + options.configFilePath = normalizeSlashes(configFileName); | ||
| 1952 | + } | ||
| 1866 | 1953 | return options; | |
| 1867 | 1954 | } | |
| 1868 | 1955 | ||
@@ -2061,7 +2148,7 @@ namespace ts { | |||
| 2061 | 2148 | // new entries in these paths. | |
| 2062 | 2149 | const wildcardDirectories = getWildcardDirectories(validatedIncludeSpecs, validatedExcludeSpecs, basePath, host.useCaseSensitiveFileNames); | |
| 2063 | 2150 | ||
| 2064 | - const spec: ConfigFileSpecs = { filesSpecs, includeSpecs, excludeSpecs, validatedIncludeSpecs, validatedExcludeSpecs, wildcardDirectories }; | ||
| 2151 | + const spec: ConfigFileSpecs = { filesSpecs, referencesSpecs: undefined, includeSpecs, excludeSpecs, validatedIncludeSpecs, validatedExcludeSpecs, wildcardDirectories }; | ||
| 2065 | 2152 | return getFileNamesFromConfigSpecs(spec, basePath, options, host, extraFileExtensions); | |
| 2066 | 2153 | } | |
| 2067 | 2154 | ||
@@ -2132,8 +2219,16 @@ namespace ts { | |||
| 2132 | 2219 | ||
| 2133 | 2220 | const literalFiles = arrayFrom(literalFileMap.values()); | |
| 2134 | 2221 | const wildcardFiles = arrayFrom(wildcardFileMap.values()); | |
| 2222 | + const projectReferences = spec.referencesSpecs && spec.referencesSpecs.map((r): ProjectReference => { | ||
| 2223 | + return { | ||
| 2224 | + ...r, | ||
| 2225 | + path: getNormalizedAbsolutePath(r.path, basePath) | ||
| 2226 | + }; | ||
| 2227 | + }); | ||
| 2228 | + | ||
| 2135 | 2229 | return { | |
| 2136 | 2230 | fileNames: literalFiles.concat(wildcardFiles), | |
| 2231 | + projectReferences, | ||
| 2137 | 2232 | wildcardDirectories, | |
| 2138 | 2233 | spec | |
| 2139 | 2234 | }; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2068,6 +2068,10 @@ namespace ts { | |||
| 2068 | 2068 | : moduleKind === ModuleKind.System; | |
| 2069 | 2069 | } | |
| 2070 | 2070 | ||
| 2071 | + export function getEmitDeclarations(compilerOptions: CompilerOptions): boolean { | ||
| 2072 | + return !!(compilerOptions.declaration || compilerOptions.composite); | ||
| 2073 | + } | ||
| 2074 | + | ||
| 2071 | 2075 | export type StrictOptionName = "noImplicitAny" | "noImplicitThis" | "strictNullChecks" | "strictFunctionTypes" | "strictPropertyInitialization" | "alwaysStrict"; | |
| 2072 | 2076 | ||
| 2073 | 2077 | export function getStrictOptionValue(compilerOptions: CompilerOptions, flag: StrictOptionName): boolean { | |
@@ -2328,6 +2332,7 @@ namespace ts { | |||
| 2328 | 2332 | const reduced = [components[0]]; | |
| 2329 | 2333 | for (let i = 1; i < components.length; i++) { | |
| 2330 | 2334 | const component = components[i]; | |
| 2335 | + if (!component) continue; | ||
| 2331 | 2336 | if (component === ".") continue; | |
| 2332 | 2337 | if (component === "..") { | |
| 2333 | 2338 | if (reduced.length > 1) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -895,7 +895,7 @@ | |||
| 895 | 895 | "category": "Error", | |
| 896 | 896 | "code": 1322 | |
| 897 | 897 | }, | |
| 898 | - "Dynamic import cannot be used when targeting ECMAScript 2015 modules.": { | ||
| 898 | + "Dynamic import is only supported when '--module' flag is 'commonjs' or 'esNext'.": { | ||
| 899 | 899 | "category": "Error", | |
| 900 | 900 | "code": 1323 | |
| 901 | 901 | }, | |
@@ -3559,6 +3559,48 @@ | |||
| 3559 | 3559 | "category": "Message", | |
| 3560 | 3560 | "code": 6197 | |
| 3561 | 3561 | }, | |
| 3562 | + "All destructured elements are unused.": { | ||
| 3563 | + "category": "Error", | ||
| 3564 | + "code": 6198, | ||
| 3565 | + "reportsUnnecessary": true | ||
| 3566 | + }, | ||
| 3567 | + | ||
| 3568 | + "Projects to reference": { | ||
| 3569 | + "category": "Message", | ||
| 3570 | + "code": 6300 | ||
| 3571 | + }, | ||
| 3572 | + "Enable project compilation": { | ||
| 3573 | + "category": "Message", | ||
| 3574 | + "code": 6302 | ||
| 3575 | + }, | ||
| 3576 | + "Project references may not form a circular graph. Cycle detected: {0}": { | ||
| 3577 | + "category": "Error", | ||
| 3578 | + "code": 6202 | ||
| 3579 | + }, | ||
| 3580 | + "Composite projects may not disable declaration emit.": { | ||
| 3581 | + "category": "Error", | ||
| 3582 | + "code": 6304 | ||
| 3583 | + }, | ||
| 3584 | + "Output file '{0}' has not been built from source file '{1}'.": { | ||
| 3585 | + "category": "Error", | ||
| 3586 | + "code": 6305 | ||
| 3587 | + }, | ||
| 3588 | + "Referenced project '{0}' must have setting \"composite\": true.": { | ||
| 3589 | + "category": "Error", | ||
| 3590 | + "code": 6306 | ||
| 3591 | + }, | ||
| 3592 | + "File '{0}' is not in project file list. Projects must list all files or use an 'include' pattern.": { | ||
| 3593 | + "category": "Error", | ||
| 3594 | + "code": 6307 | ||
| 3595 | + }, | ||
| 3596 | + "Cannot prepend project '{0}' because it does not have 'outFile' set": { | ||
| 3597 | + "category": "Error", | ||
| 3598 | + "code": 6308 | ||
| 3599 | + }, | ||
| 3600 | + "Output file '{0}' from project '{1}' does not exist": { | ||
| 3601 | + "category": "Error", | ||
| 3602 | + "code": 6309 | ||
| 3603 | + }, | ||
| 3562 | 3604 | ||
| 3563 | 3605 | "Variable '{0}' implicitly has an '{1}' type.": { | |
| 3564 | 3606 | "category": "Error", | |
@@ -3956,6 +3998,10 @@ | |||
| 3956 | 3998 | "category": "Message", | |
| 3957 | 3999 | "code": 90008 | |
| 3958 | 4000 | }, | |
| 4001 | + "Remove destructuring": { | ||
| 4002 | + "category": "Message", | ||
| 4003 | + "code": 90009 | ||
| 4004 | + }, | ||
| 3959 | 4005 | "Import '{0}' from module \"{1}\"": { | |
| 3960 | 4006 | "category": "Message", | |
| 3961 | 4007 | "code": 90013 | |
| Back | FazBrowse Home | New Git URL |
0 commit comments