Open
Description
Marked version: v7.0.2
Describe the bug
Since Marked v7.0.2, cannot narrow Token
type.
Tokens.Generic
was added to Token in #2891 but this change makes cannot narrow Token
type by Token.type
.
Line 23 in ff1602c
To Reproduce
Steps to reproduce the behavior:
import type { Token } from 'marked'
const t: Token = {
type: 'text',
raw: 'test',
text: 'test',
}
if (t.type === 'text') {
t // const t: (Tokens.Text & {
// loose?: boolean | undefined;
// tokens?: Token[] | undefined;
// }) | (Tokens.Generic & {
// loose?: boolean | undefined;
// tokens?: Token[] | undefined;
// })
t.text // (property) Tokens.Text.text: any
}
Expected behavior
import type { Token } from 'marked'
const t: Token = {
type: 'text',
raw: 'test',
text: 'test',
}
if (t.type === 'text') {
t // const t: Tokens.Text & {
// loose?: boolean | undefined;
// tokens?: Token[] | undefined;
// }
t.text // (property) Tokens.Text.text: string
}