TS2740
Type 'TextLine' is missing the following properties from type 'Position': line, character, isBefore, isBeforeOrEqual, and 6 more.
Broken Code ❌
import { Position, TextEditor } from 'vscode';
function logPosition(textEditor: TextEditor, startLine: Position = textEditor.document.lineAt(0)) {
console.log(startLine.line);
}Fixed Code ✔️
The parameter startLine is requiring a value of type Position but the default value returns a value of type TextLine, so this has to be fixed to return the expected type:
import { Position, TextEditor } from 'vscode';
function logPosition(textEditor: TextEditor, startLine: Position = textEditor.document.lineAt(0).range.start) {
console.log(startLine.line);
}