Socket
Socket
Sign inDemoInstall

@types/hoist-non-react-statics

Package Overview
Dependencies
5
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/hoist-non-react-statics

TypeScript definitions for hoist-non-react-statics


Version published
Maintainers
1
Weekly downloads
6,499,521
decreased by-14.24%

Weekly downloads

Package description

What is @types/hoist-non-react-statics?

The @types/hoist-non-react-statics package provides TypeScript type definitions for the hoist-non-react-statics package. This is useful for TypeScript projects that use hoist-non-react-statics to copy non-react specific statics from a child component to a parent component. It helps in maintaining type safety and IntelliSense in IDEs for projects that hoist statics in React components.

What are @types/hoist-non-react-statics's main functionalities?

Type Definitions for Hoisting Statics

This code demonstrates how to use @types/hoist-non-react-statics for adding TypeScript type definitions when hoisting non-react statics from a base component to a wrapped component. It ensures that the static methods and properties are correctly typed and recognized by TypeScript.

import hoistNonReactStatics from 'hoist-non-react-statics';
import React from 'react';
class BaseComponent extends React.Component {}
class WrappedComponent extends React.Component {}
hoistNonReactStatics(WrappedComponent, BaseComponent);

Other packages similar to @types/hoist-non-react-statics

Readme

Source

Installation

npm install --save @types/hoist-non-react-statics

Summary

This package contains type definitions for hoist-non-react-statics (https://github.com/mridgway/hoist-non-react-statics#readme).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/hoist-non-react-statics.

index.d.ts

import * as React from "react";

interface REACT_STATICS {
    childContextTypes: true;
    contextType: true;
    contextTypes: true;
    defaultProps: true;
    displayName: true;
    getDefaultProps: true;
    getDerivedStateFromError: true;
    getDerivedStateFromProps: true;
    mixins: true;
    propTypes: true;
    type: true;
}

interface KNOWN_STATICS {
    name: true;
    length: true;
    prototype: true;
    caller: true;
    callee: true;
    arguments: true;
    arity: true;
}

interface MEMO_STATICS {
    "$$typeof": true;
    compare: true;
    defaultProps: true;
    displayName: true;
    propTypes: true;
    type: true;
}

interface FORWARD_REF_STATICS {
    "$$typeof": true;
    render: true;
    defaultProps: true;
    displayName: true;
    propTypes: true;
}

declare namespace hoistNonReactStatics {
    type NonReactStatics<
        S extends React.ComponentType<any>,
        C extends {
            [key: string]: true;
        } = {},
    > = {
        [
            key in Exclude<
                keyof S,
                S extends React.MemoExoticComponent<any> ? keyof MEMO_STATICS | keyof C
                    : S extends React.ForwardRefExoticComponent<any> ? keyof FORWARD_REF_STATICS | keyof C
                    : keyof REACT_STATICS | keyof KNOWN_STATICS | keyof C
            >
        ]: S[key];
    };
}

declare function hoistNonReactStatics<
    T extends React.ComponentType<any>,
    S extends React.ComponentType<any>,
    C extends {
        [key: string]: true;
    } = {},
>(
    TargetComponent: T,
    SourceComponent: S,
    customStatic?: C,
): T & hoistNonReactStatics.NonReactStatics<S, C>;

export = hoistNonReactStatics;

Additional Details

Credits

These definitions were written by JounQin, and James Reggio.

FAQs

Last updated on 07 Nov 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc