Skip to content

Commit

Permalink
Fix TS types (#1582)
Browse files Browse the repository at this point in the history
* fix: resolve type errors that occur when strict is true in ts compiler options

* fix: fix renderedHtml type for react_component_hash
  • Loading branch information
kotarella1110 authored Nov 15, 2023
1 parent 99be556 commit abf403a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions node_package/src/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { ReactElement, ReactNode, Component, FunctionComponent, ComponentClass } from 'react';
import type { ReactElement, ReactNode, Component, ComponentType } from 'react';

// Don't import redux just for the type definitions
// See https://github.com/shakacode/react_on_rails/issues/1321
/* eslint-disable @typescript-eslint/no-explicit-any */
type Store = any;

type ReactComponent = FunctionComponent | ComponentClass | string;
type ReactComponent = ComponentType<any> | string;

// Keep these in sync with method lib/react_on_rails/helper.rb#rails_context
export interface RailsContext {
Expand Down Expand Up @@ -33,7 +33,7 @@ type AuthenticityHeaders = {[id: string]: string} & {'X-CSRF-Token': string | nu
type StoreGenerator = (props: Record<string, unknown>, railsContext: RailsContext) => Store

interface ServerRenderResult {
renderedHtml?: string;
renderedHtml?: string | { componentHtml: string; [key: string]: string };
redirectLocation?: {pathname: string; search: string};
routeError?: Error;
error?: Error;
Expand All @@ -44,7 +44,7 @@ type CreateReactOutputResult = ServerRenderResult | ReactElement | Promise<strin
type RenderFunctionResult = ReactComponent | ServerRenderResult | Promise<string>;

interface RenderFunction {
(props?: Record<string, unknown>, railsContext?: RailsContext, domNodeId?: string): RenderFunctionResult;
(props?: any, railsContext?: RailsContext, domNodeId?: string): RenderFunctionResult;
// We allow specifying that the function is RenderFunction and not a React Function Component
// by setting this property
renderFunction?: boolean;
Expand Down

0 comments on commit abf403a

Please sign in to comment.