Skip to content

Commit b294443

Browse files
committed
Merge pull request microsoft#3719 from Microsoft/createNodePos
Change default node pos/end to -1
2 parents ba87e14 + e4ebf1f commit b294443

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

src/compiler/core.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -764,8 +764,8 @@ namespace ts {
764764
}
765765
Node.prototype = {
766766
kind: kind,
767-
pos: 0,
768-
end: 0,
767+
pos: -1,
768+
end: -1,
769769
flags: 0,
770770
parent: undefined,
771771
};

src/compiler/utilities.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ namespace ts {
144144
return true;
145145
}
146146

147-
return node.pos === node.end && node.kind !== SyntaxKind.EndOfFileToken;
147+
return node.pos === node.end && node.pos >= 0 && node.kind !== SyntaxKind.EndOfFileToken;
148148
}
149149

150150
export function nodeIsPresent(node: Node) {
@@ -1428,8 +1428,6 @@ namespace ts {
14281428

14291429
export function createSynthesizedNode(kind: SyntaxKind, startsOnNewLine?: boolean): Node {
14301430
let node = <SynthesizedNode>createNode(kind);
1431-
node.pos = -1;
1432-
node.end = -1;
14331431
node.startsOnNewLine = startsOnNewLine;
14341432
return node;
14351433
}

src/services/services.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -7387,8 +7387,8 @@ namespace ts {
73877387
}
73887388
let proto = kind === SyntaxKind.SourceFile ? new SourceFileObject() : new NodeObject();
73897389
proto.kind = kind;
7390-
proto.pos = 0;
7391-
proto.end = 0;
7390+
proto.pos = -1;
7391+
proto.end = -1;
73927392
proto.flags = 0;
73937393
proto.parent = undefined;
73947394
Node.prototype = proto;

0 commit comments

Comments
 (0)