compiler's Issues
Infer TData and TVariables from `gql` tagged template literal
Given a GraphQL schema and a query/mutation defined using gql
we should be able to infer the type of the response and variables (if any are required). Eventually, this could evolve in a plugin architecture for the type system. The key aspect is that the plugin is provide an inferred type based on a string. A more complicated plugin architecture would provide a way for it to also generate a set of constraints for any interpolated values. It could return these constraints in the form of a custom TFun
for each call since the number of params would have to match the number of interpolated values.
template string support
String with regular template strings with interpolations. We can constrain the interpolations to only accept strings to start with and can figure out what to do about string coercion, .toString()
, and Show
ables later.
Type classes
Generate TypeScript types from compiler code
spread args support
There are two sub-cases of this:
- spreading a tuple (should work with variadic and non-variadic functions)
- spreading an array (should only work with variadic functions)
Do something better than setting `.src` on TFun's to "Lam", "App", or "Fix"
There are a couple of issues with the current implementation:
- we aren't setting
.src
consistently - it's awkward to motivate the use "App" for callback TFun's (maybe tagging its
.use
as "Callback" would be better)
Conditional types
Nested member access
It should be able to handle things like:
- a.b.c
- x[1][2][3]
- a[0].b[1]
tagged template support
For this the interpolations can have types that differ from string
.
Pattern matching
Optional params
Optional params should be modelled as T | undefined
. Need to update unifyFuncs()
to look for optional params when deciding whether it's partial application or not.
Update partial application to support application of params at any position
Given foo(a, b, c)
it should be possible to do things like foo(5, _, 10)
and have it return a function accepting a single param of type typeof b
.
JSX type support for functional components
Type refinements
Using if
statements to change the type of a variable within the then
block, e.g.
x: number | undefined
let y = if (x != undefined) {
x + 5;
} else {
0;
}
We can shadow x
within the then
block by setting its type to number
in the ctx.env
for that block.
This should also work on deep refinements, e.g. if (x.y.z != undefined)
.
Generate bindings from .d.ts files
We want to be able to generate bindings from existing sources so that we don't have to write them by hand.
varargs support
Only the last param can be varargs. Any args that are passed this way will be passed to the function as an array. inferFuncs
will need to be updated to handle this. We also need a way to mark a param on TFun
as variadic. We could introduce an ERest
node for this (and then reuse it for object/array/tuple rest).
Intersection types
This is mainly to support:
- defining common properties across a discriminated union
- function overloading
Optional chaining
a?.b?.c
should have the type typeof c | undefined
if either a
or b
can be undefined.
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.