Skip to content

Commit 6176e94

Browse files
committed
Type create/validate to accept an instance type
1 parent ca74a88 commit 6176e94

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

‎src/core/type/type.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export interface IType<C, S, T> {
9393
*
9494
* @returns An instance of that type.
9595
*/
96-
create(snapshot?: C, env?: any): this["Type"]
96+
create(snapshot?: C | T, env?: any): this["Type"]
9797

9898
/**
9999
* Checks if a given snapshot / instance is of the given type.
@@ -110,7 +110,7 @@ export interface IType<C, S, T> {
110110
* @param context Validation context, an array of { subpaths, subtypes } that should be validated
111111
* @returns The validation result, an array with the list of validation errors.
112112
*/
113-
validate(thing: C, context: IValidationContext): IValidationResult
113+
validate(thing: C | T, context: IValidationContext): IValidationResult
114114

115115
/**
116116
* Gets the textual representation of the type as a string.

‎src/types/complex-types/model.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ type DefinablePropsNames<T> = { [K in keyof T]: IsOptionalValue<T[K], never, K>
125125

126126
/** @hidden */
127127
export type ExtractCFromProps<P extends ModelProperties> = MaybeEmpty<{
128-
[k in keyof P]: P[k]["CreationType"]
128+
[k in keyof P]: P[k]["CreationType"] | P[k]["TypeWithoutSTN"]
129129
}>
130130

131131
/** @hidden */

0 commit comments

Comments
 (0)