Skip to content

Commit

Permalink
fix(runtime): add height, width Source attrs (#4943)
Browse files Browse the repository at this point in the history
add the height and width properties for the `SourceHTMLAttributes`.
prior to this commit, users attempting to properly type a `<source/>`
element in JSX would run into TypeScript errors:
```tsx
render() {
  return <picture><source height={100} width={100}/></picture>;
}
```
```
[ ERROR ]  TypeScript: src/components/my-component/my-component.tsx:31:29
           Type '{ height: number; width: number; }' is not assignable to type
           'SourceHTMLAttributes<HTMLSourceElement>'.Property 'height' does not exist on type
           'SourceHTMLAttributes<HTMLSourceElement>'.

     L30:  render() {
     L31:    return <picture><source height={100} width={100}/></picture>;
     L32:  }

[26:05.7]  build failed in 1.12 s
```

adding these typings as optional numbers resolves these types of
compile-time errors

fixes: #4942

STENCIL-977
  • Loading branch information
rwaskiewicz committed Oct 18, 2023
1 parent b97dadc commit c9a3eac
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/declarations/stencil-public-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1259,11 +1259,13 @@ export namespace JSXBase {
}

export interface SourceHTMLAttributes<T> extends HTMLAttributes<T> {
height?: number;
media?: string;
sizes?: string;
src?: string;
srcSet?: string;
type?: string;
width?: number;
}

export interface StyleHTMLAttributes<T> extends HTMLAttributes<T> {
Expand Down

0 comments on commit c9a3eac

Please sign in to comment.