Skip to content

[email protected]: @internal-stripped declarations leave dangling references in published .d.ts (Effectable, Match, Schema) — breaks skipLibCheck: false #8161

Closed

Description

@IgnisDa

What happens

[email protected] publishes declaration files that reference names which @internal stripping removes from the published dist. Three distinct dangling references, all introduced in rc.113:

Referenced from Symbol Declared at (src) Published in dist?
dist/Effectable.d.ts:11 EffectTypeId src/internal/core.ts:19 (/** @internal */) ❌ dist/internal/core.d.ts is export {};
dist/Match.d.ts:21 internal.Contextual src/internal/matcher.ts:23 (/** @internal */) ❌ dist/internal/matcher.d.ts is export {};
dist/Schema.d.ts:11008,11018 AnnotationSchemaConstraint src/Schema.ts:15516 (/** @internal */) ❌ stripped, references left in same file

Any consumer whose tsconfig does not set skipLibCheck: true fails to compile on a bare import { Effect } from "effect":

node_modules/effect/dist/Effectable.d.ts(11,15): error TS2305: Module '"./internal/core.ts"' has no exported member 'EffectTypeId'.
node_modules/effect/dist/Effectable.d.ts(55,24): error TS2589: Type instantiation is excessively deep and possibly infinite.
node_modules/effect/dist/Match.d.ts(21,41): error TS2694: Namespace '".../effect/dist/internal/matcher"' has no exported member 'Contextual'.
node_modules/effect/dist/Schema.d.ts(11008,72): error TS2304: Cannot find name 'AnnotationSchemaConstraint'.
node_modules/effect/dist/Schema.d.ts(11018,67): error TS2304: Cannot find name 'AnnotationSchemaConstraint'.

The TS2589 at Effectable.d.ts:55 appears to cascade from the unresolved EffectTypeId, which is used as a computed property key at Effectable.d.ts:58:

readonly [EffectTypeId]: AsEffectReturn<this>[typeof EffectTypeId];

Minimal reproduction

package.json — only [email protected] and [email protected] installed.

index.ts:

import { Effect } from "effect";
export const ok = Effect.succeed(1);

tsconfig.json:

{
  "compilerOptions": {
    "strict": true,
    "noEmit": true,
    "target": "ES2022",
    "module": "ESNext",
    "moduleResolution": "bundler",
    "lib": ["ES2022", "ESNext.Disposable", "DOM", "DOM.Iterable"],
    "skipLibCheck": false
  },
  "files": ["index.ts"]
}

tsc --noEmit emits exactly the five errors above. No other compiler options are required to trigger it.

Regression range

Same project, same TypeScript, only the effect version swapped:

  • 4.0.0-rc.111 — clean
  • 4.0.0-rc.112 — clean
  • 4.0.0-rc.113 — the five errors above

rc.111's Effectable.d.ts did not import from internal/core.ts at all, and its Match.d.ts had no Contextual alias. AnnotationSchemaConstraint does not appear anywhere in rc.111's Schema.d.ts.

Scope of the stripping

31 of the 32 files in dist/internal/ are export {}; (only schemaError.d.ts has content), so any public .d.ts that reaches into internal/ will dangle.

This is a recurring class

Same root cause as #6431 (preResponseHandler, beta.98) and #7187 (SchemaAST.Sentinel, beta.107), both fixed. It seems worth a systemic guard rather than another point fix — e.g. a release-time check that type-checks the published dist with skipLibCheck: false against a trivial consumer, which would catch all three of these before publish.

Expected

The published declaration set should be self-consistent: either these symbols ship in dist (drop @internal, or exempt symbols that public declarations reference), or the public declarations avoid referencing internal names.

Environment

Activity

  1. 30 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions