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

$key doesn't support dot property accessors #6314

Open
Bartozzz opened this issue May 16, 2018 · 0 comments
Open

$key doesn't support dot property accessors #6314

Bartozzz opened this issue May 16, 2018 · 0 comments

Comments

@Bartozzz
Copy link

In my opinion $key should work with both bracket (e.g. foo["bar"]) and dot (e.g. foo.bar) notations.

Reproduction on Flow/try:

/* @flow */

type Properties = {
  a: string,
  b: string
};

class Foo<Properties: Object> {
  $key: $Keys<Properties>;
  $value: $Values<Properties>;
};

const foo: Foo<Properties> = new Foo();

// ✔ Will work fine:
foo["a"] = "adsasd";

// ✔ Will throw an error because "c" in not in Properties:
foo["c"] = "adsasd";

// ✘ Will throw an error because of the dot notation:
foo.b = "adsasd";

// ✘ Will thrown an error because of deconstruction:
const {a, b} = foo;

(nothing changes when Foo extends Object)

@Bartozzz Bartozzz changed the title $key doesn't support dot notation in classes $key doesn't support dot property accessors May 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants