Skip to content

Commit

Permalink
fix(eslint-plugin): [typedef] fix regression with class properties (#…
Browse files Browse the repository at this point in the history
…4034)

Fixes #4033
  • Loading branch information
bradzacher committed Oct 20, 2021
1 parent 600d413 commit fe53d22
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
3 changes: 1 addition & 2 deletions packages/eslint-plugin/src/rules/typedef.ts
Expand Up @@ -175,8 +175,7 @@ export default util.createRule<[Options], MessageIds>({
...(memberVariableDeclaration && {
PropertyDefinition(node): void {
if (
!node.value ||
!isVariableDeclarationIgnoreFunction(node.value) ||
!(node.value && isVariableDeclarationIgnoreFunction(node.value)) &&
!node.typeAnnotation
) {
report(
Expand Down
18 changes: 18 additions & 0 deletions packages/eslint-plugin/tests/rules/typedef.test.ts
Expand Up @@ -442,6 +442,24 @@ class Foo {
},
],
},
// https://github.com/typescript-eslint/typescript-eslint/issues/4033
{
code: `
class ClassName {
public str: string = 'str';
#num: number = 13;
func: () => void = (): void => {
console.log(this.str);
};
}
`,
options: [
{
memberVariableDeclaration: true,
},
],
},
],
invalid: [
// Array destructuring
Expand Down

0 comments on commit fe53d22

Please sign in to comment.