JSMonk / hegel

An advanced static type checker
https://hegel.js.org
MIT License
2.09k stars 59 forks source link

Generics types can't be generic #149

Open munizart opened 4 years ago

munizart commented 4 years ago

IMHO, this should typecheck

type T<K> = K
type ApplyNumber<T> = T<number>
const x : ApplyNumber<T> = 3
JSMonk commented 4 years ago

Oh, okay. Will fix it. Thank you for your contribution ^_^

JSMonk commented 4 years ago

And also it's duplicate Issue #2

citizengabe commented 4 years ago

There appear to be a couple of issues at play here.

  1. Apply undeclareted generic type 'T' on line 2. Ideally, the generic type wouldn't have to be declared and could instead be inferred. But barring that, it would be nice to be able to declare that within the definition of ApplyNumber.
  2. Generic type "T" should be used with type paramteres! on line 3. This is an issue with partially applying generic types.

They're both related to #2, but I don't know that they're necessarily duplicates.