Comments (5)
This is a problem for me too. Did you find a solution, @Jovaage?
from discord.js-typings.
Sadly, no.
from discord.js-typings.
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.
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.
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)
- Make node types optional HOT 3
- DMChannel.send() return type wrong? HOT 1
- Guild.member may return undefined HOT 4
- MessageOptions property 'code' should be type 'string' | 'boolean' HOT 1
- Add 'How to use' section in readme HOT 2
- Missing "Constants" export
- package.json missing name HOT 2
- Contribute to Definetely Typed HOT 3
- discord.js 11.3.0 errors HOT 3
- node_modules/discord.js/typings/index.d.ts(267,40): error TS2689: Cannot extend an interface 'Map'. Did you mean 'implements'? HOT 11
- Cannot get typings to load HOT 2
- Turn this repostory into a npm @types package. HOT 1
- MessageOptions.files should be updated HOT 1
- Use interfaces instead of type aliases HOT 2
- Missing definition for GuildMemberRoleStore#sweep HOT 1
- createMessageCollector() options should be MessageCollectorOptions instead of CollectorOptions HOT 1
- Make this a separate git repo HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from discord.js-typings.