diff --git a/package.json b/package.json index 6c868535..b8c246f6 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,6 @@ "@macrostrat/revision-info-webpack": "^1.0.0", "@macrostrat/storybook": "workspace:*", "@mdx-js/rollup": "^2.3.0", - "@types/esprima": "^4", "@types/underscore": "^1", "@typescript-eslint/eslint-plugin": "^6.3.0", "@typescript-eslint/parser": "^6.3.0", diff --git a/src/declaration.d.ts b/src/declaration.d.ts index a87d08a3..bf7d239f 100644 --- a/src/declaration.d.ts +++ b/src/declaration.d.ts @@ -1,21 +1,57 @@ // declaration.d.ts -import type { Hyper } from "@macrostrat/hyper"; import type { Component, ReactNode, ReactElement } from "react"; +type Children = ReactNode | ReactNode[]; + +declare module "@macrostrat/hyper" { + interface Hyper { + // Function with one or two arguments + (componentOrTag: Component, children?: Children): ReactNode; + + // Function with three arguments, with one being props +

( + componentOrTag: Component

, + props: P, + children?: Children + ): ReactNode; + + // Function with one list of elements -> React fragment + (children?: ReactNode[]): ReactNode[]; + } +} + +import { Hyper } from "@macrostrat/hyper"; + // Favicon etc. declare module "*.png" { const value: string; export default value; } -// Union of hyper and record -type StyledHyper = Hyper & Record; +// Get the hyper function from our custom module + +type Classes = { readonly [key: string]: string }; + +type StyledHyper = Classes & Hyper; // Style modules declare module "*.module.styl" { + const classes: { readonly [key: string]: string }; + export default StyledHyper; +} + +// Override declarations for sass module +declare module "*.module.sass" { + const classes: Classes; + export default StyledHyper; +} + +// Override declarations for sass module +declare module "*.module.scss" { + import styles from "./main.module.sass"; const classes: { [key: string]: string }; - export default classes; + export default StyledHyper; } declare module "*.styl" { @@ -27,26 +63,3 @@ declare module "*.sass" { const content: string; export default content; } - -// Override declarations for sass module -declare module "*.module.sass" { - const classes: { [key: string]: string }; - export default classes; -} - -type Children = ReactNode | ReactNode[]; - -declare module "@macrostrat/hyper" { - export interface Hyper { - // Function with one or two arguments - (componentOrTag: Component, children?: Children): Children; - // Function with three arguments, with one being props -

( - componentOrTag: Component

, - props: P, - children?: ReactElement - ): Children; - // Function with one list of elements -> React fragment - (children?: ReactNode[]): ReactElement; - } -}