Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: incorrect type definitions in createResolveProtocol function #107

Open
shellvon opened this issue Jun 26, 2024 · 0 comments
Open

Bug: incorrect type definitions in createResolveProtocol function #107

shellvon opened this issue Jun 26, 2024 · 0 comments

Comments

@shellvon
Copy link

shellvon commented Jun 26, 2024

Currently, the default cache type in the codebase is QuickLRU<string, string>, as seen in the implementation at this line and this line. However, according to the type definitions specified in the TypeScript declarations file here, the expected type for the cache is Map<string, string>.

When attempting to use this library, TypeScript reports a type mismatch error, likely because the provided type (QuickLRU<string, string>) does not match the expected type (Map<string, string>).

report example:

image

Given the current implementation, the cache type here can be any object that implements the following interface:

interface Cache {
    has(k: string): boolean;
    get(k: string): string | undefined;
}

In other words, cache can be any object instance that has both has and get methods defined.

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

No branches or pull requests

1 participant