This repository has been archived by the owner on Nov 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Turn on type expansion. Add a bunch of examples.
Now types used by other annotated types, if in the same file, are consider implicitly annotated. This implements the major new features proposed in #70. Addresses the repro example in #64.
- Loading branch information
1 parent
efc25fc
commit a1bf47a
Showing
5 changed files
with
56 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* This type references module Tuple -- an import must be generated when this is expanded */ | ||
type lowerType = {person: Tuples.person}; | ||
|
||
type middleType = {. "lowerType": lowerType}; | ||
|
||
/* This is the only annotated type. Type expansion. */ | ||
[@genType] | ||
type topType = (int, middleType); | ||
|
||
[@genType] | ||
let testConversion = (x: topType) => x; | ||
|
||
/* MarcelCutt's example */ | ||
module A = { | ||
type user = {name: string}; | ||
}; | ||
|
||
[@genType] | ||
type b = A.user; |
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,22 @@ | ||
/** | ||
* @flow strict | ||
* @generated | ||
* @nolint | ||
*/ | ||
|
||
// $FlowExpectedError: Reason checked type sufficiently | ||
const TypeExpansionBS = require('./TypeExpansion.bs'); | ||
|
||
import type {person as Tuples_person} from '../src/basics/Tuples.re'; | ||
|
||
export type lowerType = {|+person: Tuples_person|}; | ||
|
||
export type middleType = {|+lowerType: lowerType|}; | ||
|
||
export type topType = [number, middleType]; | ||
|
||
export type A_user = {|+name: string|}; | ||
|
||
export type b = A_user; | ||
|
||
export const testConversion: (topType) => topType = function _(Arg1) { const result = TypeExpansionBS.testConversion([Arg1[0], {lowerType:[Arg1[1].lowerType.person]}]); return [result[0], {lowerType:{person:result[1].lowerType[0]}}] }; |
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