In one of my modules I use an optional tuple for a function result:
function ruleFromPosition(position): [string, number] | undefined;
and assign this to local vars in my unit tests:
let [ruleName, ruleIndex] = ruleFromPosition(position);
This results in the error:
Type must have a 'Symbol.iterator' method that returns an iterator.
I could re-write this statement as:
let [ruleName, ruleIndex] = ruleFromPosition(position)!;
, which compiles, but that disallows for nullable checks. What's the correct way to use the tuple?