Skip to content

Commit

Permalink
Update typescript v4.8 (#1718)
Browse files Browse the repository at this point in the history
## Explanation

The `typescript` package has been updated to v4.8.4 to align with the
module template. This was done to simplify the process of migrating
libraries into the monorepo.
  • Loading branch information
Gudahtt authored and MajorLift committed Oct 11, 2023
1 parent debeb7f commit b3eaf2d
Show file tree
Hide file tree
Showing 29 changed files with 93 additions and 61 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"rimraf": "^3.0.2",
"simple-git-hooks": "^2.8.0",
"ts-node": "^10.9.1",
"typescript": "~4.6.3",
"typescript": "~4.8.4",
"which": "^3.0.0"
},
"packageManager": "[email protected]",
Expand Down
2 changes: 1 addition & 1 deletion packages/accounts-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"ts-jest": "^27.1.4",
"typedoc": "^0.23.15",
"typedoc-plugin-missing-exports": "^0.23.0",
"typescript": "~4.6.3"
"typescript": "~4.8.4"
},
"peerDependencies": {
"@metamask/keyring-controller": "^8.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/address-book-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"ts-jest": "^27.1.4",
"typedoc": "^0.23.15",
"typedoc-plugin-missing-exports": "^0.23.0",
"typescript": "~4.6.3"
"typescript": "~4.8.4"
},
"engines": {
"node": ">=16.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/announcement-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"ts-jest": "^27.1.4",
"typedoc": "^0.23.15",
"typedoc-plugin-missing-exports": "^0.23.0",
"typescript": "~4.6.3"
"typescript": "~4.8.4"
},
"engines": {
"node": ">=16.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/approval-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"ts-jest": "^27.1.4",
"typedoc": "^0.23.15",
"typedoc-plugin-missing-exports": "^0.23.0",
"typescript": "~4.6.3"
"typescript": "~4.8.4"
},
"engines": {
"node": ">=16.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/assets-controllers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"ts-jest": "^27.1.4",
"typedoc": "^0.23.15",
"typedoc-plugin-missing-exports": "^0.23.0",
"typescript": "~4.6.3"
"typescript": "~4.8.4"
},
"peerDependencies": {
"@metamask/approval-controller": "^3.5.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/base-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"ts-jest": "^27.1.4",
"typedoc": "^0.23.15",
"typedoc-plugin-missing-exports": "^0.23.0",
"typescript": "~4.6.3"
"typescript": "~4.8.4"
},
"engines": {
"node": ">=16.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/composable-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"ts-jest": "^27.1.4",
"typedoc": "^0.23.15",
"typedoc-plugin-missing-exports": "^0.23.0",
"typescript": "~4.6.3"
"typescript": "~4.8.4"
},
"engines": {
"node": ">=16.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/controller-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"ts-jest": "^27.1.4",
"typedoc": "^0.23.15",
"typedoc-plugin-missing-exports": "^0.23.0",
"typescript": "~4.6.3"
"typescript": "~4.8.4"
},
"engines": {
"node": ">=16.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/ens-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"ts-jest": "^27.1.4",
"typedoc": "^0.23.15",
"typedoc-plugin-missing-exports": "^0.23.0",
"typescript": "~4.6.3"
"typescript": "~4.8.4"
},
"peerDependencies": {
"@metamask/network-controller": "^13.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/gas-fee-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"ts-jest": "^27.1.4",
"typedoc": "^0.23.15",
"typedoc-plugin-missing-exports": "^0.23.0",
"typescript": "~4.6.3"
"typescript": "~4.8.4"
},
"peerDependencies": {
"@metamask/network-controller": "^13.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/keyring-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"ts-jest": "^27.1.4",
"typedoc": "^0.23.15",
"typedoc-plugin-missing-exports": "^0.23.0",
"typescript": "~4.6.3",
"typescript": "~4.8.4",
"uuid": "^8.3.2"
},
"peerDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/logging-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"ts-jest": "^27.1.4",
"typedoc": "^0.23.15",
"typedoc-plugin-missing-exports": "^0.23.0",
"typescript": "~4.6.3"
"typescript": "~4.8.4"
},
"engines": {
"node": ">=16.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/message-manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"ts-jest": "^27.1.4",
"typedoc": "^0.23.15",
"typedoc-plugin-missing-exports": "^0.23.0",
"typescript": "~4.6.3"
"typescript": "~4.8.4"
},
"engines": {
"node": ">=16.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/name-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"ts-jest": "^27.1.4",
"typedoc": "^0.23.15",
"typedoc-plugin-missing-exports": "^0.23.0",
"typescript": "~4.6.3"
"typescript": "~4.8.4"
},
"engines": {
"node": ">=16.0.0"
Expand Down
8 changes: 6 additions & 2 deletions packages/name-controller/src/providers/etherscan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type {
NameProviderResult,
} from '../types';
import { NameType } from '../types';
import { handleFetch } from '../util';
import { handleFetch, assertIsError } from '../util';

const ID = 'etherscan';
const LABEL = 'Etherscan (Verified Contract Name)';
Expand Down Expand Up @@ -134,7 +134,10 @@ export class EtherscanNameProvider implements NameProvider {
}
}

