Skip to content

Add a new rule to enforce a method syntax #1598

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nstepien opened this issue Feb 12, 2020 · 0 comments · Fixed by #1685
Closed

Add a new rule to enforce a method syntax #1598

nstepien opened this issue Feb 12, 2020 · 0 comments · Fixed by #1685
Labels
enhancement: new plugin rule New rule request for eslint-plugin has pr there is a PR raised to close this package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@nstepien
Copy link
Contributor

Recently I found out that the shorthand method syntax is looser type-wise than the non-shorthand syntax:

interface MyInterface {
  fn1(num: number | undefined): void;
  fn2: (num: number | undefined) => void;
}

const badObject: MyInterface = {
  fn1(num: number) {}, // no error??
  fn2(num: number) {} // error
}

const shouldBeBadObject: MyInterface = {
  fn1(num: number) {}, // no error??
  fn2(num: number | undefined) {}
}

const goodObject: MyInterface = {
  fn1(num: number | undefined) {},
  fn2(num: number | undefined) {}
}

Would it make sense to add a new @typescript-eslint/eslint-plugin rule to enforce the non-/shorthand syntax?

@nstepien nstepien added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Feb 12, 2020
@bradzacher bradzacher added enhancement: new plugin rule New rule request for eslint-plugin and removed triage Waiting for team members to take a look labels Feb 12, 2020
@bradzacher bradzacher added the has pr there is a PR raised to close this label Mar 24, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement: new plugin rule New rule request for eslint-plugin has pr there is a PR raised to close this package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants