Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b33eff1

Browse filesBrowse files
committed
PR feedback
1 parent d88186b commit b33eff1
Copy full SHA for b33eff1

3 files changed

+45-36Lines changed: 45 additions & 36 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/compiler/emitter.ts‎

Copy file name to clipboardExpand all lines: src/compiler/emitter.ts
+17-17Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
460460
const { write, writeTextOfNode, writeLine, increaseIndent, decreaseIndent } = writer;
461461

462462
const sourceMap = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? createSourceMapWriter(host, writer) : getNullSourceMapWriter();
463-
const { setSourceFile, emitStart, emitEnd, emitPos, pushScope: scopeEmitStart, popScope: scopeEmitEnd } = sourceMap;
463+
const { setSourceFile, emitStart, emitEnd, emitPos, pushScope, popScope } = sourceMap;
464464

465465
let currentSourceFile: SourceFile;
466466
let currentText: string;
@@ -2692,7 +2692,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
26922692

26932693
emitToken(SyntaxKind.OpenBraceToken, node.pos);
26942694
increaseIndent();
2695-
scopeEmitStart(node.parent);
2695+
pushScope(node.parent);
26962696
if (node.kind === SyntaxKind.ModuleBlock) {
26972697
Debug.assert(node.parent.kind === SyntaxKind.ModuleDeclaration);
26982698
emitCaptureThisForNodeIfNecessary(node.parent);
@@ -2704,7 +2704,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
27042704
decreaseIndent();
27052705
writeLine();
27062706
emitToken(SyntaxKind.CloseBraceToken, node.statements.end);
2707-
scopeEmitEnd();
2707+
popScope();
27082708
}
27092709

27102710
function emitEmbeddedStatement(node: Node) {
@@ -4549,7 +4549,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
45494549

45504550
function emitDownLevelExpressionFunctionBody(node: FunctionLikeDeclaration, body: Expression) {
45514551
write(" {");
4552-
scopeEmitStart(node);
4552+
pushScope(node);
45534553

45544554
increaseIndent();
45554555
const outPos = writer.getTextPos();
@@ -4590,12 +4590,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
45904590
write("}");
45914591
emitEnd(node.body);
45924592

4593-
scopeEmitEnd();
4593+
popScope();
45944594
}
45954595

45964596
function emitBlockFunctionBody(node: FunctionLikeDeclaration, body: Block) {
45974597
write(" {");
4598-
scopeEmitStart(node);
4598+
pushScope(node);
45994599

46004600
const initialTextPos = writer.getTextPos();
46014601

@@ -4630,7 +4630,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
46304630
}
46314631

46324632
emitToken(SyntaxKind.CloseBraceToken, body.statements.end);
4633-
scopeEmitEnd();
4633+
popScope();
46344634
}
46354635

