ava
ava copied to clipboard
Provide type definitions for the JS configuration files.
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({
// ...
})
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 No preference.
Yea I don't know either. Up to whomever submits the PR I guess!