Skip to content

Add a new project root option (fixes #1513). #2034

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bin/typescript.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1134,6 +1134,7 @@ declare module "typescript" {
outDir?: string;
preserveConstEnums?: boolean;
project?: string;
projectRoot?: string;
removeComments?: boolean;
sourceMap?: boolean;
sourceRoot?: string;
Expand Down
10 changes: 9 additions & 1 deletion src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,15 @@ module ts {
shortName: "w",
type: "boolean",
description: Diagnostics.Watch_input_files,
}
},
{
name: "projectRoot",
type: "string",
isFilePath: true,
description: Diagnostics.Specifies_the_directory_where_the_project_root_is_Paths_to_source_map_sources_will_appear_relative_to_this_directory,
paramType: Diagnostics.DIRECTORY,
},

];

export function parseCommandLine(commandLine: string[]): ParsedCommandLine {
Expand Down
1 change: 1 addition & 0 deletions src/compiler/diagnosticInformationMap.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ module ts {
File_0_must_have_extension_ts_or_d_ts: { code: 6054, category: DiagnosticCategory.Error, key: "File '{0}' must have extension '.ts' or '.d.ts'." },
Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: DiagnosticCategory.Message, key: "Suppress noImplicitAny errors for indexing objects lacking index signatures." },
Do_not_emit_declarations_for_code_that_has_an_internal_annotation: { code: 6056, category: DiagnosticCategory.Message, key: "Do not emit declarations for code that has an '@internal' annotation." },
Specifies_the_directory_where_the_project_root_is_Paths_to_source_map_sources_will_appear_relative_to_this_directory: { code: 6057, category: DiagnosticCategory.Message, key: "Specifies the directory where the project root is. Paths to source map sources will appear relative to this directory." },
Variable_0_implicitly_has_an_1_type: { code: 7005, category: DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." },
Parameter_0_implicitly_has_an_1_type: { code: 7006, category: DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." },
Member_0_implicitly_has_an_1_type: { code: 7008, category: DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." },
Expand Down
4 changes: 4 additions & 0 deletions src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1737,6 +1737,10 @@
"category": "Message",
"code": 6056
},
"Specifies the directory where the project root is. Paths to source map sources will appear relative to this directory.": {
"category": "Message",
"code": 6057
},

"Variable '{0}' implicitly has an '{1}' type.": {
"category": "Error",
Expand Down
8 changes: 5 additions & 3 deletions src/compiler/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1784,9 +1784,11 @@ module ts {

function recordNewSourceFileStart(node: SourceFile) {
// Add the file to tsFilePaths
// If sourceroot option: Use the relative path corresponding to the common directory path
// otherwise source locations relative to map file location
var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir;
// If sourceroot option: use the relative path corresponding to the project root (if specified) or the common directory path
// Otherwise source locations relative to map file location
var sourcesDirectoryPath = compilerOptions.sourceRoot
? compilerOptions.projectRoot || host.getCommonSourceDirectory()
: sourceMapDir;

sourceMapData.sourceMapSources.push(getRelativePathToDirectoryOrUrl(sourcesDirectoryPath,
node.fileName,
Expand Down
1 change: 1 addition & 0 deletions src/compiler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1474,6 +1474,7 @@ module ts {
outDir?: string;
preserveConstEnums?: boolean;
project?: string;
projectRoot?: string;
removeComments?: boolean;
sourceMap?: boolean;
sourceRoot?: string;
Expand Down