effect 3.13.9 → 3.13.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Arbitrary.js +38 -22
- package/dist/cjs/Arbitrary.js.map +1 -1
- package/dist/cjs/Array.js +50 -50
- package/dist/cjs/Array.js.map +1 -1
- package/dist/cjs/Brand.js +9 -4
- package/dist/cjs/Brand.js.map +1 -1
- package/dist/cjs/Cause.js +1 -0
- package/dist/cjs/Cause.js.map +1 -1
- package/dist/cjs/Chunk.js +25 -23
- package/dist/cjs/Chunk.js.map +1 -1
- package/dist/cjs/Config.js +2 -1
- package/dist/cjs/Config.js.map +1 -1
- package/dist/cjs/Context.js +4 -4
- package/dist/cjs/Effect.js +823 -632
- package/dist/cjs/Effect.js.map +1 -1
- package/dist/cjs/Either.js +12 -12
- package/dist/cjs/Either.js.map +1 -1
- package/dist/cjs/LogLevel.js +1 -1
- package/dist/cjs/Logger.js +12 -12
- package/dist/cjs/Match.js +26 -26
- package/dist/cjs/Option.js +43 -43
- package/dist/cjs/Predicate.js +6 -2
- package/dist/cjs/Predicate.js.map +1 -1
- package/dist/cjs/Schema.js +21 -17
- package/dist/cjs/Schema.js.map +1 -1
- package/dist/cjs/SchemaAST.js +49 -25
- package/dist/cjs/SchemaAST.js.map +1 -1
- package/dist/cjs/Scope.js +2 -0
- package/dist/cjs/Scope.js.map +1 -1
- package/dist/cjs/Stream.js +93 -93
- package/dist/cjs/internal/core.js +1 -1
- package/dist/cjs/internal/core.js.map +1 -1
- package/dist/cjs/internal/schema/util.js +23 -14
- package/dist/cjs/internal/schema/util.js.map +1 -1
- package/dist/cjs/internal/version.js +1 -1
- package/dist/cjs/internal/version.js.map +1 -1
- package/dist/dts/Array.d.ts +47 -47
- package/dist/dts/Array.d.ts.map +1 -1
- package/dist/dts/Brand.d.ts +14 -6
- package/dist/dts/Brand.d.ts.map +1 -1
- package/dist/dts/Cause.d.ts +1 -0
- package/dist/dts/Cause.d.ts.map +1 -1
- package/dist/dts/Chunk.d.ts +91 -89
- package/dist/dts/Chunk.d.ts.map +1 -1
- package/dist/dts/Config.d.ts +2 -1
- package/dist/dts/Config.d.ts.map +1 -1
- package/dist/dts/Context.d.ts +4 -4
- package/dist/dts/Effect.d.ts +2107 -1621
- package/dist/dts/Effect.d.ts.map +1 -1
- package/dist/dts/Either.d.ts +33 -33
- package/dist/dts/LogLevel.d.ts +3 -3
- package/dist/dts/Logger.d.ts +16 -16
- package/dist/dts/Match.d.ts +26 -26
- package/dist/dts/Option.d.ts +84 -84
- package/dist/dts/Predicate.d.ts.map +1 -1
- package/dist/dts/Schema.d.ts +53 -21
- package/dist/dts/Schema.d.ts.map +1 -1
- package/dist/dts/SchemaAST.d.ts.map +1 -1
- package/dist/dts/Scope.d.ts +2 -0
- package/dist/dts/Scope.d.ts.map +1 -1
- package/dist/dts/Stream.d.ts +229 -229
- package/dist/esm/Arbitrary.js +38 -22
- package/dist/esm/Arbitrary.js.map +1 -1
- package/dist/esm/Array.js +50 -50
- package/dist/esm/Array.js.map +1 -1
- package/dist/esm/Brand.js +9 -4
- package/dist/esm/Brand.js.map +1 -1
- package/dist/esm/Cause.js +1 -0
- package/dist/esm/Cause.js.map +1 -1
- package/dist/esm/Chunk.js +25 -23
- package/dist/esm/Chunk.js.map +1 -1
- package/dist/esm/Config.js +2 -1
- package/dist/esm/Config.js.map +1 -1
- package/dist/esm/Context.js +4 -4
- package/dist/esm/Effect.js +845 -648
- package/dist/esm/Effect.js.map +1 -1
- package/dist/esm/Either.js +17 -17
- package/dist/esm/Either.js.map +1 -1
- package/dist/esm/LogLevel.js +1 -1
- package/dist/esm/Logger.js +12 -12
- package/dist/esm/Match.js +26 -26
- package/dist/esm/Option.js +48 -48
- package/dist/esm/Predicate.js +3 -0
- package/dist/esm/Predicate.js.map +1 -1
- package/dist/esm/Schema.js +21 -17
- package/dist/esm/Schema.js.map +1 -1
- package/dist/esm/SchemaAST.js +46 -22
- package/dist/esm/SchemaAST.js.map +1 -1
- package/dist/esm/Scope.js +2 -0
- package/dist/esm/Scope.js.map +1 -1
- package/dist/esm/Stream.js +101 -101
- package/dist/esm/internal/core.js +1 -1
- package/dist/esm/internal/core.js.map +1 -1
- package/dist/esm/internal/schema/util.js +23 -14
- package/dist/esm/internal/schema/util.js.map +1 -1
- package/dist/esm/internal/version.js +1 -1
- package/dist/esm/internal/version.js.map +1 -1
- package/package.json +1 -1
- package/src/Arbitrary.ts +39 -24
- package/src/Array.ts +116 -113
- package/src/Brand.ts +14 -6
- package/src/Cause.ts +1 -0
- package/src/Chunk.ts +97 -95
- package/src/Config.ts +2 -1
- package/src/Context.ts +4 -4
- package/src/Effect.ts +2107 -1621
- package/src/Either.ts +34 -34
- package/src/LogLevel.ts +3 -3
- package/src/Logger.ts +16 -16
- package/src/Match.ts +26 -26
- package/src/Option.ts +84 -84
- package/src/Predicate.ts +4 -0
- package/src/Schema.ts +87 -41
- package/src/SchemaAST.ts +47 -22
- package/src/Scope.ts +2 -0
- package/src/Stream.ts +229 -229
- package/src/internal/core.ts +2 -1
- package/src/internal/schema/util.ts +34 -25
- package/src/internal/version.ts +1 -1
package/src/Schema.ts
CHANGED
|
@@ -2631,14 +2631,32 @@ export const optionalWith: {
|
|
|
2631
2631
|
* @since 3.10.0
|
|
2632
2632
|
*/
|
|
2633
2633
|
export declare namespace Struct {
|
|
2634
|
+
/**
|
|
2635
|
+
* Useful for creating a type that can be used to add custom constraints to the fields of a struct.
|
|
2636
|
+
*
|
|
2637
|
+
* ```ts
|
|
2638
|
+
* import { Schema } from "effect"
|
|
2639
|
+
*
|
|
2640
|
+
* const f = <Fields extends Record<"a" | "b", Schema.Struct.Field>>(
|
|
2641
|
+
* schema: Schema.Struct<Fields>
|
|
2642
|
+
* ) => {
|
|
2643
|
+
* return schema.omit("a")
|
|
2644
|
+
* }
|
|
2645
|
+
*
|
|
2646
|
+
* // ┌─── Schema.Struct<{ b: typeof Schema.Number; }>
|
|
2647
|
+
* // ▼
|
|
2648
|
+
* const result = f(Schema.Struct({ a: Schema.String, b: Schema.Number }))
|
|
2649
|
+
* ```
|
|
2650
|
+
* @since 3.13.11
|
|
2651
|
+
*/
|
|
2652
|
+
export type Field =
|
|
2653
|
+
| Schema.All
|
|
2654
|
+
| PropertySignature.All
|
|
2655
|
+
|
|
2634
2656
|
/**
|
|
2635
2657
|
* @since 3.10.0
|
|
2636
2658
|
*/
|
|
2637
|
-
export type Fields = {
|
|
2638
|
-
readonly [x: PropertyKey]:
|
|
2639
|
-
| Schema.All
|
|
2640
|
-
| PropertySignature.All
|
|
2641
|
-
}
|
|
2659
|
+
export type Fields = { readonly [x: PropertyKey]: Field }
|
|
2642
2660
|
|
|
2643
2661
|
type OptionalEncodedPropertySignature =
|
|
2644
2662
|
| PropertySignature<PropertySignature.Token, any, PropertyKey, "?:", any, boolean, unknown>
|
|
@@ -2724,30 +2742,30 @@ export declare namespace IndexSignature {
|
|
|
2724
2742
|
*/
|
|
2725
2743
|
export type NonEmptyRecords = array_.NonEmptyReadonlyArray<Record>
|
|
2726
2744
|
|
|
2745
|
+
type MergeTuple<T extends ReadonlyArray<unknown>> = T extends readonly [infer Head, ...infer Tail] ?
|
|
2746
|
+
Head & MergeTuple<Tail>
|
|
2747
|
+
: {}
|
|
2748
|
+
|
|
2727
2749
|
/**
|
|
2728
2750
|
* @since 3.10.0
|
|
2729
2751
|
*/
|
|
2730
|
-
export type Type<
|
|
2731
|
-
Records extends IndexSignature.Records
|
|
2732
|
-
> = Types.UnionToIntersection<
|
|
2752
|
+
export type Type<Records extends IndexSignature.Records> = MergeTuple<
|
|
2733
2753
|
{
|
|
2734
|
-
[K in keyof Records]: {
|
|
2754
|
+
readonly [K in keyof Records]: {
|
|
2735
2755
|
readonly [P in Schema.Type<Records[K]["key"]>]: Schema.Type<Records[K]["value"]>
|
|
2736
2756
|
}
|
|
2737
|
-
}
|
|
2757
|
+
}
|
|
2738
2758
|
>
|
|
2739
2759
|
|
|
2740
2760
|
/**
|
|
2741
2761
|
* @since 3.10.0
|
|
2742
2762
|
*/
|
|
2743
|
-
export type Encoded<
|
|
2744
|
-
Records extends IndexSignature.Records
|
|
2745
|
-
> = Types.UnionToIntersection<
|
|
2763
|
+
export type Encoded<Records extends IndexSignature.Records> = MergeTuple<
|
|
2746
2764
|
{
|
|
2747
|
-
[K in keyof Records]: {
|
|
2765
|
+
readonly [K in keyof Records]: {
|
|
2748
2766
|
readonly [P in Schema.Encoded<Records[K]["key"]>]: Schema.Encoded<Records[K]["value"]>
|
|
2749
2767
|
}
|
|
2750
|
-
}
|
|
2768
|
+
}
|
|
2751
2769
|
>
|
|
2752
2770
|
|
|
2753
2771
|
/**
|
|
@@ -2800,7 +2818,7 @@ export interface TypeLiteral<
|
|
|
2800
2818
|
| IndexSignature.Context<Records>
|
|
2801
2819
|
>
|
|
2802
2820
|
{
|
|
2803
|
-
readonly fields:
|
|
2821
|
+
readonly fields: Readonly<Fields>
|
|
2804
2822
|
readonly records: Readonly<Records>
|
|
2805
2823
|
annotations(
|
|
2806
2824
|
annotations: Annotations.Schema<Simplify<TypeLiteral.Type<Fields, Records>>>
|
|
@@ -2910,14 +2928,11 @@ const lazilyMergeDefaults = (
|
|
|
2910
2928
|
return out
|
|
2911
2929
|
}
|
|
2912
2930
|
|
|
2913
|
-
|
|
2914
|
-
Fields extends Struct.Fields,
|
|
2915
|
-
const Records extends IndexSignature.Records
|
|
2916
|
-
>(
|
|
2931
|
+
function makeTypeLiteralClass<Fields extends Struct.Fields, const Records extends IndexSignature.Records>(
|
|
2917
2932
|
fields: Fields,
|
|
2918
2933
|
records: Records,
|
|
2919
2934
|
ast: AST.AST = getDefaultTypeLiteralAST(fields, records)
|
|
2920
|
-
): TypeLiteral<Fields, Records>
|
|
2935
|
+
): TypeLiteral<Fields, Records> {
|
|
2921
2936
|
return class TypeLiteralClass extends make<
|
|
2922
2937
|
Simplify<TypeLiteral.Type<Fields, Records>>,
|
|
2923
2938
|
Simplify<TypeLiteral.Encoded<Fields, Records>>,
|
|
@@ -2958,7 +2973,22 @@ const makeTypeLiteralClass = <
|
|
|
2958
2973
|
* @category api interface
|
|
2959
2974
|
* @since 3.10.0
|
|
2960
2975
|
*/
|
|
2961
|
-
export interface Struct<Fields extends Struct.Fields> extends
|
|
2976
|
+
export interface Struct<Fields extends Struct.Fields> extends
|
|
2977
|
+
AnnotableClass<
|
|
2978
|
+
Struct<Fields>,
|
|
2979
|
+
Simplify<Struct.Type<Fields>>,
|
|
2980
|
+
Simplify<Struct.Encoded<Fields>>,
|
|
2981
|
+
Struct.Context<Fields>
|
|
2982
|
+
>
|
|
2983
|
+
{
|
|
2984
|
+
readonly fields: Readonly<Fields>
|
|
2985
|
+
readonly records: readonly []
|
|
2986
|
+
make(
|
|
2987
|
+
props: RequiredKeys<Struct.Constructor<Fields>> extends never ? void | Simplify<Struct.Constructor<Fields>>
|
|
2988
|
+
: Simplify<Struct.Constructor<Fields>>,
|
|
2989
|
+
options?: MakeOptions
|
|
2990
|
+
): Simplify<Struct.Type<Fields>>
|
|
2991
|
+
|
|
2962
2992
|
annotations(annotations: Annotations.Schema<Simplify<Struct.Type<Fields>>>): Struct<Fields>
|
|
2963
2993
|
pick<Keys extends ReadonlyArray<keyof Fields>>(...keys: Keys): Struct<Simplify<Pick<Fields, Keys[number]>>>
|
|
2964
2994
|
omit<Keys extends ReadonlyArray<keyof Fields>>(...keys: Keys): Struct<Simplify<Omit<Fields, Keys[number]>>>
|
|
@@ -2991,8 +3021,6 @@ export interface tag<Tag extends AST.LiteralValue> extends PropertySignature<":"
|
|
|
2991
3021
|
* A tag is a literal value that is used to distinguish between different types of objects.
|
|
2992
3022
|
* The tag is optional when using the `make` method.
|
|
2993
3023
|
*
|
|
2994
|
-
* @see {@link TaggedStruct}
|
|
2995
|
-
*
|
|
2996
3024
|
* @example
|
|
2997
3025
|
* ```ts
|
|
2998
3026
|
* import * as assert from "node:assert"
|
|
@@ -3007,6 +3035,8 @@ export interface tag<Tag extends AST.LiteralValue> extends PropertySignature<":"
|
|
|
3007
3035
|
* assert.deepStrictEqual(User.make({ name: "John", age: 44 }), { _tag: "User", name: "John", age: 44 })
|
|
3008
3036
|
* ```
|
|
3009
3037
|
*
|
|
3038
|
+
* @see {@link TaggedStruct}
|
|
3039
|
+
*
|
|
3010
3040
|
* @since 3.10.0
|
|
3011
3041
|
*/
|
|
3012
3042
|
export const tag = <Tag extends AST.LiteralValue>(tag: Tag): tag<Tag> =>
|
|
@@ -3050,29 +3080,43 @@ export const TaggedStruct = <Tag extends AST.LiteralValue, Fields extends Struct
|
|
|
3050
3080
|
* @category api interface
|
|
3051
3081
|
* @since 3.10.0
|
|
3052
3082
|
*/
|
|
3053
|
-
export interface Record$<K extends Schema.All, V extends Schema.All> extends
|
|
3083
|
+
export interface Record$<K extends Schema.All, V extends Schema.All> extends
|
|
3084
|
+
AnnotableClass<
|
|
3085
|
+
Record$<K, V>,
|
|
3086
|
+
{ readonly [P in Schema.Type<K>]: Schema.Type<V> },
|
|
3087
|
+
{ readonly [P in Schema.Encoded<K>]: Schema.Encoded<V> },
|
|
3088
|
+
| Schema.Context<K>
|
|
3089
|
+
| Schema.Context<V>
|
|
3090
|
+
>
|
|
3091
|
+
{
|
|
3092
|
+
readonly fields: {}
|
|
3093
|
+
readonly records: readonly [{ readonly key: K; readonly value: V }]
|
|
3054
3094
|
readonly key: K
|
|
3055
3095
|
readonly value: V
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3096
|
+
make(
|
|
3097
|
+
props: void | { readonly [P in Schema.Type<K>]: Schema.Type<V> },
|
|
3098
|
+
options?: MakeOptions
|
|
3099
|
+
): { readonly [P in Schema.Type<K>]: Schema.Type<V> }
|
|
3100
|
+
annotations(annotations: Annotations.Schema<{ readonly [P in Schema.Type<K>]: Schema.Type<V> }>): Record$<K, V>
|
|
3059
3101
|
}
|
|
3060
3102
|
|
|
3061
|
-
|
|
3103
|
+
function makeRecordClass<K extends Schema.All, V extends Schema.All>(
|
|
3062
3104
|
key: K,
|
|
3063
3105
|
value: V,
|
|
3064
3106
|
ast?: AST.AST
|
|
3065
|
-
): Record$<K, V>
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3107
|
+
): Record$<K, V> {
|
|
3108
|
+
return class RecordClass extends makeTypeLiteralClass({}, [{ key, value }], ast) {
|
|
3109
|
+
static override annotations(
|
|
3110
|
+
annotations: Annotations.Schema<{ readonly [P in Schema.Type<K>]: Schema.Type<V> }>
|
|
3111
|
+
): Record$<K, V> {
|
|
3112
|
+
return makeRecordClass(key, value, mergeSchemaAnnotations(this.ast, annotations))
|
|
3113
|
+
}
|
|
3071
3114
|
|
|
3072
|
-
|
|
3115
|
+
static key = key
|
|
3073
3116
|
|
|
3074
|
-
|
|
3075
|
-
}
|
|
3117
|
+
static value = value
|
|
3118
|
+
}
|
|
3119
|
+
}
|
|
3076
3120
|
|
|
3077
3121
|
/**
|
|
3078
3122
|
* @category constructors
|
|
@@ -9539,7 +9583,8 @@ const makeClass = <Fields extends Struct.Fields>(
|
|
|
9539
9583
|
.join(", ")
|
|
9540
9584
|
} })`
|
|
9541
9585
|
},
|
|
9542
|
-
configurable: true
|
|
9586
|
+
configurable: true,
|
|
9587
|
+
writable: true
|
|
9543
9588
|
})
|
|
9544
9589
|
}
|
|
9545
9590
|
return klass
|
|
@@ -10500,6 +10545,7 @@ export function SortedSet<Value extends Schema.Any>(
|
|
|
10500
10545
|
* Uses `!!val` to coerce the value to a `boolean`.
|
|
10501
10546
|
*
|
|
10502
10547
|
* @see https://developer.mozilla.org/docs/Glossary/Truthy
|
|
10548
|
+
*
|
|
10503
10549
|
* @category boolean constructors
|
|
10504
10550
|
* @since 3.10.0
|
|
10505
10551
|
*/
|
|
@@ -11232,8 +11278,8 @@ const go = (ast: AST.AST, path: ReadonlyArray<PropertyKey>): Equivalence.Equival
|
|
|
11232
11278
|
let bStringKeys: Array<string> | undefined
|
|
11233
11279
|
for (let i = 0; i < indexSignatures.length; i++) {
|
|
11234
11280
|
const is = ast.indexSignatures[i]
|
|
11235
|
-
const
|
|
11236
|
-
const isSymbol = AST.isSymbolKeyword(
|
|
11281
|
+
const encodedParameter = AST.getEncodedParameter(is.parameter)
|
|
11282
|
+
const isSymbol = AST.isSymbolKeyword(encodedParameter)
|
|
11237
11283
|
if (isSymbol) {
|
|
11238
11284
|
bSymbolKeys = bSymbolKeys || Object.getOwnPropertySymbols(b)
|
|
11239
11285
|
if (aSymbolKeys.length !== bSymbolKeys.length) {
|
package/src/SchemaAST.ts
CHANGED
|
@@ -1489,13 +1489,13 @@ export class TypeLiteral implements Annotated {
|
|
|
1489
1489
|
symbol: false
|
|
1490
1490
|
}
|
|
1491
1491
|
for (let i = 0; i < indexSignatures.length; i++) {
|
|
1492
|
-
const
|
|
1493
|
-
if (isStringKeyword(
|
|
1492
|
+
const encodedParameter = getEncodedParameter(indexSignatures[i].parameter)
|
|
1493
|
+
if (isStringKeyword(encodedParameter)) {
|
|
1494
1494
|
if (parameters.string) {
|
|
1495
1495
|
throw new Error(errors_.getASTDuplicateIndexSignatureErrorMessage("string"))
|
|
1496
1496
|
}
|
|
1497
1497
|
parameters.string = true
|
|
1498
|
-
} else if (isSymbolKeyword(
|
|
1498
|
+
} else if (isSymbolKeyword(encodedParameter)) {
|
|
1499
1499
|
if (parameters.symbol) {
|
|
1500
1500
|
throw new Error(errors_.getASTDuplicateIndexSignatureErrorMessage("symbol"))
|
|
1501
1501
|
}
|
|
@@ -2177,22 +2177,37 @@ export const getTemplateLiteralCapturingRegExp = (ast: TemplateLiteral): RegExp
|
|
|
2177
2177
|
* @since 3.10.0
|
|
2178
2178
|
*/
|
|
2179
2179
|
export const getPropertySignatures = (ast: AST): Array<PropertySignature> => {
|
|
2180
|
+
const annotation = getSurrogateAnnotation(ast)
|
|
2181
|
+
if (Option.isSome(annotation)) {
|
|
2182
|
+
return getPropertySignatures(annotation.value)
|
|
2183
|
+
}
|
|
2180
2184
|
switch (ast._tag) {
|
|
2181
|
-
case "Declaration": {
|
|
2182
|
-
const annotation = getSurrogateAnnotation(ast)
|
|
2183
|
-
if (Option.isSome(annotation)) {
|
|
2184
|
-
return getPropertySignatures(annotation.value)
|
|
2185
|
-
}
|
|
2186
|
-
break
|
|
2187
|
-
}
|
|
2188
2185
|
case "TypeLiteral":
|
|
2189
2186
|
return ast.propertySignatures.slice()
|
|
2190
2187
|
case "Suspend":
|
|
2191
2188
|
return getPropertySignatures(ast.f())
|
|
2189
|
+
case "Refinement":
|
|
2190
|
+
return getPropertySignatures(ast.from)
|
|
2192
2191
|
}
|
|
2193
2192
|
return getPropertyKeys(ast).map((name) => getPropertyKeyIndexedAccess(ast, name))
|
|
2194
2193
|
}
|
|
2195
2194
|
|
|
2195
|
+
const getIndexSignatures = (ast: AST): Array<IndexSignature> => {
|
|
2196
|
+
const annotation = getSurrogateAnnotation(ast)
|
|
2197
|
+
if (Option.isSome(annotation)) {
|
|
2198
|
+
return getIndexSignatures(annotation.value)
|
|
2199
|
+
}
|
|
2200
|
+
switch (ast._tag) {
|
|
2201
|
+
case "TypeLiteral":
|
|
2202
|
+
return ast.indexSignatures.slice()
|
|
2203
|
+
case "Suspend":
|
|
2204
|
+
return getIndexSignatures(ast.f())
|
|
2205
|
+
case "Refinement":
|
|
2206
|
+
return getIndexSignatures(ast.from)
|
|
2207
|
+
}
|
|
2208
|
+
return []
|
|
2209
|
+
}
|
|
2210
|
+
|
|
2196
2211
|
/** @internal */
|
|
2197
2212
|
export const getNumberIndexedAccess = (ast: AST): AST => {
|
|
2198
2213
|
switch (ast._tag) {
|
|
@@ -2232,10 +2247,10 @@ const getTypeLiteralPropertySignature = (ast: TypeLiteral, name: PropertyKey): P
|
|
|
2232
2247
|
if (Predicate.isString(name)) {
|
|
2233
2248
|
let out: PropertySignature | undefined = undefined
|
|
2234
2249
|
for (const is of ast.indexSignatures) {
|
|
2235
|
-
const
|
|
2236
|
-
switch (
|
|
2250
|
+
const encodedParameter = getEncodedParameter(is.parameter)
|
|
2251
|
+
switch (encodedParameter._tag) {
|
|
2237
2252
|
case "TemplateLiteral": {
|
|
2238
|
-
const regex = getTemplateLiteralRegExp(
|
|
2253
|
+
const regex = getTemplateLiteralRegExp(encodedParameter)
|
|
2239
2254
|
if (regex.test(name)) {
|
|
2240
2255
|
return new PropertySignature(name, is.type, false, true)
|
|
2241
2256
|
}
|
|
@@ -2253,8 +2268,8 @@ const getTypeLiteralPropertySignature = (ast: TypeLiteral, name: PropertyKey): P
|
|
|
2253
2268
|
}
|
|
2254
2269
|
} else if (Predicate.isSymbol(name)) {
|
|
2255
2270
|
for (const is of ast.indexSignatures) {
|
|
2256
|
-
const
|
|
2257
|
-
if (isSymbolKeyword(
|
|
2271
|
+
const encodedParameter = getEncodedParameter(is.parameter)
|
|
2272
|
+
if (isSymbolKeyword(encodedParameter)) {
|
|
2258
2273
|
return new PropertySignature(name, is.type, false, true)
|
|
2259
2274
|
}
|
|
2260
2275
|
}
|
|
@@ -2298,13 +2313,15 @@ const getPropertyKeys = (ast: AST): Array<PropertyKey> => {
|
|
|
2298
2313
|
switch (ast._tag) {
|
|
2299
2314
|
case "TypeLiteral":
|
|
2300
2315
|
return ast.propertySignatures.map((ps) => ps.name)
|
|
2301
|
-
case "Suspend":
|
|
2302
|
-
return getPropertyKeys(ast.f())
|
|
2303
2316
|
case "Union":
|
|
2304
2317
|
return ast.types.slice(1).reduce(
|
|
2305
2318
|
(out: Array<PropertyKey>, ast) => Arr.intersection(out, getPropertyKeys(ast)),
|
|
2306
2319
|
getPropertyKeys(ast.types[0])
|
|
2307
2320
|
)
|
|
2321
|
+
case "Suspend":
|
|
2322
|
+
return getPropertyKeys(ast.f())
|
|
2323
|
+
case "Refinement":
|
|
2324
|
+
return getPropertyKeys(ast.from)
|
|
2308
2325
|
case "Transformation":
|
|
2309
2326
|
return getPropertyKeys(ast.to)
|
|
2310
2327
|
}
|
|
@@ -2430,8 +2447,16 @@ export const pick = (ast: AST, keys: ReadonlyArray<PropertyKey>): TypeLiteral |
|
|
|
2430
2447
|
*
|
|
2431
2448
|
* @since 3.10.0
|
|
2432
2449
|
*/
|
|
2433
|
-
export const omit = (ast: AST, keys: ReadonlyArray<PropertyKey>): TypeLiteral | Transformation =>
|
|
2434
|
-
|
|
2450
|
+
export const omit = (ast: AST, keys: ReadonlyArray<PropertyKey>): TypeLiteral | Transformation => {
|
|
2451
|
+
let indexSignatures = getIndexSignatures(ast)
|
|
2452
|
+
if (indexSignatures.length > 0) {
|
|
2453
|
+
if (indexSignatures.some((is) => isStringKeyword(getEncodedParameter(is.parameter)))) {
|
|
2454
|
+
indexSignatures = indexSignatures.filter((is) => !isTemplateLiteral(getEncodedParameter(is.parameter)))
|
|
2455
|
+
}
|
|
2456
|
+
return new TypeLiteral([], indexSignatures)
|
|
2457
|
+
}
|
|
2458
|
+
return pick(ast, getPropertyKeys(ast).filter((name) => !keys.includes(name)))
|
|
2459
|
+
}
|
|
2435
2460
|
|
|
2436
2461
|
/** @internal */
|
|
2437
2462
|
export const orUndefined = (ast: AST): AST => Union.make([ast, undefinedKeyword])
|
|
@@ -2794,7 +2819,7 @@ const toJSONAnnotations = (annotations: Annotations): object => {
|
|
|
2794
2819
|
}
|
|
2795
2820
|
|
|
2796
2821
|
/** @internal */
|
|
2797
|
-
export const
|
|
2822
|
+
export const getEncodedParameter = (
|
|
2798
2823
|
ast: Parameter
|
|
2799
2824
|
): StringKeyword | SymbolKeyword | TemplateLiteral => {
|
|
2800
2825
|
switch (ast._tag) {
|
|
@@ -2803,7 +2828,7 @@ export const getParameterBase = (
|
|
|
2803
2828
|
case "TemplateLiteral":
|
|
2804
2829
|
return ast
|
|
2805
2830
|
case "Refinement":
|
|
2806
|
-
return
|
|
2831
|
+
return getEncodedParameter(ast.from)
|
|
2807
2832
|
}
|
|
2808
2833
|
}
|
|
2809
2834
|
|
|
@@ -2866,7 +2891,7 @@ const _keyof = (ast: AST): Array<AST> => {
|
|
|
2866
2891
|
case "TypeLiteral":
|
|
2867
2892
|
return ast.propertySignatures.map((p): AST =>
|
|
2868
2893
|
Predicate.isSymbol(p.name) ? new UniqueSymbol(p.name) : new Literal(p.name)
|
|
2869
|
-
).concat(ast.indexSignatures.map((is) =>
|
|
2894
|
+
).concat(ast.indexSignatures.map((is) => getEncodedParameter(is.parameter)))
|
|
2870
2895
|
case "Suspend":
|
|
2871
2896
|
return _keyof(ast.f())
|
|
2872
2897
|
case "Union":
|
package/src/Scope.ts
CHANGED
|
@@ -120,6 +120,7 @@ export declare namespace Scope {
|
|
|
120
120
|
* `Exit` value that the scope is closed with.
|
|
121
121
|
*
|
|
122
122
|
* @see {@link addFinalizerExit}
|
|
123
|
+
*
|
|
123
124
|
* @since 2.0.0
|
|
124
125
|
* @category utils
|
|
125
126
|
*/
|
|
@@ -134,6 +135,7 @@ export const addFinalizer: (
|
|
|
134
135
|
* on the exit status.
|
|
135
136
|
*
|
|
136
137
|
* @see {@link addFinalizer}
|
|
138
|
+
*
|
|
137
139
|
* @since 2.0.0
|
|
138
140
|
* @category utils
|
|
139
141
|
*/
|