-
Notifications
You must be signed in to change notification settings - Fork 43
Open
Labels
Description
Versions
main
as of 2025-10-05
Node.js version
24.4.1
OS + version
Linux 6.16.8-arch3-1
Description
In packages/parser/src/parse/token.ts
:
const $extensions = getObjMember(node, '$extensions');
if ($extensions) {
const modeNode = getObjMember($extensions as momoa.ObjectNode, 'mode') as momoa.ObjectNode;
for (const mode of Object.keys((token.$extensions as any).mode)) {
const modeValue = (token.$extensions as any).mode[mode];
token.mode[mode] = {
// ...
};
}
}
(token.$extensions as any).mode
can be undefined and is not guarded, causing an error when running TZ with an outdated tokens.json
. The error is cryptic as it says "Cannot convert undefined or null to object".
Reproduction
Do a quick merge/rebase of the tokens listing branch, and without editing fixtures, run tests.
Expected result
I'd expect the parser to detect what exactly is missing and to provide a good error message.
Considering that $extensions.mode
was previously assumed to exist when $extensions
did, a message tailored at existing TZ users, telling them to update JSON files, could be relevant.
Extra
- I’m willing to open a PR (see CONTRIBUTING.md)
drwpow