Skip to content

Conversation

@ahejlsberg
Copy link
Member

With this change, a type without an index signature is considered related to a type with an index signature if the type of that index signature is any. For example:

var x: { foo: number, [x: string]: any };
let y = { foo: 1, baz: 2 }; 
x = y;  // No longer an error

The assignment x = y was previously considered an error because y has no index signature. However, given that an index signature of type any doesn't actually constrain properties in the type, the assignment is now permitted.

This issue was originally reported by @joewood here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use isTypeAny

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would just add function call and a redundant null check.

@RyanCavanaugh
Copy link
Member

👍

@ahejlsberg
Copy link
Member Author

@JsonFreeman Agreed.

@JsonFreeman
Copy link
Contributor

👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants