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

mapped type with indexing throws error #125

Open
ianjkaplan opened this issue Oct 1, 2021 · 1 comment
Open

mapped type with indexing throws error #125

ianjkaplan opened this issue Oct 1, 2021 · 1 comment

Comments

@ianjkaplan
Copy link

ianjkaplan commented Oct 1, 2021

Hello,

I have the following code in a type definition file i want to test

interface BaseQueues<Q extends Queue = Queue> {
    someQueue: Q;
}

interface Crons {
    someCron: { nightly: { name: string; cron: string } };
    someOtherCron: { nightly: { name: string; cron: string } };
}

type ConcreteQueues<BaseQueues> = {
    [P in keyof BaseQueues]: Crons[P] extends object
        ? Crons[P] & BaseQueues[P]
        : BaseQueues[P];
};

this code does not produce any compile time errors when creating a ConcreteQueue and accessing someQueue.someCron.nightly etc. However when i run tsd i get Type P cannot be used to index type Crons. Maybe its an issue with my type definition above?
Can someone explain why this might be happening?

Thanks in advance. I appreciate the tool!

@BendingBender
Copy link
Collaborator

Possibly a TypeScript version mismatch? What TypeScript version do you use in your project? tsd currently uses TypeScript 4.3.

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

2 participants