Skip to content

Test Node 12 #53194

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
- "18"
- "16"
- "14"
- "12"
bundle:
- "true"
include:
Expand Down
9 changes: 5 additions & 4 deletions Herebyfile.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ function createBundler(entrypoint, outfile, taskOptions = {}) {
const options = { ...await getOptions(), logLevel: "info" };
if (taskOptions.onWatchRebuild) {
const onRebuild = taskOptions.onWatchRebuild;
options.plugins = (options.plugins?.slice(0) ?? []).concat([{
options.plugins = options.plugins ? options.plugins.slice() : [];
options.plugins.push({
name: "watch",
setup: (build) => {
let firstBuild = true;
Expand All @@ -237,7 +238,7 @@ function createBundler(entrypoint, outfile, taskOptions = {}) {
}
});
}
}]);
});
}

const ctx = await esbuild.context(options);
Expand Down Expand Up @@ -297,7 +298,7 @@ function entrypointBuildTask(options) {
},
});

const mainDeps = options.mainDeps?.slice(0) ?? [];
const mainDeps = options.mainDeps ? options.mainDeps.slice() : [];
if (cmdLineOptions.bundle) {
mainDeps.push(bundle);
if (cmdLineOptions.typecheck) {
Expand All @@ -317,7 +318,7 @@ function entrypointBuildTask(options) {
const watch = task({
name: `watch-${options.name}`,
hiddenFromTaskList: true, // This is best effort.
dependencies: (options.buildDeps ?? []).concat(options.mainDeps ?? []).concat(cmdLineOptions.bundle ? [] : [shim]),
dependencies: (options.buildDeps || []).concat(options.mainDeps || []).concat(cmdLineOptions.bundle ? [] : [shim]),
run: () => {
// These watch functions return promises that resolve once watch mode has started,
// allowing them to operate as regular tasks, while creating unresolved promises
Expand Down
6 changes: 3 additions & 3 deletions scripts/build/options.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import minimist from "minimist";
import os from "os";

const ci = ["1", "true"].includes(process.env.CI ?? "");
const ci = ["1", "true"].includes(process.env.CI || "");

const parsed = minimist(process.argv.slice(2), {
boolean: ["dirty", "light", "colors", "lkg", "soft", "fix", "failed", "keepFailed", "force", "built", "ci", "bundle", "typecheck", "lint"],
Expand All @@ -26,13 +26,13 @@ const parsed = minimist(process.argv.slice(2), {
inspect: process.env.inspect || process.env["inspect-brk"] || process.env.i,
host: process.env.TYPESCRIPT_HOST || process.env.host || "node",
browser: process.env.browser || process.env.b || (os.platform() === "win32" ? "edge" : "chrome"),
timeout: +(process.env.timeout ?? 0) || 40000,
timeout: +(process.env.timeout || 0) || 40000,
tests: process.env.test || process.env.tests || process.env.t,
runners: process.env.runners || process.env.runner || process.env.ru,
light: process.env.light === undefined || process.env.light !== "false",
reporter: process.env.reporter || process.env.r,
fix: process.env.fix || process.env.f,
workers: +(process.env.workerCount ?? 0) || ((os.cpus().length - (ci ? 0 : 1)) || 1),
workers: +(process.env.workerCount || 0) || ((os.cpus().length - (ci ? 0 : 1)) || 1),
failed: false,
keepFailed: false,
lkg: false,
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/tests.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export async function runConsoleTests(runJs, defaultReporter, runInParallel, opt
}
await cleanTestDirs();

if (options.token?.signaled) {
if (options.token && options.token.signaled) {
return;
}
}
Expand Down
15 changes: 10 additions & 5 deletions scripts/build/utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,26 @@ export async function exec(cmd, args, options = {}) {
const onCanceled = () => {
proc.kill();
};
const subscription = options.token?.subscribe(onCanceled);
const subscription = options.token ? options.token.subscribe(onCanceled) : undefined;
proc.on("exit", exitCode => {
if (exitCode === 0 || ignoreExitCode) {
resolve({ exitCode: exitCode ?? undefined });
// eslint-disable-next-line no-null/no-null
resolve({ exitCode: exitCode !== undefined && exitCode !== null ? exitCode : undefined });
}
else {
const reason = options.token?.signaled ? options.token.reason ?? new CancelError() :
const reason = (options.token && options.token.signaled) ? (options.token.reason !== undefined ? options.token.reason : new CancelError()) :
new Error(`Process exited with code: ${exitCode}`);
reject(reason);
}
subscription?.unsubscribe();
if (subscription) {
subscription.unsubscribe();
}
});
proc.on("error", error => {
reject(error);
subscription?.unsubscribe();
if (subscription) {
subscription.unsubscribe();
}
});
}
else {
Expand Down
6 changes: 3 additions & 3 deletions scripts/dtsBundler.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ function containsPublicAPI(symbol) {
return result;

function containsPublicAPIWorker() {
if (!symbol.declarations?.length) {
if (!symbol.declarations || !symbol.declarations.length) {
return false;
}

Expand All @@ -171,7 +171,7 @@ function containsPublicAPI(symbol) {
}

// Namespace barrel; actual namespaces are checked below.
if (symbol.flags & ts.SymbolFlags.ValueModule && symbol.valueDeclaration?.kind === ts.SyntaxKind.SourceFile) {
if (symbol.flags & ts.SymbolFlags.ValueModule && symbol.valueDeclaration !== undefined && symbol.valueDeclaration.kind === ts.SyntaxKind.SourceFile) {
for (const me of typeChecker.getExportsOfModule(symbol)) {
if (containsPublicAPI(me)) {
return true;
Expand Down Expand Up @@ -354,7 +354,7 @@ function emitAsNamespace(name, moduleSymbol) {
}

for (const me of moduleExports) {
assert(me.declarations?.length);
assert(me.declarations && me.declarations.length);

if (me.flags & ts.SymbolFlags.Alias) {
const resolved = typeChecker.getAliasedSymbol(me);
Expand Down
2 changes: 1 addition & 1 deletion scripts/failed-tests.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class FailedTestsReporter extends Mocha.reporters.Base {
super(runner, options);
if (!runner) return;

const reporterOptions = this.reporterOptions = options?.reporterOptions || {};
const reporterOptions = this.reporterOptions = options && options.reporterOptions || {};
if (reporterOptions.file === undefined) reporterOptions.file = ".failed-tests";
if (reporterOptions.keepFailed === undefined) reporterOptions.keepFailed = false;
if (reporterOptions.reporter) {
Expand Down
11 changes: 6 additions & 5 deletions src/testRunner/unittests/evaluation/esDecorators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1863,13 +1863,14 @@ describe("unittests:: evaluation:: esDecorators", () => {
});
});

const nodeVersion = ts.Version.tryParse(process.version);
const supportsClassStaticBlock = nodeVersion && nodeVersion.major >= 16;
const nodeVersion = new ts.Version(process.versions.node);
const node16 = nodeVersion.major >= 16;
const node14 = nodeVersion.major >= 14;

const targets = [
// NOTE: Class static blocks weren't supported in Node v14
...(supportsClassStaticBlock ? [ScriptTarget.ES2022] : []),
ScriptTarget.ES2021,
...(node16 ? [ScriptTarget.ES2022] : []),
...(node14 ? [ScriptTarget.ES2021] : []),
ScriptTarget.ES2015,
];

Expand Down Expand Up @@ -2443,4 +2444,4 @@ describe("unittests:: evaluation:: esDecorators", () => {
});
});
}
});
});