Skip to content

interface type can't be assigned to index signature type with unknown #44628

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
g-plane opened this issue Jun 17, 2021 · 1 comment
Closed

interface type can't be assigned to index signature type with unknown #44628

g-plane opened this issue Jun 17, 2021 · 1 comment

Comments

@g-plane
Copy link
Contributor

g-plane commented Jun 17, 2021

Bug Report

πŸ”Ž Search Terms

interface
index signature
assignment
assignability

πŸ•— Version & Regression Information

From 4.0 to Nightly. (I haven't tested it with older versions.)

⏯ Playground Link

Playground link

πŸ’» Code

interface MyObject {
  prop: string
}

declare let a: { [x in string]: unknown }
declare let b: { [x in string]: any }
declare let c: MyObject

a = c  // error at this line
b = c

πŸ™ Actual behavior

Type 'MyObject' is not assignable to type '{ [x: string]: unknown; }'. Index signature is missing in type 'MyObject'.

πŸ™‚ Expected behavior

No errors.

@MartinJohns
Copy link
Contributor

See #42825 (comment).

@g-plane g-plane closed this as completed Jun 17, 2021
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