facebook/prop-types

Create a language ?

hugomallet opened this issue · 1 comments

Hi,

This issue is more an idea of a complementary package than a feature request.
So sorry if it is not exactly the right place to write this, but I had no better idea.

I think I would love a language on top JS (like TS) that just adds simple type checking to JS projects. Mostly to help with the use of APIs and components without the overhead of a strongly typed language.

I like PropTypes because it is meant to only check props (ie functions parameters) quite accurately.

I won’t talk too much about TS but I like it less because to me it is more a C#/Java-in-JS than a type system for JS. There are too many features that involve long compilation time and very verbose code (so the reverse of JS).

So my idea is to create a language compatible with TS (a subset then) but which does only what PropTypes does:

  • type description
  • Type checking function parameters

Thus the subset of TS would only cover :

  • types defs for function parameters
  • Shapes (interfaces)
  • Any TS feature that allows the equivalent type definition in PropTypes (such as « | » for « oneOfTypes »)
    • return types

And most importantly, no functionality such as:

  • type defs of variables
  • Generics
  • etc...

Optionally, the compiler may compile to regular PropTypes for runtime checks.

Then I have a few questions for you :

  • Is this idea totally crazy ?
  • Anyone interested ?

Thanks,

While you’re welcome to create such a thing, this repo isn’t the place to discuss it.

Good luck!