Skip to content

Commit edd16a7

Browse files
committed
Make module
1 parent d3ca1dd commit edd16a7

File tree

8 files changed

+136
-60
lines changed

8 files changed

+136
-60
lines changed

src/compiler/_namespaces/ts.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
export * from "../corePublic";
44
export * from "../core";
5-
export * from "../debug";
5+
import * as Debug from "../debug";
6+
export { Debug };
67
export * from "../semver";
78
export * from "../performanceCore";
89
export * from "../perfLogger";

src/compiler/debug.ts

Lines changed: 103 additions & 27 deletions
Large diffs are not rendered by default.

src/compiler/sys.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2032,5 +2032,5 @@ if (sys && sys.getEnvironmentVariable) {
20322032
: AssertionLevel.None);
20332033
}
20342034
if (sys && sys.debugMode) {
2035-
Debug.isDebugging = true;
2035+
Debug.setIsDebugging(true);
20362036
}

src/testRunner/runner.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,11 +264,11 @@ function handleTestConfig() {
264264
}
265265

266266
function beginTests() {
267-
ts.Debug.loggingHost = {
267+
ts.Debug.setLoggingHost({
268268
log(_level, s) {
269269
console.log(s || "");
270270
}
271-
};
271+
});
272272

273273
if (ts.Debug.isDebugging) {
274274
ts.Debug.enableDebugInfo();

src/testRunner/unittests/debugDeprecation.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import * as ts from "../_namespaces/ts";
22
import { deprecate } from "../../deprecatedCompat/deprecate";
33

44
describe("unittests:: debugDeprecation", () => {
5-
let loggingHost: ts.LoggingHost | undefined;
5+
let loggingHost: ts.Debug.LoggingHost | undefined;
66
beforeEach(() => {
77
loggingHost = ts.Debug.loggingHost;
88
});
99
afterEach(() => {
10-
ts.Debug.loggingHost = loggingHost;
10+
ts.Debug.setLoggingHost(loggingHost);
1111
loggingHost = undefined;
1212
});
1313
describe("deprecateFunction", () => {
@@ -17,11 +17,11 @@ describe("unittests:: debugDeprecation", () => {
1717
typeScriptVersion: "3.8"
1818
});
1919
let logWritten = false;
20-
ts.Debug.loggingHost = {
20+
ts.Debug.setLoggingHost({
2121
log() {
2222
logWritten = true;
2323
}
24-
};
24+
});
2525
deprecation();
2626
assert.isFalse(logWritten);
2727
});
@@ -31,11 +31,11 @@ describe("unittests:: debugDeprecation", () => {
3131
typeScriptVersion: "3.9"
3232
});
3333
let logWritten = false;
34-
ts.Debug.loggingHost = {
34+
ts.Debug.setLoggingHost({
3535
log() {
3636
logWritten = true;
3737
}
38-
};
38+
});
3939
deprecation();
4040
assert.isTrue(logWritten);
4141
});
@@ -44,11 +44,11 @@ describe("unittests:: debugDeprecation", () => {
4444
typeScriptVersion: "3.9"
4545
});
4646
let logWritten = false;
47-
ts.Debug.loggingHost = {
47+
ts.Debug.setLoggingHost({
4848
log() {
4949
logWritten = true;
5050
}
51-
};
51+
});
5252
deprecation();
5353
assert.isTrue(logWritten);
5454
});
@@ -57,11 +57,11 @@ describe("unittests:: debugDeprecation", () => {
5757
typeScriptVersion: "3.9"
5858
});
5959
let logWrites = 0;
60-
ts.Debug.loggingHost = {
60+
ts.Debug.setLoggingHost({
6161
log() {
6262
logWrites++;
6363
}
64-
};
64+
});
6565
deprecation();
6666
deprecation();
6767
assert.equal(logWrites, 1);
@@ -73,11 +73,11 @@ describe("unittests:: debugDeprecation", () => {
7373
typeScriptVersion: "3.9"
7474
});
7575
let logWritten = false;
76-
ts.Debug.loggingHost = {
76+
ts.Debug.setLoggingHost({
7777
log() {
7878
logWritten = true;
7979
}
80-
};
80+
});
8181
expect(deprecation).throws();
8282
assert.isFalse(logWritten);
8383
});
@@ -86,11 +86,11 @@ describe("unittests:: debugDeprecation", () => {
8686
error: true,
8787
});
8888
let logWritten = false;
89-
ts.Debug.loggingHost = {
89+
ts.Debug.setLoggingHost({
9090
log() {
9191
logWritten = true;
9292
}
93-
};
93+
});
9494
expect(deprecation).throws();
9595
assert.isFalse(logWritten);
9696
});

src/tsc/tsc.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import * as ts from "./_namespaces/ts";
33
// This file actually uses arguments passed on commandline and executes it
44

55
// enable deprecation logging
6-
ts.Debug.loggingHost = {
6+
ts.Debug.setLoggingHost({
77
log(_level, s) {
88
ts.sys.write(`${s || ""}${ts.sys.newLine}`);
99
}
10-
};
10+
});
1111

1212
if (ts.Debug.isDebugging) {
1313
ts.Debug.enableDebugInfo();

src/tsserver/nodeServer.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -306,18 +306,18 @@ export function initializeNodeSystem(): StartInput {
306306
const logger = createLogger();
307307

308308
// enable deprecation logging
309-
Debug.loggingHost = {
309+
Debug.setLoggingHost({
310310
log(level, s) {
311311
switch (level) {
312-
case ts.LogLevel.Error:
313-
case ts.LogLevel.Warning:
312+
case ts.Debug.LogLevel.Error:
313+
case ts.Debug.LogLevel.Warning:
314314
return logger.msg(s, Msg.Err);
315-
case ts.LogLevel.Info:
316-
case ts.LogLevel.Verbose:
315+
case ts.Debug.LogLevel.Info:
316+
case ts.Debug.LogLevel.Verbose:
317317
return logger.msg(s, Msg.Info);
318318
}
319319
}
320-
};
320+
});
321321

322322
const pending = createQueue<Buffer>();
323323
let canWrite = true;

src/typescript/typescript.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
import {
22
Debug,
3-
LogLevel,
43
} from "./_namespaces/ts";
54
import * as ts from "./_namespaces/ts";
65

76
// enable deprecation logging
87
declare const console: any;
98
if (typeof console !== "undefined") {
10-
Debug.loggingHost = {
9+
Debug.setLoggingHost({
1110
log(level, s) {
1211
switch (level) {
13-
case LogLevel.Error: return console.error(s);
14-
case LogLevel.Warning: return console.warn(s);
15-
case LogLevel.Info: return console.log(s);
16-
case LogLevel.Verbose: return console.log(s);
12+
case ts.Debug.LogLevel.Error: return console.error(s);
13+
case ts.Debug.LogLevel.Warning: return console.warn(s);
14+
case ts.Debug.LogLevel.Info: return console.log(s);
15+
case ts.Debug.LogLevel.Verbose: return console.log(s);
1716
}
1817
}
19-
};
18+
});
2019
}
2120

2221
export = ts;

0 commit comments

Comments
 (0)