Skip to content

Revert PR #53301 #53366

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

Merged
merged 1 commit into from
Mar 20, 2023
Merged
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
14 changes: 7 additions & 7 deletions src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
emptyArray,
endsWith,
ensureTrailingDirectorySeparator,
every,
Expression,
extend,
Extension,
Expand Down Expand Up @@ -2973,7 +2974,7 @@ function parseJsonConfigFileContentWorker(
};

function getConfigFileSpecs(): ConfigFileSpecs {
const referencesOfRaw = getPropFromRaw("references", (element): element is ProjectReference => !!element && typeof element === "object", "object");
const referencesOfRaw = getPropFromRaw<ProjectReference>("references", element => typeof element === "object", "object");
const filesSpecs = toPropValue(getSpecsFromRaw("files"));
if (filesSpecs) {
const hasZeroOrNoReferences = referencesOfRaw === "no-prop" || isArray(referencesOfRaw) && referencesOfRaw.length === 0;
Expand Down Expand Up @@ -3048,7 +3049,7 @@ function parseJsonConfigFileContentWorker(

function getProjectReferences(basePath: string): readonly ProjectReference[] | undefined {
let projectReferences: ProjectReference[] | undefined;
const referencesOfRaw = getPropFromRaw("references", (element): element is ProjectReference => !!element && typeof element === "object", "object");
const referencesOfRaw = getPropFromRaw<ProjectReference>("references", element => typeof element === "object", "object");
if (isArray(referencesOfRaw)) {
for (const ref of referencesOfRaw) {
if (typeof ref.path !== "string") {
Expand Down Expand Up @@ -3076,12 +3077,11 @@ function parseJsonConfigFileContentWorker(
return getPropFromRaw(prop, isString, "string");
}

function getPropFromRaw<T>(prop: "files" | "include" | "exclude" | "references", validateElement: (value: unknown) => value is T, elementTypeName: string): PropOfRaw<T> {
function getPropFromRaw<T>(prop: "files" | "include" | "exclude" | "references", validateElement: (value: unknown) => boolean, elementTypeName: string): PropOfRaw<T> {
if (hasProperty(raw, prop) && !isNullOrUndefined(raw[prop])) {
const value = raw[prop];
if (isArray(value)) {
const result = filter(value, validateElement);
if (!sourceFile && result.length !== value.length) {
if (isArray(raw[prop])) {
const result = raw[prop] as T[];
if (!sourceFile && !every(result, validateElement)) {
errors.push(createCompilerDiagnostic(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, prop, elementTypeName));
}
return result;
Expand Down