Skip to content

Commit 8346ace

Browse files
Luke ShiruLuke Shiru
andauthored
feat(remix-dev): Improve types for imported MD & MDX files (#2602)
Co-authored-by: Luke Shiru <hi@lshi.ru>
1 parent 52f29fc commit 8346ace

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

contributors.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@
280280
- luk-str
281281
- lukahartwig
282282
- lukasgerm
283+
- lukeshiru
283284
- m0nica
284285
- m5r
285286
- machour

packages/remix-dev/modules.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,33 @@ declare module "*.jpg" {
5959
export default asset;
6060
}
6161
declare module "*.md" {
62-
import type { ComponentType as MdComponentType } from "react";
62+
import type { ComponentType, ReactHTML } from "react";
6363
export let attributes: any;
6464
export let filename: string;
65-
let Component: MdComponentType;
65+
let Component: ComponentType<
66+
Readonly<Record<string, unknown>> & {
67+
components?: Readonly<
68+
Partial<
69+
Record<keyof ReactHTML | "wrapper", keyof ReactHTML | ComponentType>
70+
>
71+
>;
72+
}
73+
>;
6674
export default Component;
6775
}
6876
declare module "*.mdx" {
69-
import type { ComponentType as MdxComponentType } from "react";
77+
import type { ComponentType, ReactHTML } from "react";
7078
export let attributes: any;
7179
export let filename: string;
72-
let Component: MdxComponentType;
80+
let Component: ComponentType<
81+
Readonly<Record<string, unknown>> & {
82+
components?: Readonly<
83+
Partial<
84+
Record<keyof ReactHTML | "wrapper", keyof ReactHTML | ComponentType>
85+
>
86+
>;
87+
}
88+
>;
7389
export default Component;
7490
}
7591
declare module "*.mp3" {

0 commit comments

Comments
 (0)