tern icon indicating copy to clipboard operation
tern copied to clipboard

Generics support

Open RReverser opened this issue 10 years ago • 2 comments

It would be nice if built-in stuff like arrays and new like Promises support could be generalized for other container types through generics which are supported in TypeScript/Flow/AtScript/etc. so we could define own containers with ease and without special inference magic for each separate case.

@marijnh Do you think that it's something easy to implement? If you could do it, we would have full type system support as in other mentioned annotation-based solutions (since union types are now implemented and only generics are missing). After it's implemented, I can update TypeScript definition converter to latest API and send PR.

RReverser avatar Jan 31 '15 20:01 RReverser

I did half a 'generics' implementation for Promises (the -> Type[prop=...] syntax that is used for Promise.resolve). But this is a hack, and a more solid implementation would be good. Basically, I think we need a way to associate types with object types without stuffing them in properties (which is what my hack does), and a clean way to define functions that express relations between such types. Speaking of which, array type handling is also currently rather crude, and it would be nice if a generics system could clean it up.

This would be great to have, but I have not thought much about how to design it yet.

marijnh avatar Feb 02 '15 22:02 marijnh

I think best would be to adapt googles definition: https://github.com/google/closure-compiler/wiki/Generic-Types

TitanNano avatar Feb 14 '17 17:02 TitanNano