Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide type definitions for the JS configuration files. #3042

Open
binyamin opened this issue Jun 2, 2022 · 3 comments
Open

Provide type definitions for the JS configuration files. #3042

binyamin opened this issue Jun 2, 2022 · 3 comments

Comments

@binyamin
Copy link
Contributor

binyamin commented Jun 2, 2022

Continuing avajs/typescript#15 (comment)
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({
  // ...
})
@novemberborn
Copy link
Member

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 😇

@binyamin
Copy link
Contributor Author

@novemberborn No preference.

@novemberborn
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants