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)
- Find unexported TaggedErrors in the defining package (usually services):
rg "class \w+Error extends (Data|Schema)\.TaggedError" packages/salesforcedx-vscode-services/src
exportthe class that appears in the failing Effect's error channel:
export class EmptyComponentSetError extends Schema.TaggedError<EmptyComponentSetError>()('EmptyComponentSetError', {...}) {}
- Services public API — re-export from
index.ts:
export type { EmptyComponentSetError } from './core/componentSetService';
- 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
- [ ] TS4023 actually reported
- [ ] Export only the class in the exported Effect's error channel
- [ ] Services:
export type { ErrorName }fromindex.ts - [ ] Consumer compile passes
- [ ]
@ExportTaggedErroronly if knip flags that export unused (never in services)