Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(addRule): allow add return undefined #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MarvelSQ
Copy link
Member

@MarvelSQ MarvelSQ commented Dec 9, 2021

当前addRule要求返回boolean 或 ErrorMessage

Schema.Types.StringType().addRule(value => {
  // empty
});

而代码中的逻辑是 返回 false 或 ErrorMessage 进行处理,没有返回值会被认为是通过的
所以对应的类型声明应允许返回空

Copy link
Member

@simonguo simonguo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error: Errors in typescript@local for external dependencies:
Error: ../src/utils/createValidatorAsync.ts(24,9): error TS2345: Argument of type '(checkResult: CheckResult<E> | boolean) => CheckResult<E> | null' is not assignable to parameter of type '(value: boolean | CheckResult<E> | undefined) => CheckResult<E> | PromiseLike<CheckResult<E> | null> | null'.
  Types of parameters 'checkResult' and 'value' are incompatible.
    Type 'boolean | CheckResult<E> | undefined' is not assignable to type 'boolean | CheckResult<E>'.
      Type 'undefined' is not assignable to type 'boolean | CheckResult<E>'.

    at /home/runner/work/schema-typed/schema-typed/node_modules/dtslint/bin/index.js:206:19
    at Generator.next (<anonymous>)
    at fulfilled (/home/runner/work/schema-typed/schema-typed/node_modules/dtslint/bin/index.js:6:58)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] test:types: `dtslint --expectOnly --localTs node_modules/typescript/lib types`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] test:types script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/runner/.npm/_logs/2021-12-09T05_49_18_190Z-debug.log
npm ERR! Test failed.  See above for more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants