Giter VIP home page Giter VIP logo

Comments (5)

evaera avatar evaera commented on May 27, 2024

This is a problem for me too. Did you find a solution, @Jovaage?

from discord.js-typings.

cathrinevaage avatar cathrinevaage commented on May 27, 2024

Sadly, no.

from discord.js-typings.

zajrik avatar zajrik commented on May 27, 2024

The problem here is if we change the name of the declared module, the typings no longer map to the package itself. Open up index.d.ts in the typings yourself, change it to declare module 'Discord' and try to build. You will no longer have access to the Discord.js typings and your build will throw errors.

Yes, in a TypeScript environment we would not declare namespaces in such a way, but regrettably this is not a native TypeScript project, We are providing support for a JavaScript package, and have to make certain accommodations. You are not limited in your own code by what the module is declared as.

As far as JSDoc is concerned, it has no concept of TypeScript integrations. Whatever this module is declared as has no bearing on how you choose to document things related to this package. Or at least it shouldn't. Without seeing specific examples I can't offer any advice on the matter.

from discord.js-typings.

evaera avatar evaera commented on May 27, 2024

In my case, I was using the JSDoc comments to type check normal JavaScript with the TypeScript checker, but I didn't have access to any of discord.js's types without importing them. It looks like the types that are annotated in JSDoc aren't allowed to use types that exist elsewhere in the project in TypeScript files. There's an open issue proposing a way to import types from other files in JSDoc that would fix this problem, but looks like there's no good solution right now.

After all of that nonsense, I just decided to switch my project to TypeScript and be done with it. :P

from discord.js-typings.

zajrik avatar zajrik commented on May 27, 2024

Admittedly I hadn't considered JavaScript type checking via JSDoc annotations. As an explicit TS user, I had forgotten that was a thing. But yes, our goal is to support TypeScript, and actually using TS itself is a far better choice than the JavaScript type checking, in my opinion at least. I do understand how frustrating it can be to do a full migration, though. My framework was originally in JS and it was definitely no small task to migrate fully to TS.

If you have any questions related to getting started with TS feel free to contact me on Discord.

from discord.js-typings.

Related Issues (18)

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.