fix(shared-auth): add explicit AuthServiceInterface to fix TS inference truncation

TypeScript's ReturnType<> inference truncates large object literals,
showing only ~27 of 37 methods. This caused 5 apps to skip type-check
because verifyTwoFactor, signInWithPasskey, sendMagicLink, etc. were
invisible to consumers.

Fix: Define explicit AuthServiceInterface with all 37 methods and use
it as the return type of createAuthService(). This ensures all methods
are visible regardless of object literal size.

Verified: chat/web and presi/web now pass svelte-check for auth methods.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Till JS 2026-03-28 03:15:29 +01:00
parent b37a451d29
commit 28bf9e5adb
2 changed files with 79 additions and 3 deletions

View file

@ -1,5 +1,6 @@
import type {
AuthServiceConfig,
AuthServiceInterface,
AuthEndpoints,
AuthResult,
TokenRefreshResult,
@ -68,7 +69,7 @@ const DEFAULT_ENDPOINTS: AuthEndpoints = {
/**
* Create an authentication service with the given configuration
*/
export function createAuthService(config: AuthServiceConfig) {
export function createAuthService(config: AuthServiceConfig): AuthServiceInterface {
const baseUrl = config.baseUrl.replace(/\/$/, ''); // Remove trailing slash
const storageKeys: StorageKeys = { ...DEFAULT_STORAGE_KEYS, ...config.storageKeys };
const endpoints: AuthEndpoints = { ...DEFAULT_ENDPOINTS, ...config.endpoints };
@ -1174,6 +1175,7 @@ export function createAuthService(config: AuthServiceConfig) {
}
/**
* Type for the auth service instance
* Type for the auth service instance.
* Uses the explicit interface instead of ReturnType<> to avoid TS inference truncation.
*/
export type AuthService = ReturnType<typeof createAuthService>;
export type AuthService = AuthServiceInterface;