Skip to content

Generate TypeScript typings for functions supplied to dnsconfig.js#1830

Merged
tlimoncelli merged 47 commits into
DNSControl:masterfrom
j-f1:generate-ts
Jan 12, 2023
Merged

Generate TypeScript typings for functions supplied to dnsconfig.js#1830
tlimoncelli merged 47 commits into
DNSControl:masterfrom
j-f1:generate-ts

Conversation

@j-f1
Copy link
Copy Markdown
Contributor

@j-f1 j-f1 commented Nov 29, 2022

A .d.ts file with full documentation is now generated from existing docs files (with a few manual additions). If placed next to a dnsconfig.js file, supporting editors (VS Code but also others as well) will have a significantly improved DX.

I’m marking this as WIP because I need to do a bunch more, but I’m very interested in feedback!

  • find a better front matter parsing library (the current one behaves strangely when --- appears later on in the document)
  • manually review the generated typings for inaccuracies when compared with the prose docs
  • Fix typings for FETCH (currently it uses fetch’s typings which are only available to TS code that enables the DOM library)
  • come up with a way to ship the generated file
    • one option would be to bundle it with the program (ensuring that it always provides the correct typings that correspond to the available functionality) via a new command that spits out a dnscontrol.d.ts file into the current directory
    • another would be to host the files somewhere (maybe check the generated types.d.ts file into Git so that it can be fetched from the current release’s tag?)
    • maybe add a way to generate a suitable jsconfig.json to configure TypeScript in editors?
  • Figure out if there’s a way to make CLI_DEFAULTS cause the names it’s passed to show up as variables (Result: Probably not)
  • Docs: How to add new record types and get correct TS typings
  • Docs: How to use TS with DNSControl

Documentation is shown inline:
Screenshot_2022-11-29 15 37 36

Autocomplete shows all available record types:
Screenshot_2022-11-29 15 39 40

@j-f1 j-f1 marked this pull request as draft November 29, 2022 21:05
Copy link
Copy Markdown
Contributor

@tlimoncelli tlimoncelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Holy cow! I didn't even know that kind of thing was possible!

This is awesome! Yes, please and thank you!

@j-f1
Copy link
Copy Markdown
Contributor Author

j-f1 commented Dec 2, 2022

Some questions (actually 1 question) based on my reading through the docs:

  • For SSHFP, arę the reserved “0” algorithm/type supported as values? Or should it just be 1/2/3 allowed as parameters? (also, it would be a neat addition to support the string values like "DSA" too)

@tlimoncelli
Copy link
Copy Markdown
Contributor

Some questions (actually 1 question) based on my reading through the docs:

  • For SSHFP, arę the reserved “0” algorithm/type supported as values? Or should it just be 1/2/3 allowed as parameters? (also, it would be a neat addition to support the string values like "DSA" too)

According to the source of all knowledge 0 is reserved. I guess we could play it safe and permit it. Though, the world won't end if we guess wrong as I don't think many people use SSHFP ;-)

Tom

@j-f1
Copy link
Copy Markdown
Contributor Author

j-f1 commented Dec 2, 2022

Ok, I think this is ready for review! I’ve added a dnscontrol types command that downloads the version of the .d.ts file corresponding to the current build of dnscontrol from GitHub. I definitely want to add some more documentation but before I do that I want to make sure this is a good approach. (I’d also love any feedback on the code since this is my first time writing Go!)

@j-f1 j-f1 marked this pull request as ready for review December 2, 2022 15:37
cafferata added a commit to cafferata/dnscontrol that referenced this pull request Jan 14, 2023
cafferata added a commit to cafferata/dnscontrol that referenced this pull request Jan 14, 2023
cafferata added a commit to cafferata/dnscontrol that referenced this pull request Jan 14, 2023
cafferata added a commit to cafferata/dnscontrol that referenced this pull request Jan 14, 2023
cafferata added a commit to cafferata/dnscontrol that referenced this pull request Jan 14, 2023
cafferata added a commit to cafferata/dnscontrol that referenced this pull request Jan 14, 2023
cafferata added a commit to cafferata/dnscontrol that referenced this pull request Jan 14, 2023
cafferata added a commit to cafferata/dnscontrol that referenced this pull request Jan 14, 2023
cafferata added a commit to cafferata/dnscontrol that referenced this pull request Jan 14, 2023
cafferata added a commit to cafferata/dnscontrol that referenced this pull request Jan 14, 2023
cafferata added a commit to cafferata/dnscontrol that referenced this pull request Jan 14, 2023
cafferata added a commit to cafferata/dnscontrol that referenced this pull request Jan 14, 2023
cafferata added a commit to cafferata/dnscontrol that referenced this pull request Jan 14, 2023
cafferata added a commit to cafferata/dnscontrol that referenced this pull request Jan 14, 2023
cafferata added a commit to cafferata/dnscontrol that referenced this pull request Jan 14, 2023
cafferata added a commit to cafferata/dnscontrol that referenced this pull request Jan 14, 2023
cafferata added a commit to cafferata/dnscontrol that referenced this pull request Jan 14, 2023
cafferata added a commit to cafferata/dnscontrol that referenced this pull request Jan 14, 2023
cafferata added a commit to cafferata/dnscontrol that referenced this pull request Jan 14, 2023
cafferata added a commit to cafferata/dnscontrol that referenced this pull request Jan 14, 2023
cafferata added a commit to cafferata/dnscontrol that referenced this pull request Jan 14, 2023
cafferata added a commit to cafferata/dnscontrol that referenced this pull request Jan 16, 2023
cafferata added a commit to cafferata/dnscontrol that referenced this pull request Jan 16, 2023
cafferata added a commit to cafferata/dnscontrol that referenced this pull request Jan 16, 2023
cafferata added a commit to cafferata/dnscontrol that referenced this pull request Jan 16, 2023
cafferata added a commit to cafferata/dnscontrol that referenced this pull request Jan 16, 2023
cafferata added a commit to cafferata/dnscontrol that referenced this pull request Jan 16, 2023
cafferata added a commit to cafferata/dnscontrol that referenced this pull request Jan 16, 2023
cafferata added a commit to cafferata/dnscontrol that referenced this pull request Jan 16, 2023
cafferata added a commit to cafferata/dnscontrol that referenced this pull request Jan 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants