TypL
TypL copied to clipboard
TODOs
Keeping notes of TODOs for TypVal. This list will be updated as progress occurs.
-
Embedded External Annotations: allow annotating types/signatures for external
"#extern foo" < int; var x = foo; // x implied as 'int' "#extern SomeUtil" < func`(string, number) => bool`; var y = SomeUtil("hello","world"); // error on "world" not being 'number', y implied as 'bool'
Also, we need to define a (huge) set of these external annotations (to be imported via JSON, perhaps?) for all the built-ins and natives, such as
encodeURI(..)
,console.log(..)
,JSON.stringify(..)
, etc. -
Cross-typing: option to collect global types/signatures from non-modules, and
export
ed types/signatures from modules, and "export" them possibly as JSON, and then "import" them for a file as "external annotations". Allows checking multiple files together in a group. -
Generic types for function params/signatures, by allowing signature overloading
function foo(x = generic) { return x; } var a = foo(3); // `a` is type 'number' var b = foo("abc"); // no error, since signature is overloaded, `b` is type 'string'
-
Enforce TDZ for
var
, as well as (separately) TDZ forlet
/const
, as well as (separately) TDZ for function declarations -
Function typed-shorthand:
func`(int,string) => bool`; // returns a function like: // (x,y) => { x = int`${x}`; y = string`${y}`; return bool`false`; }
function bar(cb = func`int => string`) { var x = int`0`; x = cb("hello"); // reports error with "hello" not matching `int` param // reports error with `x` being an `int` but trying to assign a `string` to it } var b = func`int => string`;
-
Custom types (via scope-hoisted pragmas)
“#define FancyArray”; var x = FancyArray`1,2,3`;
Sub types:
“#define Automobile” < “#define Car”; “#define Automobile” < “#define Truck”; var y = Automobile``; y = Car``; y = Truck``;