Update to latest typescript (#438)

This commit is contained in:
Franck R 2022-01-27 15:25:17 +11:00 committed by GitHub
parent 95b3daf3e8
commit 6cb2b6615b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 30203 additions and 43390 deletions

View File

@ -25,3 +25,15 @@ updates:
interval: "daily"
reviewers:
- "d4nte"
- package-ecosystem: "npm"
directory: "/examples/eth-pm"
schedule:
interval: "daily"
reviewers:
- "d4nte"
- package-ecosystem: "npm"
directory: "/examples/eth-pm-wallet-encryption"
schedule:
interval: "daily"
reviewers:
- "d4nte"

View File

@ -0,0 +1,60 @@
const webpack = require('webpack');
module.exports = {
dev: (config) => {
// Override webpack 5 config from react-scripts to load polyfills
if (!config.resolve) config.resolve = {};
if (!config.resolve.fallback) config.resolve.fallback = {};
Object.assign(config.resolve.fallback, {
buffer: require.resolve('buffer'),
crypto: require.resolve('crypto-browserify'),
stream: require.resolve('stream-browserify'),
});
if (!config.plugins) config.plugins = [];
config.plugins.push(
new webpack.DefinePlugin({
'process.env.ENV': JSON.stringify('dev'),
})
);
config.plugins.push(
new webpack.ProvidePlugin({
process: 'process/browser.js',
Buffer: ['buffer', 'Buffer'],
})
);
if (!config.ignoreWarnings) config.ignoreWarnings = [];
config.ignoreWarnings.push(/Failed to parse source map/);
return config;
},
prod: (config) => {
// Override webpack 5 config from react-scripts to load polyfills
if (!config.resolve) config.resolve = {};
if (!config.resolve.fallback) config.resolve.fallback = {};
Object.assign(config.resolve.fallback, {
buffer: require.resolve('buffer'),
crypto: require.resolve('crypto-browserify'),
stream: require.resolve('stream-browserify'),
});
if (!config.plugins) config.plugins = [];
config.plugins.push(
new webpack.DefinePlugin({
'process.env.ENV': JSON.stringify('prod'),
})
);
config.plugins.push(
new webpack.ProvidePlugin({
process: 'process/browser.js',
Buffer: ['buffer', 'Buffer'],
})
);
if (!config.ignoreWarnings) config.ignoreWarnings = [];
config.ignoreWarnings.push(/Failed to parse source map/);
return config;
},
};

File diff suppressed because it is too large Load Diff

View File

@ -18,16 +18,13 @@
"js-waku": "../../build/main",
"protobufjs": "^6.11.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
"typescript": "^4.1.2",
"web-vitals": "^1.0.1"
"react-dom": "^17.0.2"
},
"scripts": {
"start": "react-scripts start",
"start": "cra-webpack-rewired start",
"build": "run-s build:*",
"build:react": "react-scripts build",
"eject": "react-scripts eject",
"build:react": "cra-webpack-rewired build",
"eject": "cra-webpack-rewired eject",
"fix": "run-s fix:*",
"test": "run-s build test:*",
"test:lint": "eslint src --ext .ts --ext .tsx",
@ -45,6 +42,8 @@
"browserslist": {
"production": [
">0.2%",
"not ie <= 99",
"not android <= 4.4.4",
"not dead",
"not op_mini all"
],
@ -57,9 +56,12 @@
"devDependencies": {
"@ethersproject/shims": "^5.3.0",
"@types/node": "^14.17.3",
"cra-webpack-rewired": "^1.0.1",
"cspell": "^5.6.6",
"eslint": "^7.29.0",
"eslint": "^8.7.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.3.1"
"prettier": "^2.3.1",
"react-scripts": "5.0.0",
"typescript": "^4.5.5"
}
}

View File

@ -0,0 +1,60 @@
const webpack = require('webpack');
module.exports = {
dev: (config) => {
// Override webpack 5 config from react-scripts to load polyfills
if (!config.resolve) config.resolve = {};
if (!config.resolve.fallback) config.resolve.fallback = {};
Object.assign(config.resolve.fallback, {
buffer: require.resolve('buffer'),
crypto: require.resolve('crypto-browserify'),
stream: require.resolve('stream-browserify'),
});
if (!config.plugins) config.plugins = [];
config.plugins.push(
new webpack.DefinePlugin({
'process.env.ENV': JSON.stringify('dev'),
})
);
config.plugins.push(
new webpack.ProvidePlugin({
process: 'process/browser.js',
Buffer: ['buffer', 'Buffer'],
})
);
if (!config.ignoreWarnings) config.ignoreWarnings = [];
config.ignoreWarnings.push(/Failed to parse source map/);
return config;
},
prod: (config) => {
// Override webpack 5 config from react-scripts to load polyfills
if (!config.resolve) config.resolve = {};
if (!config.resolve.fallback) config.resolve.fallback = {};
Object.assign(config.resolve.fallback, {
buffer: require.resolve('buffer'),
crypto: require.resolve('crypto-browserify'),
stream: require.resolve('stream-browserify'),
});
if (!config.plugins) config.plugins = [];
config.plugins.push(
new webpack.DefinePlugin({
'process.env.ENV': JSON.stringify('prod'),
})
);
config.plugins.push(
new webpack.ProvidePlugin({
process: 'process/browser.js',
Buffer: ['buffer', 'Buffer'],
})
);
if (!config.ignoreWarnings) config.ignoreWarnings = [];
config.ignoreWarnings.push(/Failed to parse source map/);
return config;
},
};

File diff suppressed because it is too large Load Diff

View File

@ -18,16 +18,13 @@
"js-waku": "../../build/main",
"protobufjs": "^6.11.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
"typescript": "^4.1.2",
"web-vitals": "^1.0.1"
"react-dom": "^17.0.2"
},
"scripts": {
"start": "react-scripts start",
"start": "cra-webpack-rewired start",
"build": "run-s build:*",
"build:react": "react-scripts build",
"eject": "react-scripts eject",
"build:react": "cra-webpack-rewired build",
"eject": "cra-webpack-rewired eject",
"fix": "run-s fix:*",
"test": "run-s build test:*",
"test:lint": "eslint src --ext .ts --ext .tsx",
@ -45,6 +42,8 @@
"browserslist": {
"production": [
">0.2%",
"not ie <= 99",
"not android <= 4.4.4",
"not dead",
"not op_mini all"
],
@ -57,9 +56,12 @@
"devDependencies": {
"@ethersproject/shims": "^5.3.0",
"@types/node": "^14.17.3",
"cra-webpack-rewired": "^1.0.1",
"cspell": "^5.6.6",
"eslint": "^7.29.0",
"eslint": "^8.7.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.3.1"
"prettier": "^2.3.1",
"react-scripts": "5.0.0",
"typescript": "^4.5.5"
}
}

46
package-lock.json generated
View File

@ -58,10 +58,10 @@
"eslint-plugin-prettier": "^4.0.0",
"fast-check": "^2.14.0",
"gh-pages": "^3.2.3",
"karma": "^6.3.4",
"karma": "^6.3.12",
"karma-chrome-launcher": "^3.1.0",
"karma-mocha": "^2.0.1",
"karma-typescript": "^5.5.1",
"karma-typescript": "^5.5.3",
"mocha": "^9.1.3",
"npm-run-all": "^4.1.5",
"nyc": "^15.1.0",
@ -76,7 +76,7 @@
"ts-proto": "^1.82.5",
"typedoc": "^0.22.10",
"typedoc-plugin-no-inherit": "^1.3.1",
"typescript": "^4.0.2",
"typescript": "^4.5.5",
"varint": "^6.0.0",
"webpack": "^5.58.1",
"webpack-cli": "^4.9.0"
@ -9941,15 +9941,15 @@
}
},
"node_modules/karma": {
"version": "6.3.9",
"resolved": "https://registry.npmjs.org/karma/-/karma-6.3.9.tgz",
"integrity": "sha512-E/MqdLM9uVIhfuyVnrhlGBu4miafBdXEAEqCmwdEMh3n17C7UWC/8Kvm3AYKr91gc7scutekZ0xv6rxRaUCtnw==",
"version": "6.3.12",
"resolved": "https://registry.npmjs.org/karma/-/karma-6.3.12.tgz",
"integrity": "sha512-qwIG+oB2YmHx4hjvYSRMNzL3YWAJ9baHaLAxiP7biFNkfpwYTUTtPck0joFpucalNLzMr+7z/FX1uY/kl8DV9A==",
"dev": true,
"dependencies": {
"body-parser": "^1.19.0",
"braces": "^3.0.2",
"chokidar": "^3.5.1",
"colors": "^1.4.0",
"colors": "1.4.0",
"connect": "^3.7.0",
"di": "^0.0.1",
"dom-serialize": "^2.2.1",
@ -10008,9 +10008,9 @@
}
},
"node_modules/karma-typescript": {
"version": "5.5.2",
"resolved": "https://registry.npmjs.org/karma-typescript/-/karma-typescript-5.5.2.tgz",
"integrity": "sha512-2rNhiCMrIF+VR8jMuovOLSRjNkjdoE/kQ4XYZU94lMkHNQtnqCaToAnztMj4fuOPRErL7VIkwvJEO7jBd47Q6A==",
"version": "5.5.3",
"resolved": "https://registry.npmjs.org/karma-typescript/-/karma-typescript-5.5.3.tgz",
"integrity": "sha512-l1FHurolXEBIzRa9ExpNtjzysAhsi/vLpTazpwLHWWK86mknvVpqor6pRZ5Nid7jvOPrTBqAq0JRuLgiCdRkFw==",
"dev": true,
"dependencies": {
"acorn": "^8.1.0",
@ -16799,9 +16799,9 @@
}
},
"node_modules/typescript": {
"version": "4.2.4",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.2.4.tgz",
"integrity": "sha512-V+evlYHZnQkaz8TRBuxTA92yZBPotr5H+WhQ7bD3hZUndx5tGOa1fuCgeSjxAzM1RiN5IzvadIXTVefuuwZCRg==",
"version": "4.5.5",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.5.tgz",
"integrity": "sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==",
"dev": true,
"bin": {
"tsc": "bin/tsc",
@ -25613,15 +25613,15 @@
}
},
"karma": {
"version": "6.3.9",
"resolved": "https://registry.npmjs.org/karma/-/karma-6.3.9.tgz",
"integrity": "sha512-E/MqdLM9uVIhfuyVnrhlGBu4miafBdXEAEqCmwdEMh3n17C7UWC/8Kvm3AYKr91gc7scutekZ0xv6rxRaUCtnw==",
"version": "6.3.12",
"resolved": "https://registry.npmjs.org/karma/-/karma-6.3.12.tgz",
"integrity": "sha512-qwIG+oB2YmHx4hjvYSRMNzL3YWAJ9baHaLAxiP7biFNkfpwYTUTtPck0joFpucalNLzMr+7z/FX1uY/kl8DV9A==",
"dev": true,
"requires": {
"body-parser": "^1.19.0",
"braces": "^3.0.2",
"chokidar": "^3.5.1",
"colors": "^1.4.0",
"colors": "1.4.0",
"connect": "^3.7.0",
"di": "^0.0.1",
"dom-serialize": "^2.2.1",
@ -25690,9 +25690,9 @@
}
},
"karma-typescript": {
"version": "5.5.2",
"resolved": "https://registry.npmjs.org/karma-typescript/-/karma-typescript-5.5.2.tgz",
"integrity": "sha512-2rNhiCMrIF+VR8jMuovOLSRjNkjdoE/kQ4XYZU94lMkHNQtnqCaToAnztMj4fuOPRErL7VIkwvJEO7jBd47Q6A==",
"version": "5.5.3",
"resolved": "https://registry.npmjs.org/karma-typescript/-/karma-typescript-5.5.3.tgz",
"integrity": "sha512-l1FHurolXEBIzRa9ExpNtjzysAhsi/vLpTazpwLHWWK86mknvVpqor6pRZ5Nid7jvOPrTBqAq0JRuLgiCdRkFw==",
"dev": true,
"requires": {
"acorn": "^8.1.0",
@ -31108,9 +31108,9 @@
"requires": {}
},
"typescript": {
"version": "4.2.4",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.2.4.tgz",
"integrity": "sha512-V+evlYHZnQkaz8TRBuxTA92yZBPotr5H+WhQ7bD3hZUndx5tGOa1fuCgeSjxAzM1RiN5IzvadIXTVefuuwZCRg==",
"version": "4.5.5",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.5.tgz",
"integrity": "sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==",
"dev": true
},
"ua-parser-js": {

View File

@ -105,10 +105,10 @@
"eslint-plugin-prettier": "^4.0.0",
"fast-check": "^2.14.0",
"gh-pages": "^3.2.3",
"karma": "^6.3.4",
"karma": "^6.3.12",
"karma-chrome-launcher": "^3.1.0",
"karma-mocha": "^2.0.1",
"karma-typescript": "^5.5.1",
"karma-typescript": "^5.5.3",
"mocha": "^9.1.3",
"npm-run-all": "^4.1.5",
"nyc": "^15.1.0",
@ -123,7 +123,7 @@
"ts-proto": "^1.82.5",
"typedoc": "^0.22.10",
"typedoc-plugin-no-inherit": "^1.3.1",
"typescript": "^4.0.2",
"typescript": "^4.5.5",
"varint": "^6.0.0",
"webpack": "^5.58.1",
"webpack-cli": "^4.9.0"

View File

@ -16,7 +16,8 @@ describe('ENRTree', () => {
it('ENRTree (root): should error if DNS root entry is mis-prefixed', () => {
try {
ENRTree.parseAndVerifyRoot(dns.enrRootBadPrefix, dns.publicKey);
} catch (e) {
} catch (err: unknown) {
const e = err as Error;
expect(e.toString()).includes(
"ENRTree root entry must start with 'enrtree-root:'"
);
@ -26,7 +27,8 @@ describe('ENRTree', () => {
it('ENRTree (root): should error if DNS root entry signature is invalid', () => {
try {
ENRTree.parseAndVerifyRoot(dns.enrRootBadSig, dns.publicKey);
} catch (e) {
} catch (err: unknown) {
const e = err as Error;
expect(e.toString()).includes('Unable to verify ENRTree root signature');
}
});
@ -34,7 +36,8 @@ describe('ENRTree', () => {
it('ENRTree (root): should error if DNS root entry is malformed', () => {
try {
ENRTree.parseAndVerifyRoot(dns.enrRootMalformed, dns.publicKey);
} catch (e) {
} catch (err: unknown) {
const e = err as Error;
expect(e.toString()).includes('Could not parse ENRTree root entry');
}
});
@ -50,7 +53,8 @@ describe('ENRTree', () => {
it('ENRTree (tree): should error if DNS tree entry is mis-prefixed', () => {
try {
ENRTree.parseTree(dns.enrTreeBadPrefix);
} catch (e) {
} catch (err: unknown) {
const e = err as Error;
expect(e.toString()).includes(
"ENRTree tree entry must start with 'enrtree:'"
);
@ -60,7 +64,8 @@ describe('ENRTree', () => {
it('ENRTree (tree): should error if DNS tree entry is misformatted', () => {
try {
ENRTree.parseTree(dns.enrTreeMalformed);
} catch (e) {
} catch (err: unknown) {
const e = err as Error;
expect(e.toString()).includes('Could not parse ENRTree tree entry');
}
});
@ -80,7 +85,8 @@ describe('ENRTree', () => {
it('ENRTree (branch): should error if DNS branch entry is mis-prefixed', () => {
try {
ENRTree.parseBranch(dns.enrBranchBadPrefix);
} catch (e) {
} catch (err: unknown) {
const e = err as Error;
expect(e.toString()).includes(
"ENRTree branch entry must start with 'enrtree-branch:'"
);

View File

@ -100,8 +100,9 @@ describe('ENR', function () {
).toString();
ENR.decodeTxt(txt);
assert.fail('Expect error here');
} catch (err) {
expect(err.message).to.be.equal(ERR_INVALID_ID);
} catch (err: unknown) {
const e = err as Error;
expect(e.message).to.be.equal(ERR_INVALID_ID);
}
});
@ -111,8 +112,9 @@ describe('ENR', function () {
'enr:-IS4QJ2d11eu6dC7E7LoXeLMgMP3kom1u3SE8esFSWvaHoo0dP1jg8O3-nx9ht-EO3CmG7L6OkHcMmoIh00IYWB92QABgmlkgnY0gmlwhH8AAAGJc2d11eu6dCsxoQIB_c-jQMOXsbjWkbN-kj99H57gfId5pfb4wa1qxwV4CIN1ZHCCIyk';
ENR.decodeTxt(txt);
assert.fail('Expect error here');
} catch (err) {
expect(err.message).to.be.equal('Failed to verify ENR: No public key');
} catch (err: unknown) {
const e = err as Error;
expect(e.message).to.be.equal('Failed to verify ENR: No public key');
}
});
});
@ -123,8 +125,9 @@ describe('ENR', function () {
const enr = new ENR({}, BigInt(0), Buffer.alloc(0));
enr.verify(Buffer.alloc(0), Buffer.alloc(0));
assert.fail('Expect error here');
} catch (err) {
expect(err.message).to.be.equal(ERR_INVALID_ID);
} catch (err: unknown) {
const e = err as Error;
expect(e.message).to.be.equal(ERR_INVALID_ID);
}
});
@ -137,8 +140,9 @@ describe('ENR', function () {
);
enr.verify(Buffer.alloc(0), Buffer.alloc(0));
assert.fail('Expect error here');
} catch (err) {
expect(err.message).to.be.equal(ERR_INVALID_ID);
} catch (err: unknown) {
const e = err as Error;
expect(e.message).to.be.equal(ERR_INVALID_ID);
}
});
@ -151,8 +155,9 @@ describe('ENR', function () {
);
enr.verify(Buffer.alloc(0), Buffer.alloc(0));
assert.fail('Expect error here');
} catch (err) {
expect(err.message).to.be.equal('Failed to verify ENR: No public key');
} catch (err: unknown) {
const e = err as Error;
expect(e.message).to.be.equal('Failed to verify ENR: No public key');
}
});
@ -173,7 +178,8 @@ describe('ENR', function () {
).toString();
try {
ENR.decodeTxt(buf);
} catch (e) {
} catch (err: unknown) {
const e = err as Error;
expect(e.message).to.equal(
'Decoded ENR invalid signature: must be a byte array'
);
@ -186,7 +192,8 @@ describe('ENR', function () {
).toString();
try {
ENR.decodeTxt(buf);
} catch (e) {
} catch (err: unknown) {
const e = err as Error;
expect(e.message).to.equal(
'Decoded ENR invalid sequence number: must be a byte array'
);