async #sendRequest(url: string) {
async #sendRequest(url: string): Promise<{
responseData?: EtherscanGetSourceCodeResponse;
error?: Error;
}> {
try {
log('Sending request', url);

Expand All @@ -144,6 +147,7 @@ export class EtherscanNameProvider implements NameProvider {

return { responseData };
} catch (error) {
assertIsError(error);
return { error };
} finally {
this.#lastRequestTime = Date.now();
Expand Down
16 changes: 16 additions & 0 deletions packages/name-controller/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,19 @@ export async function successfulFetch(request: string, options?: RequestInit) {
}
return response;
}

/**
* Assert that a value is an error. If it's not an error, throw an
* error that wraps the given value.
*
* TODO: Migrate this to @metamask/utils
*
* @param error - The value that we expect to be an error.
* @throws Throws an error wrapping the given value if it's not an error.
*/
export function assertIsError(error: unknown): asserts error is Error {
if (error instanceof Error) {
return;
}
throw new Error(`Invalid error of type '${typeof error}'`);
}
14 changes: 13 additions & 1 deletion packages/name-controller/src/utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { graphQL } from './util';
import { assertIsError, graphQL } from './util';

describe('Utils', () => {
describe('graphQL', () => {
Expand Down Expand Up @@ -51,4 +51,16 @@ describe('Utils', () => {
);
});
});

describe('assertIsError', () => {
it('does not throw if given an error', () => {
expect(() => assertIsError(new Error('test'))).not.toThrow();
});

it('throws if passed something that is not an error', () => {
expect(() => assertIsError('test')).toThrow(
`Invalid error of type 'string'`,
);
});
});
});
2 changes: 1 addition & 1 deletion packages/network-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"ts-jest": "^27.1.4",
"typedoc": "^0.23.15",
"typedoc-plugin-missing-exports": "^0.23.0",
"typescript": "~4.6.3"
"typescript": "~4.8.4"
},
"engines": {
"node": ">=16.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/notification-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"ts-jest": "^27.1.4",
"typedoc": "^0.23.15",
"typedoc-plugin-missing-exports": "^0.23.0",
"typescript": "~4.6.3"
"typescript": "~4.8.4"
},
"engines": {
"node": ">=16.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/permission-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"ts-jest": "^27.1.4",
"typedoc": "^0.23.15",
"typedoc-plugin-missing-exports": "^0.23.0",
"typescript": "~4.6.3"
"typescript": "~4.8.4"
},
"peerDependencies": {
"@metamask/approval-controller": "^3.5.1"
Expand Down
2 changes: 1 addition & 1 deletion packages/phishing-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"ts-jest": "^27.1.4",
"typedoc": "^0.23.15",
"typedoc-plugin-missing-exports": "^0.23.0",
"typescript": "~4.6.3"
"typescript": "~4.8.4"
},
"engines": {
"node": ">=16.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/polling-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"ts-jest": "^27.1.4",
"typedoc": "^0.23.15",
"typedoc-plugin-missing-exports": "^0.23.0",
"typescript": "~4.6.3"
"typescript": "~4.8.4"
},
"peerDependencies": {
"@metamask/network-controller": "^13.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/preferences-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"ts-jest": "^27.1.4",
"typedoc": "^0.23.15",
"typedoc-plugin-missing-exports": "^0.23.0",
"typescript": "~4.6.3"
"typescript": "~4.8.4"
},
"engines": {
"node": ">=16.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/rate-limit-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"ts-jest": "^27.1.4",
"typedoc": "^0.23.15",
"typedoc-plugin-missing-exports": "^0.23.0",
"typescript": "~4.6.3"
"typescript": "~4.8.4"
},
"engines": {
"node": ">=16.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/selected-network-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"ts-jest": "^27.1.4",
"typedoc": "^0.23.15",
"typedoc-plugin-missing-exports": "^0.23.0",
"typescript": "~4.6.3"
"typescript": "~4.8.4"
},
"peerDependencies": {
"@metamask/network-controller": "^13.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/signature-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"ts-jest": "^27.1.4",
"typedoc": "^0.23.15",
"typedoc-plugin-missing-exports": "^0.23.0",
"typescript": "~4.6.3"
"typescript": "~4.8.4"
},
"peerDependencies": {
"@metamask/approval-controller": "^3.5.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/transaction-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"ts-jest": "^27.1.4",
"typedoc": "^0.23.15",
"typedoc-plugin-missing-exports": "^0.23.0",
"typescript": "~4.6.3"
"typescript": "~4.8.4"
},
"peerDependencies": {
"@metamask/approval-controller": "^3.5.1",
Expand Down
Loading

0 comments on commit b3eaf2d

Please sign in to comment.