Refactor any to unknown where possible (#68)

Resolves #62
This commit is contained in:
Lukas Tetzlaff 2018-11-02 10:43:51 +00:00 committed by Sindre Sorhus
parent 7317226c80
commit d4869045c2
3 changed files with 71 additions and 69 deletions

View file

@ -21,8 +21,8 @@ const {document} = window;
const createDomElement = (element: string) => document.createElement(element);
interface Test {
is(value: any): boolean;
fixtures: any[];
is(value: unknown): boolean;
fixtures: unknown[];
}
const types = new Map<string, Test>([
@ -77,7 +77,7 @@ const types = new Map<string, Test>([
]
}],
['numericString', {
is: m.numericString,
is: is.numericString,
fixtures: [
'5',
'-3.2',
@ -106,7 +106,7 @@ const types = new Map<string, Test>([
function () {},
() => {},
async function () {},
function * (): any {}
function * (): unknown {}
// tslint:enable:no-unused no-empty no-unused-variable only-arrow-functions no-function-expression
]
}],
@ -377,7 +377,7 @@ const types = new Map<string, Test>([
]);
// This ensures a certain method matches only the types it's supposed to and none of the other methods' types
const testType = (t: TestContext & Context<any>, type: string, exclude?: string[]) => {
const testType = (t: TestContext & Context<unknown>, type: string, exclude?: string[]) => {
const testData = types.get(type);
if (testData === undefined) {
@ -436,8 +436,8 @@ test('is.symbol', t => {
test('is.numericString', t => {
testType(t, 'numericString');
t.false(m.numericString(''));
t.false(m.numericString(1));
t.false(is.numericString(''));
t.false(is.numericString(1));
});
test('is.array', t => {