DefinitelyTyped/types/find-cache-dir/find-cache-dir-tests.ts
Piotr Błażejewicz (Peter Blazejewicz) d328f3b1d0
feat(find-cache-dir): update to v3.2 (#42550)
- v2 for backward compatibility
- migrate return type from `null` to `undefined`

https://github.com/avajs/find-cache-dir#readme

Thanks!
2020-02-26 12:56:35 -08:00

20 lines
892 B
TypeScript

import findCacheDir = require('find-cache-dir');
findCacheDir({ name: 'unicorns' }); // $ExpectType string | undefined
findCacheDir({ name: 'unicorns', files: 'foo' }); // $ExpectType string | undefined
findCacheDir({ name: 'unicorns', files: ['foo', 'bar'] }); // $ExpectType string | undefined
findCacheDir({ name: 'unicorns', cwd: 'foo' }); // $ExpectType string | undefined
findCacheDir({ name: 'unicorns', create: true }); // $ExpectType string | undefined
findCacheDir({ name: 'unicorns', thunk: false }); // $ExpectType string | undefined
findCacheDir({}); // $ExpectError
findCacheDir(); // $ExpectError
const thunk = findCacheDir({ name: 'unicorns', thunk: true });
thunk; // $ExpectType ((...pathParts: string[]) => string) | undefined
if (thunk) {
thunk(); // $ExpectType string
thunk('bar.js'); // $ExpectType string
thunk('baz', 'quz.js'); // $ExpectType string
}