refactor: improve setup of type declaration files (#5914)

This commit is contained in:
Joshua Chen 2021-11-13 00:47:27 +08:00 committed by GitHub
parent 334470b5d4
commit d1308a8736
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
33 changed files with 872 additions and 868 deletions

View file

@ -0,0 +1,18 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import type {Plugin} from 'unified';
export type RemarkOrRehypePlugin =
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[Plugin<any[]>, Record<string, unknown>] | Plugin<any[]>;
export type RemarkAndRehypePluginOptions = {
remarkPlugins: RemarkOrRehypePlugin[];
rehypePlugins: RemarkOrRehypePlugin[];
beforeDefaultRemarkPlugins: RemarkOrRehypePlugin[];
beforeDefaultRehypePlugins: RemarkOrRehypePlugin[];
};

View file

@ -1,43 +0,0 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
declare module '@docusaurus/mdx-loader' {
import type {Plugin} from 'unified';
export type RemarkOrRehypePlugin =
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[Plugin<any[]>, Record<string, unknown>] | Plugin<any[]>;
export type RemarkAndRehypePluginOptions = {
remarkPlugins: RemarkOrRehypePlugin[];
rehypePlugins: RemarkOrRehypePlugin[];
beforeDefaultRemarkPlugins: RemarkOrRehypePlugin[];
beforeDefaultRehypePlugins: RemarkOrRehypePlugin[];
};
}
// TODO Types provided by MDX 2.0 https://github.com/mdx-js/mdx/blob/main/packages/mdx/types/index.d.ts
declare module '@mdx-js/mdx' {
import type {Processor} from 'unified';
import type {RemarkOrRehypePlugin} from '@docusaurus/mdx-loader';
namespace mdx {
interface Options {
filepath?: string;
skipExport?: boolean;
wrapExport?: string;
remarkPlugins?: RemarkOrRehypePlugin[];
rehypePlugins?: RemarkOrRehypePlugin[];
}
function sync(content: string, options?: Options): string;
function createMdxAstCompiler(options?: Options): Processor;
function createCompiler(options?: Options): Processor;
}
function mdx(content: string, options?: mdx.Options): Promise<string>;
export default mdx;
}