Skip to content

Commit

Permalink
feat: add Config.Config.Success (#3047)
Browse files Browse the repository at this point in the history
  • Loading branch information
sukovanej authored and gcanti committed Jun 24, 2024
1 parent 3da1497 commit a542b00
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/lucky-poets-guess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"effect": minor
---

Add `Success` type util for `Config`.
17 changes: 16 additions & 1 deletion packages/effect/dtslint/Config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as Config from "effect/Config"
import { pipe } from "effect/Function"
import { hole, pipe } from "effect/Function"

declare const string: Config.Config<string>
declare const number: Config.Config<number>
Expand Down Expand Up @@ -45,3 +45,18 @@ Config.all(numberRecord)

// $ExpectType Config<{ [x: string]: number; }>
pipe(numberRecord, Config.all)

// -------------------------------------------------------------------------------------
// Success
// -------------------------------------------------------------------------------------

// $ExpectType string
hole<Config.Config.Success<typeof string>>()

// $ExpectType number
hole<Config.Config.Success<typeof number>>()

const object = Config.all({ a: string, b: number })

// $ExpectType { a: string; b: number; }
hole<Config.Config.Success<typeof object>>()
6 changes: 6 additions & 0 deletions packages/effect/src/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ export declare namespace Config {
}
}

/**
* @since 2.5.0
* @category models
*/
export type Success<T extends Config<any>> = [T] extends [Config<infer _A>] ? _A : never

/**
* @since 2.0.0
* @category models
Expand Down

0 comments on commit a542b00

Please sign in to comment.