Skip to content

TypeScript types definition #21

Open

Description

@ovonkahle

Using React with TypeScript (TSX) requires type definitions for node modules. Are there plans to release TypeScript definition (*.d.ts) for this module?

Activity

  1. jberube commented on Mar 19, 2018

    @jberube

    Would you accept a PR if I provide one to include the *.d.ts file in this project?

  2. pbirsinger commented on Mar 5, 2019

    @pbirsinger

    Get us out of the stone ages here!

  3. sodle commented on May 27, 2019

    @sodle

    Here's a quick and dirty set of typedefs. Enough to make VSCode stop screaming about missing types, at least.
    https://gist.github.com/sodle/1173508af207a6bc277e8f3102f823de

  4. emasys commented on Jan 23, 2020

    @emasys

    An easy fix for a CRA project using @sodle's solution.
    create a .d.ts file, then add typings below into it and restart your server.

    declare interface IScriptProps {
      attributes?: object;
      onCreate?: () => void;
      onError?: () => void;
      onLoad: () => void;
      url: string;
    }
    declare class Script {
      props: IScriptProps;
      state: any;
      context: any;
      refs: any;
      forceUpdate(callback: any): void;
      render(): any;
      setState(partialState: any, callback: any): void;
    }
    
    declare module 'react-load-script' {
      export = Script;
    }
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions