mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-12 00:27:21 +02:00
refactor: ensure all types are using index signature instead of Record (#6995)
* refactor: ensure all types are using index signature instead of Record * kick CI
This commit is contained in:
parent
e8800b9d49
commit
87592bca03
99 changed files with 339 additions and 307 deletions
|
@ -12,7 +12,7 @@ import fs from 'fs-extra';
|
|||
|
||||
describe('genChunkName', () => {
|
||||
it('works', () => {
|
||||
const firstAssert: Record<string, string> = {
|
||||
const firstAssert: {[key: string]: string} = {
|
||||
'/docs/adding-blog': 'docs-adding-blog-062',
|
||||
'/docs/versioning': 'docs-versioning-8a8',
|
||||
'/': 'index',
|
||||
|
@ -34,7 +34,7 @@ describe('genChunkName', () => {
|
|||
});
|
||||
|
||||
it('emits different chunk names for different paths even with same preferred name', () => {
|
||||
const secondAssert: Record<string, string> = {
|
||||
const secondAssert: {[key: string]: string} = {
|
||||
'/blog/1': 'blog-85-f-089',
|
||||
'/blog/2': 'blog-353-489',
|
||||
};
|
||||
|
@ -44,7 +44,7 @@ describe('genChunkName', () => {
|
|||
});
|
||||
|
||||
it('only generates short unique IDs', () => {
|
||||
const thirdAssert: Record<string, string> = {
|
||||
const thirdAssert: {[key: string]: string} = {
|
||||
a: '0cc175b9',
|
||||
b: '92eb5ffe',
|
||||
c: '4a8a08f0',
|
||||
|
|
|
@ -9,7 +9,7 @@ import {simpleHash, docuHash} from '../hashUtils';
|
|||
|
||||
describe('hashUtils', () => {
|
||||
it('simpleHash', () => {
|
||||
const asserts: Record<string, string> = {
|
||||
const asserts: {[key: string]: string} = {
|
||||
'': 'd41',
|
||||
'/foo-bar': '096',
|
||||
'/foo/bar': '1df',
|
||||
|
@ -30,7 +30,7 @@ describe('hashUtils', () => {
|
|||
|
||||
describe('docuHash', () => {
|
||||
it('docuHash works', () => {
|
||||
const asserts: Record<string, string> = {
|
||||
const asserts: {[key: string]: string} = {
|
||||
'': '-d41',
|
||||
'/': 'index',
|
||||
'/foo-bar': 'foo-bar-096',
|
||||
|
|
|
@ -45,15 +45,15 @@ describe('mapAsyncSequential', () => {
|
|||
}
|
||||
|
||||
it('maps sequentially', async () => {
|
||||
const itemToTimeout: Record<string, number> = {
|
||||
const itemToTimeout: {[key: string]: number} = {
|
||||
'1': 200,
|
||||
'2': 600,
|
||||
'3': 400,
|
||||
};
|
||||
const items = Object.keys(itemToTimeout);
|
||||
|
||||
const itemMapStartsAt: Record<string, number> = {};
|
||||
const itemMapEndsAt: Record<string, number> = {};
|
||||
const itemMapStartsAt: {[key: string]: number} = {};
|
||||
const itemMapEndsAt: {[key: string]: number} = {};
|
||||
|
||||
const timeBefore = Date.now();
|
||||
await expect(
|
||||
|
|
|
@ -131,7 +131,7 @@ describe('toMessageRelativeFilePath', () => {
|
|||
|
||||
describe('escapePath', () => {
|
||||
it('works', () => {
|
||||
const asserts: Record<string, string> = {
|
||||
const asserts: {[key: string]: string} = {
|
||||
'c:/aaaa\\bbbb': 'c:/aaaa\\\\bbbb',
|
||||
'c:\\aaaa\\bbbb\\★': 'c:\\\\aaaa\\\\bbbb\\\\★',
|
||||
'\\\\?\\c:\\aaaa\\bbbb': '\\\\\\\\?\\\\c:\\\\aaaa\\\\bbbb',
|
||||
|
@ -148,7 +148,7 @@ describe('escapePath', () => {
|
|||
|
||||
describe('posixPath', () => {
|
||||
it('works', () => {
|
||||
const asserts: Record<string, string> = {
|
||||
const asserts: {[key: string]: string} = {
|
||||
'c:/aaaa\\bbbb': 'c:/aaaa/bbbb',
|
||||
'c:\\aaaa\\bbbb\\★': 'c:\\aaaa\\bbbb\\★',
|
||||
'\\\\?\\c:\\aaaa\\bbbb': '\\\\?\\c:\\aaaa\\bbbb',
|
||||
|
@ -165,7 +165,7 @@ describe('posixPath', () => {
|
|||
|
||||
describe('aliasedSitePath', () => {
|
||||
it('works', () => {
|
||||
const asserts: Record<string, string> = {
|
||||
const asserts: {[key: string]: string} = {
|
||||
'user/website/docs/asd.md': '@site/docs/asd.md',
|
||||
'user/website/versioned_docs/foo/bar.md':
|
||||
'@site/versioned_docs/foo/bar.md',
|
||||
|
|
|
@ -170,7 +170,7 @@ describe('getEditUrl', () => {
|
|||
|
||||
describe('fileToPath', () => {
|
||||
it('works', () => {
|
||||
const asserts: Record<string, string> = {
|
||||
const asserts: {[key: string]: string} = {
|
||||
'index.md': '/',
|
||||
'hello/index.md': '/hello/',
|
||||
'foo.md': '/foo',
|
||||
|
|
|
@ -69,7 +69,7 @@ export function replaceMarkdownLinks<T extends ContentPaths>({
|
|||
/**
|
||||
* A map from source paths to their URLs. Source paths are `@site` aliased.
|
||||
*/
|
||||
sourceToPermalink: Record<string, string>;
|
||||
sourceToPermalink: {[aliasedPath: string]: string};
|
||||
}): {
|
||||
/**
|
||||
* The content with all Markdown file references replaced with their URLs.
|
||||
|
|
|
@ -143,7 +143,7 @@ export function createExcerpt(fileString: string): string | undefined {
|
|||
*/
|
||||
export function parseFrontMatter(markdownFileContent: string): {
|
||||
/** Front matter as parsed by gray-matter. */
|
||||
frontMatter: Record<string, unknown>;
|
||||
frontMatter: {[key: string]: unknown};
|
||||
/** The remaining content, trimmed. */
|
||||
content: string;
|
||||
} {
|
||||
|
@ -244,7 +244,7 @@ export function parseMarkdownString(
|
|||
options?: ParseMarkdownContentTitleOptions,
|
||||
): {
|
||||
/** @see {@link parseFrontMatter} */
|
||||
frontMatter: Record<string, unknown>;
|
||||
frontMatter: {[key: string]: unknown};
|
||||
/** @see {@link parseMarkdownContentTitle} */
|
||||
contentTitle: string | undefined;
|
||||
/** @see {@link createExcerpt} */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue