Skip to content

Commit f4a5825

Browse files
committed
Add raw nodes to hast node type registry
When using this utility, the raw type will automatically be added to hast in the correct places. See DefinitelyTyped/DefinitelyTyped#55187 for more information. This also improves the types by allowing an overload of omitted vfile.
1 parent d6ffe8a commit f4a5825

File tree

8 files changed

+724
-679
lines changed

8 files changed

+724
-679
lines changed

.gitignore

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
.DS_Store
2-
*.d.ts
3-
*.log
41
coverage/
52
node_modules/
3+
.DS_Store
4+
*.log
5+
index.d.ts
6+
test.d.ts
67
yarn.lock

complex-types.d.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import type {Literal} from 'hast'
2+
3+
export interface Raw extends Literal {
4+
type: 'raw'
5+
}
6+
7+
declare module 'hast' {
8+
interface RootContentMap {
9+
raw: Raw
10+
}
11+
12+
interface ElementContentMap {
13+
raw: Raw
14+
}
15+
}

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/**
22
* @typedef {import('./lib/index.js').Options} Options
3+
* @typedef {import('./complex-types').Raw} Raw
34
*/
45

56
export {raw} from './lib/index.js'

0 commit comments

Comments
 (0)