Library of JavaScript stage-0 decorators (ES2016/ES7 proposal) inspired by Java annotations, providing commonly used decorators like @override, @deprecate, @autobind, @mixin, @readonly, @nonconfigurable, @decorate, @extendDescriptor, @time, @deprecated, @suppressWarnings. Current stable version is 0.20.0. This library targets the original stage-0 decorator proposal (not the current stage-2 spec) and is intended for use with Babel 5 or Babel 6 with babel-plugin-transform-decorators-legacy. Key differentiator: lightweight, focused on fundamental JavaScript decorators, framework-agnostic (React, Angular, etc.). TypeScript definitions are included but there are known incompatibilities with TypeScript's decorator implementation. Similar to lodash-decorators but more minimal. Release cadence is low (last release 0.20.0 in 2020).
npm install core-decoratorsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows usage of common decorators: autobind, readonly, override, debounce (deprecated), memoize (deprecated). Note deprecation warnings.
Replace @debounce with lodash-decorators' @debounce, etc.
Ensure your transpiler is configured for stage-0 decorators (babel-plugin-transform-decorators-legacy for Babel 6, or Babel 5). For TypeScript, set experimentalDecorators: true.
Consider using a different library (e.g., mobx-react or custom decorators) if you need TypeScript support. If you must use core-decorators, test thoroughly.
Do not use @mixin on classes that inherit from another class. Use composition or a different pattern.
Do not rely on @deprecated; implement your own deprecation warning logic.
Ensure @autobind is applied to a method, not a class. For React class components, use 'handleClick = () => {}' or bind in constructor.Do not attempt to reassign a @readonly decorated property. If you need mutable state, do not use @readonly.
Add the appropriate Babel plugin. For Babel 7: npm install @babel/plugin-proposal-decorators --save-dev and add to .babelrc: { 'plugins': [['@babel/plugin-proposal-decorators', { 'legacy': true }]] }Set 'experimentalDecorators': true in tsconfig.json. Note: core-decorators may still have TypeScript incompatibilities.
No dependency data recorded yet.