diff --git a/packages/passport-x/src/passport-oauth1.d.ts b/packages/passport-x/src/passport-oauth1.d.ts index 9953d434db26e..7bd266a472a4e 100644 --- a/packages/passport-x/src/passport-oauth1.d.ts +++ b/packages/passport-x/src/passport-oauth1.d.ts @@ -1,23 +1,10 @@ declare module 'passport-oauth1' { import type { Request } from 'express'; - interface OAuthGetCallback { - (err: OAuthError | null, body?: string, res?: { headers: Record }): void; - } - - interface OAuthError { - statusCode?: number; - data?: string; - } - - interface OAuthClient { - get(url: string, token: string, tokenSecret: string, callback: OAuthGetCallback): void; - } - class OAuthStrategy { name: string; - _oauth: OAuthClient; + _oauth: OAuthStrategy.OAuthClient; constructor(options: Record, verify: (...args: unknown[]) => void); @@ -32,10 +19,27 @@ declare module 'passport-oauth1' { redirect(url: string, status?: number): void; } - class InternalOAuthError extends Error { - constructor(message: string, err: unknown); + // Merged namespace so the CommonJS `module.exports = Strategy` default and the + // `exports.InternalOAuthError` named export coexist under a single `export =`. + // TS7 rejects mixing `export =` with `export { ... }`. + namespace OAuthStrategy { + interface OAuthGetCallback { + (err: OAuthError | null, body?: string, res?: { headers: Record }): void; + } + + interface OAuthError { + statusCode?: number; + data?: string; + } + + interface OAuthClient { + get(url: string, token: string, tokenSecret: string, callback: OAuthGetCallback): void; + } + + class InternalOAuthError extends Error { + constructor(message: string, err: unknown); + } } export = OAuthStrategy; - export { InternalOAuthError, OAuthClient, OAuthError, OAuthGetCallback }; }