Skip to content

Commit 041b646

Browse files
Move typewriter over to using zero based math.
1 parent e723d4c commit 041b646

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/harness/typeWriter.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,17 @@ class TypeWriterWalker {
8585

8686
private log(node: ts.Node, type: ts.Type): void {
8787
var actualPos = ts.skipTrivia(this.currentSourceFile.text, node.pos);
88-
var lineAndCharacter = this.currentSourceFile.getOneBasedLineAndCharacterOfPosition(actualPos);
88+
var lineAndCharacter = this.currentSourceFile.getZeroBasedLineAndCharacterOfPosition(actualPos);
8989
var sourceText = ts.getTextOfNodeFromSourceText(this.currentSourceFile.text, node);
9090

9191
// If we got an unknown type, we temporarily want to fall back to just pretending the name
9292
// (source text) of the node is the type. This is to align with the old typeWriter to make
9393
// baseline comparisons easier. In the long term, we will want to just call typeToString
9494
this.results.push({
95-
line: lineAndCharacter.line - 1,
96-
column: lineAndCharacter.character,
95+
line: lineAndCharacter.line,
96+
// todo(cyrusn): Not sure why column is one-based for type-writer. But I'm preserving
97+
// that behavior to prevent having a lot of baselines to fix up.
98+
column: lineAndCharacter.character + 1,
9799
syntaxKind: node.kind,
98100
sourceText: sourceText,
99101
type: this.checker.typeToString(type, node.parent, ts.TypeFormatFlags.NoTruncation | ts.TypeFormatFlags.WriteOwnNameForAnyLike)

0 commit comments

Comments
 (0)