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

Enable @typescript-eslint/ban-types #55133

Merged
merged 3 commits into from
Jul 27, 2023

Conversation

jakebailey
Copy link
Member

@jakebailey jakebailey commented Jul 24, 2023

Follow-up to #54693.

All of the things it catches are harmless, realistically, though I agree that as Function was the wrong cast as that'd let us accidentally new it or something.

I definitely disagree with the default of banning {}; that's a very useful type (especially post #49119, a number I have memorized at this point). Annoyingly, violating the rule that bans {} or Object says to use NonNullable<unknown> which is exactly {}.

The fact that Symbol is mistaken as the global Symbol I believe is a bug in ts-eslint, though I don't think it's reported so I'll do that shortly. typescript-eslint/typescript-eslint#7306

Disabling those two leaves the rule to only ban the uppercase primitive wrapper types (good) and Object (probably good), so it seems like this rule is fine to keep enabled.

@typescript-bot typescript-bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Jul 24, 2023
@fatcerberus
Copy link

as Function was the wrong cast as that'd let us accidentally new it or something

why isn’t Function treated as a top type similar to (...args: never) => unknown?

@jakebailey
Copy link
Member Author

as Function was the wrong cast as that'd let us accidentally new it or something

why isn’t Function treated as a top type similar to (...args: never) => unknown?

Presumably exactly for the reason I gave; (...args: never) => unknown can't be new-d but Function can. But, I'm not a total expert on why. I definitely read something about this in the past year but it's hard to find when the only term I can use is "function".

@jakebailey jakebailey merged commit a6df6c0 into microsoft:main Jul 27, 2023
@jakebailey jakebailey deleted the eslint-ban-types branch July 27, 2023 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants