Skip to content

Commit

Permalink
chore(typescript): update to TypeScript 4.3.5
Browse files Browse the repository at this point in the history
Update to TypeScript 4.3.5. Also required updating eslint and closure-compiler.

fix #331
  • Loading branch information
trxcllnt committed Jul 15, 2021
1 parent 01b8a46 commit 870c6ce
Show file tree
Hide file tree
Showing 113 changed files with 425 additions and 1,087 deletions.
419 changes: 90 additions & 329 deletions .eslintrc.js

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions gulp/closure-task.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,17 @@ const closureTask = ((cache) => memoizeTask(cache, async function closure(target
`${src}/**/*.js` /* <-- then sources globs */
], { base: `./` }),
sourcemaps.init(),
closureCompiler(createClosureArgs(entry_point, entry, externsPath, getUMDExportName(entry))),
closureCompiler(createClosureArgs(target, entry_point, entry, externsPath, getUMDExportName(entry)), {
platform: ['native', 'java', 'javascript']
}),
// rename the sourcemaps from *.js.map files to *.min.js.map
sourcemaps.write(`.`, { mapFile: (mapPath) => mapPath.replace(`.js.map`, `.${target}.min.js.map`) }),
gulp.dest(out)
).toPromise();
}
}))({});

const createClosureArgs = (entry_point, output, externs, libraryName) => ({
const createClosureArgs = (target, entry_point, output, externs, libraryName) => ({
externs,
entry_point,
third_party: true,
Expand All @@ -97,8 +99,8 @@ const createClosureArgs = (entry_point, output, externs, libraryName) => ({
package_json_entry_names: `module,jsnext:main,main`,
assume_function_wrapper: true,
js_output_file: `${output}.js`,
language_in: gCCLanguageNames[`es2015`],
language_out: gCCLanguageNames[`esnext`],
language_in: gCCLanguageNames[`esnext`],
language_out: gCCLanguageNames[target],
output_wrapper: `(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['${libraryName}'], factory) :
Expand Down
12 changes: 5 additions & 7 deletions gulp/compile-task.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,16 @@ const { npmPkgName } = require('./util');
const { memoizeTask } = require('./memoize-task');
const { empty: ObservableEmpty } = require('rxjs');

const minifyTask = require('./minify-task');
const closureTask = require('./closure-task');
const typescriptTask = require('./typescript-task');
const { copyMainTask, copyTSTask } = require('./copy-main-task');

const compileTask = ((cache) => memoizeTask(cache, function compile(target, format, ...args) {
return target === `src` ? ObservableEmpty()
: target === npmPkgName ? copyMainTask(target, format, ...args)()
: target === `ts` ? copyTSTask(target, format, ...args)()
: format === `umd` ? target === `es5` ? closureTask(target, format, ...args)()
: minifyTask(target, format, ...args)()
: typescriptTask(target, format, ...args)();
return target === `src` ? ObservableEmpty()
: target === npmPkgName ? copyMainTask(target, format, ...args)()
: target === `ts` ? copyTSTask(target, format, ...args)()
: format === `umd` ? closureTask(target, format, ...args)()
: typescriptTask(target, format, ...args)();
}))({});

module.exports = compileTask;
Expand Down
103 changes: 0 additions & 103 deletions gulp/minify-task.js

This file was deleted.

20 changes: 13 additions & 7 deletions gulp/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,19 @@ function shouldRunInChildProcess(target, format) {

const gulp = path.join(path.parse(require.resolve(`gulp`)).dir, `bin/gulp.js`);
function spawnGulpCommandInChildProcess(command, target, format) {
const args = [gulp, command, '-t', target, '-m', format, `--silent`];
const opts = {
stdio: [`ignore`, `inherit`, `inherit`],
env: { ...process.env, NODE_NO_WARNINGS: `1` }
};
return asyncDone(() => child_process.spawn(`node`, args, opts))
.catch((e) => { throw `Error in "${command}:${taskName(target, format)}" task`; });
const err = [];
return asyncDone(() => {
const child = child_process.spawn(
`node`,
[gulp, command, '-t', target, '-m', format, `-L`],
{
stdio: [`ignore`, `ignore`, `pipe`],
env: { ...process.env, NODE_NO_WARNINGS: `1` }
});
child.stderr.on('data', (line) => err.push(line));
return child;
}).catch(() => Promise.reject(err.length > 0 ? err.join('\n')
: `Error in "${command}:${taskName(target, format)}" task.`));
}

const logAndDie = (e) => { if (e) { process.exit(1) } };
Expand Down
6 changes: 3 additions & 3 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ knownTargets.forEach((target) => {
gulp.task(`build:${umd}`, gulp.series(
`build:${cls}`,
`clean:${umd}`, `compile:${umd}`, `package:${umd}`,
function remove_closure_tmp_files() {
return del(targetDir(target, `cls`))
}
// function remove_closure_tmp_files() {
// return del(targetDir(target, `cls`))
// }
));
});

Expand Down
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
"devDependencies": {
"@types/glob": "7.1.1",
"@types/jest": "25.1.3",
"@typescript-eslint/eslint-plugin": "2.21.0",
"@typescript-eslint/parser": "2.21.0",
"@typescript-eslint/eslint-plugin": "4.26.0",
"@typescript-eslint/parser": "4.26.0",
"abortcontroller-polyfill": "1.4.0",
"async-done": "1.3.2",
"benchmark": "2.1.4",
Expand All @@ -66,10 +66,11 @@
"coveralls": "3.0.9",
"cz-conventional-changelog": "3.1.0",
"del": "5.1.0",
"eslint": "6.8.0",
"eslint": "7.27.0",
"eslint-plugin-jest": "24.3.6",
"esm": "3.2.25",
"glob": "7.1.6",
"google-closure-compiler": "20200517.0.0",
"google-closure-compiler": "20210601.0.0",
"gulp": "4.0.2",
"gulp-json-transform": "0.4.7",
"gulp-rename": "2.0.0",
Expand Down Expand Up @@ -97,7 +98,7 @@
"ts-jest": "25.2.1",
"ts-node": "8.6.2",
"typedoc": "0.16.10",
"typescript": "3.9.3",
"typescript": "4.3.5",
"validate-commit-msg": "2.14.0",
"web-stream-tools": "0.0.1",
"web-streams-polyfill": "2.1.0",
Expand Down
4 changes: 2 additions & 2 deletions spec/asynciterable-operators/catcherror-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ test('AsyncIterable#catchError error catches', async () => {
test('AsyncIterable#catchError no error misses', async () => {
const xs = range(0, 10);
const res = xs.pipe(catchError(async (_: Error) => of(42)));
expect(sequenceEqual(res, xs)).resolves.toBeTruthy();
await expect(sequenceEqual(res, xs)).resolves.toBeTruthy();
});

test('AsyncIterable#catchError source and handler types are composed', async () => {
const xs = range(0, 10);
const res = xs.pipe(catchError(async (_: Error) => of('foo')));
expect(sequenceEqual(res, xs)).resolves.toBeTruthy();
await expect(sequenceEqual(res, xs)).resolves.toBeTruthy();
});
10 changes: 3 additions & 7 deletions spec/asynciterable-operators/debounce-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,9 @@ test(
const ys = as(xs()).pipe(debounce(300));
const controller = new AbortController();
const it = ys[Symbol.asyncIterator](controller.signal);
try {
await hasNext(it, 1);
controller.abort();
await hasNext(it, 3);
} catch (e) {
expect(e).toBeInstanceOf(AbortError);
}
await hasNext(it, 1);
controller.abort();
await expect(hasNext(it, 3)).rejects.toThrow(AbortError);
await noNext(it);
},
10 * 1000
Expand Down
6 changes: 1 addition & 5 deletions spec/asynciterable-operators/defaultifempty-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,5 @@ test('AsyncIterable#defaultIfEmpty throws', async () => {
const ys = xs.pipe(defaultIfEmpty(0));

const it = ys[Symbol.asyncIterator]();
try {
await it.next();
} catch (e) {
expect(e != null).toBeTruthy();
}
await expect(it.next()).rejects.toThrow();
});
18 changes: 3 additions & 15 deletions spec/asynciterable-operators/filter-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,7 @@ test('AsyncIterable#filter throws part way through', async () => {
await hasNext(it, 8);
await hasNext(it, 5);
await hasNext(it, 7);
try {
await it.next();
} catch (e) {
expect(e != null).toBeTruthy();
}
await expect(it.next()).rejects.toThrow(err);
});

test('AsyncIterable#filter with index throws part way through', async () => {
Expand All @@ -90,23 +86,15 @@ test('AsyncIterable#filter with index throws part way through', async () => {
await hasNext(it, 8);
await hasNext(it, 5);
await hasNext(it, 7);
try {
await it.next();
} catch (e) {
expect(e != null).toBeTruthy();
}
await expect(it.next()).rejects.toThrow(err);
});

test('AsyncIterable#filter with error source', async () => {
const xs = throwError(new Error());
const ys = xs.pipe(filter(async (x) => x % 2 === 0));

const it = ys[Symbol.asyncIterator]();
try {
await it.next();
} catch (e) {
expect(e != null).toBeTruthy();
}
await expect(it.next()).rejects.toThrow();
});

test('AsyncIterable#filter with empty source', async () => {
Expand Down
6 changes: 1 addition & 5 deletions spec/asynciterable-operators/finalize-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@ test('AsyncIterable#finally calls even with error', async () => {
const it = xs[Symbol.asyncIterator]();
expect(done).toBeFalsy();

try {
await hasNext(it, 0);
} catch (e) {
expect(e).toEqual(err);
}
await expect(hasNext(it, 0)).rejects.toThrow(err);

expect(done).toBeTruthy();
});
18 changes: 3 additions & 15 deletions spec/asynciterable-operators/flatmap-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ test('Iterable#flatMap selector returns throw', async () => {
hasNext(it, 0);
hasNext(it, 0);
hasNext(it, 1);
try {
await it.next();
} catch (e) {
expect(e != null).toBeTruthy();
}
await expect(it.next()).rejects.toThrow(err);
});

test('Iterable#flatMap with error throws', async () => {
Expand All @@ -38,11 +34,7 @@ test('Iterable#flatMap with error throws', async () => {
const ys = xs.pipe(flatMap((x) => range(0, x)));

const it = ys[Symbol.asyncIterator]();
try {
await it.next();
} catch (e) {
expect(e != null).toBeTruthy();
}
await expect(it.next()).rejects.toThrow(err);
});

test('Iterable#flatMap selector throws error', async () => {
Expand All @@ -61,9 +53,5 @@ test('Iterable#flatMap selector throws error', async () => {
hasNext(it, 0);
hasNext(it, 0);
hasNext(it, 1);
try {
await it.next();
} catch (e) {
expect(e != null).toBeTruthy();
}
await expect(it.next()).rejects.toThrow(err);
});
Loading

0 comments on commit 870c6ce

Please sign in to comment.