Skip to content

Commit

Permalink
refactor: move ambient module extension into global type.d.ts file
Browse files Browse the repository at this point in the history
extract it from index.tsx
allow for extension by importing solid-js itself to not overwrite but extend and make HTMLAttributes known
see: solidjs/solid#616 (comment) and https://github.com/solidjs/solid/blob/89baf1206a1df27ab5a666b6c31729fd1505e341/packages/solid/h/jsx-runtime/src/jsx.d.ts
  • Loading branch information
wridgeu committed Jan 11, 2023
1 parent aff16eb commit 863cfc2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
21 changes: 0 additions & 21 deletions packages/frontend/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,6 @@ import { render } from "solid-js/web";
import "./index.css";
import { App } from "./components/App";

// https://stackoverflow.com/a/72239265/10323879
declare module "solid-js" {
namespace JSX {
interface IntrinsicElements {
"ui5-table": HTMLAttributes<HTMLElement>; //JSX.IntrinsicElements["table"];
"ui5-table-column": HTMLAttributes<HTMLElement>;
"ui5-table-row": HTMLAttributes<HTMLElement>;
"ui5-table-cell": HTMLAttributes<HTMLElement>;
"ui5-badge": HTMLAttributes<HTMLElement>;
"ui5-button": HTMLAttributes<HTMLElement>;
"ui5-toast": HTMLAttributes<HTMLElement>;
"ui5-input": HTMLAttributes<HTMLElement> & {
"show-clear-icon"?: boolean;
value?: string;
placeholder?: string;
};
"ui5-icon": HTMLAttributes<HTMLElement> & { name: string; slot: string };
}
}
}

render(
() => (
<Router>
Expand Down
22 changes: 22 additions & 0 deletions packages/frontend/src/types.d.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import "solid-js"; //thanks to: https://github.com/solidjs/solid/issues/616#issuecomment-904193450

// https://stackoverflow.com/a/72239265/10323879
declare module "solid-js" {
namespace JSX {
interface IntrinsicElements {
"ui5-table": HTMLAttributes<HTMLElement>; //JSX.IntrinsicElements["table"];
"ui5-table-column": HTMLAttributes<HTMLElement>;
"ui5-table-row": HTMLAttributes<HTMLElement>;
"ui5-table-cell": HTMLAttributes<HTMLElement>;
"ui5-badge": HTMLAttributes<HTMLElement>;
"ui5-button": HTMLAttributes<HTMLElement>;
"ui5-toast": HTMLAttributes<HTMLElement>;
"ui5-input": HTMLAttributes<HTMLElement> & {
"show-clear-icon"?: boolean;
value?: string;
placeholder?: string;
};
"ui5-icon": HTMLAttributes<HTMLElement> & { name: string; slot: string };
}
}
}

0 comments on commit 863cfc2

Please sign in to comment.