Comparing version 1.0.1 to 1.1.0
@@ -70,2 +70,8 @@ import { assertNotAny, assertType } from "@valu/assert"; | ||
test("can create env", () => { | ||
const env = new TypedEnv<"FOO" | "BAR">({}); | ||
const values = env.createEnv({ BAR: "value" }); | ||
expect(values).toEqual({ BAR: "value" }); | ||
}); | ||
() => { | ||
@@ -105,1 +111,21 @@ const env = new TypedEnv<"FOO">({}); | ||
}; | ||
() => { | ||
// create env | ||
const env = new TypedEnv<"FOO" | "BAR">({}); | ||
const values = env.createEnv({ BAR: "value" }); | ||
const s: string = values.BAR; | ||
assertNotAny(values.BAR); | ||
// @ts-expect-error | ||
values.bad; | ||
// @ts-expect-error | ||
values.FOO; | ||
// @ts-expect-error | ||
env.createEnv({ bad: "value" }); | ||
}; |
@@ -0,1 +1,7 @@ | ||
## v1.1.0 | ||
2022-06-20 | ||
- Add .createEnv() [7d160af](https://github.com/valu-digital/npm-packages/commit/7d160af) - Esa-Matti Suuronen | ||
## v1.0.1 | ||
@@ -2,0 +8,0 @@ |
@@ -8,3 +8,8 @@ export declare class TypedEnv<EnvKey extends string = ""> { | ||
delete(key: EnvKey): void; | ||
createEnv<Subset extends EnvKey>(env: { | ||
[P in Subset]?: string; | ||
}): { | ||
[P in Subset]: string; | ||
}; | ||
} | ||
//# sourceMappingURL=index.d.ts.map |
@@ -29,4 +29,7 @@ "use strict"; | ||
} | ||
createEnv(env) { | ||
return env; | ||
} | ||
} | ||
exports.TypedEnv = TypedEnv; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@valu/env", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -37,2 +37,8 @@ export class TypedEnv<EnvKey extends string = ""> { | ||
} | ||
createEnv<Subset extends EnvKey>(env: { [P in Subset]?: string }): { | ||
[P in Subset]: string; | ||
} { | ||
return env as any; | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9705
208