Skip to content

Conversation

@blakeembrey
Copy link
Member

@blakeembrey blakeembrey commented Jan 22, 2026

Alternative to #59. I prefer to author in TypeScript and skip the infrastructure around testing types independently. Uses the same scripts as path-to-regexp for automatic formatting and testing.

This PR doesn't break backward compatibility in the API (but does in node.js version support). It minimally changes the code and tests to add types and test using vitest.

I plan to add benchmarks (using the built-in vitest framework) and optimize the code paths (similar to the work done for cookie) in further PRs. I think there's at least a 50% bump available, and that may require minor API changes (e.g. avoid assigning to an object).

@blakeembrey blakeembrey requested review from a team and bjohansebas January 22, 2026 19:07
Comment on lines +15 to +30
export = rangeParser;

namespace rangeParser {
export interface Range {
start: number;
end: number;
}

export interface Result extends Array<Range> {
type: string;
}

export interface Options {
combine?: boolean;
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Is the namespace necessary here, or is it enough to just export it?

Copy link
Member Author

Choose a reason for hiding this comment

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

You can't export anything extra because I left it in CommonJS format with export =.

Copy link
Member Author

Choose a reason for hiding this comment

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

I tried not to refactor too much in this PR and left that for the perf one, this one is more of a direct port with types added.

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.

2 participants