src/content/docs/linter/rules/no-parameter-properties.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="TypeScript and TSX" icon="seti:typescript"> ## Summary - Rule available since: `v1.0.0` - Diagnostic Category: [`lint/style/noParameterProperties`](/reference/diagnostics#diagnostic-category) - This rule isn't recommended, so you need to enable it. - This rule doesn't have a fix. - The default severity of this rule is [**warning**](/reference/diagnostics#warning). - Sources: - Inspired from [`@typescript-eslint/parameter-properties`](https://typescript-eslint.io/rules/parameter-properties){
"linter": {
"rules": {
"style": {
"noParameterProperties": "error"
}
}
}
}
Disallow the use of parameter properties in class constructors.
TypeScript includes a "parameter properties" shorthand for declaring a class constructor parameter and class property in one location.
Parameter properties can confuse those new to TypeScript as they are less explicit than other ways of declaring and initializing class members.
Moreover, private class properties, starting with #, cannot be turned into "parameter properties".
This questions the future of this feature.
class A {
constructor(readonly name: string) {}
}
class A {
constructor(name: string) {}
}