lukescott / es-type-hinting

Typing hinting syntax for ECMAScript
3 stars 2 forks source link

Goal of the type hinting #9

Closed Naddiseo closed 9 years ago

Naddiseo commented 9 years ago

To keep the spec shorter and more to the point, a hands off approach to the actual linting/enforcing should be taken. Basically, we define the syntax, but not how it should be interpreted by the engine, or a linter.

Precedents: Python's type hinting Rational and Goals

Naddiseo commented 9 years ago

How much semantic specification do we actually want to make?

Naddiseo commented 9 years ago

What is responsible for the checking?

The KIS approach to this spec would be to copy what mypy and python did: allow an arbitrary, but valid, expression as the hint, then leave it to a library/build tool/linter to do the checking. Of course, if the hinting is kept around afterwards, a la decorators, the engine can also use them if it so chose. Pros:

Cons:

lukescott commented 9 years ago

Arbitrary, not meaning "any expression", but a single variable reference, I'm assuming. If that's the case static analysis should work. Flow does this. Although I'm not sure you can catch everything, so having runtime checking may be beneficial.

Naddiseo commented 9 years ago

There are a couple options we can explore.

  1. Run-time only
  2. Compile time only
  3. Run-time with optional Compile time
  4. Compile time with optional Run-time
  5. Optional Compile and Run time

I'll flesh this thought out tomorrow; I have to get up in 6 hours.