0.1.0 • Published 6 years ago

proposal-decorators-types v0.1.0

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

Flow JS types for ECMAScript decorators

Beware - experimental technology

Please be aware that at the time of writing, ECMAScript decorators are an experimental technology which has yet to be ratified. It is subject to change and breakage.

This repository

This repository contains Flow JS types which are useful for working with decorators, a technology which will likely be added to a future JavaScript/ECMAScript version.

// Adds a field in addition to the decorated one, which gets the value in a sassy way
function mySassyDecorator(descriptor : FieldDescriptor<string>) : FieldOutputDescriptor<string,mixed> {
    return {
        ...descriptor,
        extras: [
            {
                kind: 'method',
                key: descriptor.key + 'WithSass',
                placement: 'prototype',
                descriptor: {
                    get: () => 'Yo, it\'s ' + this[descriptor.key],
                }
            }
        ]
    }
}

Specification version

Because decorators are an evolving specification (a moving target), it is important to note the version for which this library was created.

This library targets the Babel decorator plugin @babel/plugin-proposal-decorators version 7.1.0.