Skip to content

Commit ee07b85

Browse files
committed
fix(types): resolve 4 tsgo errors in cli
- config-command-factory: the validations array literal triggers TS's discriminated-union inference because the first object has no nook field and the second one does. spec.validate() output then fails to append because it carries a pass field that neither variant accepts. Fix: declare an explicit Validation type so the array widens to checkCommandInput's full param shape. - transport-http (x3): AuthenticatedRequest declared its auth as AuthInfo|undefined while the MCP transport expects AuthInfo with the ?: alone carrying may-be-missing semantics. Under exactOptionalPropertyTypes the explicit |undefined is stricter than the upstream signature. Drop the union. All four errors were pre-existing; surfaced during the utils → util rename pass.
1 parent 688e019 commit ee07b85

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

packages/cli/src/commands/config/config-command-factory.mts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,18 @@ ${spec.helpExamples.map(ex => ` $ ${command} ${ex}`).join('\n')}
9494
const value = rest.join(' ')
9595
const outputKind = getOutputKind(json, markdown)
9696

97-
// Build validation checks.
98-
const validations = [
97+
// Build validation checks. The shape matches `checkCommandInput`'s
98+
// param exactly so spec.validate() output (which may include
99+
// `pass?`) appends cleanly without the inferred discriminated-union
100+
// narrowing kicking in.
101+
type Validation = {
102+
test: boolean
103+
message: string
104+
fail: string
105+
nook?: boolean | undefined
106+
pass?: string | undefined
107+
}
108+
const validations: Validation[] = [
99109
{
100110
test: key === 'test' || isSupportedConfigKey(key),
101111
message: 'Config key should be the first arg',

packages/cli/src/commands/mcp/transport-http.mts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@ const logger = getDefaultLogger()
3333
const SESSION_TTL_MS = 30 * 60 * 1000
3434
const SESSION_REAP_INTERVAL_MS = 60_000
3535

36-
type AuthenticatedRequest = IncomingMessage & { auth?: AuthInfo | undefined }
36+
// `auth?: AuthInfo` (NOT `AuthInfo | undefined`) matches the MCP
37+
// transport's `IncomingMessage & { auth?: AuthInfo }` parameter type.
38+
// Adding `| undefined` here would make the property explicitly-undefinable,
39+
// which trips exactOptionalPropertyTypes when handing the request to
40+
// transport.handleRequest().
41+
type AuthenticatedRequest = IncomingMessage & { auth?: AuthInfo }
3742

3843
interface Session {
3944
lastActivity: number

0 commit comments

Comments
 (0)