Skip to content

Commit 16e3fcb

Browse files
committed
Refactor types
1 parent e3075a5 commit 16e3fcb

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

dev/lib/html.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/**
22
* @typedef {import('micromark-util-types').HtmlExtension} HtmlExtension
3-
*
3+
*/
4+
5+
/**
46
* @typedef Options
57
* Configuration (optional).
68
* @property {string} [clobberPrefix='user-content-']
@@ -31,22 +33,26 @@ import {sanitizeUri} from 'micromark-util-sanitize-uri'
3133

3234
const own = {}.hasOwnProperty
3335

36+
/** @type {Options} */
37+
const defaultOptions = {}
38+
3439
/**
3540
* Function that can be called to get an HTML extension for micromark (passed
3641
* in `htmlExtensions`).
3742
*
38-
* @param {Options} [options={}]
43+
* @param {Options | null | undefined} [options]
3944
* Configuration (optional).
4045
* @returns {HtmlExtension}
4146
* HTML extension for micromark (passed in `htmlExtensions`).
4247
*/
43-
export function gfmFootnoteHtml(options = {}) {
44-
const label = options.label || 'Footnotes'
45-
const backLabel = options.backLabel || 'Back to content'
48+
export function gfmFootnoteHtml(options) {
49+
const config = options || defaultOptions
50+
const label = config.label || 'Footnotes'
51+
const backLabel = config.backLabel || 'Back to content'
4652
const clobberPrefix =
47-
options.clobberPrefix === undefined || options.clobberPrefix === null
53+
config.clobberPrefix === undefined || config.clobberPrefix === null
4854
? 'user-content-'
49-
: options.clobberPrefix
55+
: config.clobberPrefix
5056
return {
5157
enter: {
5258
gfmFootnoteDefinition() {

dev/lib/syntax.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/**
2+
* @typedef {import('micromark-util-types').Event} Event
3+
* @typedef {import('micromark-util-types').Exiter} Exiter
24
* @typedef {import('micromark-util-types').Extension} Extension
35
* @typedef {import('micromark-util-types').Resolver} Resolver
6+
* @typedef {import('micromark-util-types').State} State
47
* @typedef {import('micromark-util-types').Token} Token
58
* @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext
69
* @typedef {import('micromark-util-types').Tokenizer} Tokenizer
7-
* @typedef {import('micromark-util-types').Exiter} Exiter
8-
* @typedef {import('micromark-util-types').State} State
9-
* @typedef {import('micromark-util-types').Event} Event
1010
*/
1111

1212
import {ok as assert} from 'uvu/assert'
@@ -113,7 +113,7 @@ function tokenizePotentialGfmFootnoteCall(effects, ok, nok) {
113113
/** @type {Resolver} */
114114
function resolveToPotentialGfmFootnoteCall(events, context) {
115115
let index = events.length
116-
/** @type {Token|undefined} */
116+
/** @type {Token | undefined} */
117117
let labelStart
118118

119119
// Find an opening.
@@ -298,7 +298,7 @@ function tokenizeDefinitionStart(effects, ok, nok) {
298298
/** @type {string} */
299299
let identifier
300300
let size = 0
301-
/** @type {boolean|undefined} */
301+
/** @type {boolean | undefined} */
302302
let data
303303

304304
return start

0 commit comments

Comments
 (0)