mammoth
mammoth copied to clipboard
`Array<Token>` is assignable to `Token`
I sometimes have to use Token
to build expressions that Mammoth doesn't currently support. I noticed that Array<Token>
is assignable to Token
:
import {Token} from '@ff00ff/mammoth/.build/tokens';
const ts =
function f(ts: Array<Token>): Token {
return ts; // was expecting a type error here
}
This means TS doesn't catch errors where I accidentally pass Array<Token>
where a Token
is expected.
Maybe Mammoth should change Token
to be nominally typed to avoid this issue?