-
Notifications
You must be signed in to change notification settings - Fork 4
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
TypeScript fails to resolve the app type at module level, resulting in never type for top-level app instances.
Minimal Example
// This works fine inside test function scope
it('should work', () => {
const app = createApp({
plugins: [createDefaultPlugin(), createGamePlugin()] as const,
systemSets: ['First', 'Update', 'Last']
});
app.update(); // ✅ Works fine
});
// But fails at module level
const app = createApp({
plugins: [createDefaultPlugin(), createGamePlugin()] as const,
systemSets: ['First', 'Update', 'Last']
});
app.update(); // ❌ Error: Property 'update' does not exist on type 'never'Root Cause
The issue (probably) stems from a circular type dependency in the plugin system. Here's the exact dependency chain:
TPlugin
-> setup: (app: TApp<GAppContext>)
-> TApp
-> TAppContext
-> TMergePlugins
-> TAnyPlugin
-> TPluginThe circular dependency occurs because:
- Plugin's
setupfunction needsTApp<GAppContext>type TAppdepends onTAppContextfor extensionsTAppContextusesTMergePluginsto combine plugin shapesTMergePluginsworks withTAnyPluginTAnyPluginis based onTPlugin, completing the circle
TypeScript can resolve this in function scope where it has complete type context, but fails at module level during initial pass.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working