JSMonk / hegel

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

Does hegel have type `any` or no `any` ? #209

Closed Raynos closed 4 years ago

Raynos commented 4 years ago

I saw that the website documentation say that the type system has no "any" in it.

Then I read the type definition of the builtin Array ( https://github.com/JSMonk/hegel/blob/master/packages/typings/standard/index.d.ts#L246 )

And the some() method on the array has any for the thisArg parameter.

This looks like a contradiction.

JSMonk commented 4 years ago

Hi @Raynos Hegel doesn't have any type. (It has "unknown" instead which is equivalent of unknown in TypeScript and mixed in Flow.js. But, you mentioned right, that inside d.ts files we still have any, because Hegel tries to fully understand Definition Language. But, in duration of the analysis of a d.ts file - any will be converted to unknown and you will not have an ability to use it as any in TypeScript. Thank you for the question ^_^.

Raynos commented 4 years ago

Converting any to unknown is a neat trick. I like it.

I’ve gone pretty far down the type inference hole with https://github.com/Raynos/jsig

I’m excited that someone else is making a pass at a sound system. I had to give up as I couldn’t figure out how to implement generics ...

JSMonk commented 4 years ago

@Raynos I interpret generic as a function at the type. Also, you can help us, if you are interested in building a static type checker with a sound type system. We will happy to a new contributor ^_^