Skip to content
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

[consistent-type-assertions] assertionStyle doesn't enforces <const> case #4684

Closed
3 tasks done
gtkatakura opened this issue Mar 14, 2022 · 2 comments · Fixed by #4685
Closed
3 tasks done

[consistent-type-assertions] assertionStyle doesn't enforces <const> case #4684

gtkatakura opened this issue Mar 14, 2022 · 2 comments · Fixed by #4685
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@gtkatakura
Copy link
Contributor

gtkatakura commented Mar 14, 2022

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have read the FAQ and my problem is not listed.

Repro

const example = <const>{ key: 'value' }
{
  "rules": {
    "@typescript-eslint/consistent-type-assertions": ["error", {"assertionStyle":"as"}]
  }
}

Expected Result

Should complains about the const forcing to use as const.

Actual Result

assertionStyle doesn't has impact over <const> or as const today

Versions

package version
@typescript-eslint/eslint-plugin 5.15.0
@typescript-eslint/parser 5.15.0
TypeScript 3.9.10
ESLint 7.32.0
node 14.17.6
@gtkatakura gtkatakura added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look labels Mar 14, 2022
@bradzacher
Copy link
Member

bradzacher commented Mar 14, 2022

I'm not sure I understand - why do you think that as const shouldn't be allowed?
as const is always safe to do because it only ever narrows the type - it doesn't do an unsafe conversion of the type or anything of the sort.

@bradzacher bradzacher added awaiting response Issues waiting for a reply from the OP or another party and removed triage Waiting for maintainers to take a look labels Mar 14, 2022
@gtkatakura
Copy link
Contributor Author

gtkatakura commented Mar 14, 2022

I am talking about the styling. It should enforces me to use as const instead <const> because I defined the assertionStyle as as. Today assertionStyle doesn't enforces any style over const.

@bradzacher bradzacher added bug Something isn't working accepting prs Go ahead, send a pull request that resolves this issue and removed awaiting response Issues waiting for a reply from the OP or another party labels Mar 14, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
2 participants