8000 Docs: [no-unnecessary-type-assertion] incorrect examples don't report errors · Issue #8458 · typescript-eslint/typescript-eslint · GitHub
[go: up one dir, main page]

Skip to content

Docs: [no-unnecessary-type-assertion] incorrect examples don't report errors #8458 8000

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
2 tasks done
teppeis opened this issue Feb 14, 2024 · 2 comments · Fixed by #8558
Closed
2 tasks done

Docs: [no-unnecessary-type-assertion] incorrect examples don't report errors #8458

teppeis opened this issue Feb 14, 2024 · 2 comments · Fixed by #8558
Labels
accepting prs Go ahead, send a pull request that resolves this issue documentation Documentation ("docs") that needs adding/updating locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.

Comments

@teppeis
Copy link
Contributor
teppeis commented Feb 14, 2024

Before You File a Documentation Request Please Confirm You Have Done The Following...

Suggested Changes

Some incorrect examples for no-unnecessary-type-assertion don't report expected errors.

  1. reports an expected error
  2. doesn't report errors!
  3. doesn't report errors!
  4. doesn't report errors!
  5. reports an expected error

Should they report errors as expected?

Affected URL(s)

https://typescript-eslint.io/rules/no-unnecessary-type-assertion/#examples

@teppeis teppeis added documentation Documentation ("docs") that needs adding/updating triage Waiting for team members to take a look labels Feb 14, 2024
@auvred
Copy link
Member
auvred commented Feb 14, 2024

Interestingly, these "invalid" examples are literally present in the valid test cases.

'const foo = 3 as number;',
'const foo = <number>3;',
'const foo = <3>3;',
'const foo = 3 as 3;',

Look like we should update the examples!

+1 on #8382

@teppeis teppeis changed the title Docs: incorrect examples for no-unnecessary-type-assertion don't report errors in the playground Docs: [no-unnecessary-type-assertion] incorrect examples don't report errors Feb 16, 2024
@teppeis
Copy link
Contributor Author
teppeis commented Feb 16, 2024

That difference between testing and documentation seems to have existed since the first implementation (38abc28) five years ago.

I think this rule should report errors for the incorrect examples like const foo = <3>3, as documented. 
Because these "type assertions that do not change the type of an expression".

@JoshuaKGoldberg JoshuaKGoldberg added accepting prs Go ahead, send a pull request that resolves this issue and removed triage Waiting for team members to take a look labels Feb 23, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 26, 2024
@bradzacher bradzacher added the locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. label Apr 14, 2025
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 documentation Documentation ("docs") that needs adding/updating locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.
Projects
None yet
4 participants
0