Code Monkey home page Code Monkey logo

Comments (3)

d-fischer avatar d-fischer commented on June 21, 2024 2

While implementing this, I've found a few issues with passing fetch options, so I'm implementing a different solution now:

  • The internal types don't depend on the dom lib, the @types/web package or anything else anymore. Instead, the smallest common denominator was extracted into and exported from the @d-fischer/cross-fetch package.
  • If you need to pass fetch options that are specific to one platform, you can now augment the TwitchApiCallFetchOptions type (this is possible because it was changed to an interface)
  • This is a breaking change for all current users of the fetchOptions config option (but I'm pretty sure your approach would be too in some obscure way), so it will only be implemented in version 7.0.

Stay tuned for a new prerelease version within the next week.

from twurple.

d-fischer avatar d-fischer commented on June 21, 2024

As the types used are inherently global, do you have a better solution for this?

from twurple.

AdrianGonz97 avatar AdrianGonz97 commented on June 21, 2024

@d-fischer Sure! One way we can accomplish this would be to use and import the @types/web package as a replacement for the triple slash lib directive to acquire the DOM types.

I've already tested this out with Twurple and it works perfectly! It no longer overrides the types globally. You can checkout how my reproduction is no longer showing any compile errors here. Just clone and switch branches with git checkout fix/using-@types/web.

To add the package, we just run the following:

cd packages/api-call

# it's fine to add this as a devDependency
yarn add @typescript/lib-dom@npm:@types/web --dev 

We then remove the directive /// <reference lib="dom" /> from both packages/api-call/src/apiCall.ts and packages/api-call/src/TwitchApiCallOptions.ts.

Finally, we just need to import the following at the top of the file (we only need to import it once):

// packages/api-call/src/TwitchApiCallOptions.ts

import '@typescript/lib-dom';

from twurple.

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.