lezer-parser/lezer

Typings for Tree.resolve changed in `0.15.11`

paddyobrien opened this issue · 1 comments

The return type of Tree.resolve and Tree.resolveInner have changed to any in @​lezer/common@0.15.11.

Looking at the diff that caused this it appears the change was unintentional.

Before:

resolve(pos: number, side?: -1 | 0 | 1): SyntaxNode;
resolveInner(pos: number, side?: -1 | 0 | 1): SyntaxNode;

After:

resolve(pos: number, side?: -1 | 0 | 1): any;
resolveInner(pos: number, side?: -1 | 0 | 1): any;

Indeed. Looks a lot like a TypeScript regression—it sets the return type of resolveNode to any though that function only ever returns a variable with type SyntaxNode, and implicit any is turned off in the TS config, so it should at least error if it can't figure out a type. (Didn't report it yet, since I couldn't find a simple script that reproduces the issue.)

Patch lezer-parser/common@2d7ea5d adds an explicit return type.