r/javascript • • Oct 11 '17

JavaScript's Promise is Memory Unsafe

https://alexn.org/blog/2017/10/11/javascript-promise-memory-unsafe.html
70 Upvotes

77 comments sorted by

View all comments

1

u/Skhmt Oct 11 '17
type Task<A> = () => Promise<A>

interface List<A>

class Cons<A> implements List<A> { 
constructor(
    public readonly head: A, 
    public readonly tail: Task<List<A>>) {}
}

class Nil implements List<A> {
constructor(public readonly error?: any) {}
}

Is that javascript?

2

u/alexelcu Oct 12 '17

It's TypeScript, could be Flow, the syntax isn't relevant, I just wanted to make clear what the types are.

Having a static typing background, that's how I think even when working with plain JavaScript.