Skip to content

Commit 0169b9e

Browse files
committed
fix(types): flip residual T | null declarations to T | undefined
Cleanup of null→undefined autofix fallout (task #52 / related). The autofix changed assignment sites (`return null` → `return undefined`, `= null` → `= undefined`) but didn't update the type unions, leaving 17 TS2322 errors where `undefined` was assigned to a `T | null` slot. Fixes: * src/auth.ts: getOrganizations() return type → Promise<X | undefined> * src/data/editor-config.ts: onDidChangeConfigurationDisposable union * src/data/go/mod-parser.ts: parseGoMod() return type * src/data/go/wasm-executor.ts: _pendingEvent union; fsync callback uses the (null, undefined) Node-style "no error, void result" pattern (the null IS the API contract here — inline rule disable). * src/ui/decorations.ts: packageData union * src/ui/externals/parse-externals.ts: parseExternals() return type * src/ui/purl-alerts-and-scores/manager.ts: pkgData/error unions No behavior change — only type-side adjustments to match the assignment shape the autofix already chose. tsgo check now passes (0 errors).
1 parent 57d39b0 commit 0169b9e

7 files changed

Lines changed: 13 additions & 9 deletions

File tree

src/auth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ export function getAuthHeader(apiKey: string) {
320320

321321
export async function getOrganizations(
322322
apiKey: string,
323-
): Promise<OrganizationsRecord | null> {
323+
): Promise<OrganizationsRecord | undefined> {
324324
const authHeader = getAuthHeader(apiKey)
325325
const orgReq = https.get('https://api.socket.dev/v0/organizations', {
326326
method: 'GET',

src/data/editor-config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ export function activate(context: vscode.ExtensionContext) {
4444
})
4545
context.subscriptions.push(onDidChangeConfigurationDisposable)
4646
}
47-
let onDidChangeConfigurationDisposable: vscode.Disposable | null = null
47+
let onDidChangeConfigurationDisposable: vscode.Disposable | undefined =
48+
undefined
4849
function getValuesForListener(listener: Listener) {
4950
return getConfigValues(listener.sections)
5051
}

src/data/go/mod-parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ interface GoParseError {
122122
const isParseError = (data: unknown): data is GoParseError =>
123123
typeof (data as GoParseError).Error === 'string'
124124

125-
export async function parseGoMod(src: string): Promise<GoModFile | null> {
125+
export async function parseGoMod(src: string): Promise<GoModFile | undefined> {
126126
if (!goWASM) {
127127
// WebAssembly.instantiate has two overloads. TypeScript can't tell
128128
// a Uint8Array from a `WebAssembly.Module` (both fit the second

src/data/go/wasm-executor.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class GoExecutor<T extends Record<string, unknown> = Record<string, unknown>> {
5252
private exitCode: number | undefined
5353
private instance: GoInstance | undefined
5454
private mem: DataView | undefined
55-
_pendingEvent: GoPendingEvent | null
55+
_pendingEvent: GoPendingEvent | undefined
5656

5757
constructor() {
5858
this._pendingEvent = undefined
@@ -102,7 +102,8 @@ class GoExecutor<T extends Record<string, unknown> = Record<string, unknown>> {
102102
callback(enosys())
103103
},
104104
fsync(_fd: number, callback: GoCallback<void>) {
105-
callback(undefined)
105+
// oxlint-disable-next-line socket/prefer-undefined-over-null -- GoCallback uses Node-style `(err, result)` signature; null signals "no error".
106+
callback(null, undefined)
106107
},
107108
ftruncate(_fd: number, _length: number, callback: GoCallback) {
108109
callback(enosys())

src/ui/decorations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ class DecorationManagerForPURL {
214214
this.documentManagersForDocumentsWithThisPURL.delete(manager)
215215
}
216216
purl: SimPURL
217-
packageData: PURLPackageData | null = undefined
217+
packageData: PURLPackageData | undefined = undefined
218218
decorationType: vscode.TextEditorDecorationType
219219
decorationTypes: DecorationTypes
220220
isBuiltin: boolean

src/ui/externals/parse-externals.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ export function hydrateJSONRefs(src: string): ExternalRef[] {
7171

7272
export async function parseExternals(
7373
doc: vscode.TextDocument,
74-
): Promise<Map<SimPURL, { builtin: boolean; ranges: vscode.Range[] }> | null> {
74+
): Promise<
75+
Map<SimPURL, { builtin: boolean; ranges: vscode.Range[] }> | undefined
76+
> {
7577
const languageId = doc.languageId
7678
const src = doc.getText()
7779
const results = new ExternalPurlRangeManager()

src/ui/purl-alerts-and-scores/manager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ export type PackageScoreAndAlerts = {
4343
export class PURLPackageData {
4444
purl: SimPURL
4545
watchers: Set<(pkgData: PURLPackageData) => void> = new Set()
46-
pkgData!: PackageScoreAndAlerts | null
46+
pkgData: PackageScoreAndAlerts | undefined = undefined
4747
mtime: number = -Infinity
48-
error: string | null = undefined
48+
error: string | undefined = undefined
4949
setError(reason: string) {
5050
this.error = reason
5151
if (!this.pkgData) {

0 commit comments

Comments
 (0)