Skip to content

Commit d57d7e4

Browse files
committed
satisfy types
1 parent 0260aea commit d57d7e4

4 files changed

Lines changed: 16 additions & 17 deletions

File tree

packages/mdx/lib/compiler.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@ type CompiledMDX = {
2424
readingTime: ReadTimeResults;
2525
};
2626

27-
type MDXVFile = VFile & {
28-
data: Omit<CompiledMDX, 'frontmatter'> & {
29-
matter: Record<string, unknown>;
30-
};
27+
type MDXVFileData = Omit<CompiledMDX, 'frontmatter'> & {
28+
matter: Record<string, unknown>;
3129
};
3230

3331
/**
@@ -42,7 +40,7 @@ type MDXVFile = VFile & {
4240
* @returns Promise resolving to compiled MDX content and metadata
4341
*/
4442
export default async function compile(
45-
source: MDXVFile,
43+
source: VFile,
4644
fileExtension: 'md' | 'mdx',
4745
components: MDXComponents = {},
4846
props: Record<string, unknown> = {}
@@ -77,7 +75,11 @@ export default async function compile(
7775

7876
// Retrieve some parsed data from the VFile metadata
7977
// such as frontmatter and Markdown headings
80-
const { headings = [], matter: frontmatter, readingTime } = source.data || {};
78+
const {
79+
headings = [],
80+
matter: frontmatter,
81+
readingTime,
82+
} = (source.data || {}) as MDXVFileData;
8183

8284
headings.forEach((heading: Heading) => {
8385
// we re-sluggify the links to match the GitHub slugger

packages/mdx/lib/highlighter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
} from '@shikijs/core';
55
import { createJavaScriptRegexEngine } from '@shikijs/engine-javascript';
66

7-
import { LANGUAGES, DEFAULT_THEME } from '../shiki.config.mjs';
7+
import { LANGUAGES, DEFAULT_THEME } from '../shiki.config';
88

99
// Create a memoized minimal Shiki Syntax Highlighter
1010
export const shiki = createHighlighterCoreSync({

packages/mdx/lib/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import GithubSlugger from 'github-slugger';
22

3-
import { LANGUAGES } from '../shiki.config.mjs';
3+
import { LANGUAGES } from '../shiki.config';
44

55
export const createGitHubSlugger = () => {
66
const githubSlugger = new GithubSlugger();
Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
'use strict';
2-
1+
import type { LanguageRegistration, ThemeRegistration } from 'shiki';
32
import diffLanguage from 'shiki/langs/diff.mjs';
43
import dockerLanguage from 'shiki/langs/docker.mjs';
54
import iniLanguage from 'shiki/langs/ini.mjs';
@@ -14,15 +13,13 @@ import shikiNordTheme from 'shiki/themes/nord.mjs';
1413

1514
/**
1615
* All languages needed within the Node.js website for syntax highlighting.
17-
*
18-
* @type {Array<import('shiki').LanguageRegistration>}
1916
*/
20-
export const LANGUAGES = [
17+
export const LANGUAGES: Array<LanguageRegistration> = [
2118
{
2219
...javaScriptLanguage[0],
23-
// We path the JavaScript language to include the CommonJS and ES Module aliases
20+
// We patch the JavaScript language to include the CommonJS and ES Module aliases
2421
// that are commonly used (non-standard aliases) within our API docs and Blog posts
25-
aliases: javaScriptLanguage[0].aliases.concat('cjs', 'mjs'),
22+
aliases: javaScriptLanguage[0].aliases!.concat('cjs', 'mjs'),
2623
},
2724
...iniLanguage,
2825
...jsonLanguage,
@@ -36,8 +33,8 @@ export const LANGUAGES = [
3633
];
3734

3835
// This is the default theme we use for our Shiki Syntax Highlighter
39-
export const DEFAULT_THEME = {
40-
// We updating this color because the background color and comment text color
36+
export const DEFAULT_THEME: ThemeRegistration = {
37+
// We update this color because the background color and comment text color
4138
// in the Codebox component do not comply with accessibility standards
4239
// @see https://www.w3.org/WAI/WCAG21/Understanding/contrast-minimum.html
4340
colorReplacements: { '#616e88': '#707e99' },

0 commit comments

Comments
 (0)