babel-plugin-parameter-decorator weekly downloads statistics
By WarnerHooh · npm · Babel plugins
Function parameter decorator transform plugin for babel v7, just like typescript.
babel-plugin-parameter-decorator has 42,741 recorded weekly downloads on npm, an increase of 28.7% over the past 30 days, ranking #827 of 3,247 tracked listings.
About babel-plugin-parameter-decorator
Babel Plugin Parameter Decorator
Function parameter decorator transform plugin for babel v7, just like typescript parameter decorator
function validate(target, property, descriptor) {
const fn = descriptor.value;
descriptor.value = function (...args) {
const metadata = `meta_${property}`;
target[metadata].forEach(function (metadata) {
if (args[metadata.index] === undefined) {
throw new Error(`${metadata.key} is required`);
}
});
return fn.apply(this, args);
};
return descriptor;
}
function required(key) {
return function (target, propertyKey, parameterIndex) {
const metadata = `meta_${propertyKey}`;
target[metadata] = [
...(target[metadata] || []),
{
index: parameterIndex,
key
}
]
};
}
class Greeter {
constructor(message) {
this.greeting = message;
}
@validate
greet(@required('name') name) {
return "Hello " + name + ", " + this.greeting;
}
}
NOTE:
This package depends on @babel/plugin-proposal-decorators.
Installation & Usage
npm install @babel/plugin-proposal-decorators babel-plugin-parameter-decorator -D
And the .babelrc looks like:
{
"plugins": [
["@babel/plugin-proposal-decorators", { "legacy": true }],
"babel-plugin-parameter-decorator"
]
}
By default, @babel/preset-typescript will remove imports only referenced in Decorators.
Since this is prone to break Decorators, make sure disable it by setting onlyRemoveTypeImports to true:
{
...
"presets": [
[
"@babel/preset-typescript",
{ "onlyRemoveTypeImports": true }
]
]
...
}
Additional
If you'd like to compile typescript files by babel, the file extensions .ts or .tsx expected, or we will get runtime error!
🎊 Hopefully this plugin would get along with typescript private/public keywords in constructor. For example,
@Factory
class Greeter {
private counter: Counter = this.sentinel.counter;
constructor(private greeting: string, @Inject(Sentinel) private sentinel: Sentinel) {
}
@validate
greet(@required('name') name: string) {
return "Hello " + name + ", " + this.greeting;
}
count() {
return this.counter.number;
}
}
And your .babelrc looks like:
{
"presets": [
"@babel/preset-env",
"@babel/preset-typescript"
],
"plugins": [
["@babel/plugin-proposal-decorators", { "legacy": true }],
["@babel/plugin-proposal-class-properties", { "loose" : true }],
"babel-plugin-parameter-decorator"
]
}
Description from the npm listing.
- babel
- babel-plugin
- function
- parameter
- decorators
- typescript
README badge
Show your rank in a README or on your website. The badge updates automatically.
Charts
Images: 30d · 1y · all time · 1600×900 dark
Adoption over time
7/30/90-day growth
Ranking history
Listing placement
Listing placement
Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.
Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.
Recent observations
Full history (592)Similar npm Babel plugins plugins
All 20 babel-plugin-parameter-decorator alternativesData source
Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.
Listing: https://www.npmjs.com/package/babel-plugin-parameter-decorator. First seen Oct 16, 2026; last successful collection Oct 29, 2026. See the methodology.