dashersw / dashersw/gea

[BUG] props with defaults seem to generate a 'not defined' error

Open
#91 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1.2k
Forks
47
PR merge metrics
No merged PRs in 30d

Description

This does not throw an error:

```tsx
import { Component } from "@geajs/core";
import type { JSX } from "@geajs/core/jsx-runtime";

export type FooButtonProps = JSX.IntrinsicElements["button"];

export class FooButton extends Component {
template({ children, class: cls, ...props }: FooButtonProps) {
return (

{children}

);
}
}
```

But as soon as I try assigning a default to the `cls` prop instead of using null coalescing, I get an error:

```tsx
import { Component } from "@geajs/core";
import type { JSX } from "@geajs/core/jsx-runtime";

export type FooButtonProps = JSX.IntrinsicElements["button"];

export class FooButton extends Component {
template({ children, class: cls = "", ...props }: FooButtonProps) { // <---------
return (

{children}

);
}
}

// throws
// Uncaught ReferenceError: cls is not defined
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the provided TSX reproduction and trace how the JSX transform handles template parameter destructuring with a default value. The work is done when assigning a default to cls no longer causes a ReferenceError and the existing nullish-coalescing example still behaves correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.