-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Type checking support for
new.target
and import.meta
as mixed
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
- Loading branch information
1 parent
e6831b4
commit 627e366
Showing
7 changed files
with
80 additions
and
38 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// @flow | ||
|
||
(import.meta: mixed); // OK | ||
(import.meta: 1); // Error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
Error ----------------------------------------------------------------------------------------------- import_meta.js:4:2 | ||
|
||
Cannot cast `import.meta` to number literal `1` because mixed [1] is incompatible with number literal `1` [2]. | ||
[incompatible-cast] | ||
|
||
import_meta.js:4:2 | ||
4| (import.meta: 1); // Error | ||
^^^^^^^^^^^ [1] | ||
|
||
References: | ||
import_meta.js:4:15 | ||
4| (import.meta: 1); // Error | ||
^ [2] | ||
|
||
|
||
Error ------------------------------------------------------------------------------------------------ new_target.js:5:4 | ||
|
||
Cannot cast `new.target` to boolean because mixed [1] is incompatible with boolean [2]. [incompatible-cast] | ||
|
||
new_target.js:5:4 | ||
5| (new.target: boolean); // Error | ||
^^^^^^^^^^ [1] | ||
|
||
References: | ||
new_target.js:5:16 | ||
5| (new.target: boolean); // Error | ||
^^^^^^^ [2] | ||
|
||
|
||
Error ----------------------------------------------------------------------------------------------- new_target.js:13:6 | ||
|
||
Cannot cast `new.target` to boolean because mixed [1] is incompatible with boolean [2]. [incompatible-cast] | ||
|
||
new_target.js:13:6 | ||
13| (new.target: boolean); // Error | ||
^^^^^^^^^^ [1] | ||
|
||
References: | ||
new_target.js:13:18 | ||
13| (new.target: boolean); // Error | ||
^^^^^^^ [2] | ||
|
||
|
||
|
||
Found 3 errors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// @flow | ||
|
||
function Foo() { | ||
(new.target: mixed); // OK | ||
(new.target: boolean); // Error | ||
|
||
if (!new.target) {} // OK | ||
} | ||
|
||
class A { | ||
constructor() { | ||
(new.target: mixed); // OK | ||
(new.target: boolean); // Error | ||
} | ||
} |