Repository: eslint/eslint
File: lib/types/rules/ecmascript-6.d.ts (TypeScript)

Code before:
                     */
                    namespaceFrom: boolean;
                }>;
            }>,
        ]
    >;

    /**
     * Rule to disallow specified modules when loaded by `import`.
     *
     * @since 2.0.0-alpha-1
     * @see https://eslint.org/docs/rules/no-restricted-imports
     */
    "no-restricted-imports": Linter.RuleEntry<
        [
            ...Array<
                | string
                | ({
                      name: string;
                      message?: string;
                      importNames?: string[];
                      allowImportNames?: string[];
                  } & (
                      | { importNames?: string[]; allowImportNames?: never }
                      | { allowImportNames?: string[]; importNames?: never }
                  ))
                | Partial<{
                      paths: Array<
                          | string
                          | ({
                                name: string;
                                message?: string;
                                importNames?: string[];
                                allowImportNames?: string[];
                            } & (
                                | {
                                      importNames?: string[];
                                      allowImportNames?: never;
                                  }
                                | {
                                      allowImportNames?: string[];
                                      importNames?: never;
                                  }
                            ))
                      >;
                      patterns: Array<
                          string | ValidNoRestrictedImportPatternOptions
                      >;
                  }>
            >
        ]

Review comment (bug):
[Bug] `importNames` and `allowImportNames` will become `?: undefined` in this union, not `?: never`, even with [`exactOptionalPropertyTypes`](https://aka.ms/tsconfig#exactOptionalPropertyTypes) [[Playground showing `exactOptionalPropertyTypes`](https://www.typescriptlang.org/play/?exactOptionalPropertyTypes=true#code/C4TwDgpgBAKhDOwoF4oAoDeAoKUB2AhgLYQBcUiATgJZ4DmA3DlCfPAXRAPzlW2PNqRMAHtKwAHLEEPCsBr0A2gF0muAgBsNIgO4BJYWMnT4svktVYAvlABk6ZrgA+UDFCGjxU1mfn8VDFCa2vqGXiayeBAAbhCUUFaOUC5uwboGnsY+vH4WgR5G3jLkUbHxibgAlJVYWAAmEADGGgSU0I0ieIhQ0ZoArmSwCMBMWNQAZui9GgMAdAXhrJWuzNMDalAA9JtQAHpctbhrELNpoZlF8BvbuLj7hz39JwtZCNc7t-dWQA)].

This is because `never | undefined` is `undefined`, not `never`. So `importNames?: string[]` & `importNames?: never` becomes `importNames?: never`.

I'd rearrange this to something like the `ValidNoRestrictedImportPatternOptions` earlier in the file. As in, have a type for the common options (`name`, `message`) and then `&` it with other types.

Code after:
                     * @default false
                     */
                    defaultFrom: boolean;
                    /**
                     * @default false
                     */
                    namedFrom: boolean;
                    /**
                     * @default false
                     */
                    namespaceFrom: boolean;
                }>;
            }>,
        ]
    >;

    /**
     * Rule to disallow specified modules when loaded by `import`.
     *
     * @since 2.0.0-alpha-1
     * @see https://eslint.org/docs/rules/no-restricted-imports
     */
    "no-restricted-imports": Linter.RuleEntry<
        [
            ...Array<
                | string
                | ValidNoRestrictedImportPathOptions
                | Partial<{
                      paths: Array<string | ValidNoRestrictedImportPathOptions>;
                      patterns: Array<string | ValidNoRestrictedImportPatternOptions>;
                  }>
            >
        ]
    >;

    /**
     * Rule to disallow `this`/`super` before calling `super()` in constructors.
     *
     * @remarks
     * Recommended by ESLint, the rule was enabled in `eslint:recommended`.
     *
     * @since 0.24.0
     * @see https://eslint.org/docs/rules/no-this-before-super
     */
    "no-this-before-super": Linter.RuleEntry<[]>;

    /**
     * Rule to disallow unnecessary computed property keys in object literals.
     *
     * @since 2.9.0
     * @see https://eslint.org/docs/rules/no-useless-computed-key