Skip to content

Add TypeScript definitions for package exports#5

Draft
Copilot wants to merge 7 commits intomainfrom
copilot/re-export-dom-node-types
Draft

Add TypeScript definitions for package exports#5
Copilot wants to merge 7 commits intomainfrom
copilot/re-export-dom-node-types

Conversation

Copy link

Copilot AI commented Feb 5, 2026

This PR adds TypeScript type definitions to the @exodus/replay package, providing type safety for TypeScript users.

Changes Made

Individual Type Definition Files

Created separate .d.ts files for each export module:

  • fetch.d.ts: Type definitions for fetch-related exports

    • FetchRecorderOptions interface
    • Function signatures for fetchRecorder, fetchReplayer, fetchApi
  • websocket.d.ts: Type definitions for WebSocket-related exports

    • WebSocketRecorderOptions and WebSocketReplayerOptions interfaces
    • Function signatures for WebSocketRecorder, WebSocketReplayer
  • util.d.ts: Type definitions for utility exports

    • PrettyJSONOptions interface
    • Function signature for prettyJSON
  • index.d.ts: Main entry point that re-exports types and functions from individual modules

Package Configuration

  • package.json: Updated exports with types field for each submodule, enabling proper TypeScript resolution for both main and submodule imports
  • .eslintignore: Added *.d.ts to skip linting TypeScript definition files

Design Decisions

The type definitions only export package-specific interfaces and function signatures. Standard DOM/Web API types (like Response, Request, Headers, WebSocket, MessageEvent, etc.) are not re-exported because:

  • They are already available to TypeScript users through the standard lib definitions
  • They are not exported by the JavaScript modules
  • Re-exporting them would be redundant and misleading

Usage

TypeScript users now get full type safety for both main and submodule imports:

// Import from main module
import { fetchRecorder, type FetchRecorderOptions } from '@exodus/replay'

// Or import directly from submodules
import { fetchRecorder } from '@exodus/replay/fetch'
import { WebSocketReplayer } from '@exodus/replay/websocket'

Testing

  • ✅ All TypeScript definitions validated with tsc
  • ✅ All existing tests pass (60/60 replay tests)
  • ✅ Linter passes with no errors
  • ✅ Security scan (CodeQL) found 0 vulnerabilities

The changes are purely additive type definitions with no runtime impact.

Original prompt

This section details on the original issue you should resolve

<issue_title>Types</issue_title>
<issue_description>Re-export existing DOM / Node.js types where possible</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits February 5, 2026 17:00
Co-authored-by: ChALkeR <291301+ChALkeR@users.noreply.github.com>
Co-authored-by: ChALkeR <291301+ChALkeR@users.noreply.github.com>
Co-authored-by: ChALkeR <291301+ChALkeR@users.noreply.github.com>
Copilot AI changed the title [WIP] Re-export existing DOM and Node.js types Add TypeScript definitions re-exporting standard DOM/Node.js types Feb 5, 2026
Copilot AI requested a review from ChALkeR February 5, 2026 17:04
Copy link
Collaborator

@ChALkeR ChALkeR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot add types to each export individually

Co-authored-by: ChALkeR <291301+ChALkeR@users.noreply.github.com>
Copy link
Author

Copilot AI commented Feb 5, 2026

@copilot add types to each export individually

Done. Added individual type definition files for each export:

  • fetch.d.ts - Types for fetch API exports
  • websocket.d.ts - Types for WebSocket exports
  • util.d.ts - Types for utility exports
  • index.d.ts - Re-exports all types from individual modules

Updated package.json exports to specify types for each submodule. Commit: 4c3b069

Copilot AI requested a review from ChALkeR February 5, 2026 19:13
util.d.ts Outdated
Comment on lines 3 to 6
// Re-export standard binary data types
export type ArrayBuffer = globalThis.ArrayBuffer
export type Uint8Array = globalThis.Uint8Array
export type DataView = globalThis.DataView
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot These are not needed, don't do useless things

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed. util.js only exports prettyJSON, so the binary data type re-exports were unnecessary. Commit: 9dcd9c8

Co-authored-by: ChALkeR <291301+ChALkeR@users.noreply.github.com>
Copilot AI requested a review from ChALkeR February 5, 2026 19:20
fetch.d.ts Outdated
export type RequestInfo = globalThis.RequestInfo
export type RequestInit = globalThis.RequestInit
export type Blob = globalThis.Blob
export type ReadableStream<R = any> = globalThis.ReadableStream<R>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot don't export other useless things too

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed. Standard DOM/Web API types (Response, Request, Headers, WebSocket, MessageEvent, etc.) are already available through TypeScript's lib definitions and don't need to be re-exported. Only package-specific interfaces and function signatures remain. Commit: 944d66f

…cket.d.ts

Co-authored-by: ChALkeR <291301+ChALkeR@users.noreply.github.com>
Copilot AI changed the title Add TypeScript definitions re-exporting standard DOM/Node.js types Add TypeScript definitions for package exports Feb 5, 2026
Copilot AI requested a review from ChALkeR February 5, 2026 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Types

2 participants