mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-10 15:25:54 -06:00
Additional source map fixes for initializers and arrow functions.
This commit is contained in:
parent
b69e65f1f9
commit
68aa646f0f
@ -1345,15 +1345,15 @@ const _super = (function (geti, seti) {
|
||||
}
|
||||
|
||||
function emitIfStatement(node: IfStatement) {
|
||||
const openParenPos = writeToken(SyntaxKind.IfKeyword, node.pos);
|
||||
const openParenPos = writeToken(SyntaxKind.IfKeyword, node.pos, node);
|
||||
write(" ");
|
||||
writeToken(SyntaxKind.OpenParenToken, openParenPos);
|
||||
writeToken(SyntaxKind.OpenParenToken, openParenPos, node);
|
||||
emitExpression(node.expression);
|
||||
writeToken(SyntaxKind.CloseParenToken, node.expression.end);
|
||||
writeToken(SyntaxKind.CloseParenToken, node.expression.end, node);
|
||||
emitEmbeddedStatement(node.thenStatement);
|
||||
if (node.elseStatement) {
|
||||
writeLine();
|
||||
writeToken(SyntaxKind.ElseKeyword, node.thenStatement.end);
|
||||
writeToken(SyntaxKind.ElseKeyword, node.thenStatement.end, node);
|
||||
if (node.elseStatement.kind === SyntaxKind.IfStatement) {
|
||||
write(" ");
|
||||
emit(node.elseStatement);
|
||||
|
||||
@ -949,28 +949,30 @@ namespace ts {
|
||||
* @param initializer The initializer for the parameter.
|
||||
*/
|
||||
function addDefaultValueAssignmentForInitializer(statements: Statement[], parameter: ParameterDeclaration, name: Identifier, initializer: Expression): void {
|
||||
statements.push(
|
||||
createIf(
|
||||
createStrictEquality(
|
||||
getSynthesizedClone(name),
|
||||
createVoidZero()
|
||||
),
|
||||
setNodeEmitFlags(
|
||||
createBlock([
|
||||
createStatement(
|
||||
createAssignment(
|
||||
getSynthesizedClone(name),
|
||||
visitNode(initializer, visitor, isExpression)
|
||||
)
|
||||
const statement = createIf(
|
||||
createStrictEquality(
|
||||
getSynthesizedClone(name),
|
||||
createVoidZero()
|
||||
),
|
||||
setNodeEmitFlags(
|
||||
createBlock([
|
||||
createStatement(
|
||||
createAssignment(
|
||||
setNodeEmitFlags(getMutableClone(name), NodeEmitFlags.NoSourceMap),
|
||||
setNodeEmitFlags(visitNode(initializer, visitor, isExpression), NodeEmitFlags.NoSourceMap),
|
||||
/*location*/ parameter
|
||||
)
|
||||
]),
|
||||
NodeEmitFlags.SingleLine
|
||||
),
|
||||
/*elseStatement*/ undefined,
|
||||
/*location*/ undefined,
|
||||
{ startOnNewLine: true }
|
||||
)
|
||||
)
|
||||
], /*location*/ parameter),
|
||||
NodeEmitFlags.SingleLine | NodeEmitFlags.NoTrailingSourceMap | NodeEmitFlags.NoTokenSourceMaps
|
||||
),
|
||||
/*elseStatement*/ undefined,
|
||||
/*location*/ parameter,
|
||||
{ startOnNewLine: true }
|
||||
);
|
||||
|
||||
setNodeEmitFlags(statement, NodeEmitFlags.NoTokenSourceMaps | NodeEmitFlags.NoTrailingSourceMap);
|
||||
statements.push(statement);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1365,9 +1367,8 @@ namespace ts {
|
||||
}
|
||||
|
||||
const expression = visitNode(body, visitor, isExpression);
|
||||
const returnStatement = createReturn(expression);
|
||||
setSourceMapRange(returnStatement, body);
|
||||
setNodeEmitFlags(returnStatement, NodeEmitFlags.NoTokenSourceMaps | NodeEmitFlags.NoTrailingSourceMap);
|
||||
const returnStatement = createReturn(expression, /*location*/ body);
|
||||
setNodeEmitFlags(returnStatement, NodeEmitFlags.NoTokenSourceMaps | NodeEmitFlags.NoTrailingSourceMap | NodeEmitFlags.NoTrailingComments);
|
||||
statements.push(returnStatement);
|
||||
|
||||
// To align with the source map emit for the old emitter, we set a custom
|
||||
@ -2364,7 +2365,7 @@ namespace ts {
|
||||
// Methods on classes are handled in visitClassDeclaration/visitClassExpression.
|
||||
// Methods with computed property names are handled in visitObjectLiteralExpression.
|
||||
Debug.assert(!isComputedPropertyName(node.name));
|
||||
const functionExpression = transformFunctionLikeToExpression(node, /*location*/ node, /*name*/ undefined);
|
||||
const functionExpression = transformFunctionLikeToExpression(node, /*location*/ moveRangePos(node, -1), /*name*/ undefined);
|
||||
setNodeEmitFlags(functionExpression, NodeEmitFlags.NoLeadingComments | getNodeEmitFlags(functionExpression));
|
||||
return createPropertyAssignment(
|
||||
node.name,
|
||||
|
||||
@ -219,22 +219,23 @@ namespace ts {
|
||||
/*location*/ exportEquals
|
||||
);
|
||||
|
||||
setNodeEmitFlags(statement, NodeEmitFlags.NoTokenSourceMaps);
|
||||
setNodeEmitFlags(statement, NodeEmitFlags.NoTokenSourceMaps | NodeEmitFlags.NoComments);
|
||||
statements.push(statement);
|
||||
}
|
||||
else {
|
||||
statements.push(
|
||||
createStatement(
|
||||
createAssignment(
|
||||
createPropertyAccess(
|
||||
createIdentifier("module"),
|
||||
"exports"
|
||||
),
|
||||
exportEquals.expression
|
||||
const statement = createStatement(
|
||||
createAssignment(
|
||||
createPropertyAccess(
|
||||
createIdentifier("module"),
|
||||
"exports"
|
||||
),
|
||||
/*location*/ exportEquals
|
||||
)
|
||||
exportEquals.expression
|
||||
),
|
||||
/*location*/ exportEquals
|
||||
);
|
||||
|
||||
setNodeEmitFlags(statement, NodeEmitFlags.NoComments);
|
||||
statements.push(statement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
//// [ES5For-of26.js.map]
|
||||
{"version":3,"file":"ES5For-of26.js","sourceRoot":"","sources":["ES5For-of26.ts"],"names":[],"mappings":"AAAA,GAAG,CAAC,CAAuB,UAAM,EAAN,MAAC,CAAC,EAAE,CAAC,CAAC,EAAN,cAAM,EAAN,IAAM;IAA5B,eAAkB,EAAb,UAAK,EAAL,0BAAK,EAAE,UAAK,EAAL,0BAAK;IAClB,CAAC,CAAC;IACF,CAAC,CAAC;CACL"}
|
||||
{"version":3,"file":"ES5For-of26.js","sourceRoot":"","sources":["ES5For-of26.ts"],"names":[],"mappings":"AAAA,GAAG,CAAC,CAAuB,UAAM,EAAN,MAAC,CAAC,EAAE,CAAC,CAAC,EAAN,cAAM,EAAN,IAAM;IAAxB,IAAA,WAAc,EAAb,UAAK,EAAL,0BAAK,EAAE,UAAK,EAAL,0BAAK;IAClB,CAAC,CAAC;IACF,CAAC,CAAC;CACL"}
|
||||
@ -58,35 +58,38 @@ sourceFile:ES5For-of26.ts
|
||||
---
|
||||
>>> var _b = _a[_i], _c = _b[0], a = _c === void 0 ? 0 : _c, _d = _b[1], b = _d === void 0 ? 1 : _d;
|
||||
1->^^^^
|
||||
2 > ^^^^^^^^^^^^^^^
|
||||
3 > ^^
|
||||
4 > ^^^^^^^^^^
|
||||
5 > ^^
|
||||
6 > ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
7 > ^^
|
||||
8 > ^^^^^^^^^^
|
||||
9 > ^^
|
||||
10> ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
2 > ^^^^
|
||||
3 > ^^^^^^^^^^^
|
||||
4 > ^^
|
||||
5 > ^^^^^^^^^^
|
||||
6 > ^^
|
||||
7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
8 > ^^
|
||||
9 > ^^^^^^^^^^
|
||||
10> ^^
|
||||
11> ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
1->
|
||||
2 > var [a = 0, b = 1]
|
||||
3 >
|
||||
4 > a = 0
|
||||
5 >
|
||||
6 > a = 0
|
||||
7 > ,
|
||||
8 > b = 1
|
||||
9 >
|
||||
10> b = 1
|
||||
1->Emitted(2, 5) Source(1, 6) + SourceIndex(0)
|
||||
2 >Emitted(2, 20) Source(1, 24) + SourceIndex(0)
|
||||
3 >Emitted(2, 22) Source(1, 11) + SourceIndex(0)
|
||||
4 >Emitted(2, 32) Source(1, 16) + SourceIndex(0)
|
||||
5 >Emitted(2, 34) Source(1, 11) + SourceIndex(0)
|
||||
6 >Emitted(2, 60) Source(1, 16) + SourceIndex(0)
|
||||
7 >Emitted(2, 62) Source(1, 18) + SourceIndex(0)
|
||||
8 >Emitted(2, 72) Source(1, 23) + SourceIndex(0)
|
||||
9 >Emitted(2, 74) Source(1, 18) + SourceIndex(0)
|
||||
10>Emitted(2, 100) Source(1, 23) + SourceIndex(0)
|
||||
2 >
|
||||
3 > [a = 0, b = 1]
|
||||
4 >
|
||||
5 > a = 0
|
||||
6 >
|
||||
7 > a = 0
|
||||
8 > ,
|
||||
9 > b = 1
|
||||
10>
|
||||
11> b = 1
|
||||
1->Emitted(2, 5) Source(1, 10) + SourceIndex(0)
|
||||
2 >Emitted(2, 9) Source(1, 10) + SourceIndex(0)
|
||||
3 >Emitted(2, 20) Source(1, 24) + SourceIndex(0)
|
||||
4 >Emitted(2, 22) Source(1, 11) + SourceIndex(0)
|
||||
5 >Emitted(2, 32) Source(1, 16) + SourceIndex(0)
|
||||
6 >Emitted(2, 34) Source(1, 11) + SourceIndex(0)
|
||||
7 >Emitted(2, 60) Source(1, 16) + SourceIndex(0)
|
||||
8 >Emitted(2, 62) Source(1, 18) + SourceIndex(0)
|
||||
9 >Emitted(2, 72) Source(1, 23) + SourceIndex(0)
|
||||
10>Emitted(2, 74) Source(1, 18) + SourceIndex(0)
|
||||
11>Emitted(2, 100) Source(1, 23) + SourceIndex(0)
|
||||
---
|
||||
>>> a;
|
||||
1 >^^^^
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
//// [sourceMapValidationClassWithDefaultConstructorAndCapturedThisStatement.js.map]
|
||||
{"version":3,"file":"sourceMapValidationClassWithDefaultConstructorAndCapturedThisStatement.js","sourceRoot":"","sources":["sourceMapValidationClassWithDefaultConstructorAndCapturedThisStatement.ts"],"names":[],"mappings":"AAAA;IAAA;QAAA,iBAGC;QAFU,MAAC,GAAG,EAAE,CAAC;QACP,YAAO,GAAG,cAAM,OAAA,KAAI,CAAC,CAAC,GAAA,CAAC;IAClC,CAAC;IAAD,cAAC;AAAD,CAAC,AAHD,IAGC"}
|
||||
{"version":3,"file":"sourceMapValidationClassWithDefaultConstructorAndCapturedThisStatement.js","sourceRoot":"","sources":["sourceMapValidationClassWithDefaultConstructorAndCapturedThisStatement.ts"],"names":[],"mappings":"AAAA;IAAA;QAAA,iBAGC;QAFU,MAAC,GAAG,EAAE,CAAC;QACP,YAAO,GAAG,cAAM,OAAA,KAAI,CAAC,CAAC,EAAN,CAAM,CAAC;IAClC,CAAC;IAAD,cAAC;AAAD,CAAC,AAHD,IAGC"}
|
||||
@ -58,8 +58,9 @@ sourceFile:sourceMapValidationClassWithDefaultConstructorAndCapturedThisStatemen
|
||||
6 > ^^^^^
|
||||
7 > ^
|
||||
8 > ^
|
||||
9 > ^^^
|
||||
10> ^
|
||||
9 > ^^
|
||||
10> ^
|
||||
11> ^
|
||||
1->
|
||||
> public
|
||||
2 > returnA
|
||||
@ -70,7 +71,8 @@ sourceFile:sourceMapValidationClassWithDefaultConstructorAndCapturedThisStatemen
|
||||
7 > .
|
||||
8 > a
|
||||
9 >
|
||||
10> ;
|
||||
10> this.a
|
||||
11> ;
|
||||
1->Emitted(5, 9) Source(3, 12) + SourceIndex(0)
|
||||
2 >Emitted(5, 21) Source(3, 19) + SourceIndex(0)
|
||||
3 >Emitted(5, 24) Source(3, 22) + SourceIndex(0)
|
||||
@ -79,8 +81,9 @@ sourceFile:sourceMapValidationClassWithDefaultConstructorAndCapturedThisStatemen
|
||||
6 >Emitted(5, 50) Source(3, 32) + SourceIndex(0)
|
||||
7 >Emitted(5, 51) Source(3, 33) + SourceIndex(0)
|
||||
8 >Emitted(5, 52) Source(3, 34) + SourceIndex(0)
|
||||
9 >Emitted(5, 55) Source(3, 34) + SourceIndex(0)
|
||||
10>Emitted(5, 56) Source(3, 35) + SourceIndex(0)
|
||||
9 >Emitted(5, 54) Source(3, 28) + SourceIndex(0)
|
||||
10>Emitted(5, 55) Source(3, 34) + SourceIndex(0)
|
||||
11>Emitted(5, 56) Source(3, 35) + SourceIndex(0)
|
||||
---
|
||||
>>> }
|
||||
1 >^^^^
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
//// [sourceMapValidationFunctions.js.map]
|
||||
{"version":3,"file":"sourceMapValidationFunctions.js","sourceRoot":"","sources":["sourceMapValidationFunctions.ts"],"names":[],"mappings":"AAAA,IAAI,SAAS,GAAG,CAAC,CAAC;AAClB,eAAe,QAAgB;IAC3B,SAAS,EAAE,CAAC;IACZ,MAAM,CAAC,SAAS,CAAC;AACrB,CAAC;AACD,gBAAgB,QAAgB,EAAE,CAAM,EAAE,CAAU;IAAlB,iBAAM,GAAN,MAAM;IAAc,oBAAuB;SAAvB,WAAuB,CAAvB,sBAAuB,CAAvB,IAAuB;QAAvB,mCAAuB;;IACzE,SAAS,EAAE,CAAC;IACZ,MAAM,CAAC,SAAS,CAAC;AACrB,CAAC;AACD,aAAa,QAAgB,EAAE,CAAM,EAAE,CAAU;IAAlB,iBAAM,GAAN,MAAM;IAAc,oBAAuB;SAAvB,WAAuB,CAAvB,sBAAuB,CAAvB,IAAuB;QAAvB,mCAAuB;;IAEtE,MAAM,CAAC;AACX,CAAC"}
|
||||
{"version":3,"file":"sourceMapValidationFunctions.js","sourceRoot":"","sources":["sourceMapValidationFunctions.ts"],"names":[],"mappings":"AAAA,IAAI,SAAS,GAAG,CAAC,CAAC;AAClB,eAAe,QAAgB;IAC3B,SAAS,EAAE,CAAC;IACZ,MAAM,CAAC,SAAS,CAAC;AACrB,CAAC;AACD,gBAAgB,QAAgB,EAAE,CAAM,EAAE,CAAU;IAAlB,kBAAA,EAAA,MAAM;IAAc,oBAAuB;SAAvB,WAAuB,CAAvB,sBAAuB,CAAvB,IAAuB;QAAvB,mCAAuB;;IACzE,SAAS,EAAE,CAAC;IACZ,MAAM,CAAC,SAAS,CAAC;AACrB,CAAC;AACD,aAAa,QAAgB,EAAE,CAAM,EAAE,CAAU;IAAlB,kBAAA,EAAA,MAAM;IAAc,oBAAuB;SAAvB,WAAuB,CAAvB,sBAAuB,CAAvB,IAAuB;QAAvB,mCAAuB;;IAEtE,MAAM,CAAC;AACX,CAAC"}
|
||||
@ -112,15 +112,15 @@ sourceFile:sourceMapValidationFunctions.ts
|
||||
---
|
||||
>>> if (n === void 0) { n = 10; }
|
||||
1->^^^^
|
||||
2 > ^^^^^^^^^^^^^^^^^
|
||||
3 > ^^^
|
||||
2 > ^^^^^^^^^^^^^^^^^^
|
||||
3 > ^^
|
||||
4 > ^^^^^^
|
||||
1->
|
||||
2 > n = 10
|
||||
3 >
|
||||
2 >
|
||||
3 >
|
||||
4 > n = 10
|
||||
1->Emitted(7, 5) Source(6, 35) + SourceIndex(0)
|
||||
2 >Emitted(7, 22) Source(6, 41) + SourceIndex(0)
|
||||
2 >Emitted(7, 23) Source(6, 35) + SourceIndex(0)
|
||||
3 >Emitted(7, 25) Source(6, 35) + SourceIndex(0)
|
||||
4 >Emitted(7, 31) Source(6, 41) + SourceIndex(0)
|
||||
---
|
||||
@ -233,15 +233,15 @@ sourceFile:sourceMapValidationFunctions.ts
|
||||
---
|
||||
>>> if (n === void 0) { n = 10; }
|
||||
1->^^^^
|
||||
2 > ^^^^^^^^^^^^^^^^^
|
||||
3 > ^^^
|
||||
2 > ^^^^^^^^^^^^^^^^^^
|
||||
3 > ^^
|
||||
4 > ^^^^^^
|
||||
1->
|
||||
2 > n = 10
|
||||
3 >
|
||||
2 >
|
||||
3 >
|
||||
4 > n = 10
|
||||
1->Emitted(16, 5) Source(10, 32) + SourceIndex(0)
|
||||
2 >Emitted(16, 22) Source(10, 38) + SourceIndex(0)
|
||||
2 >Emitted(16, 23) Source(10, 32) + SourceIndex(0)
|
||||
3 >Emitted(16, 25) Source(10, 32) + SourceIndex(0)
|
||||
4 >Emitted(16, 31) Source(10, 38) + SourceIndex(0)
|
||||
---
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user