test(web): typecheck core test files in the typecheck script (#1043)

SH
1d ago
+27-22

Description

Closes #1043.

packages/core/tsconfig.json excludes **/*.test.ts. The config that covers the tests, tsconfig.test.json, was only used as an ESLint parser project, so type errors in the Web test files were never reported.

  • packages/core typecheck is now tsc --noEmit && tsc -p tsconfig.test.json --noEmit, the same shape as the RN core package. The root bindings/web typecheck already runs it, so the web-typecheck job in pr-build.yml picks it up with no workflow change.
  • tsconfig.test.json now excludes **/*.test-d.ts. That file belongs to tsd (test:types). It imports @runanywhere/web through dist/, which the root script only builds after the core typecheck.
  • Fixed the errors the config reports, all in test fakes and fixtures. No src/ changes:
    • RunAnywhere+TTSLifecycle, RunAnywhere+VADStream: the fake module interface extended both EmscriptenRunanywhereModule and ModalityProtoModule, whose shared members differ in readonly and optionality (TS2320). They now use the intersection-type and Partial + installCurrentModelRegistryExports(...) pattern that RunAnywhere+VADLifecycle already uses. This also covers the _rac_solution_*, getValue/setValue and registry members the literals omit.
    • RunAnywhere+TextGenerationStream: same TS2320. The fake only goes to ModalityProtoAdapter.registerModuleCapabilities, so it now extends ModalityProtoModule only. resolveSecondToken was narrowed to null and then called (TS2349).
    • RunAnywhere+CrossWasmModelLifecycle: the module literal omitted the required _rac_solution_* and model-registry members. It is now typed as Partial<...>.
    • runtime/EmscriptenModule: the fake was missing the required getValue and setValue.
    • RunAnywhere+ToolCalling: addFunction's never[] callback type could not be stored in its Map, and stringToUTF8 returned undefined instead of number.
    • RunAnywhere+StructuredOutput: two StructuredOutputValidation literals were missing repairAttempted and repairAttempts.
    • RunAnywhere+STTLifecycle: _rac_audio_float32_to_pcm16 was not declared on the fake module type.
    • RunAnywhere+CrossWasmRAG: ragQueryStream is optional on RAGProvider and was called without a guard.

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Refactoring

Testing

  • Lint passes locally
  • Added/updated tests for changes

Ran in bindings/web: npm run typecheck (includes tsc -p packages/core/tsconfig.test.json --noEmit), npm run lint, npm test.

Platform-Specific Testing (check all that apply)

Swift SDK / iOS Sample:

  • Tested on iPhone (Simulator or Device)
  • Tested on iPad / Tablet
  • Tested on Mac (macOS target)

Kotlin SDK / Android Sample:

  • Tested on Android Phone (Emulator or Device)
  • Tested on Android Tablet

Flutter SDK / Flutter Sample:

  • Tested on iOS
  • Tested on Android

React Native SDK / React Native Sample:

  • Tested on iOS
  • Tested on Android

Web SDK / Web Sample:

  • Tested in Chrome (Desktop)
  • Tested in Firefox
  • Tested in Safari
  • WASM backends load (LlamaCpp + ONNX)
  • OPFS storage persistence verified (survives page refresh)
  • Settings persistence verified (localStorage)

Labels

Please add the appropriate label(s):

SDKs:

  • Swift SDK - Changes to Swift SDK (bindings/swift)
  • Kotlin SDK - Changes to Kotlin SDK (bindings/kotlin)
  • Flutter SDK - Changes to Flutter SDK (bindings/flutter)
  • React Native SDK - Changes to React Native SDK (bindings/react-native)
  • Web SDK - Changes to Web SDK (bindings/web)
  • Commons - Changes to shared native code (core)

Sample Apps:

  • Flutter Sample - Changes to Flutter example app (bindings/flutter/example)
  • React Native Sample - Changes to React Native example app (bindings/react-native/example)
  • Minimal Examples - Changes to an in-repo SDK harness (bindings/{swift,kotlin,web}/example)

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Documentation updated (if needed)

Screenshots

N/A


Summary by cubic

Makes packages/core typechecking cover test files, so type errors in them are now reported instead of silently passing. Fixes the type errors the config now surfaces, all in test fakes and fixtures; no src/ changes.

  • typecheck now runs tsc --noEmit plus tsc -p tsconfig.test.json --noEmit, and the root bindings/web script already runs it, so the CI workflow picks it up without changes.
  • tsconfig.test.json excludes **/*.test-d.ts, which belongs to test:types and imports through dist/.
  • Test fakes were updated to match the real module shapes: intersection types instead of duplicate interface extensions, Partial wrappers plus installCurrentModelRegistryExports, and missing members (getValue/setValue, _rac_audio_float32_to_pcm16, repairAttempted, repairAttempts) added or narrowed.

Summary by CodeRabbit

  • Tests

    • Updated test fixtures and type definitions across model lifecycle, streaming, speech, retrieval, structured output, and tool-calling scenarios.
    • Expanded runtime test mocks to cover additional module behavior and validation metadata.
  • Chores

    • Extended TypeScript checks to include the test project and exclude declaration test files.