diff --git a/src/cancellationToken/cancellationToken.ts b/src/cancellationToken/cancellationToken.ts
index aaa19750b8710..57c82e7522fa6 100644
--- a/src/cancellationToken/cancellationToken.ts
+++ b/src/cancellationToken/cancellationToken.ts
@@ -1,6 +1,6 @@
///
-import fs = require("fs");
+import * as fs from "fs";
interface ServerCancellationToken {
isCancellationRequested(): boolean;
diff --git a/src/harness/findUpDir.ts b/src/harness/findUpDir.ts
index 6fd1b51b0719d..2a7cda59d5fec 100644
--- a/src/harness/findUpDir.ts
+++ b/src/harness/findUpDir.ts
@@ -1,5 +1,5 @@
-const { join, resolve, dirname } = require("path") as typeof import("path");
-const { existsSync } = require("fs") as typeof import("fs");
+import { existsSync } from "fs";
+import { dirname, join, resolve } from "path";
// search directories upward to avoid hard-wired paths based on the
// build tree (same as scripts/build/findUpDir.js)
diff --git a/src/harness/harnessGlobals.ts b/src/harness/harnessGlobals.ts
index 97c363e95f413..9de9537181f49 100644
--- a/src/harness/harnessGlobals.ts
+++ b/src/harness/harnessGlobals.ts
@@ -1,19 +1,17 @@
-import * as ts from "./_namespaces/ts";
+import * as chai from "chai";
-// Block scoped definitions work poorly for global variables, temporarily enable var
-/* eslint-disable no-var */
+import * as ts from "./_namespaces/ts";
// this will work in the browser via browserify
declare global {
// Module transform: converted from ambient declaration
- var assert: typeof _chai.assert;
+ var assert: typeof chai.assert; // eslint-disable-line no-var
}
declare global {
// Module transform: converted from ambient declaration
- var expect: typeof _chai.expect;
+ var expect: typeof chai.expect; // eslint-disable-line no-var
}
-var _chai: typeof import("chai") = require("chai");
-globalThis.assert = _chai.assert;
+globalThis.assert = chai.assert;
{
// chai's builtin `assert.isFalse` is featureful but slow - we don't use those features,
// so we'll just overwrite it as an alterative to migrating a bunch of code off of chai
@@ -39,7 +37,7 @@ globalThis.assert = _chai.assert;
}
};
}
-globalThis.expect = _chai.expect;
-/* eslint-enable no-var */
+globalThis.expect = chai.expect;
+
// empty ts namespace so this file is included in the `ts.ts` namespace file generated by the module swapover
-// This way, everything that ends up importing `ts` downstream also imports this file and picks up its augmentation
\ No newline at end of file
+// This way, everything that ends up importing `ts` downstream also imports this file and picks up its augmentation
diff --git a/src/testRunner/externalCompileRunner.ts b/src/testRunner/externalCompileRunner.ts
index 93c9cce362ec0..766b939ab4b0d 100644
--- a/src/testRunner/externalCompileRunner.ts
+++ b/src/testRunner/externalCompileRunner.ts
@@ -1,10 +1,10 @@
+import * as del from "del";
+import * as fs from "fs";
+import * as path from "path";
+
import * as ts from "./_namespaces/ts";
import { Baseline, IO, isWorker, RunnerBase, TestRunnerKind } from "./_namespaces/Harness";
-const fs: typeof import("fs") = require("fs");
-const path: typeof import("path") = require("path");
-const del: typeof import("del") = require("del");
-
interface ExecResult {
stdout: Buffer;
stderr: Buffer;
diff --git a/src/testRunner/unittests/services/languageService.ts b/src/testRunner/unittests/services/languageService.ts
index 53631ce5bfb0b..27b75cadfe429 100644
--- a/src/testRunner/unittests/services/languageService.ts
+++ b/src/testRunner/unittests/services/languageService.ts
@@ -1,7 +1,7 @@
+import { expect } from "chai";
+
import * as ts from "../../_namespaces/ts";
-const _chai: typeof import("chai") = require("chai");
-const expect: typeof _chai.expect = _chai.expect;
describe("unittests:: services:: languageService", () => {
const files: {[index: string]: string} = {
"foo.ts": `import Vue from "./vue";
diff --git a/src/testRunner/unittests/tsserver/session.ts b/src/testRunner/unittests/tsserver/session.ts
index 4e27b3983df03..5148809511e39 100644
--- a/src/testRunner/unittests/tsserver/session.ts
+++ b/src/testRunner/unittests/tsserver/session.ts
@@ -1,9 +1,9 @@
+import { expect } from "chai";
+
import * as ts from "../../_namespaces/ts";
import * as Harness from "../../_namespaces/Harness";
import * as Utils from "../../_namespaces/Utils";
-const _chai: typeof import("chai") = require("chai");
-const expect: typeof _chai.expect = _chai.expect;
let lastWrittenToHost: string;
const noopFileWatcher: ts.FileWatcher = { close: ts.noop };
const mockHost: ts.server.ServerHost = {
diff --git a/src/typingsInstaller/nodeTypingsInstaller.ts b/src/typingsInstaller/nodeTypingsInstaller.ts
index aae6b44b45ae4..f043e44a18e43 100644
--- a/src/typingsInstaller/nodeTypingsInstaller.ts
+++ b/src/typingsInstaller/nodeTypingsInstaller.ts
@@ -1,3 +1,6 @@
+import * as fs from "fs";
+import * as path from "path";
+
import {
installNpmPackages, Log, RequestCompletedAction, TypingsInstaller,
} from "./_namespaces/ts.server.typingsInstaller";
@@ -11,16 +14,6 @@ import {
MapLike, normalizeSlashes, stringContains, sys, toPath, version,
} from "./_namespaces/ts";
-const fs: {
- appendFileSync(file: string, content: string): void
-} = require("fs");
-
-const path: {
- join(...parts: string[]): string;
- dirname(path: string): string;
- basename(path: string, extension?: string): string;
-} = require("path");
-
class FileLog implements Log {
constructor(private logFile: string | undefined) {
}
diff --git a/src/watchGuard/watchGuard.ts b/src/watchGuard/watchGuard.ts
index 3835540d9c990..233781365c5c4 100644
--- a/src/watchGuard/watchGuard.ts
+++ b/src/watchGuard/watchGuard.ts
@@ -1,10 +1,9 @@
-///
+import * as fs from "fs";
if (process.argv.length < 3) {
process.exit(1);
}
const directoryName = process.argv[2];
-const fs: { watch(directoryName: string, options: any, callback: () => {}): any } = require("fs");
// main reason why we need separate process to check if it is safe to watch some path
// is to guard against crashes that cannot be intercepted with protected blocks and
// code in tsserver already can handle normal cases, like non-existing folders.