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

Type compatibilty of Record is evaluated differently when aliased #51687

Closed
Fredx87 opened this issue Nov 29, 2022 · 2 comments
Closed

Type compatibilty of Record is evaluated differently when aliased #51687

Fredx87 opened this issue Nov 29, 2022 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@Fredx87
Copy link

Fredx87 commented Nov 29, 2022

Bug Report

πŸ”Ž Search Terms

record alias generic function argument type compatibility evaluation

πŸ•— Version & Regression Information

4.9.3

  • This changed between versions 4.1 and 4.2

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

type MyKey = "foo" | "bar";

type Alias = Record<MyKey, string>;

declare function fn1(param: Record<MyKey, string>): void;
declare function fn2(param: Alias): void;

declare const x: Record<string, string>;

// Ok:
fn1(x)

// Error:
fn2(x)

πŸ™ Actual behavior

When a function has an argument with a Record with a generic key, it is possible to pass a Record<string, string> if the parameter type is declared inline, but the compiler returns an error if the parameter type is a alias.

πŸ™‚ Expected behavior

The behavior should be the same independent of how the parameter type is defined.

@fatcerberus
Copy link

#49852 (comment)

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Dec 1, 2022
@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