Skip to content

Toolcraft inferred declarations leak unresolvable toolcraft-schema imports #509

Description

@kamilio

Summary

A downstream package that exports an inferred Toolcraft command tree emits public declarations containing bare import("toolcraft-schema") references. With toolcraft@0.0.102, toolcraft-schema is bundled beneath Toolcraft, so those references are not resolvable from the downstream package unless it separately declares toolcraft-schema as a direct dependency.

This makes Toolcraft's inferred public types depend on transitive hoisting that the current published package layout no longer provides.

Reproduction

Package library-a:

import { defineCommand, defineGroup, S } from "toolcraft";

export const root = defineGroup({
  name: "example",
  children: [
    defineCommand({
      name: "hello",
      params: S.Object({ name: S.String() }),
      handler: async ({ params }) => ({ greeting: params.name }),
    }),
  ],
});

Build declarations and inspect the output. It contains types such as:

import("toolcraft-schema").ObjectSchema<...>

Then:

  1. Publish/pack library-a with only toolcraft@0.0.102 declared.
  2. Install it into a clean consumer.
  3. Run TypeScript with skipLibCheck: false.
  4. The consumer cannot resolve toolcraft-schema, because the published Toolcraft archive places it at node_modules/toolcraft/node_modules/toolcraft-schema rather than at a location reachable from library-a's declaration file.

The current workaround is for every downstream library exporting inferred command trees to declare the exact toolcraft-schema version directly.

Expected behavior

A package should be able to export an inferred Toolcraft tree while declaring Toolcraft itself, without knowing that generated declarations leak a separately named schema package.

Possible fixes include:

  • make public Toolcraft types refer to schema types through toolcraft re-exports;
  • expose an annotation/helper whose emitted declaration does not contain bare toolcraft-schema imports;
  • or document and encode toolcraft-schema as a peer/direct dependency contract rather than a bundled implementation detail.

Acceptance criteria

A packed downstream library exporting an inferred command tree compiles in a clean consumer with skipLibCheck: false and both exactOptionalPropertyTypes modes, without the downstream library adding an otherwise undocumented direct toolcraft-schema dependency.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is not working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions