Skip to content

Re-exported types with generic defaults reference unexported types #53

@NotMirrox

Description

@NotMirrox

Description

When re-exporting a type that has a generic default parameter, pesde includes the default even when the default type itself is not exported. This causes errors for developers trying to use the re-exported type.

Example

-- In the source package (not exported)
type Callback = () -> ()

-- In the source package (exported)
export type ReadonlySignal<T = Callback> = ...

-- After re-export in dependent package
export type ReadonlySignal<T = Callback> = module.ReadonlySignal<T>

The re-exported type still references Callback as the default, but Callback was never exported, causing an error when trying to use ReadonlySignal without explicit type parameters.

Current Behavior

Generic defaults are preserved in re-exports even when the default type is not exported, resulting in references to undefined types.

Expected Behavior

Either:

  1. Strip generic defaults when re-exporting if the default type is not also exported, or
  2. Automatically detect and re-export types used as generic defaults

Reproduction

Either:

  1. Create a package with a type that has a generic default referencing an internal type
  2. Re-export that type without exporting the default type
  3. Try to use the re-exported type in a package without providing the generic parameter
  4. Observe error about undefined type

Or:

  1. Add dependency: wcs = { wally = "cheetiedotpy/wcs", version = "^2.5.0" }
  2. Re-export ReadonlySignal from wcs: export type ReadonlySignal<T = Callback> = module.ReadonlySignal<T>
  3. Try to use the re-exported type in a package without providing the generic parameter
  4. Observe error about undefined Callback type

Environment

  • Luau
  • pesde: pesde-pkg/pesde@0.7.1+registry.0.2.3
  • Operating system: Windows 10

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions