Skip to content

Record<string, unknown> extends type but not interface #45237

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

Closed
brianconnoly opened this issue Jul 29, 2021 · 2 comments
Closed

Record<string, unknown> extends type but not interface #45237

brianconnoly opened this issue Jul 29, 2021 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@brianconnoly
Copy link

Bug Report

πŸ”Ž Search Terms

Record with unknown extending type works but interface doesnt

πŸ•— Version & Regression Information

  • This changed between versions 3.3 and 3.5

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

interface Api {
    request: Record<string, unknown> | void;
    response: Record<string, unknown> | void;
}

interface Generic<A extends Api> {
    test: A;
}

interface ITestRequest {
    a?: string;
    b?: number;
}

type TTestRequest = {
    a?: string;
    b?: number;
};

interface TestInterface {
    request: ITestRequest;
    response: void;
}
interface TestType {
    request: TTestRequest;
    response: void;
}

// This doesnt work
type Genered1 = Generic<TestInterface>;

// But this does
type Genered2 = Generic<TestType>;

πŸ™ Actual behavior

ITestRequest fails to extend Record<string, unknown>

πŸ™‚ Expected behavior

ITestRequest works as TTestRequest and can be passed under signature Record<string, unknown>

@MartinJohns
Copy link
Contributor

Duplicate of #42825. Used search terms: interface extends record unknown

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Aug 5, 2021
@typescript-bot
Copy link
Collaborator

This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

4 participants