Skip to content

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
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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