Allow 'paths' without 'baseUrl' (#40101)

* Allow paths without baseUrl

* Remove exception for leading * paths

* Add comment, remove commented code

* Update baselines

* Remove unnecessary default

* Fix test harness

* Fix baseline

* Resolve relative to host.getCurrentDirectory() with createProgram API
This commit is contained in:
Andrew Branch
2020-09-11 12:58:40 -07:00
committed by GitHub
parent aa2756a5d7
commit 9c8d11b5ed
26 changed files with 295 additions and 22 deletions

View File

@@ -2994,10 +2994,6 @@ namespace ts {
}
}
if (options.paths && options.baseUrl === undefined) {
createDiagnosticForOptionName(Diagnostics.Option_paths_cannot_be_used_without_specifying_baseUrl_option, "paths");
}
if (options.composite) {
if (options.declaration === false) {
createDiagnosticForOptionName(Diagnostics.Composite_projects_may_not_disable_declaration_emit, "declaration");
@@ -3056,6 +3052,9 @@ namespace ts {
if (!hasZeroOrOneAsteriskCharacter(subst)) {
createDiagnosticForOptionPathKeyValue(key, i, Diagnostics.Substitution_0_in_pattern_1_can_have_at_most_one_Asterisk_character, subst, key);
}
if (!options.baseUrl && !pathIsRelative(subst) && !pathIsAbsolute(subst)) {
createDiagnosticForOptionPathKeyValue(key, i, Diagnostics.Non_relative_paths_are_not_allowed_when_baseUrl_is_not_set_Did_you_forget_a_leading_Slash);
}
}
else {
createDiagnosticForOptionPathKeyValue(key, i, Diagnostics.Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2, subst, key, typeOfSubst);
@@ -3339,7 +3338,7 @@ namespace ts {
});
}
function createDiagnosticForOptionPathKeyValue(key: string, valueIndex: number, message: DiagnosticMessage, arg0: string | number, arg1: string | number, arg2?: string | number) {
function createDiagnosticForOptionPathKeyValue(key: string, valueIndex: number, message: DiagnosticMessage, arg0?: string | number, arg1?: string | number, arg2?: string | number) {
let needCompilerDiagnostic = true;
const pathsSyntax = getOptionPathsSyntax();
for (const pathProp of pathsSyntax) {