Skip to content

Commit

Permalink
Turn on noImplicitAny flag - fixes #3 (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
SamVerschueren authored and sindresorhus committed Feb 1, 2018
1 parent 184a1eb commit ec9483a
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 9 deletions.
2 changes: 2 additions & 0 deletions package.json
Expand Up @@ -49,7 +49,9 @@
"devDependencies": {
"@sindresorhus/is": "^0.7.0",
"@types/highlight.js": "^9.12.2",
"@types/lodash.isequal": "^4.5.2",
"@types/node": "^8.0.31",
"@types/vali-date": "^1.0.0",
"add-module-exports-webpack-plugin": "^0.1.0",
"ava": "*",
"awesome-typescript-loader": "^3.2.3",
Expand Down
6 changes: 4 additions & 2 deletions source/index.ts
@@ -1,5 +1,5 @@
import {ArgumentError} from './lib/argument-error';
import {Predicate, validatorSymbol} from './lib/predicates/predicate';
import {Predicate, validatorSymbol, Validator} from './lib/predicates/predicate';
import {StringPredicate} from './lib/predicates/string';
import {NumberPredicate} from './lib/predicates/number';
import {BooleanPredicate} from './lib/predicates/boolean';
Expand Down Expand Up @@ -155,7 +155,9 @@ export interface Ow {
}

const main = <T>(value: T, predicate: Predicate<T>) => {
for (const {validator, message} of predicate[validatorSymbol]) {
const validators: Validator<any>[] = (predicate as any)[validatorSymbol];

for (const {validator, message} of validators) {
const result = validator(value);

if (typeof result !== 'boolean' || !result) {
Expand Down
2 changes: 1 addition & 1 deletion source/lib/operators/not.ts
Expand Up @@ -14,7 +14,7 @@ export const not = <T extends Predicate>(predicate: T) => {
validator.message = (x: any) => `[NOT] ${message(x)}`;
validator.validator = (x: any) => !fn(x);

predicate[validatorSymbol].push(validator);
(predicate as any)[validatorSymbol].push(validator);

return predicate;
};
Expand Down
2 changes: 1 addition & 1 deletion source/lib/predicates/array.ts
@@ -1,4 +1,4 @@
import * as isEqual from 'lodash.isequal';
import isEqual = require('lodash.isequal'); // tslint:disable-line:no-require-imports
import ow from '../..';
import {Predicate, Context} from './predicate';

Expand Down
2 changes: 1 addition & 1 deletion source/lib/predicates/map.ts
@@ -1,4 +1,4 @@
import * as isEqual from 'lodash.isequal';
import isEqual = require('lodash.isequal'); // tslint:disable-line:no-require-imports
import {Predicate, Context} from './predicate';
import hasItems from '../utils/has-items';
import ofType from '../utils/of-type';
Expand Down
2 changes: 1 addition & 1 deletion source/lib/predicates/predicate.ts
Expand Up @@ -33,7 +33,7 @@ export class Predicate<T = any> {
) {
this.addValidator({
message: value => `Expected argument to be of type \`${type}\` but received type \`${is(value)}\``,
validator: value => is[type](value)
validator: value => (is as any)[type](value)
});
}

Expand Down
2 changes: 1 addition & 1 deletion source/lib/predicates/set.ts
@@ -1,4 +1,4 @@
import * as isEqual from 'lodash.isequal';
import isEqual = require('lodash.isequal'); // tslint:disable-line:no-require-imports
import {Predicate, Context} from './predicate';
import hasItems from '../utils/has-items';
import ofType from '../utils/of-type';
Expand Down
2 changes: 1 addition & 1 deletion source/test/undefined.ts
Expand Up @@ -2,7 +2,7 @@ import test from 'ava';
import m from '..';

test('undefined', t => {
let x; // tslint:disable-line:prefer-const
const x = undefined;
const y = 12;

t.notThrows(() => m(undefined, m.undefined));
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Expand Up @@ -11,7 +11,7 @@
"pretty": true,
"newLine": "lf",
"stripInternal": true,
"noImplicitAny": false,
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noUnusedLocals": true,
Expand Down

0 comments on commit ec9483a

Please sign in to comment.