-
-
Notifications
You must be signed in to change notification settings - Fork 262
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix the
Schema.TemplateLiteral
output type when the arguments inclu… (
- Loading branch information
Showing
3 changed files
with
224 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
"effect": patch | ||
--- | ||
|
||
Fix the `Schema.TemplateLiteral` output type when the arguments include a branded type. | ||
|
||
Before | ||
|
||
```ts | ||
import { Schema } from "effect" | ||
|
||
const schema = Schema.TemplateLiteral( | ||
"a ", | ||
Schema.String.pipe(Schema.brand("MyBrand")) | ||
) | ||
|
||
// type Type = `a ${Schema.brand<typeof Schema.String, "MyBrand"> & string}` | ||
// | `a ${Schema.brand<typeof Schema.String, "MyBrand"> & number}` | ||
// | `a ${Schema.brand<typeof Schema.String, "MyBrand"> & bigint}` | ||
// | `a ${Schema.brand<...> & false}` | ||
// | `a ${Schema.brand<...> & true}` | ||
type Type = typeof schema.Type | ||
``` | ||
After | ||
```ts | ||
import { Schema } from "effect" | ||
|
||
const schema = Schema.TemplateLiteral( | ||
"a ", | ||
Schema.String.pipe(Schema.brand("MyBrand")) | ||
) | ||
|
||
// type Type = `a ${string & Brand<"MyBrand">}` | ||
type Type = typeof schema.Type | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters