Skip to content

desktop: vue-tsc fails with 5 type errors on http/https union in electron/main/index.ts #563

Open

Description

@ncw1992120

Problem

npm run build (which runs vue-tsc --noEmit) in mateclaw-desktop fails with 5 type errors, all in electron/main/index.ts:

electron/main/index.ts(303,24): error TS2349: This expression is not callable.
electron/main/index.ts(303,57): error TS7006: Parameter 'res' implicitly has an 'any' type.
electron/main/index.ts(433,24): error TS2349: This expression is not callable.
electron/main/index.ts(433,56): error TS7006: Parameter 'res' implicitly has an 'any' type.
electron/main/index.ts(440,22): error TS7006: Parameter 'err' implicitly has an 'any' type.

Root cause

Introduced in b563f93c (open-source the Electron desktop app). The backend health-check code does:

const client = isHttps ? https : http
const req = client.get(`${url}/`, reqOpts, (res) => { ... })

client is inferred as typeof https | typeof http — a union type. TypeScript refuses to call .get() on a union because the two overloads aren't identical (TS2349), which then cascades: the callback parameters can't be inferred, producing the TS7006 implicit-any errors on res and err.

This affects both occurrences of the health-check helper (lines ~300 and ~433).

Reproduce

cd mateclaw-desktop
npm install
npx vue-tsc --noEmit   # → 5 errors

Confirmed on dev (e294b32).

Fix

Cast client to typeof http at the call site. https exposes the same callable surface as http, so runtime behavior is unchanged:

const req = (client as typeof http).get(`${url}/`, reqOpts, (res) => { ... })

PR with the fix: incoming.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions