-
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.
[flow][ast] add one-sided (
implies
) type guard variant
Summary: We will be adding a qualifier to type guard definition to express the notion of a "one-sided" refinement (see [relevant TS issue](microsoft/TypeScript#15048)). The new syntax will be: ``` function foo(x: T): implies x is R { ... } ``` A one-sided type guard will only refine the then-branch of a conditional. We are adding this feature to unblock stricter [consistency checking](https://flow.org/en/docs/types/type-guards/#predicate-type-is-consistent-with-refined-type) for the else case of default type guards (two-sided). One-sided type guards continue to have the existing consistency checking. See this exchange for more context: https://twitter.com/danvdk/status/1765745099554668830. This diff adds AST support. Changelog: [internal] Reviewed By: SamChou19815 Differential Revision: D56506513 fbshipit-source-id: fb2adb11ca184bbf983973fa4d7369c5aa5f7cdb
- Loading branch information
1 parent
d1fcac6
commit 97e798a
Showing
4 changed files
with
4 additions
and
0 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
|
@@ -670,6 +670,7 @@ and Type : sig | |
and kind = | ||
| Default | ||
| Asserts | ||
| Implies | ||
|
||
and ('M, 'T) t' = { | ||
kind: kind; | ||
|
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
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