Skip to content

Commit 98d77d2

Browse files
committed
perf: prefer interface over type alias
1 parent 2925003 commit 98d77d2

47 files changed

Lines changed: 176 additions & 155 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.changeset/young-ends-grow.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
"@reactive-dot/wallet-polkadot-vault": patch
3+
"@reactive-dot/wallet-readonly": patch
4+
"@reactive-dot/wallet-ledger": patch
5+
"@reactive-dot/wallet-mimir": patch
6+
"@reactive-dot/react": patch
7+
"@reactive-dot/core": patch
8+
"@reactive-dot/vue": patch
9+
---
10+
11+
Prefer `interface` over `type` alias for object types and use `extends` instead of intersection types (`&`), yielding better TypeScript type-checking performance and more consistent error messages.
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
{
2-
"name": "@polkadot-api/descriptors",
32
"version": "0.1.0-autogenerated.12798067100670306101",
3+
"name": "@polkadot-api/descriptors",
44
"files": [
55
"dist"
66
],
77
"type": "module",
8-
"sideEffects": false,
9-
"main": "./dist/index.js",
10-
"module": "./dist/index.js",
11-
"browser": "./dist/index.js",
12-
"types": "./dist/index.d.ts",
138
"exports": {
149
".": {
1510
"types": "./dist/index.d.ts",
@@ -19,7 +14,12 @@
1914
},
2015
"./package.json": "./package.json"
2116
},
17+
"main": "./dist/index.js",
18+
"module": "./dist/index.js",
19+
"browser": "./dist/index.js",
20+
"types": "./dist/index.d.ts",
21+
"sideEffects": false,
2222
"peerDependencies": {
23-
"polkadot-api": ">=2.0.1"
23+
"polkadot-api": ">=2.0.0"
2424
}
2525
}

examples/react/src/account-select.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import type { WalletAccount } from "@reactive-dot/core/wallets.js";
22
import { useConnectedWallets, useAccounts } from "@reactive-dot/react";
33
import { type ReactNode, useState } from "react";
44

5-
type AccountSelectProps = {
5+
interface AccountSelectProps {
66
children: (account: WalletAccount) => ReactNode;
7-
};
7+
}
88

99
export function AccountSelect({ children }: AccountSelectProps) {
1010
const connectedWallets = useConnectedWallets();

examples/react/src/app.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ export function App() {
5050
);
5151
}
5252

53-
type ExampleProps = { chainName: string };
53+
interface ExampleProps {
54+
chainName: string;
55+
}
5456

5557
function Example({ chainName }: ExampleProps) {
5658
const resetQueryError = useQueryErrorResetter();

examples/react/src/ink-contract.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ export function InkContracts() {
1717
);
1818
}
1919

20-
type ContractProps = {
20+
interface ContractProps {
2121
address: string;
22-
};
22+
}
2323

2424
function Psp22TokenInfo({ address }: ContractProps) {
2525
const [timestamp, [tokenName, tokenDecimals, tokenSymbol, totalSupply]] = useLazyLoadQuery(

examples/react/src/query.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@ function SpendableBalances() {
121121
);
122122
}
123123

124-
type SpendableBalanceProps = {
124+
interface SpendableBalanceProps {
125125
account: PolkadotAccount;
126-
};
126+
}
127127

128128
function SpendableBalance({ account }: SpendableBalanceProps) {
129129
return (
@@ -180,10 +180,10 @@ function PendingPoolRewards() {
180180
);
181181
}
182182

183-
type PendingRewardsProps = {
183+
interface PendingRewardsProps {
184184
account: PolkadotAccount;
185185
rewards: bigint;
186-
};
186+
}
187187

188188
function PendingRewards({ account, rewards }: PendingRewardsProps) {
189189
return (

examples/react/src/wallet-connection.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ export function WalletConnection() {
2727
);
2828
}
2929

30-
type WalletItemProps = {
30+
interface WalletItemProps {
3131
wallet: Wallet;
32-
};
32+
}
3333

3434
function WalletItem({ wallet }: WalletItemProps) {
3535
const connectedWallets = useConnectedWallets();
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
{
2-
"name": "@polkadot-api/descriptors",
32
"version": "0.1.0-autogenerated.12798067100670306101",
3+
"name": "@polkadot-api/descriptors",
44
"files": [
55
"dist"
66
],
77
"type": "module",
8-
"sideEffects": false,
9-
"main": "./dist/index.js",
10-
"module": "./dist/index.js",
11-
"browser": "./dist/index.js",
12-
"types": "./dist/index.d.ts",
138
"exports": {
149
".": {
1510
"types": "./dist/index.d.ts",
@@ -19,7 +14,12 @@
1914
},
2015
"./package.json": "./package.json"
2116
},
17+
"main": "./dist/index.js",
18+
"module": "./dist/index.js",
19+
"browser": "./dist/index.js",
20+
"types": "./dist/index.d.ts",
21+
"sideEffects": false,
2222
"peerDependencies": {
23-
"polkadot-api": ">=2.0.1"
23+
"polkadot-api": ">=2.0.0"
2424
}
2525
}

packages/core/src/actions/get-block-extrinsics.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ type Extra = Partial<{
4646
[key: string]: unknown;
4747
}>;
4848

49-
type Call = {
49+
interface Call {
5050
module: string;
5151
func: string;
5252
args: unknown;
53-
};
53+
}
5454

5555
type Extrinsic = { version: number; call: Call } & (
5656
| { signed: false }

packages/core/src/actions/get-block.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import type { PolkadotClient } from "polkadot-api";
33
import { of } from "rxjs";
44
import { expect, it } from "vitest";
55

6-
type DummyBlock = { id: string };
6+
interface DummyBlock {
7+
id: string;
8+
}
79

810
it("should return the best block when options.tag is 'best'", () =>
911
new Promise<void>((resolve) => {

0 commit comments

Comments
 (0)