-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Flow parser should support import.meta #6913
Comments
Summary: Resolves facebook#6913. As with `new.target`, we can parse the expression, but we fail to typecheck it. Clients can use a suppression comment to ignore uses of `import.meta` in an otherwise valid file. The parse error message on inputs like `import.notMeta` was chosen to be consistent with the message emitted by Babylon. Test Plan: Unit tests added, and all existing tests pass. wchargin-branch: parse-import-meta
Summary: Resolves facebook#6913. As with `new.target`, we can parse the expression, but we fail to typecheck it. Clients can use a suppression comment to ignore uses of `import.meta` in an otherwise valid file. The parse error message on inputs like `import.notMeta` was chosen to be consistent with the message emitted by Babylon. Test Plan: Unit tests added, and all existing tests pass. wchargin-branch: parse-import-meta
Implemented in #6958. |
Friendly ping on that PR. I know some folks were interested in this and |
We didn't get a response from your previously friendly ping @wchargin, so I'm pinging again hoping we are gonna get some response now :) |
We can't migrate to modules while flow is not supporting it (flow-remove-types makes an error on this syntax too). Or we have to get around the __dirname variable. |
It's not implemeted yet( Though import.meta is living standard already. |
I cannot use flow because use of import.meta breaks flow parsing of the entire source file from that point forward... Yes, I am using import.meta.url to obtain __dirname in node scripts. |
I use this ugly workaround to make both Flow and Node.js happy: // $FlowFixMe
let __filename /*: string */ = url.fileURLToPath(import /*:: ("") */.meta.url); I don't know if this works with flow-removes-types or Babel, though. |
The above workaround didn't quite work for me but this does: import { dirname } from 'path';
import { fileURLToPath } from 'url';
const __dirname/*:string*/ = dirname(fileURLToPath(/*::(*/import/*::('fs'):any)*/.meta.url)); // facebook/flow PR#6958 |
Summary: Rather than give an `unsupported-syntax` error when `new.target` or `import.meta` are used, type them as `mixed`. This is a bit more useful (and still safe). Fixes #1152 Reference to #6913 Changelog: [feature] Added type checking support for `new.target` and `import.meta` as `mixed` Reviewed By: mroch Differential Revision: D30745294 fbshipit-source-id: 1026ddde29936b7c5c8f81daf3a7b2515a514679
import.meta
is a stage 3 proposal that has shipped in Chrome, Firefox, and Node 10. Flow should be able to parse this syntax.https://flow.org/try/#0PQKgBAAgZgNg9gdzCYAoVBLAtgBzgJwBcA6LAU0IENiBXfGAbiA
The text was updated successfully, but these errors were encountered: