c12 icon indicating copy to clipboard operation
c12 copied to clipboard

`extends` isn't typed in `createDefineConfig`

Open rijkvanzanten opened this issue 2 years ago • 1 comments
trafficstars

Environment

Node 20.2.0 c12 1.4.1

Reproduction

// my-config.mjs
import { createDefineConfig } from "c12";

export interface MyConfig {
	github: {
		token: string;
	};
}

export const defineConfig = createDefineConfig<MyConfig>();


// Elsewhere:
import { defineConfig } from './my-config.mjs';

export default defineConfig({
  extends: ['./example.ts']
});

Describe the bug

Argument of type '{ extends: string[]; github: { token: string; }; }' is not assignable to parameter of type 'InputConfig<MyConfig, ConfigLayerMeta>'.
  Object literal may only specify known properties, and 'extends' does not exist in type 'InputConfig<MyConfig, ConfigLayerMeta>'.

Additional context

The only additional types added in are the ones prefixed with $:

CleanShot 2023-05-16 at 16 57 16@2x

extends seems to be the only "system" added key that's not prefixed with $ 🤔

Logs

No response

rijkvanzanten avatar May 16 '23 21:05 rijkvanzanten

Hi dear @rijkvanzanten. I know it is a frustrating DX but an intentional behavior because essentially the extends key can be renamed to something else therefore we cannot statically add a built-in type for it. However you can both extend the defined config.

pi0 avatar Jul 06 '23 13:07 pi0