Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default (decoratorWithParams(function intl(
target: Target,
key: keyof Target,
desc: PropertyDescriptor & { initializer: () => GetterFn },
dependentKeys: string[] = []
) {
const value: GetterFn = desc.value;
const initializer: () => GetterFn = desc.initializer;
delete desc.value;
delete desc.initializer;
const cp = intlMacro(...dependentKeys, function(
intl: IntlService, // eslint-disable-line no-shadow
propertyKey: string
) {
const fn: GetterFn = value || initializer.call(this);
assert(
`@intl: You need to decorate a function, but you decorated '${fn}'.`,
typeof fn === 'function'
);
return fn.call(this, intl, propertyKey);
});
// @ts-ignore
return cp(target, key, desc);
}) as unknown) as ((
...args: Parameters