Comments (2)
hey, thanks! Yes I'm absolutely interested in this, so right now you can do stuff like this:
import t, {reify} from 'flow-runtime';
import type {Type} from 'flow-runtime';
type User = {
id: number;
name: string;
};
const UserType = (reify: Type<User>); // keeps flow happy, you could just reference User directly.
// every type can be converted back to its flow representation with toString():
console.log(String(User));
// certain types, like type aliases support a boolean
// argument on toString() indicating whether or not to include the
// full declaration:
console.log(UserType.toString(true));
UserType.getProperty("id").unwrap().assert(123);
UserType.getProperty("name").unwrap().assert("Sally");
UserType.getProperty("name").unwrap().assert(false);
I'd like to have a way to serialize and deserialize the types themselves, but whatever format that ends up being needs some way to support cycles.
from flow-runtime.
Is there anyway to iterate over the properties of the objects? flow-io
has UserType.props
? But the babel transformer for this runtime is super useful.
from flow-runtime.
Related Issues (20)
- How do I get a list of class properties? HOT 1
- Array.from breaks on older browsers
- Feature request: opt-in Assert<T> type for arguments
- How to configure with create react app without ejecting ?
- Howto get function annotations HOT 5
- Function inside generic function doesn't work
- Configuration for React Native HOT 4
- Type spread on imported types doesn't work HOT 3
- Outdated flow-runtime on npm HOT 2
- Evaluate discontinuing development/ support of the non-core packages HOT 2
- Type Destructors current status
- Migrate site to Webpack 2, 3 or 4 HOT 1
- flow-runtime ParameterType remember doesn't work with arrays HOT 1
- Runtime types generated when not used HOT 4
- Support arbitrary conversions with a Type#convert method HOT 1
- import t from 'flow-runtime' doesn't get transpiled when sourceType = unambiguous
- Export Flow types as part of the module
- Dictionary objects checks are not consistent with flow behavoiur
- Problem with Literal Types extracted from an object using $Values<typeof OBJECT> HOT 1
- With recent versions of babel, type imports don't get correctly converted to runtime type imports [working on a fix]
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flow-runtime.