From d00905367e69da770e3c1518a0626084e197ccbd Mon Sep 17 00:00:00 2001 From: Andy Edwards Date: Mon, 13 Jul 2020 12:05:59 -0500 Subject: [PATCH 1/6] docs(README.md): add note about readonly props --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4a1d68b..25dd8fa 100644 --- a/README.md +++ b/README.md @@ -249,8 +249,8 @@ type Thing = t.ExtractType ``` The type of `Thing` will be `{ name: string, comment?: string }`. Note that the property types in the explicit type parameter -(`any`) are ignored. The type parameter just indicates which -properties are required and which are optional. +(`any`) are ignored. The type parameter just indicates which properties are required and which are optional, and also allows +you to mark properties readonly. These attributes will be reflected in `t.ExtractType`. You can also use the `t.optionalNullOr(t.string())` as a shorthand for `t.optional(t.nullOr(t.string()))`. From 71b7e2d3bd5f058fc12f5801c75989892bcb5f3d Mon Sep 17 00:00:00 2001 From: Andy Edwards Date: Mon, 13 Jul 2020 14:20:00 -0500 Subject: [PATCH 2/6] docs(README.md): hide coverage until codecov is working --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 25dd8fa..449c9a6 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ # typescript-validators [![CircleCI](https://circleci.com/gh/jcoreio/typescript-validators.svg?style=svg)](https://circleci.com/gh/jcoreio/typescript-validators) -[![Coverage Status](https://codecov.io/gh/jcoreio/typescript-validators/branch/master/graph/badge.svg)](https://codecov.io/gh/jcoreio/typescript-validators) + + [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) [![npm version](https://badge.fury.io/js/typescript-validators.svg)](https://badge.fury.io/js/typescript-validators) From 89d911413e03fd4f7e54506322532e6bf2aa23a8 Mon Sep 17 00:00:00 2001 From: Andy Edwards Date: Mon, 13 Jul 2020 14:34:18 -0500 Subject: [PATCH 3/6] chore: upgrade codecov client --- package.json | 2 +- yarn.lock | 71 +++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 54 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index 82b0915..47c42d1 100644 --- a/package.json +++ b/package.json @@ -120,7 +120,7 @@ "babel-eslint": "^10.0.1", "babel-plugin-istanbul": "^5.1.0", "chai": "^4.2.0", - "codecov": "^3.1.0", + "codecov": "^3.7.0", "copy": "^0.3.2", "cross-env": "^5.2.0", "dedent-js": "^1.0.1", diff --git a/yarn.lock b/yarn.lock index 4314735..94ce0df 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1160,6 +1160,11 @@ lodash "^4.17.4" read-pkg-up "^7.0.0" +"@tootallnate/once@1": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-1.1.2.tgz#ccb91445360179a04e7fe6aff78c00ffc1eeaf82" + integrity sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw== + "@types/chai@^4.2.0": version "4.2.7" resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.2.7.tgz#1c8c25cbf6e59ffa7d6b9652c78e547d9a41692d" @@ -1329,6 +1334,13 @@ agent-base@5: resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-5.1.1.tgz#e8fb3f242959db44d63be665db7a8e739537a32c" integrity sha512-TMeqbNl2fMW0nMjTEPOwe3J/PRFP4vqeoNuQMG0HlMrtm5QxKqdvAkZ1pRBQ/ulIyDD5Yq0nJ7YbdD8ey0TO3g== +agent-base@6: + version "6.0.1" + resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-6.0.1.tgz#808007e4e5867decb0ab6ab2f928fbdb5a596db4" + integrity sha512-01q25QQDwLSsyfhrKbn8yuur+JNw0H+0Y4JiGIKd3z9aYk/w/2kxD/Upc+t2ZBBSUNff50VjPsSW2YxM8QYKVg== + dependencies: + debug "4" + agent-base@~4.2.1: version "4.2.1" resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-4.2.1.tgz#d89e5999f797875674c07d87f260fc41e83e8ca9" @@ -1515,7 +1527,7 @@ argv-formatter@~1.0.0: resolved "https://registry.yarnpkg.com/argv-formatter/-/argv-formatter-1.0.0.tgz#a0ca0cbc29a5b73e836eebe1cbf6c5e0e4eb82f9" integrity sha1-oMoMvCmltz6Dbuvhy/bF4OTrgvk= -argv@^0.0.2: +argv@0.0.2: version "0.0.2" resolved "https://registry.yarnpkg.com/argv/-/argv-0.0.2.tgz#ecbd16f8949b157183711b1bda334f37840185ab" integrity sha1-7L0W+JSbFXGDcRsb2jNPN4QBhas= @@ -2197,16 +2209,16 @@ code-point-at@^1.0.0: resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77" integrity sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c= -codecov@^3.1.0: - version "3.6.1" - resolved "https://registry.yarnpkg.com/codecov/-/codecov-3.6.1.tgz#f39fc49413445555f81f8e3ca5730992843b4517" - integrity sha512-IUJB6WG47nWK7o50etF8jBadxdMw7DmoQg05yIljstXFBGB6clOZsIj6iD4P82T2YaIU3qq+FFu8K9pxgkCJDQ== +codecov@^3.7.0: + version "3.7.0" + resolved "https://registry.yarnpkg.com/codecov/-/codecov-3.7.0.tgz#4a09939cde24447a43f36d068e8b4e0188dc3f27" + integrity sha512-uIixKofG099NbUDyzRk1HdGtaG8O+PBUAg3wfmjwXw2+ek+PZp+puRvbTohqrVfuudaezivJHFgTtSC3M8MXww== dependencies: - argv "^0.0.2" - ignore-walk "^3.0.1" - js-yaml "^3.13.1" - teeny-request "^3.11.3" - urlgrey "^0.4.4" + argv "0.0.2" + ignore-walk "3.0.3" + js-yaml "3.13.1" + teeny-request "6.0.1" + urlgrey "0.4.4" collection-visit@^1.0.0: version "1.0.0" @@ -4086,6 +4098,15 @@ http-proxy-agent@^3.0.0: agent-base "5" debug "4" +http-proxy-agent@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/http-proxy-agent/-/http-proxy-agent-4.0.1.tgz#8a8c8ef7f5932ccf953c296ca8291b95aa74aa3a" + integrity sha512-k0zdNgqWTGA6aeIRVpvfVob4fL52dTfaehylg0Y4UvSySvOq/Y+BOyPrgpUrA7HylqvU8vIZGsRuXmspskV0Tg== + dependencies: + "@tootallnate/once" "1" + agent-base "6" + debug "4" + http-signature@~1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.2.0.tgz#9aecd925114772f3d95b65a60abb8f7c18fbace1" @@ -4095,7 +4116,7 @@ http-signature@~1.2.0: jsprim "^1.2.2" sshpk "^1.7.0" -https-proxy-agent@^2.2.1, https-proxy-agent@^2.2.3: +https-proxy-agent@^2.2.3: version "2.2.4" resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-2.2.4.tgz#4ee7a737abd92678a293d9b34a1af4d0d08c787b" integrity sha512-OmvfoQ53WLjtA9HeYP9RNrWMJzzAz1JGaSFr1nijg0PVR1JaD/xbJq1mdEIIlxGpXp9eSe/O2LgU9DJmTPd0Eg== @@ -4156,7 +4177,7 @@ iferr@^1.0.2: resolved "https://registry.yarnpkg.com/iferr/-/iferr-1.0.2.tgz#e9fde49a9da06dc4a4194c6c9ed6d08305037a6d" integrity sha512-9AfeLfji44r5TKInjhz3W9DyZI1zR1JAf2hVBMGhddAKPqBsupb89jGfbCTHIGZd6fGZl9WlHdn4AObygyMKwg== -ignore-walk@^3.0.1: +ignore-walk@3.0.3, ignore-walk@^3.0.1: version "3.0.3" resolved "https://registry.yarnpkg.com/ignore-walk/-/ignore-walk-3.0.3.tgz#017e2447184bfeade7c238e4aefdd1e8f95b1e37" integrity sha512-m7o6xuOaT1aqheYHKf8W6J5pYH85ZI9w077erOzLje3JsB1gkafkAhHHY19dqjulgIZHFm32Cp5uNZgcQqdJKw== @@ -7905,6 +7926,13 @@ stream-each@^1.1.0: end-of-stream "^1.1.0" stream-shift "^1.0.0" +stream-events@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/stream-events/-/stream-events-1.0.5.tgz#bbc898ec4df33a4902d892333d47da9bf1c406d5" + integrity sha512-E1GUzBSgvct8Jsb3v2X15pjzN1tYebtbLaMg+eBOUOAxgbLoSbT2NS91ckc5lJD1KfLjId+jXJRgo0qnV5Nerg== + dependencies: + stubs "^3.0.0" + stream-iterate@^1.1.0: version "1.2.0" resolved "https://registry.yarnpkg.com/stream-iterate/-/stream-iterate-1.2.0.tgz#2bd7c77296c1702a46488b8ad41f79865eecd4e1" @@ -8078,6 +8106,11 @@ strip-json-comments@2.0.1, strip-json-comments@^2.0.1, strip-json-comments@~2.0. resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo= +stubs@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/stubs/-/stubs-3.0.0.tgz#e8d2ba1fa9c90570303c030b6900f7d5f89abe5b" + integrity sha1-6NK6H6nJBXAwPAMLaQD31fiavls= + success-symbol@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/success-symbol/-/success-symbol-0.1.0.tgz#24022e486f3bf1cdca094283b769c472d3b72897" @@ -8169,13 +8202,15 @@ tar@^4.4.10, tar@^4.4.12, tar@^4.4.13: safe-buffer "^5.1.2" yallist "^3.0.3" -teeny-request@^3.11.3: - version "3.11.3" - resolved "https://registry.yarnpkg.com/teeny-request/-/teeny-request-3.11.3.tgz#335c629f7645e5d6599362df2f3230c4cbc23a55" - integrity sha512-CKncqSF7sH6p4rzCgkb/z/Pcos5efl0DmolzvlqRQUNcpRIruOhY9+T1FsIlyEbfWd7MsFpodROOwHYh2BaXzw== +teeny-request@6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/teeny-request/-/teeny-request-6.0.1.tgz#9b1f512cef152945827ba7e34f62523a4ce2c5b0" + integrity sha512-TAK0c9a00ELOqLrZ49cFxvPVogMUFaWY8dUsQc/0CuQPGF+BOxOQzXfE413BAk2kLomwNplvdtMpeaeGWmoc2g== dependencies: - https-proxy-agent "^2.2.1" + http-proxy-agent "^4.0.0" + https-proxy-agent "^4.0.0" node-fetch "^2.2.0" + stream-events "^1.0.5" uuid "^3.3.2" temp-dir@^1.0.0: @@ -8566,7 +8601,7 @@ url-parse-lax@^1.0.0: dependencies: prepend-http "^1.0.1" -urlgrey@^0.4.4: +urlgrey@0.4.4: version "0.4.4" resolved "https://registry.yarnpkg.com/urlgrey/-/urlgrey-0.4.4.tgz#892fe95960805e85519f1cd4389f2cb4cbb7652f" integrity sha1-iS/pWWCAXoVRnxzUOJ8stMu3ZS8= From 302588f8a24d4453fef48eea49301bc7e1c7f766 Mon Sep 17 00:00:00 2001 From: Andy Edwards Date: Mon, 13 Jul 2020 14:35:00 -0500 Subject: [PATCH 4/6] chore: format README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 449c9a6..e7e17f7 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,10 @@ # typescript-validators [![CircleCI](https://circleci.com/gh/jcoreio/typescript-validators.svg?style=svg)](https://circleci.com/gh/jcoreio/typescript-validators) + + [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) [![npm version](https://badge.fury.io/js/typescript-validators.svg)](https://badge.fury.io/js/typescript-validators) From cd3227889c4161e839f0d5ce158921a581344017 Mon Sep 17 00:00:00 2001 From: Andy Edwards Date: Mon, 13 Jul 2020 15:44:06 -0500 Subject: [PATCH 5/6] chore: re-enable coverage badge --- README.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/README.md b/README.md index e7e17f7..25dd8fa 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,7 @@ # typescript-validators [![CircleCI](https://circleci.com/gh/jcoreio/typescript-validators.svg?style=svg)](https://circleci.com/gh/jcoreio/typescript-validators) - - - - +[![Coverage Status](https://codecov.io/gh/jcoreio/typescript-validators/branch/master/graph/badge.svg)](https://codecov.io/gh/jcoreio/typescript-validators) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) [![npm version](https://badge.fury.io/js/typescript-validators.svg)](https://badge.fury.io/js/typescript-validators) From 94410f83b3979d6711c9e0b5357773df8540db85 Mon Sep 17 00:00:00 2001 From: Andy Edwards Date: Thu, 16 Jul 2020 14:56:15 -0500 Subject: [PATCH 6/6] fix(instanceOf): fix output type --- src/index.ts | 6 +++--- src/types/InstanceOfType.ts | 8 +++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/index.ts b/src/index.ts index a4892e8..6fc85d3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -173,9 +173,9 @@ export const record = ( value: Type ): RecordType => new RecordType(key, value) -export const instanceOf = ( - classType: T -): Type => new InstanceOfType(classType) +export const instanceOf = (classType: { + new (...args: any[]): T +}): Type => new InstanceOfType(classType) export const tuple = []>( ...types: T diff --git a/src/types/InstanceOfType.ts b/src/types/InstanceOfType.ts index 9be88b4..431afbd 100644 --- a/src/types/InstanceOfType.ts +++ b/src/types/InstanceOfType.ts @@ -3,13 +3,11 @@ import Type from './Type' import getErrorMessage from '../getErrorMessage' import Validation, { ErrorTuple, IdentifierPath } from '../Validation' -export default class InstanceOfType< - T extends { new (...args: any[]): any } -> extends Type { +export default class InstanceOfType extends Type { typeName = 'InstanceOfType' - classType: T + classType: { new (...args: any[]): T } - constructor(classType: T) { + constructor(classType: { new (...args: any[]): T }) { super() this.classType = classType }