Repository: jquense/yup
Pull request #1139 (2020-12-03 22:31:07)

Update README.md
fix typo


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index cd7c1f1..aeb206d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,15 @@
+## [0.32.1](https://github.com/jquense/yup/compare/v0.32.0...v0.32.1) (2020-12-04)
+
+
+### Bug Fixes
+
+* cyclical import ([d5c5391](https://github.com/jquense/yup/commit/d5c5391)), closes [#1138](https://github.com/jquense/yup/issues/1138)
+* some strict fn type improvements ([8092218](https://github.com/jquense/yup/commit/8092218))
+
+
+
+
+
 # [0.32.0](https://github.com/jquense/yup/compare/v0.31.1...v0.32.0) (2020-12-03)
 
 
diff --git a/README.md b/README.md
index e2e7894..c895733 100644
--- a/README.md
+++ b/README.md
@@ -1183,7 +1183,7 @@ const person = object({
   color: string().default('red').required(),
 });
 
-const nameAndAge = person.omit('color']);
+const nameAndAge = person.omit(['color']);
 nameAndAge.getDefault(); // => { age: 30, name: 'pat'}
 ```
 
diff --git a/docs/typescript.md b/docs/typescript.md
index 7336755..201fb02 100644
--- a/docs/typescript.md
+++ b/docs/typescript.md
@@ -3,7 +3,7 @@
 `yup` comes with robust typescript support! However, because of how dynamic `yup` is
 not everything can be statically typed safely, but for most cases it's "Good Enough".
 
-Not that `yup` schema actually produce _two_ different types: the result of casting an input, and the value after validation.
+Note that `yup` schema actually produce _two_ different types: the result of casting an input, and the value after validation.
 Why are these types different? Because a schema can produce a value via casting that
 would not pass validation!
 
@@ -14,7 +14,7 @@ schema.cast(null); // -> null
 schema.validateSync(null); // ValidationError this is required!
 ```
 
-By itself this seems weird, but has it uses when handling user input. To get a
+By itself this seems weird, but has it's uses when handling user input. To get a
 TypeScript type that matches all possible `cast()` values, use `yup.TypeOf<typeof schema>`.
 To produce a type that matches a valid object for the schema use `yup.Asserts<typeof schema>>`
 
@@ -80,7 +80,7 @@ const badPersonSchema: SchemaOf<Person> = object({
 
 For type utilties to work correctly you have
 
-- `strictNullChecks: true` (or `strict)
+- `strictNullChecks: true` (or `strict`)
 - `strictFunctionTypes: false`
 
 In your tsconfig.json.
diff --git a/package.json b/package.json
index 8386fbd..3c768c4 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "yup",
-  "version": "0.32.0",
+  "version": "0.32.1",
   "description": "Dead simple Object schema validation",
   "main": "lib/index.js",
   "module": "es/index.js",
diff --git a/src/Condition.ts b/src/Condition.ts
index d4148cd..78daa08 100644
--- a/src/Condition.ts
+++ b/src/Condition.ts
@@ -68,7 +68,7 @@ class Condition<T extends SchemaLike = SchemaLike> {
       ref.getValue(options?.value, options?.parent, options?.context),
     );
 
-    let schema = this.fn.apply(base, values.concat(base, options));
+    let schema = this.fn.apply(base, values.concat(base, options) as any);
 
     if (schema === undefined || schema === base) return base;
 
diff --git a/src/number.ts b/src/number.ts
index 5014957..20db17e 100644
--- a/src/number.ts
+++ b/src/number.ts
@@ -1,6 +1,6 @@
 import { MixedLocale, number as locale } from './locale';
 import isAbsent from './util/isAbsent';
-import type { AnyObject, Maybe } from './types';
+import type { AnyObject, Maybe, Message } from './types';
 import type Reference from './Reference';
 import type { Defined, If, Thunk } from './util/types';
 import BaseSchema from './schema';
diff --git a/src/object.ts b/src/object.ts
index d375ff8..6a66f6c 100644
--- a/src/object.ts
+++ b/src/object.ts
@@ -27,7 +27,10 @@ export type Assign<T extends {}, U extends {}> = {
 
 export type AnyObject = Record<string, any>;
 
-export type ObjectShape = Record<string, AnySchema | Reference | Lazy<any>>;
+export type ObjectShape = Record<
+  string,
+  AnySchema | Reference | Lazy<any, any>
+>;
 
 export type DefaultFromShape<Shape extends ObjectShape> = {
   [K in keyof Shape]: Shape[K] extends ObjectSchema<infer TShape>
diff --git a/src/schema.ts b/src/schema.ts
index ed1fa16..69f50ca 100644
--- a/src/schema.ts
+++ b/src/schema.ts
@@ -24,7 +24,7 @@ import {
   AnyObject,
 } from './types';
 
-import { ValidationError } from '.';
+import ValidationError from './ValidationError';
 import type { Asserts } from './util/types';
 import ReferenceSet from './util/ReferenceSet';
 import Reference from './Reference';
@@ -106,7 +106,7 @@ export default abstract class BaseSchema<
   readonly deps: readonly string[] = [];
 
   tests: Test[];
-  transforms: TransformFunction<this>[];
+  transforms: TransformFunction<AnySchema>[];
 
   private conditions: Condition[] = [];
 
@@ -332,7 +332,7 @@ export default abstract class BaseSchema<
     return result;
   }
 
-  protected _cast(rawValue: any, _options: CastOptions<TContext>) {
+  protected _cast(rawValue: any, _options: CastOptions<TContext>): any {
     let value =
       rawValue === undefined
         ? rawValue
@@ -553,7 +553,7 @@ export default abstract class BaseSchema<
 
   transform(fn: TransformFunction<this>) {
     var next = this.clone();
-    next.transforms.push(fn);
+    next.transforms.push(fn as TransformFunction<any>);
     return next;
   }
 
@@ -645,7 +645,7 @@ export default abstract class BaseSchema<
       if (dep.isSibling) next.deps.push(dep.key);
     });
 
-    next.conditions.push(new Condition<this>(deps, options!));
+    next.conditions.push(new Condition(deps, options!) as Condition);
 
     return next;
   }
diff --git a/src/util/createValidation.ts b/src/util/createValidation.ts
index d41fbeb..a6cefef 100644
--- a/src/util/createValidation.ts
+++ b/src/util/createValidation.ts
@@ -13,7 +13,7 @@ import type { AnySchema } from '../schema';
 
 export type CreateErrorOptions = {
   path?: string;
-  message?: Message;
+  message?: Message<any>;
   params?: ExtraParams;
   type?: string;
 };
@@ -45,7 +45,7 @@ export type TestOptions<TSchema extends AnySchema = AnySchema> = {
 
 export type TestConfig<TValue = unknown, TContext = {}> = {
   name?: string;
-  message?: Message;
+  message?: Message<any>;
   test: TestFunction<TValue, TContext>;
   params?: ExtraParams;
   exclusive?: boolean;
@@ -59,7 +59,7 @@ export default function createValidation(config: {
   name?: string;
   test: TestFunction;
   params?: ExtraParams;
-  message?: Message;
+  message?: Message<any>;
 }) {
   function validate<TSchema extends AnySchema = AnySchema>(
     {
diff --git a/tsconfig.json b/tsconfig.json
index 53149fb..d02ef30 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -2,7 +2,8 @@
   "extends": "@4c/tsconfig/web",
   "compilerOptions": {
     "allowJs": true,
-    "rootDir": "src"
+    "rootDir": "src",
+    "strictFunctionTypes": true
   },
   "include": ["src"]
 }


Test patch:
diff --git a/test/types.ts b/test/types.ts
index a67c203..2c817bc 100644
--- a/test/types.ts
+++ b/test/types.ts
@@ -79,6 +79,9 @@ string().required().nullable();
     lazy: lazy(() => number().required()),
   });
 
+  const foo = object({
+    string: string().default(''),
+  });
   // type F = StringSchema<string>;
   // type f = F extends TypedSchema ? F['__inputType'] : false;