Switch back to legacy decorators

Empirically the build is fine with these, but it is unfortunate that we have to reply on deprecated semantics. TypeScript should help fix this.
pull/21833/head
Travis Ralston 2020-01-28 16:44:30 +00:00
parent cf2538fbed
commit 330b489fd5
2 changed files with 3 additions and 7 deletions

View File

@ -11,7 +11,7 @@ module.exports = {
"@babel/preset-react" "@babel/preset-react"
], ],
"plugins": [ "plugins": [
["@babel/plugin-proposal-decorators", {decoratorsBeforeExport: true}], ["@babel/plugin-proposal-decorators", {legacy: true}],
"@babel/plugin-proposal-export-default-from", "@babel/plugin-proposal-export-default-from",
"@babel/plugin-proposal-numeric-separator", "@babel/plugin-proposal-numeric-separator",
"@babel/plugin-proposal-class-properties", "@babel/plugin-proposal-class-properties",

View File

@ -32,13 +32,9 @@ import * as sdk from '../index';
* with a skinned version. If no skinned version is available, this component * with a skinned version. If no skinned version is available, this component
* will be used. * will be used.
*/ */
export function replaceableComponent<T extends{new(...args: any[])}>(name: string) { export function replaceableComponent(name: string, origComponent: React.Component) {
// Decorators return a function to override the class (origComponent). This // Decorators return a function to override the class (origComponent). This
// ultimately assumes that `getComponent()` won't throw an error and instead // ultimately assumes that `getComponent()` won't throw an error and instead
// return a falsey value like `null` when the skin doesn't have a component. // return a falsey value like `null` when the skin doesn't have a component.
return (origComponent) => { return () => sdk.getComponent(name) || origComponent;
const c = sdk.getComponent(name) || origComponent;
c.kind = "class"; // appeases babel
return c;
};
} }