| TypeScript Notation | Our Notation |
|---|---|
{ name: string, age: number, [otherField: string]: boolean } | name → string age → number otherField → boolean |
| string[] | index → string |
function doubleNum(x) { return x * 2 } let y = doubleNum(5) | function doubleNum(x) { return x * 2 } let y = doubleNum(5) |
Basic Click to expand the function calls. | function threeTimesNum(x: number) { return x * 3 } function sixTimesNum(x: number) { return threeTimesNum(x) * 2 } let y = sixTimesNum(5) |
Substitution Inputs are paramaterized when needed. | function twoTimesNum(x: number) { return x * 2 } function squareNum(x: number) { return x * x } let z = squareNum(twoTimesNum(5)) |
Limitations There are some limitations when capturing types. I started working on an interpreter, but you really need ownership tracking to do this correctly ( struggles to deal with async/await). It's still very useful for getting a sense of the shape of your code; you simply can't do this very well in VS Code. See Example 2 for a real world example. | type User = name → string age → number function doThingsToUser(user: User, ...fns: index → (User)→undefined for (const f of fns) {f(user)} } function setUserName(user: User) { user.name = 'Bob' } let user = { name: 'Max', age: 99 } doThingsToUser(user, setUserName) |