diff --git a/lib/tsc.js b/lib/tsc.js index 8abe56b22a74c..50c0b1f54f56a 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -67,7 +67,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { var ts; (function (ts) { ts.versionMajorMinor = "4.1"; - ts.version = "4.1.5"; + ts.version = "4.1.6"; var NativeCollections; (function (NativeCollections) { function tryGetNativeMap() { @@ -4448,8 +4448,8 @@ var ts; }, getFileSize: function (path) { try { - var stat = _fs.statSync(path); - if (stat.isFile()) { + var stat = statSync(path); + if (stat === null || stat === void 0 ? void 0 : stat.isFile()) { return stat.size; } } @@ -4494,6 +4494,9 @@ var ts; } }; return nodeSystem; + function statSync(path) { + return _fs.statSync(path, { throwIfNoEntry: false }); + } function enableCPUProfiler(path, cb) { if (activeSession) { cb(); @@ -4539,19 +4542,20 @@ var ts; if (activeSession && activeSession !== "stopping") { var s_1 = activeSession; activeSession.post("Profiler.stop", function (err, _a) { + var _b; var profile = _a.profile; if (!err) { try { - if (_fs.statSync(profilePath).isDirectory()) { + if ((_b = statSync(profilePath)) === null || _b === void 0 ? void 0 : _b.isDirectory()) { profilePath = _path.join(profilePath, (new Date()).toISOString().replace(/:/g, "-") + "+P" + process.pid + ".cpuprofile"); } } - catch (_b) { + catch (_c) { } try { _fs.mkdirSync(_path.dirname(profilePath), { recursive: true }); } - catch (_c) { + catch (_d) { } _fs.writeFileSync(profilePath, JSON.stringify(cleanupPaths(profile))); } @@ -4740,7 +4744,10 @@ var ts; if (typeof dirent === "string" || dirent.isSymbolicLink()) { var name = ts.combinePaths(path, entry); try { - stat = _fs.statSync(name); + stat = statSync(name); + if (!stat) { + continue; + } } catch (e) { continue; @@ -4771,7 +4778,10 @@ var ts; var originalStackTraceLimit = Error.stackTraceLimit; Error.stackTraceLimit = 0; try { - var stat = _fs.statSync(path); + var stat = statSync(path); + if (!stat) { + return false; + } switch (entryKind) { case 0: return stat.isFile(); case 1: return stat.isDirectory(); @@ -4803,8 +4813,9 @@ var ts; } } function getModifiedTime(path) { + var _a; try { - return _fs.statSync(path).mtime; + return (_a = statSync(path)) === null || _a === void 0 ? void 0 : _a.mtime; } catch (e) { return undefined; diff --git a/lib/tsserver.js b/lib/tsserver.js index e8afc692648bb..a4f0e241cf987 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -94,7 +94,7 @@ var ts; // If changing the text in this section, be sure to test `configurePrerelease` too. ts.versionMajorMinor = "4.1"; /** The version of the TypeScript compiler release */ - ts.version = "4.1.5"; + ts.version = "4.1.6"; /* @internal */ var Comparison; (function (Comparison) { @@ -7022,8 +7022,8 @@ var ts; }, getFileSize: function (path) { try { - var stat = _fs.statSync(path); - if (stat.isFile()) { + var stat = statSync(path); + if (stat === null || stat === void 0 ? void 0 : stat.isFile()) { return stat.size; } } @@ -7069,6 +7069,15 @@ var ts; } }; return nodeSystem; + /** + * `throwIfNoEntry` was added so recently that it's not in the node types. + * This helper encapsulates the mitigating usage of `any`. + * See https://github.com/nodejs/node/pull/33716 + */ + function statSync(path) { + // throwIfNoEntry will be ignored by older versions of node + return _fs.statSync(path, { throwIfNoEntry: false }); + } /** * Uses the builtin inspector APIs to capture a CPU profile * See https://nodejs.org/api/inspector.html#inspector_example_usage for details @@ -7123,20 +7132,21 @@ var ts; if (activeSession && activeSession !== "stopping") { var s_1 = activeSession; activeSession.post("Profiler.stop", function (err, _a) { + var _b; var profile = _a.profile; if (!err) { try { - if (_fs.statSync(profilePath).isDirectory()) { + if ((_b = statSync(profilePath)) === null || _b === void 0 ? void 0 : _b.isDirectory()) { profilePath = _path.join(profilePath, (new Date()).toISOString().replace(/:/g, "-") + "+P" + process.pid + ".cpuprofile"); } } - catch (_b) { + catch (_c) { // do nothing and ignore fallible fs operation } try { _fs.mkdirSync(_path.dirname(profilePath), { recursive: true }); } - catch (_c) { + catch (_d) { // do nothing and ignore fallible fs operation } _fs.writeFileSync(profilePath, JSON.stringify(cleanupPaths(profile))); @@ -7375,7 +7385,10 @@ var ts; if (typeof dirent === "string" || dirent.isSymbolicLink()) { var name = ts.combinePaths(path, entry); try { - stat = _fs.statSync(name); + stat = statSync(name); + if (!stat) { + continue; + } } catch (e) { continue; @@ -7408,7 +7421,10 @@ var ts; var originalStackTraceLimit = Error.stackTraceLimit; Error.stackTraceLimit = 0; try { - var stat = _fs.statSync(path); + var stat = statSync(path); + if (!stat) { + return false; + } switch (entryKind) { case 0 /* File */: return stat.isFile(); case 1 /* Directory */: return stat.isDirectory(); @@ -7440,8 +7456,9 @@ var ts; } } function getModifiedTime(path) { + var _a; try { - return _fs.statSync(path).mtime; + return (_a = statSync(path)) === null || _a === void 0 ? void 0 : _a.mtime; } catch (e) { return undefined; @@ -160609,6 +160626,7 @@ var ts; var nextFileToCheck = 0; return { getModifiedTime: getModifiedTime, poll: poll, startWatchTimer: startWatchTimer, addFile: addFile, removeFile: removeFile }; function getModifiedTime(fileName) { + // Caller guarantees that `fileName` exists, so there'd be no benefit from throwIfNoEntry return fs.statSync(fileName).mtime; } function poll(checkedIndex) { diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index f1e50768d9709..f225c4ae14e25 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -288,7 +288,7 @@ var ts; // If changing the text in this section, be sure to test `configurePrerelease` too. ts.versionMajorMinor = "4.1"; /** The version of the TypeScript compiler release */ - ts.version = "4.1.5"; + ts.version = "4.1.6"; /* @internal */ var Comparison; (function (Comparison) { @@ -7216,8 +7216,8 @@ var ts; }, getFileSize: function (path) { try { - var stat = _fs.statSync(path); - if (stat.isFile()) { + var stat = statSync(path); + if (stat === null || stat === void 0 ? void 0 : stat.isFile()) { return stat.size; } } @@ -7263,6 +7263,15 @@ var ts; } }; return nodeSystem; + /** + * `throwIfNoEntry` was added so recently that it's not in the node types. + * This helper encapsulates the mitigating usage of `any`. + * See https://github.com/nodejs/node/pull/33716 + */ + function statSync(path) { + // throwIfNoEntry will be ignored by older versions of node + return _fs.statSync(path, { throwIfNoEntry: false }); + } /** * Uses the builtin inspector APIs to capture a CPU profile * See https://nodejs.org/api/inspector.html#inspector_example_usage for details @@ -7317,20 +7326,21 @@ var ts; if (activeSession && activeSession !== "stopping") { var s_1 = activeSession; activeSession.post("Profiler.stop", function (err, _a) { + var _b; var profile = _a.profile; if (!err) { try { - if (_fs.statSync(profilePath).isDirectory()) { + if ((_b = statSync(profilePath)) === null || _b === void 0 ? void 0 : _b.isDirectory()) { profilePath = _path.join(profilePath, (new Date()).toISOString().replace(/:/g, "-") + "+P" + process.pid + ".cpuprofile"); } } - catch (_b) { + catch (_c) { // do nothing and ignore fallible fs operation } try { _fs.mkdirSync(_path.dirname(profilePath), { recursive: true }); } - catch (_c) { + catch (_d) { // do nothing and ignore fallible fs operation } _fs.writeFileSync(profilePath, JSON.stringify(cleanupPaths(profile))); @@ -7569,7 +7579,10 @@ var ts; if (typeof dirent === "string" || dirent.isSymbolicLink()) { var name = ts.combinePaths(path, entry); try { - stat = _fs.statSync(name); + stat = statSync(name); + if (!stat) { + continue; + } } catch (e) { continue; @@ -7602,7 +7615,10 @@ var ts; var originalStackTraceLimit = Error.stackTraceLimit; Error.stackTraceLimit = 0; try { - var stat = _fs.statSync(path); + var stat = statSync(path); + if (!stat) { + return false; + } switch (entryKind) { case 0 /* File */: return stat.isFile(); case 1 /* Directory */: return stat.isDirectory(); @@ -7634,8 +7650,9 @@ var ts; } } function getModifiedTime(path) { + var _a; try { - return _fs.statSync(path).mtime; + return (_a = statSync(path)) === null || _a === void 0 ? void 0 : _a.mtime; } catch (e) { return undefined; diff --git a/lib/typescript.js b/lib/typescript.js index d644aea385de1..bc97fa33f3a19 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -288,7 +288,7 @@ var ts; // If changing the text in this section, be sure to test `configurePrerelease` too. ts.versionMajorMinor = "4.1"; /** The version of the TypeScript compiler release */ - ts.version = "4.1.5"; + ts.version = "4.1.6"; /* @internal */ var Comparison; (function (Comparison) { @@ -7216,8 +7216,8 @@ var ts; }, getFileSize: function (path) { try { - var stat = _fs.statSync(path); - if (stat.isFile()) { + var stat = statSync(path); + if (stat === null || stat === void 0 ? void 0 : stat.isFile()) { return stat.size; } } @@ -7263,6 +7263,15 @@ var ts; } }; return nodeSystem; + /** + * `throwIfNoEntry` was added so recently that it's not in the node types. + * This helper encapsulates the mitigating usage of `any`. + * See https://github.com/nodejs/node/pull/33716 + */ + function statSync(path) { + // throwIfNoEntry will be ignored by older versions of node + return _fs.statSync(path, { throwIfNoEntry: false }); + } /** * Uses the builtin inspector APIs to capture a CPU profile * See https://nodejs.org/api/inspector.html#inspector_example_usage for details @@ -7317,20 +7326,21 @@ var ts; if (activeSession && activeSession !== "stopping") { var s_1 = activeSession; activeSession.post("Profiler.stop", function (err, _a) { + var _b; var profile = _a.profile; if (!err) { try { - if (_fs.statSync(profilePath).isDirectory()) { + if ((_b = statSync(profilePath)) === null || _b === void 0 ? void 0 : _b.isDirectory()) { profilePath = _path.join(profilePath, (new Date()).toISOString().replace(/:/g, "-") + "+P" + process.pid + ".cpuprofile"); } } - catch (_b) { + catch (_c) { // do nothing and ignore fallible fs operation } try { _fs.mkdirSync(_path.dirname(profilePath), { recursive: true }); } - catch (_c) { + catch (_d) { // do nothing and ignore fallible fs operation } _fs.writeFileSync(profilePath, JSON.stringify(cleanupPaths(profile))); @@ -7569,7 +7579,10 @@ var ts; if (typeof dirent === "string" || dirent.isSymbolicLink()) { var name = ts.combinePaths(path, entry); try { - stat = _fs.statSync(name); + stat = statSync(name); + if (!stat) { + continue; + } } catch (e) { continue; @@ -7602,7 +7615,10 @@ var ts; var originalStackTraceLimit = Error.stackTraceLimit; Error.stackTraceLimit = 0; try { - var stat = _fs.statSync(path); + var stat = statSync(path); + if (!stat) { + return false; + } switch (entryKind) { case 0 /* File */: return stat.isFile(); case 1 /* Directory */: return stat.isDirectory(); @@ -7634,8 +7650,9 @@ var ts; } } function getModifiedTime(path) { + var _a; try { - return _fs.statSync(path).mtime; + return (_a = statSync(path)) === null || _a === void 0 ? void 0 : _a.mtime; } catch (e) { return undefined; diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index 5de94cc871fd9..c1e36c20af971 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -288,7 +288,7 @@ var ts; // If changing the text in this section, be sure to test `configurePrerelease` too. ts.versionMajorMinor = "4.1"; /** The version of the TypeScript compiler release */ - ts.version = "4.1.5"; + ts.version = "4.1.6"; /* @internal */ var Comparison; (function (Comparison) { @@ -7216,8 +7216,8 @@ var ts; }, getFileSize: function (path) { try { - var stat = _fs.statSync(path); - if (stat.isFile()) { + var stat = statSync(path); + if (stat === null || stat === void 0 ? void 0 : stat.isFile()) { return stat.size; } } @@ -7263,6 +7263,15 @@ var ts; } }; return nodeSystem; + /** + * `throwIfNoEntry` was added so recently that it's not in the node types. + * This helper encapsulates the mitigating usage of `any`. + * See https://github.com/nodejs/node/pull/33716 + */ + function statSync(path) { + // throwIfNoEntry will be ignored by older versions of node + return _fs.statSync(path, { throwIfNoEntry: false }); + } /** * Uses the builtin inspector APIs to capture a CPU profile * See https://nodejs.org/api/inspector.html#inspector_example_usage for details @@ -7317,20 +7326,21 @@ var ts; if (activeSession && activeSession !== "stopping") { var s_1 = activeSession; activeSession.post("Profiler.stop", function (err, _a) { + var _b; var profile = _a.profile; if (!err) { try { - if (_fs.statSync(profilePath).isDirectory()) { + if ((_b = statSync(profilePath)) === null || _b === void 0 ? void 0 : _b.isDirectory()) { profilePath = _path.join(profilePath, (new Date()).toISOString().replace(/:/g, "-") + "+P" + process.pid + ".cpuprofile"); } } - catch (_b) { + catch (_c) { // do nothing and ignore fallible fs operation } try { _fs.mkdirSync(_path.dirname(profilePath), { recursive: true }); } - catch (_c) { + catch (_d) { // do nothing and ignore fallible fs operation } _fs.writeFileSync(profilePath, JSON.stringify(cleanupPaths(profile))); @@ -7569,7 +7579,10 @@ var ts; if (typeof dirent === "string" || dirent.isSymbolicLink()) { var name = ts.combinePaths(path, entry); try { - stat = _fs.statSync(name); + stat = statSync(name); + if (!stat) { + continue; + } } catch (e) { continue; @@ -7602,7 +7615,10 @@ var ts; var originalStackTraceLimit = Error.stackTraceLimit; Error.stackTraceLimit = 0; try { - var stat = _fs.statSync(path); + var stat = statSync(path); + if (!stat) { + return false; + } switch (entryKind) { case 0 /* File */: return stat.isFile(); case 1 /* Directory */: return stat.isDirectory(); @@ -7634,8 +7650,9 @@ var ts; } } function getModifiedTime(path) { + var _a; try { - return _fs.statSync(path).mtime; + return (_a = statSync(path)) === null || _a === void 0 ? void 0 : _a.mtime; } catch (e) { return undefined; diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index efc7337b2c7fb..5d37a4a4d476b 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -83,7 +83,7 @@ var ts; // If changing the text in this section, be sure to test `configurePrerelease` too. ts.versionMajorMinor = "4.1"; /** The version of the TypeScript compiler release */ - ts.version = "4.1.5"; + ts.version = "4.1.6"; /* @internal */ var Comparison; (function (Comparison) { @@ -7011,8 +7011,8 @@ var ts; }, getFileSize: function (path) { try { - var stat = _fs.statSync(path); - if (stat.isFile()) { + var stat = statSync(path); + if (stat === null || stat === void 0 ? void 0 : stat.isFile()) { return stat.size; } } @@ -7058,6 +7058,15 @@ var ts; } }; return nodeSystem; + /** + * `throwIfNoEntry` was added so recently that it's not in the node types. + * This helper encapsulates the mitigating usage of `any`. + * See https://github.com/nodejs/node/pull/33716 + */ + function statSync(path) { + // throwIfNoEntry will be ignored by older versions of node + return _fs.statSync(path, { throwIfNoEntry: false }); + } /** * Uses the builtin inspector APIs to capture a CPU profile * See https://nodejs.org/api/inspector.html#inspector_example_usage for details @@ -7112,20 +7121,21 @@ var ts; if (activeSession && activeSession !== "stopping") { var s_1 = activeSession; activeSession.post("Profiler.stop", function (err, _a) { + var _b; var profile = _a.profile; if (!err) { try { - if (_fs.statSync(profilePath).isDirectory()) { + if ((_b = statSync(profilePath)) === null || _b === void 0 ? void 0 : _b.isDirectory()) { profilePath = _path.join(profilePath, (new Date()).toISOString().replace(/:/g, "-") + "+P" + process.pid + ".cpuprofile"); } } - catch (_b) { + catch (_c) { // do nothing and ignore fallible fs operation } try { _fs.mkdirSync(_path.dirname(profilePath), { recursive: true }); } - catch (_c) { + catch (_d) { // do nothing and ignore fallible fs operation } _fs.writeFileSync(profilePath, JSON.stringify(cleanupPaths(profile))); @@ -7364,7 +7374,10 @@ var ts; if (typeof dirent === "string" || dirent.isSymbolicLink()) { var name = ts.combinePaths(path, entry); try { - stat = _fs.statSync(name); + stat = statSync(name); + if (!stat) { + continue; + } } catch (e) { continue; @@ -7397,7 +7410,10 @@ var ts; var originalStackTraceLimit = Error.stackTraceLimit; Error.stackTraceLimit = 0; try { - var stat = _fs.statSync(path); + var stat = statSync(path); + if (!stat) { + return false; + } switch (entryKind) { case 0 /* File */: return stat.isFile(); case 1 /* Directory */: return stat.isDirectory(); @@ -7429,8 +7445,9 @@ var ts; } } function getModifiedTime(path) { + var _a; try { - return _fs.statSync(path).mtime; + return (_a = statSync(path)) === null || _a === void 0 ? void 0 : _a.mtime; } catch (e) { return undefined; diff --git a/package.json b/package.json index 7e90d946609b1..2d7aa389ea767 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "typescript", "author": "Microsoft Corp.", "homepage": "https://www.typescriptlang.org/", - "version": "4.1.5", + "version": "4.1.6", "license": "Apache-2.0", "description": "TypeScript is a language for application scale JavaScript development", "keywords": [ diff --git a/src/compiler/corePublic.ts b/src/compiler/corePublic.ts index c98c2aa9b4204..a87b5c1589f6c 100644 --- a/src/compiler/corePublic.ts +++ b/src/compiler/corePublic.ts @@ -3,7 +3,7 @@ namespace ts { // If changing the text in this section, be sure to test `configurePrerelease` too. export const versionMajorMinor = "4.1"; /** The version of the TypeScript compiler release */ - export const version = "4.1.5" as string; + export const version = "4.1.6" as string; /** * Type of objects whose values are all of the same type.