fix: harden generated identifiers and types
This commit is contained in:
@@ -1566,6 +1566,13 @@ const JS_RESERVED = new Set([
|
||||
"enum",
|
||||
"with",
|
||||
"debugger",
|
||||
"implements",
|
||||
"interface",
|
||||
"package",
|
||||
"private",
|
||||
"protected",
|
||||
"public",
|
||||
"static",
|
||||
]);
|
||||
|
||||
/** A JS reference for a prop/state name (reserved words get a `__p_` prefix). */
|
||||
|
||||
@@ -1387,3 +1387,14 @@ test("style blocks compile with stable page/component/layout metadata", () => {
|
||||
expect(layout).toContain("export const __wrnexusStyles");
|
||||
expect(page).toMatch(/data-wrnexus-style-id="wrn-page-[a-z0-9]+"/);
|
||||
});
|
||||
|
||||
test("strict-mode reserved prop names compile through safe local references", () => {
|
||||
const output = compileWireFile(`component Visibility {
|
||||
props { private: boolean = false }
|
||||
view { {#if private}<span>Private</span>{/if} }
|
||||
}`);
|
||||
|
||||
expect(output).toContain("const __p_private: boolean");
|
||||
expect(output).toContain("(__p_private) ?");
|
||||
expect(output).not.toContain("const private:");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user