Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ All notable changes to **Luix** will be documented in this file.

Format follows [Keep a Changelog](https://keepachangelog.com/).

## [Unreleased]

### Vide events are no longer flagged as unknown props ([#4](https://github.com/ericplane/Luix/issues/4))

Vide passes events as plain table keys — `Activated = function() … end`,
`MouseEnter = …`, `MouseButton1Down = …`. Completion already merged the
class's events into the prop list for frameworks with `eventsAsProps`,
but the unknown-prop diagnostic only consulted `flattenClassProps`, so
every Vide event handler on a host class was warned about as
`Unknown property`. The diagnostic now unions `flattenClassEvents` into
its known set when the call's alias belongs to an `eventsAsProps`
framework. React, Roact and Fusion spell events as computed keys and
are unaffected.
## [1.5.2]

### Fusion 0.3 and StyLua-formatted calls are recognised ([#3](https://github.com/ericplane/Luix/issues/3))
Expand Down
17 changes: 16 additions & 1 deletion src/diagnostics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
getPropType,
defaultPropsMap,
flattenClassProps,
flattenClassEvents,
isDeprecatedValidProp,
cornerRadiusConflicts,
} from "./data";
Expand All @@ -22,7 +23,7 @@ import {
} from "./parser";
import { getAutoImportConfig } from "./config";
import { configChangeAffects, getConfig } from "./configCompat";
import { getAliasPartition } from "./frameworks";
import { findFrameworkForAlias, getAliasPartition } from "./frameworks";
import { WorkspaceIndex } from "./workspaceIndex";
import { planUICornerRefactor } from "./uiCorner";

Expand Down Expand Up @@ -549,6 +550,20 @@ function computePropValidationDiagnostics(
// ---- Unknown / wrong-enum (Roblox host class only) ----
if (call.isStringLiteralName && defaultPropsMap[call.className]) {
const known = new Set(flattenClassProps(call.className));
// Frameworks that take events as plain table keys (Vide:
// `Activated = function() … end`) put event names in the same
// props table. Completion already merges them (see
// `completion.ts`); mirror that here so they aren't flagged
// "Unknown property" (issue #4). React/Roact/Fusion spell events
// as computed keys, which the entry scanner never yields.
const framework = call.alias
? findFrameworkForAlias(call.alias)
: undefined;
if (framework?.eventsAsProps) {
for (const event of flattenClassEvents(call.className)) {
known.add(event);
}
}
for (const entry of entries) {
if (known.has(entry.key)) {
// Check enum type, if we know one. Use class-aware lookup so
Expand Down