Skip to content

Commit

Permalink
Fix type error introduced by new typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Oct 8, 2021
1 parent f2af1bd commit 68b797d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion packages/rehype-katex/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ export default function rehypeKatex(options) {
value,
assign({}, settings, {displayMode, throwOnError: true})
)
} catch (error) {
} catch (exception) {
const error = /** @type {Error} */ (exception)
const fn = throwOnError ? 'fail' : 'message'
const origin = [source, error.name.toLowerCase()].join(':')

Expand Down
3 changes: 2 additions & 1 deletion packages/rehype-katex/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ test('rehype-katex', (t) => {
.processSync(
'<p>Lorem</p>\n<p><span class="math-inline">\\alpa</span></p>'
)
} catch (error) {
} catch (exception) {
const error = /** @type {Error} */ (exception)
t.equal(
error.message,
'KaTeX parse error: Undefined control sequence: \\alpa at position 1: \\̲a̲l̲p̲a̲',
Expand Down
3 changes: 2 additions & 1 deletion packages/remark-html-katex/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ export default function remarkHtmlKatex(options = {}) {
throwOnError: true
})
)
} catch (error) {
} catch (exception) {
const error = /** @type {Error} */ (exception)
const fn = throwOnError ? 'fail' : 'message'
const origin = [source, error.name.toLowerCase()].join(':')

Expand Down
3 changes: 2 additions & 1 deletion packages/remark-html-katex/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ test('remark-html-katex', (t) => {
.use(remarkHtmlKatex, {throwOnError: true})
.use(remarkHtml)
.processSync('Lorem\n$\\alpa$')
} catch (error) {
} catch (exception) {
const error = /** @type {Error} */ (exception)
t.equal(
error.message,
'KaTeX parse error: Undefined control sequence: \\alpa at position 1: \\̲a̲l̲p̲a̲',
Expand Down

0 comments on commit 68b797d

Please sign in to comment.