-
Notifications
You must be signed in to change notification settings - Fork 72
Open
Description
TypeScript Type Resolution Errors for websocketClient and restClient
Description
TypeScript cannot properly resolve types for websocketClient and restClient exports from @massive.com/client-js, causing them to be treated as error types. This results in unsafe assignment and call errors when using strict TypeScript/ESLint rules.
Package Version
@massive.com/client-js:^9.0.0- TypeScript:
^5.9.3 - ESLint with
@typescript-eslint/eslint-plugin:^8.47.0
Error Messages
For websocketClient:
Unsafe assignment of an error typed value.
Unsafe call of a(n) `error` type typed value.
Unsafe member access .stocks on an `error` typed value.
For restClient:
Unsafe assignment of an error typed value.
Unsafe call of a(n) `error` type typed value.
Unsafe member access .getStocksSnapshotTicker on an `error` typed value.
Minimal Reproduction
import { websocketClient, restClient } from '@massive.com/client-js';
// This causes type errors
const wsClient = websocketClient('api-key', 'ws-url');
const ws = wsClient.stocks(); // Error: Unsafe member access
const rest = restClient('api-key');
const snapshot = await rest.getStocksSnapshotTicker('AAPL'); // Error: Unsafe callExpected Behavior
TypeScript should be able to properly infer and resolve the types for both websocketClient and restClient without requiring manual type assertions. The type definitions should be properly exported and accessible.
Type Definitions Location
The type definitions exist in:
node_modules/@massive.com/client-js/dist/main.d.ts
The declarations are:
declare const websocketClient: (apiKey: string, apiBase?: string, exchange?: string) => IWebsocketClient;declare const restClient: (apikey: string, restApiBase?: string, globalFetchOptions?: {...}) => DefaultApi;
However, TypeScript cannot resolve these types when importing from the package.
Possible Causes
- Missing or incorrect
typesfield inpackage.json - Type definitions not properly exported from the package entry point
- Module resolution issues with the type definitions
- Missing dependencies for type resolution (e.g.,
websockettypes)
Additional Context
- Node.js version:
>=22.18.0 - Module system: ES modules (
"type": "module") - The types exist in the package but TypeScript cannot resolve them during import
Suggested Fix
- Ensure
package.jsonincludes propertypesfield pointing to the type definitions - Verify that all type dependencies are properly declared
- Consider re-exporting types explicitly if needed
- Test type resolution with a fresh TypeScript project
Note: This issue prevents proper type checking and IntelliSense support.
Metadata
Metadata
Assignees
Labels
No labels