Skip to content

Commit

Permalink
fix types?
Browse files Browse the repository at this point in the history
  • Loading branch information
slorber committed Oct 25, 2023
1 parent 28c6db9 commit 31aaa9d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/docusaurus-mdx-loader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"fs-extra": "^11.1.1",
"hastscript": "^7.1.0",
"image-size": "^1.0.2",
"mdast-util-mdx": "^2.0.0",
"mdast-util-mdx": "^3.0.0",
"mdast-util-to-string": "^3.2.0",
"rehype-raw": "^6.1.1",
"remark-directive": "^3.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export default function plugin(): Transformer {
const slugs = createSlugger();
visit(root, 'heading', (headingNode: Heading) => {
const data = headingNode.data ?? (headingNode.data = {});
// @ts-expect-error: TODO how to fix?
const properties = (data.hProperties || (data.hProperties = {})) as {
id: string;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,11 @@ export default function codeCompatPlugin(this: Processor): Transformer {
visit(root, 'code', (node: Code) => {
node.data = node.data || {};

// @ts-expect-error: TODO how to fix?
node.data.hProperties = node.data.hProperties || {};
// @ts-expect-error: TODO how to fix?
node.data.hProperties.metastring = node.meta;

// Retrocompatible support for live codeblock metastring
// Not really the appropriate place to handle that :s
// @ts-expect-error: TODO how to fix?
node.data.hProperties.live = node.meta?.split(' ').includes('live');
});
};
Expand Down
6 changes: 5 additions & 1 deletion packages/docusaurus-mdx-loader/src/remark/toc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ import type {Node, Parent} from 'unist';
import type {Heading, Literal} from 'mdast';
// @ts-expect-error: TODO see https://github.com/microsoft/TypeScript/issues/49721
import type {Transformer} from 'unified';
import type {
MdxjsEsm,
// @ts-expect-error: TODO see https://github.com/microsoft/TypeScript/issues/49721
} from 'mdast-util-mdx';

// TODO as of April 2023, no way to import/re-export this ESM type easily :/
// TODO upgrade to TS 5.3
Expand Down Expand Up @@ -119,7 +123,7 @@ const plugin: Plugin = function plugin(

export default plugin;

async function createExportNode(name: string, object: any) {
async function createExportNode(name: string, object: any): Promise<MdxjsEsm> {
const {valueToEstree} = await import('estree-util-value-to-estree');

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,10 @@ declare module 'vfile' {
contentTitle?: string;
}
}

declare module 'unist' {
interface Data {
hName?: string;
hProperties?: Record<string, unknown>;
}
}

0 comments on commit 31aaa9d

Please sign in to comment.