GithubHelp home page GithubHelp logo

question[TypeScript] How should AggregateError be imported as type when using TypeScript without esModuleInterop option about aggregate-error HOT 5 CLOSED

sindresorhus avatar sindresorhus commented on September 1, 2024
question[TypeScript] How should AggregateError be imported as type when using TypeScript without esModuleInterop option

from aggregate-error.

Comments (5)

gr2m avatar gr2m commented on September 1, 2024 2

Update: I've found sindresorhus/memoize#31 (comment) (thanks @smockle)

from aggregate-error.

sindresorhus avatar sindresorhus commented on September 1, 2024 1

This is not the place to ask for general TypeScript support.

from aggregate-error.

oscard0m avatar oscard0m commented on September 1, 2024 1

Considering the way this library is exposing AggregateError, Is there a way to import AggregateError in a ESModule way as Typescript type (so, no const AggreagateError = require('aggregate-error') and without enabling esModuleInterop option?

I don't think that's possible, no. That is indeed a weird limitation though. I would have expected import type AggreagateError = require('aggregate-error') to work. I would bring this up with the TS team.

You are totally right. Sorry for "spamming" issues here. I will address this question to the proper TypeScript channel.

Thanks for your attention and support ❤️

from aggregate-error.

sindresorhus avatar sindresorhus commented on September 1, 2024

Considering the way this library is exposing AggregateError, Is there a way to import AggregateError in a ESModule way as Typescript type (so, no const AggreagateError = require('aggregate-error') and without enabling esModuleInterop option?

I don't think that's possible, no. That is indeed a weird limitation though. I would have expected import type AggreagateError = require('aggregate-error') to work. I would bring this up with the TS team.

from aggregate-error.

gr2m avatar gr2m commented on September 1, 2024

@sindresorhus the current CommonJS-style export makes aggregate-error hard to consume for ES Module-style libraries such as all the @octokit/* modules. Every consumer of e.g. @octokit/webhooks will have to add skipLibCheck: true to their TSConfig settings, there is nothing on our side that we can do.

A workaround was kindly suggested by @smockle via https://github.com/smockle/aggregate-error-test/: but it requires us to override aggregate-error's type definitions, which puts the burden on us to keep it up-to-date with the implementation.

I understand the change was done here: #9 which I think references sindresorhus/p-cancelable#19, but I don't see the reason why you decided to make that change? Is there a discussion somewhere that I can learn more about your reasoning?

from aggregate-error.

Related Issues (11)

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.