@types/mdx 2.0.5 → 2.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mdx/README.md +1 -1
- mdx/index.d.ts +1 -1
- mdx/package.json +2 -2
- mdx/types.d.ts +55 -8
mdx/README.md
CHANGED
|
@@ -8,7 +8,7 @@ This package contains type definitions for mdx (https://github.com/mdx-js/mdx).
|
|
|
8
8
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/mdx.
|
|
9
9
|
|
|
10
10
|
### Additional Details
|
|
11
|
-
* Last updated:
|
|
11
|
+
* Last updated: Tue, 22 Aug 2023 18:04:26 GMT
|
|
12
12
|
* Dependencies: none
|
|
13
13
|
* Global values: none
|
|
14
14
|
|
mdx/index.d.ts
CHANGED
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
* It should now be possible to import both the MDX component and the exported constant `message`.
|
|
60
60
|
*/
|
|
61
61
|
declare module '*.mdx' {
|
|
62
|
-
// eslint-disable-next-line no-self-import
|
|
62
|
+
// eslint-disable-next-line @definitelytyped/no-self-import
|
|
63
63
|
import { MDXProps } from 'mdx/types';
|
|
64
64
|
|
|
65
65
|
/**
|
mdx/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@types/mdx",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.7",
|
|
4
4
|
"description": "TypeScript definitions for mdx",
|
|
5
5
|
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/mdx",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,6 +30,6 @@
|
|
|
30
30
|
},
|
|
31
31
|
"scripts": {},
|
|
32
32
|
"dependencies": {},
|
|
33
|
-
"typesPublisherContentHash": "
|
|
33
|
+
"typesPublisherContentHash": "91e24fb42a72ce9b37c45fb6ed3028c4f46b6b6bb7d9a21e89793a984f7cfd22",
|
|
34
34
|
"typeScriptVersion": "4.3"
|
|
35
35
|
}
|
mdx/types.d.ts
CHANGED
|
@@ -1,12 +1,56 @@
|
|
|
1
1
|
// Internal helper types
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
//
|
|
8
|
-
type
|
|
9
|
-
|
|
3
|
+
/**
|
|
4
|
+
* This is the global JSX.ElementType if it’s defined, otherwise never.
|
|
5
|
+
*/
|
|
6
|
+
// @ts-ignore JSX runtimes may optionally define JSX.ElementType. The MDX types need to work regardless whether this is
|
|
7
|
+
// defined or not.
|
|
8
|
+
type ElementType = any extends JSX.ElementType ? never : JSX.ElementType;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* This matches any function component types that ar part of `ElementType`.
|
|
12
|
+
*/
|
|
13
|
+
type FunctionElementType = Extract<ElementType, (props: Record<string, any>) => any>;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* This matches any class component types that ar part of `ElementType`.
|
|
17
|
+
*/
|
|
18
|
+
type ClassElementType = Extract<ElementType, new (props: Record<string, any>) => any>;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* A valid JSX string component.
|
|
22
|
+
*/
|
|
23
|
+
type StringComponent = Extract<keyof JSX.IntrinsicElements, ElementType extends never ? string : ElementType>;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* A valid JSX function component.
|
|
27
|
+
*/
|
|
28
|
+
type FunctionComponent<Props> = ElementType extends never
|
|
29
|
+
? // If JSX.ElementType isn’t defined, the valid return type is JSX.Element
|
|
30
|
+
(props: Props) => JSX.Element | null
|
|
31
|
+
: FunctionElementType extends never
|
|
32
|
+
? // If JSX.ElementType is defined, but doesn’t allow function components, function components are disallowed.
|
|
33
|
+
never
|
|
34
|
+
: // If JSX.ElementType allows function components, its return value determines what is a valid.
|
|
35
|
+
(props: Props) => ReturnType<FunctionElementType>;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A valid JSX class component.
|
|
39
|
+
*/
|
|
40
|
+
type ClassComponent<Props> = ElementType extends never
|
|
41
|
+
? // If JSX.ElementType isn’t defined, the valid return type is a constructor that returns JSX.ElementClass
|
|
42
|
+
new (props: Props) => JSX.ElementClass
|
|
43
|
+
: ClassElementType extends never
|
|
44
|
+
? // If JSX.ElementType is defined, but doesn’t allow constructors, function components are disallowed.
|
|
45
|
+
never
|
|
46
|
+
: // If JSX.ElementType allows class components, its return value determines what is a valid.
|
|
47
|
+
new (props: Props) => InstanceType<ClassElementType>;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Any allowed JSX component.
|
|
51
|
+
*/
|
|
52
|
+
type Component<Props> = FunctionComponent<Props> | ClassComponent<Props> | StringComponent;
|
|
53
|
+
|
|
10
54
|
interface NestedMDXComponents {
|
|
11
55
|
[key: string]: NestedMDXComponents | Component<any>;
|
|
12
56
|
}
|
|
@@ -19,7 +63,7 @@ interface NestedMDXComponents {
|
|
|
19
63
|
* The key is the name of the element to override. The value is the component to render instead.
|
|
20
64
|
*/
|
|
21
65
|
export type MDXComponents = NestedMDXComponents & {
|
|
22
|
-
[Key in
|
|
66
|
+
[Key in StringComponent]?: Component<JSX.IntrinsicElements[Key]>;
|
|
23
67
|
} & {
|
|
24
68
|
/**
|
|
25
69
|
* If a wrapper component is defined, the MDX content will be wrapped inside of it.
|
|
@@ -62,3 +106,6 @@ export interface MDXModule {
|
|
|
62
106
|
*/
|
|
63
107
|
default: MDXContent;
|
|
64
108
|
}
|
|
109
|
+
|
|
110
|
+
// This marks the file as a module, meaning not all types are implicitly exported.
|
|
111
|
+
export {};
|