Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

no-unnecessary-type-assertion, no-unnecessary-type-assertion #4050

Open
jpike88 opened this issue Dec 12, 2022 · 13 comments
Open

no-unnecessary-type-assertion, no-unnecessary-type-assertion #4050

jpike88 opened this issue Dec 12, 2022 · 13 comments
Labels
task A task, an action that needs to be performed

Comments

@jpike88
Copy link

jpike88 commented Dec 12, 2022

Description

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

@jpike88 jpike88 added the task A task, an action that needs to be performed label Dec 12, 2022
@xunilrj
Copy link
Contributor

xunilrj commented Dec 12, 2022

We don't have type information currently.
Any idea what we could do with the information we have now?

@latin-1
Copy link

latin-1 commented Dec 13, 2022

@xunilrj Sorry for bothering you. Is there a future roadmap for type information? I'd like to know more about how Rome plans to implement type-related rules like typescript-eslint. Thanks

@xunilrj
Copy link
Contributor

xunilrj commented Dec 13, 2022

Is there a future roadmap for type information?

Yes.

We are currently researching interesting type aware lints and what implementation would they need.
That is why I asked.

The lint examples also looks not realistic to me. Would be interesting to see real use cases of this rule.

@jpike88
Copy link
Author

jpike88 commented Dec 13, 2022

Yeah the examples in the link are poor.

it’s more like:

‘’’
const x: number = 4;
‘’’

This kind of unneeded type declaration adds noise to the code

@xunilrj
Copy link
Contributor

xunilrj commented Dec 13, 2022

Nice. These I think we can do.
I will put here in my list to research.

@latin-1
Copy link

latin-1 commented Dec 13, 2022

@xunilrj Is there an issue for tracking the type info feature? This is so important to me that I'd like to know when it will be available so that I can move my projects to Rome. Thanks

@xunilrj
Copy link
Contributor

xunilrj commented Dec 13, 2022

Not yet. I am still researching about type aware lints.
@latin-1 Do you have other lint rules you think are essential?

@latin-1
Copy link

latin-1 commented Dec 13, 2022

@xunilrj
https://typescript-eslint.io/rules/no-floating-promises/
I can’t write async code without it 😝


Edited: For a real-world use case:

import fs from "node:fs/promises";
(async () => {
  fs.writeFile(...);
  // ^ oops, I forgot to write `await`

  // do something with that file
})();

@Conaclos
Copy link
Contributor

Conaclos commented Dec 14, 2022

@xunilrj
I could add the following recommended rule from ESLint TypeScript that require type info:

a single promise rule could merge several promise-related rules?

I could merge the following recommended rule into a single rule no-any:

I could also add the following strict rules:

And the following rules:

Rome could implement a "simple" type system (ignoring advanced type features such as mapped types, conditional types, interface merging).

@Conaclos
Copy link
Contributor

Just for reference: the TS team is discussing which semantic rule is worth the linting time.

@github-actions
Copy link

👋 @rome/staff please triage this issue by adding one of the following labels: S-Bug: confirmed, S-Planned , S-Wishlist or umbrella

@jpike88
Copy link
Author

jpike88 commented Apr 24, 2023

just got caught out by something that switch-exhaustiveness-check would have prevented. I think just a simple type checking system capable of unioning literals or something would be plenty... no need to go full on

@gkiely
Copy link

gkiely commented Apr 24, 2023

One great benefit of no-unsafe-assignment is that it prevents any library types from leaking into your codebase. It's a nice reminder to assert the expected type.

While I can use Rome for linting development builds. Without this rule it is not feasible for me to use it for production builds.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
task A task, an action that needs to be performed
Projects
None yet
Development

No branches or pull requests

6 participants