feat(cli): CLI generated types #3453
Draft
+5,950
−1,700
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pr adds the code to auto-generate the typings based on the desiredProprieties, this (will) build on the work already been done in #3255.
Currently the code has a bunch of
FIXME
,TODO
and testing stuff that I use when testing the codeTo test the code, make use you are in the
packages/discordeno
directory (there are hard-coded path at the moment) then build the source, and runnode ./bin/discordeno.js
, then in thepackages/bot/src/transformers
there will be atransformers.test.generated.ts
along side thetransformers.generated.ts
, the 2 file exist to be confronted1. The CLI builds that generated.ts file based on thepackages/discordeno/src/bin/transformers.ts
file, in there, all the transformer proprieties are present along their metadata like comment, if they are optional, etcThe generated file uses inline
import
functions to import the types from other packages, because it was simpler to codeCurrently my objective is getting something that works, then I will cleanup the generation code and provably move it to a different file rather than keeping it all in the src/bin/index.ts file
This pr also removes the
internalABC
proprieties that were in some objects, there are now "untyped" in the publicly exposed type, a user COULD override them with a customizer, so it might get reverted this changeTODO
object
not an empty interface (that equals toNonNullable<unknown>
sostring | number | object | symbol | bigint | ...
)discordeno.config.js
(or.ts
(??))src/bin/transformers.ts
file or the transformers is not miserableEverything that is marked with a
??
in the TODO means that it's not sure that it will get donecloses #3190
closes #2983
Footnotes
While eslint can be disabled with a comment, prettier can not, so each time a commit is made the
transformers.generated.ts
file gets formatted, so to compare the files and not having to clean with prettier, just run it on the other file as well ↩Currently, I have a dependency array that can be used to disable a propriety if it does not have it's dependencies, eg.
user.tag
depends onuser.username
anduser.discrminator
,interaction.reply
depends oninteraction.token
,interaction.id
andinteraction.type
↩Since Deno does not use the node_modules folder there ia the need to find another way to source generate stuff under a Deno environment ↩