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

Document createDefineConfig #84

Open
1 task done
rijkvanzanten opened this issue May 16, 2023 · 1 comment
Open
1 task done

Document createDefineConfig #84

rijkvanzanten opened this issue May 16, 2023 · 1 comment

Comments

@rijkvanzanten
Copy link
Contributor

Describe the feature

I was just about to open a feature request to suggest adding a util / type to allow the easy creation of your own defineConfig type for use with .ts files, and to my big surprise, it already exists!

c12/src/types.ts

Lines 103 to 108 in d239195

export function createDefineConfig<
T extends UserInputConfig = UserInputConfig,
MT extends ConfigLayerMeta = ConfigLayerMeta
>(): DefineConfig<T, MT> {
return (input: InputConfig<T, MT>) => input;
}

Howeverrrrrrr now I have no clue how to actually use it 👀 A starting point is by copying:

c12/test/types.ts

Lines 4 to 22 in d239195

interface MyConfig {
foo: string;
}
interface MyMeta {
metaFoo: string;
}
const defineMyConfig = createDefineConfig<MyConfig, MyMeta>();
const userConfig = defineMyConfig({
foo: "bar",
$meta: {
metaFoo: "bar",
},
$development: {
foo: "bar",
},
});

and hacking around, but that leaves me with the question: what's $meta? How is it intended to be used as opposed to "regular" options? The PR that implements it ended with a "resolved in discord discussion" which leaves me hanging 🙈

Happy to open a PR to document this in the readme once the $meta question is answered 🙂👍🏻

Additional information

  • Would you be willing to help implement this feature?
@pi0
Copy link
Member

pi0 commented Jul 6, 2023

Hi dear @rijkvanzanten sorry for answering too late. $meta is a reserved namespace intended for layer meta itself. A configuration such as a layer name, author, repo, creds, etc goes in there separating it from the standard user-intended configuration.

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

No branches or pull requests

2 participants