ava icon indicating copy to clipboard operation
ava copied to clipboard

Provide type definitions for the JS configuration files.

Open binyamin opened this issue 3 years ago • 3 comments

Continuing https://github.com/avajs/typescript/issues/15#issuecomment-1140477835 cc @novemberborn


Summary

When a user configures AVA with JavaScript, it would be useful to have type definition. Users might consume these through JSDoc comments, or through a typed wrapper function.

Details

A wrapper function would be defined like this:

/**
 *
 * Configure AVA, with intellisense
 *
 * @param {Config} config - A configuration object
 * @returns {Config}
 */
export const defineConfig = (config) => config;

The function would be used like this:

import { defineConfig } from 'ava/config';

export default defineConfig({
  // ...
})

binyamin avatar Jun 02 '22 15:06 binyamin

We could then also export the Config type from ava/config. I think we should export it through the export map, see #3041. That makes it require TypeScript 4.7 but that's fine for a new feature.

We'd need a way to type the factory methods also.

I'm happy to start with something small and then improve it in subsequent releases.

Would config or define be slightly nicer? Sorry, just bike-shedding 😇

novemberborn avatar Jun 02 '22 15:06 novemberborn

@novemberborn No preference.

binyamin avatar Jun 19 '22 23:06 binyamin

Yea I don't know either. Up to whomever submits the PR I guess!

novemberborn avatar Jun 23 '22 15:06 novemberborn