Skip to content

Commit

Permalink
chore: Use pnpm and test types
Browse files Browse the repository at this point in the history
  • Loading branch information
znck committed Feb 10, 2019
1 parent 5109471 commit 5067a7f
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 18 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ prop-types.js
yarn.lock
shrinkwrap.yaml
coverage.lcov
/remove.js
/remove.js
types/*.js
3 changes: 3 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
testMatch: ['<rootDir>/test/*.spec.js']
}
8 changes: 8 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"include": ["src"],
"exclude": ["node_modules"],
"compilerOptions": {
"resolveJsonModule": true,
"lib": ["esnext"]
}
}
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
"remove.js"
],
"scripts": {
"test": "jest",
"test": "npm run test:unit && npm run test:types",
"test:unit": "jest",
"test:types": "tsc types/index.spec.ts",
"pre:build": "rm -rf dist/",
":build": "rollup -c --environment BUILD:production",
"prepublishOnly": "npm run :build",
Expand Down Expand Up @@ -40,12 +42,12 @@
"@babel/core": "^7.2.2",
"@babel/preset-env": "^7.2.3",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^23.6.0",
"jest": "^23.6.0",
"regenerator-runtime": "^0.13.1",
"babel-jest": "^24.1.0",
"jest": "^24.1.0",
"rollup": "^1.1.0",
"rollup-plugin-babel": "^4.3.1",
"standard-version": "^4.4.0"
"standard-version": "^4.4.0",
"typescript": "^3.3.3"
},
"dependencies": {
"vue": "2.*"
Expand Down
18 changes: 9 additions & 9 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ export interface PropTypes {
arrayOf<T>(type: ValidatorFn<T>): PropValidator<Array<T>>

oneOf<T>(...args: T[]): PropValidator<T>
oneOf<T1>(arg1: T1): PropValidator<T1 | T2 | T3 | T4>
oneOf<T1, T2>(arg1: T1, arg2: T2): PropValidator<T1 | T2 | T3 | T4>
oneOf<T1, T2, T3>(arg1: T1, arg2: T2, arg3: T3): PropValidator<T1 | T2 | T3 | T4>
oneOf<T1>(arg1: T1): PropValidator<T1>
oneOf<T1, T2>(arg1: T1, arg2: T2): PropValidator<T1 | T2>
oneOf<T1, T2, T3>(arg1: T1, arg2: T2, arg3: T3): PropValidator<T1 | T2 | T3>
oneOf<T1, T2, T3, T4>(arg1: T1, arg2: T2, arg3: T3, arg4: T4): PropValidator<T1 | T2 | T3 | T4>
oneOf<T1, T2, T3, T4, T5>(arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5): PropValidator<T1 | T2 | T3 | T4 | T5>
oneOf<T1, T2, T3, T4, T5, T6>(arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6): PropValidator<T1 | T2 | T3 | T4 | T5 | T6>
Expand Down Expand Up @@ -89,20 +89,20 @@ export interface PropTypesChain<
T,
U = T extends string
? string
: T extends StringConstructor
: T extends String
? string
: T extends number
? number
: T extends NumberConstructor
: T extends Number
? number
: T extends boolean
? boolean
: T extends BooleanConstructor
: T extends Boolean
? boolean
: T extends symbol
? symbol
: T extends Symbol
? Symbol
: T extends SymbolConstructor
? Symbol
? symbol
: (() => T)
> {
isRequired: PropOptions<T>
Expand Down
4 changes: 1 addition & 3 deletions types/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const props = {
string: PropTypes.string.value('foo').validate(value => 'foo' == value).isRequired,
number: PropTypes.number.value(1).validate(value => 1 == value).isRequired,
boolean: PropTypes.bool.value(true).validate(value => value).isRequired,
symbol: PropTypes.symbol.value(Symbol('1')).validate(value => !!value).isRequired,
array: PropTypes.array.value(() => []).validate(value => 1 === value.length).isRequired,
object: PropTypes.object.value(() => ({})).validate(value => 'foo' in value).isRequired,
func: PropTypes.func.value(() => (a: string) => null).validate(value => value()).isRequired,
Expand All @@ -24,7 +23,7 @@ const props = {

date: PropTypes.instanceOf(Date).value(() => new Date()).validate(value => value.getTime() > 0).isRequired,
foo: PropTypes.instanceOf(Foo).value(() => new Foo()).validate(value => value.isValid).isRequired,
String: PropTypes.instanceOf(String).value(() => new String()).validate(value => value.at(0) > 'a').isRequired,
String: PropTypes.instanceOf(String).value(String('str')).validate(value => value.charAt(0) > 'a').isRequired,

shape: PropTypes.shape({
foo: PropTypes.bool,
Expand All @@ -34,7 +33,6 @@ const props = {

objectOfNumber: PropTypes.objectOf(PropTypes.number).value(() => ({ foo: 1, bar: 2 })).validate(value => value.foo > 0).isRequired,
objectOfString: PropTypes.objectOf(Number),
objectOfSymbol: PropTypes.objectOf(Symbol),
objectOfValidatorInferredType: PropTypes.objectOf((value: { foo: boolean}) => value.foo).value(() => ({ one: { foo: true } })),
}

Expand Down

0 comments on commit 5067a7f

Please sign in to comment.