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

Support typeof x === "symbol" #1015

Closed
mroch opened this issue Oct 30, 2015 · 20 comments
Closed

Support typeof x === "symbol" #1015

mroch opened this issue Oct 30, 2015 · 20 comments

Comments

@mroch
Copy link
Contributor

mroch commented Oct 30, 2015

not sure what flow's support for Symbol in general is, but typeof x === "symbol" is not currently supported so we should fix that and whatever else is necessary for that to work properly.

@samwgoldman
Copy link
Member

Support for well-known symbols would be really handy. For example, if we understood Symbol.iterator (and plugged that into dynamic object keys), it would be possible to define custom iterators for object types (Generators let us define iterables today, but in a more limited way.)

@ghost
Copy link

ghost commented Apr 28, 2017

It would be a welcome improvement for Flow to properly support typeof x === "symbol" and related stuff for ES2015 symbols in general. TypeScript seems to be well-ahead in this regard.

@chyzwar
Copy link

chyzwar commented Dec 3, 2017

I think there are two things,

One is proper support for the primitive data type of symbol.

  6: export type EventName = string | symbol;
                                      ^^^^^^ symbol. Could not resolve name

Second is support for common symbols:
@@iterator

@lll000111

This comment has been minimized.

@bradennapier
Copy link

Any update here?

@devsnek
Copy link

devsnek commented Aug 3, 2018

so when will this actually happen?

@bradennapier
Copy link

:(

@kevinSuttle
Copy link
Contributor

@devsnek
Copy link

devsnek commented Oct 23, 2018

@kevinSuttle the Symbol primitive if supported, but specifically using typeof with "symbol" is not.

@lll000111

This comment has been minimized.

@TrySound

This comment has been minimized.

@lll000111

This comment has been minimized.

@TrySound

This comment has been minimized.

@villesau
Copy link
Contributor

Just a side note: Importing pull request does not mean that it will be merged. AFAIK FB has their internal review tools that they use instead of github. If importing means something, it can be interpreted in a way that they are considering the proposed change. If you are more interested in that particular issue ( #7271 ), there is pretty interesting, even philosophical conversation about the topic: #7128 If you think that my opinion is the correct one, you can show support by thumbing it up :)

If you are willing to contribute but don't now how to climb the OCaml mountain, this might help you forward: #4181 (comment)
They have some (pretty sparse though) documentation about flow internals in their wiki as well: https://github.com/facebook/flow/wiki/The-Flow-Codebase:-Introduction

@TrySound
Copy link
Contributor

@villesau Well, yes. But at least being imported it will be considered.

@goodmind
Copy link
Contributor

#7405

@TrySound
Copy link
Contributor

TrySound commented Feb 6, 2019

Merged. Will be in upcoming release.

@TrySound TrySound closed this as completed Feb 6, 2019
@a7madgamal
Copy link

https://flow.org/en/docs/types/primitives/
I suppose someone needs to remove the mentioned ticket

@bugb
Copy link

bugb commented May 6, 2019

agree with @a7madgamal, the doc seem has not been updated for a while!

@kevinbarabash
Copy link

kevinbarabash commented Aug 11, 2019

I noticed that while:

function testSymbol(x: mixed) {
  if (typeof x === "symbol") { // ok
    (x: string); // error
  }
}

errors correctly, the following does not:

let x: mixed;
if (typeof x === "symbol") {
  (x: string);  // no error, should there be?
}

Is this difference in behavior intentional?

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