Skip to content

Commit

Permalink
fix(config-tools): Included types definition with package
Browse files Browse the repository at this point in the history
  • Loading branch information
sullivanpj committed Dec 4, 2023
1 parent cb3b2bf commit d4176fb
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 1 deletion.
36 changes: 36 additions & 0 deletions packages/config-tools/declarations.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import * as z from "zod";
import { StormConfigSchema } from "./src/schema";

type TStormConfig = z.infer<typeof StormConfigSchema>;

declare type StormConfig<
TExtensionName extends
keyof TStormConfig["extensions"] = keyof TStormConfig["extensions"],
TExtensionConfig extends
TStormConfig["extensions"][TExtensionName] = TStormConfig["extensions"][TExtensionName]
> = TStormConfig & {
extensions:
| (TStormConfig["extensions"] & {
[extensionName in TExtensionName]: TExtensionConfig;
})
| {};
};
export { StormConfig };

/**
* Type-check to determine if `obj` is a `StormError` object
*
* @param value - the object to check
* @returns The function isStormError is returning a boolean value.
*/
declare function createStormConfig<
TExtensionName extends
keyof StormConfig["extensions"] = keyof StormConfig["extensions"],
TExtensionConfig extends Record<string, any> = Record<string, any>,
TExtensionSchema extends
z.ZodType<TExtensionConfig> = z.ZodType<TExtensionConfig>
>(
extensionName?: TExtensionName,
schema?: TExtensionSchema
): StormConfig<TExtensionName, TExtensionConfig>;
export { createStormConfig };
1 change: 1 addition & 0 deletions packages/config-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"url": "https://github.com/storm-software/storm-ops.git",
"directory": "packages/config-tools"
},
"types": "declarations.d.ts",
"dependencies": {
"cosmiconfig": "^9.0.0",
"zod": "^3.22.4"
Expand Down
22 changes: 22 additions & 0 deletions packages/config-tools/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,28 @@
".js": ".js"
}
},
"assets": [
{
"input": "./packages/config-tools",
"glob": "*.md",
"output": "."
},
{
"input": "",
"glob": "LICENSE",
"output": "."
},
{
"input": "./packages/config-tools",
"glob": "package.json",
"output": "."
},
{
"input": "./packages/config-tools",
"glob": "declarations.d.ts",
"output": "."
}
],
"configurations": {
"production": {
"debug": false,
Expand Down
2 changes: 1 addition & 1 deletion packages/config-tools/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"noEmit": true
},
"files": [],
"include": ["src/**/*.ts", "src/**/*.js", "bin/**/*"],
"include": ["src/**/*.ts", "src/**/*.js", "bin/**/*", "declarations.d.ts"],
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"],
"composite": true
}

0 comments on commit d4176fb

Please sign in to comment.