Skip to content

Vide events (Activated, MouseButton1Down, …) flagged as luix.unknown-prop — diagnostic never consults flattenClassEvents #4

Description

@WaleedAmer

Version: 1.5.2 (Marketplace, also v1.5.2 tag) · VS Code on Windows · luix.frameworks default · Vide via create "X" { … }

What happens

Every event passed the Vide way (a plain table key) on a host class is flagged by the unknown-prop diagnostic:

local create = require(game.ReplicatedStorage.Packages.vide).create

create "TextButton" {
	Text = "Buy",
	Activated = function() end,        -- Unknown property `Activated` on `TextButton`. luix(luix.unknown-prop)
	MouseEnter = function() end,       -- same
	MouseLeave = function() end,       -- same
	MouseButton1Down = function() end, -- same
	MouseButton1Up = function() end,   -- same
}

This is Vide's documented event syntax and the code runs fine. The README says Vide events are supported as plain keys ("Vide — events are plain table keys; Luix already merges the class's events into the prop suggestion list for you"), and completion does offer them — but the diagnostic contradicts the completion.

Where it comes from

src/diagnostics.ts (v1.5.2), unknown-prop block:

// ---- Unknown / wrong-enum (Roblox host class only) ----
if (call.isStringLiteralName && defaultPropsMap[call.className]) {
  const known = new Set(flattenClassProps(call.className));   // line 551 — properties only
  for (const entry of entries) {
    if (known.has(entry.key)) {  continue; }
    if (isFrameworkSpecialKey(entry.key)) continue;           // only Children / key / ref
    if (isDeprecatedValidProp(call.className, entry.key)) continue;
     push UnknownProp

known is seeded from flattenClassProps only. flattenClassEvents is never imported into diagnostics.ts (it's only used by completion.ts and elementSnippets.ts), so GuiButton.events / GuiObject.events in data.ts — which do list Activated, MouseButton1Down, MouseEnter, … — never reach the check. The escape hatch isFrameworkSpecialKey only knows Children/key/ref.

The completion provider handles this correctly: completion.ts ~L229–247 resolves the framework via findFrameworkForAlias(detected.alias) and, when framework.eventsAsProps is true (Vide, and direct instance calls attributed to Vide), merges flattenClassEvents(baseClass) into the prop list. The diagnostic has no equivalent gate.

Suggested fix

Mirror the completion provider's gate in the diagnostic:

const known = new Set(flattenClassProps(call.className));
const framework = call.alias && findFrameworkForAlias(call.alias);
if (framework?.eventsAsProps) {
  for (const e of flattenClassEvents(call.className)) known.add(e);
}

(React/Roact/Fusion are unaffected since their events are computed keys — [React.Event.X], [OnEvent "X"] — which the entry scanner already leaves out.)

Workaround

"luix.propValidation.enabled": false — the luix.props override doesn't help since it's only read by completions, and there's no inline ignore directive.

Activity

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions