How to use the tsd.expectAssignable function in tsd

To help you get started, we’ve selected a few tsd examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sindresorhus / meow / index.test-d.ts View on Github external
import {expectAssignable, expectType} from 'tsd';
import {PackageJson} from 'type-fest';
import meow = require('.');
import {Result} from '.';

expectType>(meow('Help text'));
expectType>(meow('Help text', {hardRejection: false}));
expectAssignable<{flags: {foo: number}}>(
	meow({flags: {foo: {type: 'number'}}})
);
expectAssignable<{flags: {foo: string}}>(
	meow({flags: {foo: {type: 'string'}}})
);
expectAssignable<{flags: {foo: boolean}}>(
	meow({flags: {foo: {type: 'boolean'}}})
);
expectType>(meow({description: 'foo'}));
expectType>(meow({description: false}));
expectType>(meow({help: 'foo'}));
expectType>(meow({help: false}));
expectType>(meow({version: 'foo'}));
expectType>(meow({version: false}));
expectType>(meow({autoHelp: false}));
expectType>(meow({autoVersion: false}));
expectType>(meow({pkg: {foo: 'bar'}}));
expectType>(meow({argv: ['foo', 'bar']}));
expectType>(meow({inferType: true}));
github fregante / webext-storage-cache / index.test-d.ts View on Github external
import {expectType, expectNotAssignable, expectAssignable} from 'tsd';
import cache from '.';

type Primitive = boolean | number | string;
type Value = Primitive | Primitive[] | Record;

expectType>(cache.has('key'));
expectType>(cache.delete('key'));

expectType>(cache.get('key'));
expectType>(cache.get('key'));
expectNotAssignable>(cache.get('key'));

expectAssignable>(cache.set('key', 1));
expectAssignable>(cache.set('key', true));
expectAssignable>(cache.set('key', [true, 'string']));
expectAssignable>>(cache.set('key', {wow: [true, 'string']}));
expectAssignable>(cache.set('key', 1, 1));

tsd

Check TypeScript type definitions

MIT
Latest version published 4 months ago

Package Health Score

80 / 100
Full package analysis