46364636
function findInitialSuperCall(ctor: ConstructorDeclaration): ExpressionStatement {
@@ -4916,7 +4916,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
49164916
let startIndex = 0;
49174917

49184918
write(" {");
4919-
scopeEmitStart(node, "constructor");
4919+
pushScope(node, "constructor");
49204920
increaseIndent();
49214921
if (ctor) {
49224922
// Emit all the directive prologues (like "use strict"). These have to come before
@@ -4966,7 +4966,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
49664966
}
49674967
decreaseIndent();
49684968
emitToken(SyntaxKind.CloseBraceToken, ctor ? (<Block>ctor.body).statements.end : node.members.end);
4969-
scopeEmitEnd();
4969+
popScope();
49704970
emitEnd(<Node>ctor || node);
49714971
if (ctor) {
49724972
emitTrailingComments(ctor);
@@ -5103,14 +5103,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
51035103

51045104
write(" {");
51055105
increaseIndent();
5106-
scopeEmitStart(node);
5106+
pushScope(node);
51075107
writeLine();
51085108
emitConstructor(node, baseTypeNode);
51095109
emitMemberFunctionsForES6AndHigher(node);
51105110
decreaseIndent();
51115111
writeLine();
51125112
emitToken(SyntaxKind.CloseBraceToken, node.members.end);
5113-
scopeEmitEnd();
5113+
popScope();
51145114

51155115
// TODO(rbuckton): Need to go back to `let _a = class C {}` approach, removing the defineProperty call for now.
51165116

@@ -5197,7 +5197,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
51975197
tempParameters = undefined;
51985198
computedPropertyNamesToGeneratedNames = undefined;
51995199
increaseIndent();
5200-
scopeEmitStart(node);
5200+
pushScope(node);
52015201
if (baseTypeNode) {
52025202
writeLine();
52035203
emitStart(baseTypeNode);
@@ -5230,7 +5230,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
52305230
decreaseIndent();
52315231
writeLine();
52325232
emitToken(SyntaxKind.CloseBraceToken, node.members.end);
5233-
scopeEmitEnd();
5233+
popScope();
52345234
emitStart(node);
52355235
write(")(");
52365236
if (baseTypeNode) {
@@ -5792,12 +5792,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
57925792
emitEnd(node.name);
57935793
write(") {");
57945794
increaseIndent();
5795-
scopeEmitStart(node);
5795+
pushScope(node);
57965796
emitLines(node.members);
57975797
decreaseIndent();
57985798
writeLine();
57995799
emitToken(SyntaxKind.CloseBraceToken, node.members.end);
5800-
scopeEmitEnd();
5800+
popScope();
58015801
write(")(");
58025802
emitModuleMemberName(node);
58035803
write(" || (");
@@ -5921,15 +5921,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
59215921
else {
59225922
write("{");
59235923
increaseIndent();
5924-
scopeEmitStart(node);
5924+
pushScope(node);
59255925
emitCaptureThisForNodeIfNecessary(node);
59265926
writeLine();
59275927
emit(node.body);
59285928
decreaseIndent();
59295929
writeLine();
59305930
const moduleBlock = <ModuleBlock>getInnerMostModuleDeclarationFromDottedModule(node).body;
59315931
emitToken(SyntaxKind.CloseBraceToken, moduleBlock.statements.end);
5932-
scopeEmitEnd();
5932+
popScope();
59335933
}
59345934
write(")(");
59355935
// write moduleDecl = containingModule.m only if it is not exported es6 module member
Collapse file

‎src/compiler/sourcemap.ts‎

Copy file name to clipboardExpand all lines: src/compiler/sourcemap.ts
+11-11Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ namespace ts {
2222
export function getNullSourceMapWriter(): SourceMapWriter {
2323
if (nullSourceMapWriter === undefined) {
2424
nullSourceMapWriter = {
25-
getSourceMapData: nop,
26-
setSourceFile: nop,
27-
emitStart: nop,
28-
emitEnd: nop,
29-
emitPos: nop,
30-
pushScope: nop,
31-
popScope: nop,
32-
getText: nop,
33-
getSourceMappingURL: nop,
34-
initialize: nop,
35-
reset: nop,
25+
getSourceMapData(): SourceMapData { return undefined; },
26+
setSourceFile(sourceFile: SourceFile): void { },
27+
emitStart(range: TextRange): void { },
28+
emitEnd(range: TextRange): void { },
29+
emitPos(pos: number): void { },
30+
pushScope(scopeDeclaration: Node, scopeName?: string): void { },
31+
popScope(): void { },
32+
getText(): string { return undefined; },
33+
getSourceMappingURL(): string { return undefined; },
34+
initialize(filePath: string, sourceMapFilePath: string, sourceFiles: SourceFile[], isBundledEmit: boolean): void { },
35+
reset(): void { },
3636
};
3737
}
3838

Collapse file

‎src/compiler/utilities.ts‎

Copy file name to clipboardExpand all lines: src/compiler/utilities.ts
+17-8Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2418,14 +2418,10 @@ namespace ts {
24182418
* Serialize an object graph into a JSON string. This is intended only for use on an acyclic graph
24192419
* as the fallback implementation does not check for circular references by default.
24202420
*/
2421-
export const stringify: (value: any) => string = JSON && JSON.stringify ? JSON.stringify : function stringify(value: any): string {
2422-
if (Debug.shouldAssert(AssertionLevel.Aggressive)) {
2423-
Debug.assert(!hasCycles(value, []), "Detected circular reference before serializing object graph.");
2424-
}
2425-
2426-
return value === undefined ? undefined : stringifyValue(value);
2427-
};
2428-
2421+
export const stringify: (value: any) => string = JSON && JSON.stringify
2422+
? JSON.stringify
2423+
: stringifyFallback;
2424+
24292425
function hasCycles(value: any, stack: any[]) {
24302426
/* tslint:disable:no-null */
24312427
if (typeof value !== "object" || value === null) {
@@ -2449,6 +2445,19 @@ namespace ts {
24492445
return false;
24502446
}
24512447

2448+
/**
2449+
* Serialize an object graph into a JSON string. This is intended only for use on an acyclic graph
2450+
* as the fallback implementation does not check for circular references by default.
2451+
*/
2452+
function stringifyFallback(value: any): string {
2453+
if (Debug.shouldAssert(AssertionLevel.Aggressive)) {
2454+
Debug.assert(!hasCycles(value, []), "Detected circular reference before serializing object graph.");
2455+
}
2456+
2457+
// JSON.stringify returns `undefined` here, instead of the string "undefined".
2458+
return value === undefined ? undefined : stringifyValue(value);
2459+
}
2460+
24522461
function stringifyValue(value: any): string {
24532462
return typeof value === "string" ? `"${escapeString(value)}"`
24542463
: typeof value === "number" ? isFinite(value) ? String(value) : "null"

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.