Procházet zdrojové kódy

fix: fix deprecations and misused types

This commit fixes places where we were using deprecated APIs or misusing types
which can now be caught with our upgraded typescript parser.
Connor Prussin před 8 měsíci
rodič
revize
52fc042b11

+ 3 - 3
apps/api-reference/src/components/EvmApi/parameter.ts

@@ -13,9 +13,9 @@ export enum ParameterType {
   IntArray,
 }
 
-export const TRANSFORMS: {
-  [paramType in ParameterType]?: (value: string) => unknown;
-} = {
+export const TRANSFORMS: Partial<
+  Record<ParameterType, (value: string) => unknown>
+> = {
   [ParameterType.PriceFeedIdArray]: (value) => [value],
   [ParameterType.HexArray]: (value) => [value],
   [ParameterType.IntArray]: (value) => [value],

+ 1 - 4
apps/insights/src/omit-keys.ts

@@ -1,7 +1,4 @@
-export const omitKeys = <T extends Record<string, unknown>>(
-  obj: T,
-  keys: string[],
-) => {
+export const omitKeys = (obj: Record<string, unknown>, keys: string[]) => {
   const omitSet = new Set(keys);
   return Object.fromEntries(
     Object.entries(obj).filter(([key]) => !omitSet.has(key)),

+ 1 - 1
apps/staking/src/components/Menu/index.tsx

@@ -9,7 +9,7 @@ import {
   Popover,
   Menu as BaseMenu,
   MenuItem as BaseMenuItem,
-  Section as BaseSection,
+  MenuSection as BaseSection,
   Separator as BaseSeparator,
 } from "react-aria-components";
 

+ 3 - 3
apps/staking/tailwind.config.ts

@@ -11,9 +11,9 @@ const tailwindConfig = {
     forms,
     animate,
     reactAria,
-    tailwindPlugin(({ addVariant }) => {
-      addVariant("search-cancel", "&::-webkit-search-cancel-button");
-      addVariant("search-decoration", "&::-webkit-search-decoration");
+    tailwindPlugin((plugin) => {
+      plugin.addVariant("search-cancel", "&::-webkit-search-cancel-button");
+      plugin.addVariant("search-decoration", "&::-webkit-search-decoration");
     }),
   ],
   theme: {

+ 1 - 1
governance/pyth_staking_sdk/src/utils/position.ts

@@ -71,7 +71,7 @@ export const deserializeStakeAccountPositions = (
 ) => {
   const coder = new BorshCoder(idl);
   let i = 8; // Skip discriminator
-  const owner = new PublicKey(data.slice(i, i + 32));
+  const owner = new PublicKey(data.subarray(i, i + 32));
   const numberOfPositions = Math.floor(
     (data.length - POSITIONS_ACCOUNT_HEADER_SIZE) / POSITION_BUFFER_SIZE,
   );

+ 4 - 1
packages/component-library/src/Alert/index.stories.tsx

@@ -19,7 +19,10 @@ const meta = {
       control: "select",
       options: Object.keys(Icon),
       mapping: Object.fromEntries(
-        Object.entries(Icon).map(([key, Icon]) => [key, <Icon key={key} />]),
+        Object.entries(Icon).map(([key, Icon]) => [
+          key,
+          <Icon weights={new Map()} key={key} />,
+        ]),
       ),
       table: {
         category: "Contents",

+ 4 - 1
packages/component-library/src/Card/index.stories.tsx

@@ -41,7 +41,10 @@ const meta = {
       control: "select",
       options: Object.keys(Icon),
       mapping: Object.fromEntries(
-        Object.entries(Icon).map(([key, Icon]) => [key, <Icon key={key} />]),
+        Object.entries(Icon).map(([key, Icon]) => [
+          key,
+          <Icon weights={new Map()} key={key} />,
+        ]),
       ),
       table: {
         category: "Contents",

+ 6 - 6
packages/component-library/src/Table/index.tsx

@@ -108,25 +108,25 @@ export const Table = <T extends string>({
         {...props}
       >
         <TableHeader columns={columns} className={styles.tableHeader ?? ""}>
-          {(column: ColumnConfig<T>) => (
+          {(columnConfig: ColumnConfig<T>) => (
             <Column
               data-sticky-header={stickyHeader === undefined ? undefined : ""}
-              {...column}
-              {...cellProps(column, headerCellClassName, {
+              {...columnConfig}
+              {...cellProps(columnConfig, headerCellClassName, {
                 "--sticky-header-top":
                   typeof stickyHeader === "string" ? stickyHeader : 0,
               } as CSSProperties)}
             >
-              {({ allowsSorting, sort, sortDirection }) => (
+              {({ allowsSorting, sortDirection, ...column }) => (
                 <>
-                  <div className={styles.name}>{column.name}</div>
+                  <div className={styles.name}>{columnConfig.name}</div>
                   {allowsSorting && (
                     <Button
                       className={styles.sortButton ?? ""}
                       size="xs"
                       variant="ghost"
                       onPress={() => {
-                        sort(
+                        column.sort(
                           sortDirection === "ascending"
                             ? "descending"
                             : "ascending",

+ 1 - 4
packages/component-library/src/Virtualizer/index.tsx

@@ -1,6 +1,3 @@
 "use client";
 
-export {
-  UNSTABLE_Virtualizer as Virtualizer,
-  UNSTABLE_ListLayout as ListLayout,
-} from "react-aria-components";
+export { Virtualizer, ListLayout } from "react-aria-components";