#1285·acorn

[acorn] Missing `value` property in `Token` (TypeScript)

Author: e6nlaqCreated Mar 24, 2024Updated Apr 18, 2024
typescript
import * as acorn from "acorn";

const token = acorn.tokenizer("const", { ecmaVersion: 6 });

console.log(token.getToken().value);

If you compile a file like the above with tsc, you will get the following error:

index.ts:5:30 - error TS2339: Property 'value' does not exist on type 'Token'.

5 console.log(token.getToken().value);
                               ~~~~~


Found 1 error in index.ts:5

Since the value property actually exists, the type definition is considered incorrect.