core
core copied to clipboard
Enable noUncheckedIndexedAccess TypeScript flag
Adds the noUncheckedIndexedAccess TypeScript compiler flag to the repo-wide package tsconfig.json. Ref: https://github.com/MetaMask/metamask-module-template/pull/84
The following controllers must be updated to resolve issues with this rule:
- [x] AddressBookController (8914b53)
- [x] ApprovalController (8914b53)
- [x] AssetsContractController (8914b53)
- [x] BaseControllerV2 (8914b53)
- [x] PreferencesController (8914b53)
- [ ] AssetsDetectionController
- [ ] EnsController
- [ ] NotificationController
- [ ] TokenBalancesController
- [ ] TokenListController
- [ ] TokensController
- 7 violations, the second most.
- [ ] TransactionController
- 26 violations, (by far) the most.
Remaining violations as of 8914b53
src/assets/AssetsDetectionController.ts(360,23): error TS2532: Object is possibly 'undefined'.
src/assets/AssetsDetectionController.ts(361,21): error TS2532: Object is possibly 'undefined'.
src/assets/TokenBalancesController.ts(122,15): error TS2339: Property 'address' does not exist on type 'Token | undefined'.
src/assets/TokenBalancesController.ts(128,9): error TS2532: Object is possibly 'undefined'.
src/assets/TokenBalancesController.ts(131,9): error TS2532: Object is possibly 'undefined'.
src/assets/TokenListController.ts(218,15): error TS2339: Property 'erc20' does not exist on type 'StaticToken | undefined'.
src/assets/TokenListController.ts(218,22): error TS2339: Property 'logo' does not exist on type 'StaticToken | undefined'.
src/assets/TokensController.ts(314,5): error TS2532: Object is possibly 'undefined'.
src/assets/TokensController.ts(439,15): error TS2532: Object is possibly 'undefined'.
src/assets/TokensController.ts(441,56): error TS2532: Object is possibly 'undefined'.
src/assets/TokensController.ts(443,11): error TS2532: Object is possibly 'undefined'.
src/assets/TokensController.ts(445,16): error TS2532: Object is possibly 'undefined'.
src/assets/TokensController.ts(451,30): error TS2532: Object is possibly 'undefined'.
src/assets/TokensController.ts(455,31): error TS2345: Argument of type 'SuggestedAssetMeta | undefined' is not assignable to parameter of type 'SuggestedAssetMeta'.
Type 'undefined' is not assignable to type 'SuggestedAssetMeta'.
src/notification/NotificationController.ts(81,9): error TS2322: Type 'StateNotification | undefined' is not assignable to type 'StateNotification'.
Type 'undefined' is not assignable to type 'StateNotification'.
src/notification/NotificationController.ts(104,7): error TS2532: Object is possibly 'undefined'.
src/notification/NotificationController.ts(104,7): error TS2322: Type 'boolean | undefined' is not assignable to type 'boolean'.
Type 'undefined' is not assignable to type 'boolean'.
src/third-party/EnsController.ts(78,8): error TS2532: Object is possibly 'undefined'.
src/third-party/EnsController.ts(84,12): error TS2532: Object is possibly 'undefined'.
src/third-party/EnsController.ts(86,21): error TS2769: No overload matches this call.
Overload 1 of 2, '(o: {}): string[]', gave the following error.
Argument of type '{ [ensName: string]: EnsEntry; } | undefined' is not assignable to parameter of type '{}'.
Type 'undefined' is not assignable to type '{}'.
Overload 2 of 2, '(o: object): string[]', gave the following error.
Argument of type '{ [ensName: string]: EnsEntry; } | undefined' is not assignable to parameter of type 'object'.
Type 'undefined' is not assignable to type 'object'.
src/third-party/EnsController.ts(108,9): error TS2532: Object is possibly 'undefined'.
src/third-party/EnsController.ts(145,7): error TS2532: Object is possibly 'undefined'.
src/transaction/TransactionController.ts(459,9): error TS2322: Type 'MethodData | undefined' is not assignable to type 'MethodData'.
Type 'undefined' is not assignable to type 'MethodData'.
src/transaction/TransactionController.ts(600,23): error TS2532: Object is possibly 'undefined'.
src/transaction/TransactionController.ts(603,24): error TS2532: Object is possibly 'undefined'.
src/transaction/TransactionController.ts(607,11): error TS2345: Argument of type 'TransactionMeta | undefined' is not assignable to parameter of type 'TransactionMeta'.
Type 'undefined' is not assignable to type 'TransactionMeta'.
src/transaction/TransactionController.ts(613,30): error TS2345: Argument of type 'TransactionMeta | undefined' is not assignable to parameter of type 'TransactionMeta'.
src/transaction/TransactionController.ts(624,7): error TS2532: Object is possibly 'undefined'.
src/transaction/TransactionController.ts(625,7): error TS2532: Object is possibly 'undefined'.
src/transaction/TransactionController.ts(626,7): error TS2532: Object is possibly 'undefined'.
src/transaction/TransactionController.ts(629,12): error TS2532: Object is possibly 'undefined'.
src/transaction/TransactionController.ts(630,19): error TS2532: Object is possibly 'undefined'.
src/transaction/TransactionController.ts(636,46): error TS2532: Object is possibly 'undefined'.
src/transaction/TransactionController.ts(641,27): error TS2532: Object is possibly 'undefined'.
src/transaction/TransactionController.ts(643,15): error TS2532: Object is possibly 'undefined'.
src/transaction/TransactionController.ts(644,31): error TS2532: Object is possibly 'undefined'.
src/transaction/TransactionController.ts(657,7): error TS2532: Object is possibly 'undefined'.
src/transaction/TransactionController.ts(658,30): error TS2345: Argument of type 'TransactionMeta | undefined' is not assignable to parameter of type 'TransactionMeta'.
src/transaction/TransactionController.ts(661,7): error TS2532: Object is possibly 'undefined'.
src/transaction/TransactionController.ts(662,30): error TS2345: Argument of type 'TransactionMeta | undefined' is not assignable to parameter of type 'TransactionMeta'.
src/transaction/TransactionController.ts(666,7): error TS2532: Object is possibly 'undefined'.
src/transaction/TransactionController.ts(667,7): error TS2532: Object is possibly 'undefined'.
src/transaction/TransactionController.ts(668,30): error TS2345: Argument of type 'TransactionMeta | undefined' is not assignable to parameter of type 'TransactionMeta'.
src/transaction/TransactionController.ts(669,24): error TS2532: Object is possibly 'undefined'.
src/transaction/TransactionController.ts(671,28): error TS2345: Argument of type 'TransactionMeta | undefined' is not assignable to parameter of type 'TransactionMeta'.
src/transaction/TransactionController.ts(952,15): error TS2532: Object is possibly 'undefined'.
src/transaction/TransactionController.ts(1034,27): error TS2532: Object is possibly 'undefined'.
src/transaction/TransactionController.ts(1038,32): error TS2532: Object is possibly 'undefined'.