Skip to content

Fix ServerSpec | undefined type safety and wire up TS project references - #414

Open
isc-klu wants to merge 10 commits into
intersystems:masterfrom
isc-klu:fix/server-spec-undefined-type
Open

Fix ServerSpec | undefined type safety and wire up TS project references#414
isc-klu wants to merge 10 commits into
intersystems:masterfrom
isc-klu:fix/server-spec-undefined-type

Conversation

@isc-klu

@isc-klu isc-klu commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

This fixes #413.

Summary

getServerSpec() could return undefined at runtime, but was typed as always returning ServerSpec, silently masking unresolved-server crashes at every call site. This PR fixes the types, adds guards, and wires up TS project references so common's types are enforced across client/server.

Changes

  • common/src/types.ts: ProtocolMethods["intersystems/server/resolveFromUri"] now returns Promise<ServerSpec | undefined>.
  • server/src/utils/functions.ts: getServerSpec return type fixed to Promise<ServerSpec | undefined>.
  • server/src/utils/types.ts / variables.ts: Exported ProtocolMethods; connection.sendRequest now strongly typed against it.
  • Providers (completion.ts, definition.ts, diagnostic.ts, documentLink.ts, formatting.ts, hover.ts, refactoring.ts, signatureHelp.ts, typeDefinition.ts, typeHierarchy.ts): Added if (!server) { ... } guards at each getServerSpec call site with appropriate fallback returns (or a thrown error in onDiagnostics).
  • client/src/extension.ts: resolveServerSpec returns Promise<ServerSpec | undefined> instead of using a non-null assertion; caller uses serverSpec?.active.
  • Project references: common is now a composite project referenced by client, server, and the root tsconfig.json. Added skipLibCheck: true to client/server.
  • package.json: clean script now also removes tsconfig.tsbuildinfo files.
  • .vscode/settings.json: Renamed deprecated typescript.* settings to js/ts.* equivalents; unrelated objectscript.conn.active: false picked up locally (droppable if preferred).

Testing

npm run compile (tsc -b) completes with zero errors.

- Fix getServerSpec and ProtocolMethods resolveFromUri to return ServerSpec | undefined
- Add guards at all getServerSpec call sites across providers
- Fix resolveServerSpec in client to avoid non-null assertion
- Add TS project references for common from client/server/root
- Update clean script to remove tsbuildinfo files
- Rename deprecated typescript.* settings to js/ts.*
@isc-klu
isc-klu marked this pull request as ready for review August 21, 2026 16:28
@isc-klu
isc-klu requested a review from isc-bsaviano as a code owner August 21, 2026 16:28
Comment thread client/src/extension.ts Outdated
Comment thread .vscode/settings.json Outdated
Comment thread server/src/providers/diagnostic.ts Outdated
Comment thread server/src/providers/hover.ts
Comment thread client/src/extension.ts
Comment thread server/src/providers/completion.ts Outdated
Comment thread server/src/providers/diagnostic.ts Outdated
@isc-klu
isc-klu requested a review from isc-bsaviano August 21, 2026 20:42
@isc-klu isc-klu self-assigned this Aug 21, 2026
// Make the request
const respdata = await makeRESTRequest("POST", 1, "/action/query", { ...server, namespace }, querydata);
const respdata =
server && (await makeRESTRequest("POST", 1, "/action/query", { ...server, namespace }, querydata));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You can avoid all these diffs by putting the server check inside makeRESTRequest(). Dispatching to that method is free; we just don't want to send the request to the client needlessly.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Diagnositics fail when running on a document that has no server connection

2 participants