GithubHelp home page GithubHelp logo

Add types to package.json export about use-debounce HOT 3 CLOSED

 avatar commented on June 9, 2024
Add types to package.json export

from use-debounce.

Comments (3)

xnimorz avatar xnimorz commented on June 9, 2024

Hey @edu-bound
I'm sorry but I'm not sure I clearly understand the issue, may I ask for some examples, please?

from use-debounce.

 avatar commented on June 9, 2024

Sure. In package.json, the exports field is as follows,

{
  "exports": {
    "./package.json": "./package.json",
    ".": {
      "import": "./esm/index.js",
      "require": "./lib/index.js"
    }
  }
}

Some tools recoginze the exports field and change their behavior based on its value. An example of such a tool is the ESLint plugin eslint-plugin-import-alias.

When a type not declared in the exports field is imported it, understandably, throws the following error,

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/useDebouncedCallback' is not defined by "exports" in /home/aryzing/workspace/project/node_modules/use-debounce/package.json

Therefore the ask is to please include useful types (in particular the one I'm after is DebouncedState<T>) in the exports fields. To TS consumers, it makes sense to have them as part of the package's exposed API.

Eg, with the current structure of the published package,

{
  "exports": {
    "./package.json": "./package.json",
    ".": {
      "import": "./esm/index.js",
      "require": "./lib/index.js"
    },
    "./esm/useDebouncedCallback": {
      "import": "./esm/useDebouncedCallback.d.ts"
    }
  },
}

from use-debounce.

xnimorz avatar xnimorz commented on June 9, 2024

got it, please, feel free to make a PR

from use-debounce.

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.