Comments (9)
SOS
from discord-api-types.
from discord-api-types.
Sike, I'm blind. I can repro, however this is not something that can be fixed without casts or typeguard methods :c
We'll probably add in more typeguards for situations like these
from discord-api-types.
You can only narrow one property at time. In the first condition of your if statement typescript sees you're trying to narrow the interaction, not the data type of that interaction, only the the first condition is taken into consideration since the other is another property.
from discord-api-types.
So how would I do it? I thought two separate if statements but that is weird and doesn't work anyway
from discord-api-types.
For now, either cast or wait till we implement typeguards 😅
from discord-api-types.
Ok.
from discord-api-types.
I was able to work around this issue by... creating my own framework based on discord-api-types that has classes around interactions with type guards lol.
I don't think there is anything possible for discord-api-types, as it's a type library, and type guards are functions that do checks at runtime, which would make interactions classes, which would take discord-api-types out of devDependencies and bloat compiled code...
So yeah, the only thing possible while keeping discord-api-types purely a typings library would be to cast. 😕
from discord-api-types.
Also interaction type guards just got merged in to 0.28.0 in utils, so I guess this is solved :)
from discord-api-types.
Related Issues (20)
- APIInteractionDataResolvedGuildMember is missing any way to identify user
- GuildFeature is not a two-way enum HOT 5
- Cannot use RESTError HOT 3
- Gateway Documentation changed HOT 1
- FormattingPatterns.SlashCommand no longer matches official documentation example HOT 2
- Interface to associate GatewayDispatchEvents and relevant DataPayload (proposed code below) HOT 5
- APIChannel types could be more "strict" HOT 1
- Documentation broken.... like litreally.... HOT 2
- GatewayDispatchPayload doesn't include GatewayGuildAuditLogEntryCreateDispatch HOT 1
- APIRole - Missing Type - APIRole["permissions_new"] HOT 3
- Make types more specific and useful for type narrowing
- importsNotUsedAsValues deprecation HOT 1
- Website not displaying `<` chars
- AutoMod Trigger Type Limit Error HOT 2
- Broken types for thread events
- Route extension typings HOT 2
- Workflow for dev releases is failing HOT 2
- Dependency Dashboard
- types masquerading as cjs HOT 1
- Action Required: Fix Renovate Configuration
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-api-types.