Skip to content

Commit 2f9048c

Browse files
committed
Require BaseState to be declared explicitly
1 parent 2dbfdca commit 2f9048c

7 files changed

Lines changed: 11 additions & 7 deletions

src/action-common.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export interface BaseState {
2222

2323
/** Describes different state features that an Action may have. */
2424
export interface FeatureState {
25+
Base: BaseState;
2526
Logger: {
2627
/** The logger that is in use. */
2728
logger: Logger;
@@ -52,7 +53,7 @@ export type StateFeature = keyof FeatureState;
5253

5354
/** Constructs the intersection of all state types identifies by `Fs`. */
5455
export type FieldsOf<Fs extends readonly StateFeature[]> = Fs extends []
55-
? BaseState
56+
? Record<never, never>
5657
: Fs extends [
5758
infer Head extends StateFeature,
5859
...infer Tail extends readonly StateFeature[],
@@ -68,7 +69,7 @@ export type ActionState<Fs extends readonly StateFeature[]> = FieldsOf<Fs>;
6869
* Each Action can then augment the `state` further if additional features are required.
6970
*/
7071
export type ActionMain = (
71-
state: ActionState<["Logger", "Env", "Actions"]>,
72+
state: ActionState<["Base", "Logger", "Env", "Actions"]>,
7273
) => Promise<void>;
7374

7475
/** A specification for a CodeQL Action step. */

src/analyze-action.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ async function runAutobuildIfLegacyGoWorkflow(config: Config, logger: Logger) {
212212
await runAutobuild(config, BuiltInLanguage.go, logger);
213213
}
214214

215-
async function run({ startedAt, logger }: ActionState<["Logger"]>) {
215+
async function run({ startedAt, logger }: ActionState<["Base", "Logger"]>) {
216216
// To capture errors appropriately, keep as much code within the try-catch as
217217
// possible, and only use safe functions outside.
218218

src/autobuild-action.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ async function sendCompletedStatusReport(
6868
}
6969
}
7070

71-
async function run({ startedAt, logger }: ActionState<["Logger"]>) {
71+
async function run({ startedAt, logger }: ActionState<["Base", "Logger"]>) {
7272
// To capture errors appropriately, keep as much code within the try-catch as
7373
// possible, and only use safe functions outside.
7474

src/init-action.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,9 @@ async function sendCompletedStatusReport(
203203
}
204204
}
205205

206-
async function run(actionState: ActionState<["Logger", "Env", "Actions"]>) {
206+
async function run(
207+
actionState: ActionState<["Base", "Logger", "Env", "Actions"]>,
208+
) {
207209
// To capture errors appropriately, keep as much code within the try-catch as
208210
// possible, and only use safe functions outside.
209211

src/setup-codeql-action.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ async function sendCompletedStatusReport(
9090
async function run({
9191
startedAt,
9292
logger,
93-
}: ActionState<["Logger"]>): Promise<void> {
93+
}: ActionState<["Base", "Logger"]>): Promise<void> {
9494
// To capture errors appropriately, keep as much code within the try-catch as
9595
// possible, and only use safe functions outside.
9696

src/testing-utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ export function getTestActionsEnv(): ActionsEnv {
194194

195195
/** For testing purposes, we make all available state features accessible in `TestEnv`. */
196196
type AllState = [
197+
"Base",
197198
"Logger",
198199
"Env",
199200
"ReadOnlyEnv",

src/upload-sarif-action.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ async function sendSuccessStatusReport(
5454
}
5555
}
5656

57-
async function run({ startedAt, logger }: ActionState<["Logger"]>) {
57+
async function run({ startedAt, logger }: ActionState<["Base", "Logger"]>) {
5858
// To capture errors appropriately, keep as much code within the try-catch as
5959
// possible, and only use safe functions outside.
6060
try {

0 commit comments

Comments
 (0)