Skip to content

Commit

Permalink
Add raw nodes to hast node type registry
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
wooorm committed Aug 22, 2021
1 parent d6ffe8a commit f4a5825
Show file tree
Hide file tree
Showing 8 changed files with 724 additions and 679 deletions.
7 changes: 4 additions & 3 deletions .gitignore
@@ -1,6 +1,7 @@
.DS_Store
*.d.ts
*.log
coverage/
node_modules/
.DS_Store
*.log
index.d.ts
test.d.ts
yarn.lock
15 changes: 15 additions & 0 deletions complex-types.d.ts
@@ -0,0 +1,15 @@
import type {Literal} from 'hast'

export interface Raw extends Literal {
type: 'raw'
}

declare module 'hast' {
interface RootContentMap {
raw: Raw
}

interface ElementContentMap {
raw: Raw
}
}
1 change: 1 addition & 0 deletions index.js
@@ -1,5 +1,6 @@
/**
* @typedef {import('./lib/index.js').Options} Options
* @typedef {import('./complex-types').Raw} Raw
*/

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

0 comments on commit f4a5825

Please sign in to comment.