Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Fix typo #1310

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Fix typo #1310

wants to merge 1 commit into from

Conversation

vwkd
Copy link

@vwkd vwkd commented Apr 4, 2020

The handbook reads

x is compatible with y if y has at least the same members as x

I believe the types should be flipped

y is compatible with x if y has at least the same members as x

Because compatibility is viewed from the point of view of the type that is assigned not from the point of view of the type being assigned to.

An example:

interface Named {
  name: string;
}

class Person {
  name: string;
  age: number;
}

let x: Named;
let y = new Person();

x = y; // valid, since y is compatible with x
y = x; // invalid, since x is not compatible with y

Mathematically speaking, y is compatible with x iff x \subseteq y, instead of y \subseteq x like currently stated.

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.

1 participant