Skip to content

Importing Fusion with Wally breaks Scope type generics #440

@s-wick

Description

@s-wick

Importing the Wally package and using wally-package-types generates this file (fusion.lua):

local REQUIRED_MODULE = require(script.Parent._Index["elttob_fusion@0.3.0"]["fusion"])
export type Animatable = REQUIRED_MODULE.Animatable 
export type UsedAs<T> = REQUIRED_MODULE.UsedAs<T>
export type Child = REQUIRED_MODULE.Child 
export type Computed<T> = REQUIRED_MODULE.Computed<T>
export type Contextual<T> = REQUIRED_MODULE.Contextual<T>
export type GraphObject = REQUIRED_MODULE.GraphObject 
export type For<KO, VO> = REQUIRED_MODULE.For<KO, VO>
export type Observer = REQUIRED_MODULE.Observer 
export type PropertyTable = REQUIRED_MODULE.PropertyTable 
export type Scope<Constructors > = REQUIRED_MODULE.Scope<Constructors >
export type ScopedObject = REQUIRED_MODULE.ScopedObject 
export type SpecialKey = REQUIRED_MODULE.SpecialKey 
export type Spring<T> = REQUIRED_MODULE.Spring<T>
export type StateObject<T> = REQUIRED_MODULE.StateObject<T>
export type Task = REQUIRED_MODULE.Task 
export type Tween<T> = REQUIRED_MODULE.Tween<T>
export type Use = REQUIRED_MODULE.Use 
export type Value<T, S = T> = REQUIRED_MODULE.Value<T, S >
export type Version = REQUIRED_MODULE.Version 
return REQUIRED_MODULE

All types are exported correctly except for Scope, whose generic is broken, as it relies on the Fusion type which is not exported in the entry point file (init.luau):

type Fusion = Types.Fusion
...
export type Scope<Constructors = Fusion> = Types.Scope<Constructors>

Using the Fusion.Scope type in VSCode with the LuauLSP yields the following type error:

TypeError: Type parameter list is required Luau[1018](https://luau-lang.org/typecheck)

The simplest fix to the issue is to just export the Fusion type from init.luau:

export type Fusion = Types.Fusion

And fixing the Scope type in fusion.lua:

export type Fusion = REQUIRED_MODULE.Fusion
export type Scope<Constructors = Fusion> = REQUIRED_MODULE.Scope<Constructors >

This resolves the error, but is overwritten with updates to the package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions