Quantcast
Channel: ReScript Forum - Latest posts
Viewing all articles
Browse latest Browse all 2592

Leverage ES decorators

$
0
0

Attributes in ReScript looks like ES decorators, but they really have nothing to do with each other outside of looking the same. Decorators in ReScript are arbitrary meta information attached to various parts of your code, that’s accessible only at compile time where something needs to process them into actual syntax in order for them to have any effect on the resulting code. Just like @tsnobip says, that’s typically PPXes, whether external or internal to the compiler. But in this case I don’t think there’s anything a PPX could do to emit that type of code.

However, if there are clear use cases one could explore what it’d mean to have a dedicated attribute for ES decorators, that is then emitted as actual code. Just like we do today with @directive for functions to emit things like 'use client' for React Server Components. There are a lot of things to figure out around type checking and similar though.

This specific feature is probably easiest to solve by just using what this desugars too like @cometkim says (higher order functions). But, speaking in general - we’re always interested in looking into functionality that supports concrete and important use cases in JS. But, keep in mind that in general the JS features we target needs to be stable/standardized.


Viewing all articles
Browse latest Browse all 2592

Trending Articles