typescript-eslint: Bug: ban-types renames locally shadowed builtin uppercase type

Before You File a Bug Report Please Confirm You Have Done The Following…

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Playground Link

https://typescript-eslint.io/play/#ts=4.9.3&sourceType=module&code=C4TwDgpgBAysBOBLAdgcwCoHsCqzGeQB44k0oIAPYCZAEwGcp6EVUA+KAXlhbMurqMABgBIA3igBmEeFAAyEYNXgBfcVJlQAShGYqhAKChQA-PMXKoAHx6kMOPAUI7mbI1ABcUZBABuMgG4gA&eslintrc=N4KABGBEAOCGBOBnApvSAuKABALgT2mUQGN4BLaHAWiIBsyA7HAejiVUgBpwp4BXWkQxhQECJFwEipCtTqMWAI1gMq+QomGRU8APZoeAXxCGgA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA

Repro Code

type StringToUnion<String extends string> = String extends `${infer Letter}${infer Rest}`
  ? Letter | StringToUnion<Rest>
  : never;

ESLint Config

module.exports = {
  "parser": "@typescript-eslint/parser",
  "rules": {
    "@typescript-eslint/ban-types": "error"
  }
};

tsconfig

{
  "compilerOptions": {
    // ...
  }
}

Expected Result

The rule does not return an error and does not change String in String extends `${infer Letter}${infer Rest} to string when --fix is used.

Actual Result

eslint returns:

error  Don't use `String` as a type. Use string instead  @typescript-eslint/ban-types

Additional Info

No response

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 18 (12 by maintainers)

Most upvoted comments

Ban types is deprecated and it’s replacement has scope analysis to support this. Closing as fixed.

I would suggest looking at TS’s own types:

type Omit<T, K extends keyof any> = Pick<T, Exclude<keyof T, K>>;
type Extract<T, U> = T extends U ? T : never;
type Capitalize<S extends string> = intrinsic;

Sindre often “does his own thing”, and the popularity of type-fest largely comes from the fact that it’s “a Sindre package”, but other libraries like ts-toolbelt and utility-types all adopt the short identifiers convention. But anyway, that’s definitely off-topic.