Skip to content

Commit 60feb37

Browse files
committed
Handle error spans on manufactured checked nodes, add petit-dom test (its nice and small)
1 parent 3c6dc4e commit 60feb37

File tree

6 files changed

+5590
-0
lines changed

6 files changed

+5590
-0
lines changed

src/compiler/checker.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18764,6 +18764,7 @@ namespace ts {
1876418764
// Fake up a property declaration for the children
1876518765
childrenPropSymbol.valueDeclaration = createPropertySignature(/*modifiers*/ undefined, unescapeLeadingUnderscores(jsxChildrenPropertyName), /*questionToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined);
1876618766
childrenPropSymbol.valueDeclaration.parent = attributes;
18767+
childrenPropSymbol.valueDeclaration.original = parent;
1876718768
childrenPropSymbol.valueDeclaration.symbol = childrenPropSymbol;
1876818769
const childPropMap = createSymbolTable();
1876918770
childPropMap.set(jsxChildrenPropertyName, childrenPropSymbol);
@@ -20307,6 +20308,7 @@ namespace ts {
2030720308

2030820309
function createSyntheticExpression(parent: Node, type: Type | ((mode: CheckMode | undefined) => Type), isSpread?: boolean) {
2030920310
const result = <SyntheticExpression>createNode(SyntaxKind.SyntheticExpression, parent.pos, parent.end);
20311+
result.original = parent;
2031020312
result.parent = parent;
2031120313
result.type = type;
2031220314
result.isSpread = isSpread || false;

src/compiler/utilities.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,9 @@ namespace ts {
312312
export function getSourceFileOfNode(node: Node): SourceFile;
313313
export function getSourceFileOfNode(node: Node | undefined): SourceFile | undefined;
314314
export function getSourceFileOfNode(node: Node): SourceFile {
315+
if (node.original) {
316+
return getSourceFileOfNode(node.original);
317+
}
315318
while (node && node.kind !== SyntaxKind.SourceFile) {
316319
node = node.parent;
317320
}
@@ -849,6 +852,9 @@ namespace ts {
849852
}
850853

851854
export function getErrorSpanForNode(sourceFile: SourceFile, node: Node): TextSpan {
855+
while (node.original) {
856+
node = node.original;
857+
}
852858
let errorNode: Node | undefined = node;
853859
switch (node.kind) {
854860
case SyntaxKind.SourceFile:
@@ -2927,6 +2933,7 @@ namespace ts {
29272933
case SyntaxKind.TemplateExpression:
29282934
case SyntaxKind.ParenthesizedExpression:
29292935
case SyntaxKind.OmittedExpression:
2936+
case SyntaxKind.SyntheticExpression:
29302937
return 20;
29312938

29322939
default:

0 commit comments

Comments
 (0)