proposal-decorators-types

0.1.0 • Public • Published

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.

Package Sidebar

Install

npm i proposal-decorators-types

Weekly Downloads

0

Version

0.1.0

License

MIT

Unpacked Size

9.28 kB

Total Files

12

Last publish

Collaborators

  • craigfowler