Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add note about TypeScript requiring types for namespaced attributes #954

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
5 changes: 4 additions & 1 deletion src/routes/configuration/typescript.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -748,12 +748,15 @@ declare module "solid-js" {
count: number;
name: string;
}
interface ExplicitBoolAttributes {
disabled: boolean;
}
}
}

// Usage
<Input prop:name={name()} prop:count={count()}/>
<my-web-component attr:name={name()} attr:count={count()}/>
<my-web-component attr:name={name()} attr:count={count()} bool:disabled={true}/>
```

#### Custom directives
Expand Down
2 changes: 2 additions & 0 deletions src/routes/reference/jsx-attributes/attr.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ Forces the prop to be treated as an attribute instead of a property. Useful for
```tsx
<my-element attr:status={props.status} />
```

Note: Type definitions are required when using TypeScript. See the [TypeScript](/configuration/typescript#forcing-properties-and-custom-attributes) page for examples.
2 changes: 2 additions & 0 deletions src/routes/reference/jsx-attributes/bool.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ This attribute is most useful for Web Components.
<my-element />

```

Note: Type definitions are required when using TypeScript. See the [TypeScript](/configuration/typescript#forcing-properties-and-custom-attributes) page for examples.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use the Callout component

<Callout type="info" title="Strong-Typing Custom Properties">...</Callout>

2 changes: 1 addition & 1 deletion src/routes/reference/jsx-attributes/on.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const handler = {

// or inline

<div on:click={{passive:true, handleEvent(e) => console.log("Weeeee!")}} />
<div on:click={{passive:true, handleEvent(e) { console.log("Weeeee!")}}} />
```

This new syntax replaces the now deprecated `oncapture:` and it's future proof for any posible new event listener options.
2 changes: 2 additions & 0 deletions src/routes/reference/jsx-attributes/prop.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ Forces the prop to be treated as a property instead of an attribute.
```tsx
<div prop:scrollTop={props.scrollPos + "px"} />
```

Note: Type definitions are required when using TypeScript. See the [TypeScript](/configuration/typescript#forcing-properties-and-custom-attributes) page for examples.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use the Callout component

<Callout type="info" title="Strong-Typing Custom Properties">...</Callout>

Loading