Adding type hints to Renovate config.js files

Featured image for sharing metadata for article

I'm a fan of using Renovate's config.js file format for the global self-hosting configuration.

One thing that's always caught me out, compared to the repo-level configuration, is that I don't get IDE autocomplete by default.

Today, I ended up sitting down to look at how to get it working - and turns out it was ~2 lines of code to add 🫣

(This is based on my experience using Neovim 0.11.4, and ts_ls 5.0.1)

Because it is "just" a JavaScript file, we can take advantage of JSDoc annotations on our types.

With help from GPT-4.1 (via GitHub Copilot), I managed to work out the right syntax to get this working:

/**
 * @typedef {import('renovate/dist/config/types').AllConfig} AllConfig
 */

/** @type {AllConfig} */
module.exports = {
  allowedCommands: ['*'],
  allowedEnv: ['*'],
};

This now gives you autocomplete and type hinting when you go to modify module.exports, based on Renovate's inbuilt types.

Note that you may need to npm install renovate in the directory/workspace that you're running from.

You can also see it in action in the following Asciicast:

Written by Jamie Tanna's profile image Jamie Tanna on , and last updated on .

Content for this article is shared under the terms of the Creative Commons Attribution Non Commercial Share Alike 4.0 International, and code is shared under the GNU Affero General Public License v3.0 only.

#blogumentation #renovate #neovim #javascript #typescript.

πŸ€– Content in this blog post (prose or code snippets) includes code derived from the following LLMs:

  • gpt-4.1

This post was filed under articles.

Interactions with this post

Interactions with this post

Below you can find the interactions that this page has had using WebMention.

Have you written a response to this post? Let me know the URL:

Do you not have a website set up with WebMention capabilities? You can use Comment Parade.