🚀
DNSControl
🚀
DNSControl
  • Introduction to DNSControl
  • Getting Started
    • Overview
    • Examples
    • Migrating zones to DNSControl
    • TypeScript autocomplete and type checking
  • Language Reference
    • JavaScript DSL
    • Top Level Functions
      • D
      • DEFAULTS
      • DOMAIN_ELSEWHERE
      • DOMAIN_ELSEWHERE_AUTO
      • D_EXTEND
      • FETCH
      • HASH
      • IP
      • NewDnsProvider
      • NewRegistrar
      • PANIC
      • REV
      • REVCOMPAT
      • getConfiguredDomains
      • require
      • require_glob
    • Domain Modifiers
      • A
      • AAAA
      • ALIAS
      • AUTODNSSEC_OFF
      • AUTODNSSEC_ON
      • CAA
      • CAA_BUILDER
      • CNAME
      • DHCID
      • DNAME
      • DNSKEY
      • DISABLE_IGNORE_SAFETY_CHECK
      • DMARC_BUILDER
      • DS
      • DefaultTTL
      • DnsProvider
      • FRAME
      • HTTPS
      • IGNORE
      • IGNORE_NAME
      • IGNORE_TARGET
      • IMPORT_TRANSFORM
      • IMPORT_TRANSFORM_STRIP
      • INCLUDE
      • LOC
      • LOC_BUILDER_DD
      • LOC_BUILDER_DMM_STR
      • LOC_BUILDER_DMS_STR
      • LOC_BUILDER_STR
      • M365_BUILDER
      • MX
      • NAMESERVER
      • NAMESERVER_TTL
      • NAPTR
      • NO_PURGE
      • NS
      • PTR
      • PURGE
      • SOA
      • SPF_BUILDER
      • SRV
      • SSHFP
      • SVCB
      • TLSA
      • TXT
      • URL
      • URL301
      • Service Provider specific
        • Akamai Edge Dns
          • AKAMAICDN
        • Amazon Route 53
          • R53_ALIAS
        • Azure DNS
          • AZURE_ALIAS
        • Cloudflare DNS
          • CF_REDIRECT
          • CF_SINGLE_REDIRECT
          • CF_TEMP_REDIRECT
          • CF_WORKER_ROUTE
        • ClouDNS
          • CLOUDNS_WR
    • Record Modifiers
      • TTL
      • Service Provider specific
        • Amazon Route 53
          • R53_ZONE
          • R53_EVALUATE_TARGET_HEALTH
    • Why CNAME/MX/NS targets require a "dot"
  • Provider
    • Supported providers
    • Akamai Edge DNS
    • Amazon Route 53
    • AutoDNS
    • AXFR+DDNS
    • Azure DNS
    • Azure Private DNS
    • BIND
    • Bunny DNS
    • CentralNic Reseller (CNR) - formerly RRPProxy
    • Cloudflare
    • ClouDNS
    • CSC Global
    • deSEC
    • DigitalOcean
    • DNS Made Easy
    • DNSimple
    • DNS-over-HTTPS
    • DOMAINNAMESHOP
    • Dynadot
    • easyname
    • Exoscale
    • Gandi_v5
    • Gcore
    • Google Cloud DNS
    • Hetzner DNS Console
    • HEXONET
    • hosting.de
    • Huawei Cloud DNS
    • Hurricane Electric DNS
    • Internet.bs
    • INWX
    • Linode
    • Loopia
    • LuaDNS
    • Microsoft DNS Server on Microsoft Windows Server
    • Mythic Beasts
    • Namecheap
    • Name.com
    • Netcup
    • Netlify
    • NS1
    • OpenSRS
    • Oracle Cloud
    • OVH
    • Packetframe
    • Porkbun
    • PowerDNS
    • Realtime Register
    • RWTH DNS-Admin
    • Sakura Cloud
    • SoftLayer DNS
    • TransIP
    • Vultr
  • Commands
    • preview/push
    • check-creds
    • get-zones
    • get-certs
    • fmt
    • creds.json
    • Global Flag
    • Disabling Colors
  • Advanced features
    • CI/CD example for GitLab
    • CLI variables
    • Nameservers and Delegations
    • Notifications
    • Useful code tricks
    • JSON Reports
  • Developer info
    • Code Style Guide
    • Documentation Style Guide
    • DNSControl is an opinionated system
    • Writing new DNS providers
    • Creating new DNS Resource Types (rtypes)
    • Integration Tests
    • Test a branch
    • Unit Testing DNS Data
    • Bug Triage Process
    • Bring-Your-Own-Secrets for automated testing
    • Debugging with dlv
    • ALIAS Records
    • TXT record testing
    • DNS records ordering
  • Release
    • How to build and ship a release
    • Changelog v3.16.0
    • GitHub releases
Powered by GitBook
On this page
  • What is this?
  • How to activate auto-completion
  • Bugs?
  • Known bugs/issue
  • Bug: CLI_DEFAULTS not implemented
  • Known issue: FETCH not always accurate
Edit on GitHub
  1. Getting Started

TypeScript autocomplete and type checking

What is this?

Would you like your editor to support auto-completion and other advanced IDE features when editing dnsconfig.js? Yes you can!

While DNSControl does not support TypeScript syntax in dnsconfig.js, you can still use TypeScript’s features in editors which support it.

If you’re using Visual Studio Code (or another editor that supports TypeScript), you should now be able to see the type information in your dnsconfig.js file as you type. Hover over record names to read their documentation without having to open the documentation website!

How to activate auto-completion

To set up TypeScript support in Visual Studio Code, follow these steps:

  1. Run this command to generate the file types-dnscontrol.d.ts.

dnscontrol write-types

This file has all the information your editor or IDE needs. It must be in the same directory as the dnsconfig.js file you are editing.

NOTE: Re-run the dnscontrol write-types command any time you upgrade DNSControl. Because it is generated from the command, it will always be correct for the version of DNSControl you are using.

  1. Tell your editor

At this point some features (autocomplete) will work. However to get the full experience, including type checking (i.e. red squiggly underlines when you misuse APIs), there is one more step.

Add these comments to the top of your dnsconfig.js file:

dnsconfig.js
// @ts-check
/// <reference path="types-dnscontrol.d.ts" />

That should be all you need to do!

Bugs?

BUGS: Not all features of DNSControl work perfectly at the moment. Please report bugs and feature requests on https://github.com/StackExchange/dnscontrol/issues

NOTE: This feature is currently experimental. We might change the installation instructions as we find better ways to enable this.

Known bugs/issue

Bug: CLI_DEFAULTS not implemented

Values passed to CLI_DEFAULTS (and the corresponding -v command-line option) don’t show up as global variables

Workaround: create a new .d.ts file in the same folder as your dnsconfig.js file. In that file, add the following line for each variable you want to use (replacing VARIABLE_NAME with the name of the variable).

.d.ts
declare const VARIABLE_NAME: string;

This will tell TypeScript that the variable exists, and that it’s a string.

Known issue: FETCH not always accurate

FETCH is always shown as available, even if you don’t run DNSControl with the --allow-fetch flag.

PreviousMigrating zones to DNSControlNextJavaScript DSL

Last updated 1 year ago

If your editor requires extra steps, please and we'll update this page.

file a bug