Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -67,26 +67,36 @@ export type StateForParameter = {
};
};

type ActionType = "PRIMARY" | "SECONDARY";

export type ActionForResponse = {
name: string;
from: string;
to: string;
filterCond: string;
type: ActionType;
executableUser?: {
entities: ExecutableUserEntityForResponse[];
};
};
} & (
| {
type: "PRIMARY";
}
| {
type: "SECONDARY";
executableUser: {
entities: ExecutableUserEntityForResponse[];
};
}
);

export type ActionForParameter = {
name: string;
from: string;
to: string;
filterCond?: string;
type?: ActionType;
executableUser?: {
entities: ExecutableUserEntityForParameter[];
};
};
} & (
| {
type?: "PRIMARY";
}
| {
type: "SECONDARY";
executableUser: {
entities: ExecutableUserEntityForParameter[];
};
}
);
Comment on lines +92 to +102
Copy link

Copilot AI Nov 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The discriminated union for ActionForParameter has a logical flaw. When type is optional on line 94 (type?: "PRIMARY"), it creates ambiguity: if type is undefined, TypeScript cannot determine which union branch applies. This breaks the discriminated union pattern and could allow objects without type or executableUser to pass type checking. Consider making type required for both branches (remove the ? on line 94) to maintain proper type discrimination, or restructure to explicitly handle the case where type is omitted (e.g., by making it a three-way union with an explicit branch for { type?: undefined }).

Copilot uses AI. Check for mistakes.
Loading