Skip to content

Commit 7ba7ed7

Browse files
committed
Update types for optional things to be more consistent
1 parent 1581d7c commit 7ba7ed7

File tree

14 files changed

+61
-60
lines changed

14 files changed

+61
-60
lines changed

src/commands/fix/git.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export function getSocketFixCommitMessage(
5050

5151
export function getSocketFixPullRequestBody(
5252
ghsaIds: string[],
53-
ghsaDetails?: Map<string, GhsaDetails>,
53+
ghsaDetails?: Map<string, GhsaDetails> | undefined,
5454
): string {
5555
const vulnCount = ghsaIds.length
5656
if (vulnCount === 1) {

src/commands/fix/pull-request.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ export async function cleanupSocketFixPrs(
198198

199199
export type PrAutoMergeState = {
200200
enabled: boolean
201-
details?: string[]
201+
details?: string[] | undefined
202202
}
203203

204204
export type SocketPrsOptions = {

src/commands/login/cmd-login.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ async function run(
8989
}
9090

9191
const { apiBaseUrl, apiProxy } = cli.flags as {
92-
apiBaseUrl?: string
93-
apiProxy?: string
92+
apiBaseUrl?: string | undefined
93+
apiProxy?: string | undefined
9494
}
9595

9696
await attemptLogin(apiBaseUrl, apiProxy)

src/constants.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export type IpcObject = Readonly<{
167167
}>
168168

169169
export type ProcessEnv = {
170-
[K in keyof ENV]?: string
170+
[K in keyof ENV]?: string | undefined
171171
}
172172

173173
const ALERT_TYPE_CRITICAL_CVE = 'criticalCVE'

src/flags.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export type NumberFlag = Flag<'number', number> | Flag<'number', number[], true>
1818

1919
export type StringFlag = Flag<'string', string> | Flag<'string', string[], true>
2020

21-
export type MeowFlag = AnyFlag & { description: string; hidden?: boolean }
21+
export type MeowFlag = AnyFlag & { description: string; hidden?: boolean | undefined }
2222

2323
// We use this description in getFlagListOutput, meow doesn't care.
2424
export type MeowFlags = Record<string, MeowFlag>

src/shadow/npm/arborist/types.mts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import type {
1414
} from '@npmcli/arborist'
1515

1616
export type ArboristOptions = BaseArboristOptions & {
17-
npmCommand?: string
18-
npmVersion?: string
17+
npmCommand?: string | undefined
18+
npmVersion?: string | undefined
1919
}
2020

2121
export type ArboristClass = ArboristInstance & {
@@ -37,10 +37,10 @@ export type ArboristInstance = Omit<
3737
actualTree?: NodeClass | null | undefined
3838
diff: Diff | null
3939
idealTree?: NodeClass | null | undefined
40-
buildIdealTree(options?: BuildIdealTreeOptions): Promise<NodeClass>
41-
loadActual(options?: ArboristOptions): Promise<NodeClass>
42-
loadVirtual(options?: ArboristOptions): Promise<NodeClass>
43-
reify(options?: ArboristReifyOptions): Promise<NodeClass>
40+
buildIdealTree(options?: BuildIdealTreeOptions | undefined): Promise<NodeClass>
41+
loadActual(options?: ArboristOptions | undefined): Promise<NodeClass>
42+
loadVirtual(options?: ArboristOptions | undefined): Promise<NodeClass>
43+
reify(options?: ArboristReifyOptions | undefined): Promise<NodeClass>
4444
}
4545

4646
export type ArboristReifyOptions = ReifyOptions & ArboristOptions
@@ -111,7 +111,7 @@ export type EdgeClass = Omit<
111111
get to(): NodeClass | null
112112
new (...args: any): EdgeClass
113113
detach(): void
114-
reload(hard?: boolean): void
114+
reload(hard?: boolean | undefined): void
115115
satisfiedBy(node: NodeClass): boolean
116116
}
117117

@@ -178,9 +178,9 @@ export type NodeClass = Omit<
178178
new (...args: any): NodeClass
179179
addEdgeIn(edge: EdgeClass): void
180180
addEdgeOut(edge: EdgeClass): void
181-
canDedupe(preferDedupe?: boolean): boolean
182-
canReplace(node: NodeClass, ignorePeers?: string[]): boolean
183-
canReplaceWith(node: NodeClass, ignorePeers?: string[]): boolean
181+
canDedupe(preferDedupe?: boolean | undefined): boolean
182+
canReplace(node: NodeClass, ignorePeers?: string[] | undefined): boolean
183+
canReplaceWith(node: NodeClass, ignorePeers?: string[] | undefined): boolean
184184
deleteEdgeIn(edge: EdgeClass): void
185185
matches(node: NodeClass): boolean
186186
recalculateOutEdgesOverrides(): void

src/types.mts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,20 @@ export type CResult<T> =
1111
ok: true
1212
data: T
1313
// The message prop may contain warnings that we want to convey.
14-
message?: string
14+
message?: string | undefined
1515
}
1616
| {
1717
ok: false
1818
// This should be set to process.exitCode if this
1919
// payload is actually displayed to the user.
2020
// Defaults to 1 if not set.
21-
code?: number
21+
code?: number | undefined
2222
// Short message, for non-json this would show in
2323
// the red banner part of an error message.
2424
message: string
2525
// Full explanation. Shown after the red banner of
2626
// a non-json error message. Optional.
27-
cause?: string
27+
cause?: string | undefined
2828
// If set, this may conform to the actual payload.
29-
data?: unknown
29+
data?: unknown | undefined
3030
}

src/utils/alert/artifact.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export type ArtifactAlertUpgrade = Remap<
4141
>
4242

4343
export type CveProps = {
44-
firstPatchedVersionIdentifier?: string
44+
firstPatchedVersionIdentifier?: string | undefined
4545
vulnerableVersionRange: string
4646
[key: string]: any
4747
}

src/utils/api.mts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ import type {
2121
const NO_ERROR_MESSAGE = 'No error message returned'
2222

2323
export type CommandRequirements = {
24-
permissions?: string[]
25-
quota?: number
24+
permissions?: string[] | undefined
25+
quota?: number | undefined
2626
}
2727

2828
/**
2929
* Get command requirements from requirements.json based on command path.
3030
*/
3131
function getCommandRequirements(
32-
cmdPath?: string,
32+
cmdPath?: string | undefined,
3333
): CommandRequirements | undefined {
3434
if (!cmdPath) {
3535
return undefined
@@ -43,7 +43,7 @@ function getCommandRequirements(
4343
/**
4444
* Log required permissions for a command when encountering 403 errors.
4545
*/
46-
function logPermissionsFor403(cmdPath?: string): void {
46+
function logPermissionsFor403(cmdPath?: string | undefined): void {
4747
const requirements = getCommandRequirements(cmdPath)
4848
if (!requirements?.permissions?.length) {
4949
return

src/utils/config.mts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ export interface LocalConfig {
2020
apiKey?: string | null | undefined
2121
apiProxy?: string | null | undefined
2222
apiToken?: string | null | undefined
23-
defaultOrg?: string
23+
defaultOrg?: string | undefined
2424
enforcedOrgs?: string[] | readonly string[] | null | undefined
25-
skipAskToPersistDefaultOrg?: boolean
26-
org?: string // convenience alias for defaultOrg
25+
skipAskToPersistDefaultOrg?: boolean | undefined
26+
// Convenience alias for defaultOrg.
27+
org?: string | undefined
2728
}
2829

2930
const sensitiveConfigKeyLookup: Set<keyof LocalConfig> = new Set(['apiToken'])

0 commit comments

Comments
 (0)