GithubHelp home page GithubHelp logo

Add type declarations about gatsby-plugin-intl HOT 3 OPEN

wiziple avatar wiziple commented on May 10, 2024 9
Add type declarations

from gatsby-plugin-intl.

Comments (3)

artemtam avatar artemtam commented on May 10, 2024 1

Covers everything except deprecated withIntl:

declare module 'gatsby-plugin-intl' {
    import * as gatsby from 'gatsby';
    import React from 'react';

    export * from 'react-intl';

    export class Link<TState> extends gatsby.Link<TState> {}
    export const navigate: typeof gatsby.navigate;
    export const changeLocale: (language: string, to?: string) => void;
    export const IntlContextProvider: React.Provider;
    export const IntlContextConsumer: React.Consumer;
}

Makes sense to add this to the project, so we don't need to implement dirty hacks.

from gatsby-plugin-intl.

BertrandFritsch avatar BertrandFritsch commented on May 10, 2024 1

With that file definition, I get an error stating that React.Provider and React.Consumer require one type argument, which is the type of the value.

11:37 Generic type 'Consumer' requires 1 type argument(s).
     9 |   export const changeLocale: (language: string, to?: string) => void;
    10 |   export const IntlContextProvider: React.Provider;
  > 11 |   export const IntlContextConsumer: React.Consumer;
       |                                     ^
    12 | }

from gatsby-plugin-intl.

joernb avatar joernb commented on May 10, 2024

Here is a quick and dirty workaround for a .d.ts file. However, it is incomplete and does not cover everything, that is exported from index.js:

declare module "gatsby-plugin-intl" {
  import * as gatsby from "gatsby";
  export class Link<TState> extends gatsby.Link<TState> {}
  export const navigate: typeof gatsby.navigate;
  export const changeLocale: (language: string, to?: string) => void;
}

from gatsby-plugin-intl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.