Ts4023 effect errors

From forcedotcom/salesforcedx-vscode · View interactive version

Ts4023 effect errors is an AI agent skill from the GitHub repository forcedotcom/salesforcedx-vscode. Fix TS4023 when an exported Effect's error channel names a TaggedError from another module. Use when tsc reports "has or is using name 'X' from external module but cannot be named".

How to use this skill

Skill file

TS4023 with Effect Error Types

TS4023 = exported Effect .d.ts names an error from another module that did not export it. Typical: a services method error leaks into a consumer command.

Export only that class. Same-file, catchTag'd, or absent from an exported signature → leave unexported (OrgNotDeletableError, ToastActionError).

TS4023 message is misleading: cites Effect internals (Channel, Sink, Stream from effect/Cause), not the missing error.

Fix (defining module → consumer)

  1. Find unexported TaggedErrors in the defining package (usually services):
rg "class \w+Error extends (Data|Schema)\.TaggedError" packages/salesforcedx-vscode-services/src
  1. export the class that appears in the failing Effect's error channel:
export class EmptyComponentSetError extends Schema.TaggedError<EmptyComponentSetError>()('EmptyComponentSetError', {...}) {}
  1. Services public API — re-export from index.ts:
export type { EmptyComponentSetError } from './core/componentSetService';
  1. Compile the consumer that failed:
npm run compile -w packages/salesforcedx-vscode-metadata

Knip after a required same-package export

TS4023 required export in a non-services package, knip flags it unused → tag:

/** @ExportTaggedError */
export class NoFilesRetrievedError extends Schema.TaggedError<NoFilesRetrievedError>()('NoFilesRetrievedError', {
  message: Schema.String
}) {}

Knip unused on a TaggedError with no TS4023 → unexport; do not tag.

Services errors are imported by other packages; knip already sees them used. No @ExportTaggedError there (no-export-tagged-error-in-services).

Checklist

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.