(all) #43 Implement support for optional typing
This took a while
Supported functionality as of this MR
-
Types can be specified for local variables. They can also be inferred from their usage.
var a: int = 32; var a = 42; // inferred to int
-
Variable types can also be inferred from e.g. calling functions, the result of binary operators etc:
fun f(): int { return 42; } var a = f(); // inferred to int var b = 32 * 42 * 52; // likewise
Limitations
-
Function parameters and return types are currently mandatory; they cannot be inferred from their usage (as in TypeScript). This is something we aim to fix within the scope of #43 in the longer run.
// The type specifiers below are currently mandatory fun f(s: string): int { }