Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Docs: Explain how to get around "not portable" TypeScript type errors #7605

Copy link
Copy link
Closed
@JoshuaKGoldberg

Description

@JoshuaKGoldberg
Issue body actions

Before You File a Documentation Request Please Confirm You Have Done The Following...

Suggested Changes

Following up on #5032 -> #5036, it's still easy to get a dreaded "The inferred type of '...' cannot be named without a reference to '.../node_modules/@typescript-eslint/utils/dist/ts-eslint/Rule.js'. This is likely not portable. A type annotation is necessary." TypeScript type error when using ESLintUtils.RuleCreator:

import { ESLintUtils } from "@typescript-eslint/utils";

export const createRule = ESLintUtils.RuleCreator((name) => `.../${name}.md`);
//           ~~~~~~~~~~
// The inferred type of 'createRule' cannot be named without a reference to
// '../../node_modules/@typescript-eslint/utils/dist/ts-eslint/Rule.js'.
// This is likely not portable. A type annotation is necessary.

How do we recommend third party packages do this?

Also mentioned by @Josh-Cena on the Discord: https://discord.com/channels/1026804805894672454/1130171307909202021/1130171307909202021. And stumbled onto (again) by me in JoshuaKGoldberg/eslint-plugin-expect-type@2660939.

Interestingly, DefinitelyTyped-tools doesn't seem to have this issue... https://github.com/microsoft/DefinitelyTyped-tools/blob/b6b22fc00eebbcfa26120cc314c3f7d2179106ba/packages/eslint-plugin/src/util.ts

I'd consider this issue to be a more specific subset of #5444.

Affected URL(s)

https://typescript-eslint.io/developers/custom-rules

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issueGo ahead, send a pull request that resolves this issuedocumentationDocumentation ("docs") that needs adding/updatingDocumentation ("docs") that needs adding/updating

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.