cloudflare / cloudflare/speedtest

Improve TS type for onResultsChange callback parameter

Open
#70 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
738
Forks
83
Avg merge
1d 12h
Merged PRs (30d)
6

Description

The `onResultsChange` callback in `src/index.d.ts` has a loosely typed parameter:

```ts
onResultsChange: ({ type: string }) => void;
```

This should be a union type matching the MeasurementConfig types to provide better type safety:
```ts
onResultsChange: ({ type: 'download' | 'upload' | 'latency' | 'packetLoss' }) => void;
```
or
```ts
onResultsChange: (change: { type: MeasurementConfig['type'] }) => void;
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.