How to use the tsd.expectType 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 chalk / chalk / index.test-d.ts View on Github external
// - Chalk -
// -- Instance --
expectType(new chalk.Instance({level: 1}));

// -- Properties --
expectType(chalk.level);

// -- Template literal --
expectType(chalk``);
const name = 'John';
expectType(chalk`Hello {bold.red ${name}}`);
expectType(chalk`Works with numbers {bold.red ${1}}`);

// -- Color methods --
expectType(chalk.hex('#DEADED'));
expectType(chalk.keyword('orange'));
expectType(chalk.rgb(0, 0, 0));
expectType(chalk.hsl(0, 0, 0));
expectType(chalk.hsv(0, 0, 0));
expectType(chalk.hwb(0, 0, 0));
expectType(chalk.ansi(30));
expectType(chalk.ansi256(0));
expectType(chalk.bgHex('#DEADED'));
expectType(chalk.bgKeyword('orange'));
expectType(chalk.bgRgb(0, 0, 0));
expectType(chalk.bgHsl(0, 0, 0));
expectType(chalk.bgHsv(0, 0, 0));
expectType(chalk.bgHwb(0, 0, 0));
expectType(chalk.bgAnsi(30));
expectType(chalk.bgAnsi256(0));
github aws / aws-xray-sdk-node / packages / core / test-d / index.test-d.ts View on Github external
expectType>(objects);
}

expectType(AWSXRay.captureHTTPs(http, true));
expectType(AWSXRay.captureHTTPs(https, true));

expectType(AWSXRay.captureHTTPsGlobal(http, true));
expectType(AWSXRay.captureHTTPsGlobal(https, true));

expectType(AWSXRay.capturePromise());
expectType(AWSXRay.capturePromise.patchThirdPartyPromise(Promise));

expectType<'error' | 'fault' | undefined>(AWSXRay.utils.getCauseTypeFromHttpStatus(200));
expectType(AWSXRay.utils.wildcardMatch('*', 'foo'));
expectType(AWSXRay.utils.LambdaUtils.validTraceData('moop'));
expectType(AWSXRay.utils.LambdaUtils.validTraceData());
expectType(AWSXRay.utils.LambdaUtils.populateTraceData(segment, 'moop'));
expectType<{ [key: string]: string }>(AWSXRay.utils.processTraceData());
expectType<{ [key: string]: string }>(AWSXRay.utils.processTraceData('Root=1-58ed6027-14afb2e09172c337713486c0;'));
const urlWithoutQuery: Omit = AWSXRay.utils.objectWithoutProperties(
  url.parse('url'), ['query'],
  true
);
expectError(urlWithoutQuery.query);

new AWSXRay.database.SqlData('databaseVer', 'driverVer', 'user', 'url', 'queryType');
const sqlData: AWSXRay.database.SqlData = new AWSXRay.database.SqlData();
expectType(sqlData.database_version);
expectType(sqlData.driver_version);
expectType(sqlData.preparation);
expectType(sqlData.url);
github sindresorhus / type-fest / test-d / package-json.ts View on Github external
import {expectType} from 'tsd';
import {PackageJson, LiteralUnion} from '..';

const packageJson: PackageJson = {};

expectType(packageJson.name);
expectType(packageJson.version);
expectType(packageJson.description);
expectType(packageJson.keywords);
expectType | undefined>(packageJson.homepage);
expectType(packageJson.bugs);
expectType(packageJson.license);
expectType | undefined>(packageJson.licenses);
expectType(packageJson.author);
expectType(packageJson.contributors);
expectType(packageJson.maintainers);
expectType(packageJson.files);
expectType(packageJson.main);
expectType(packageJson.bin);
expectType(packageJson.types);
expectType(packageJson.typings);
expectType(packageJson.man);
expectType(packageJson.directories);
github sindresorhus / parse-columns / index.test-d.ts View on Github external
transform(element, header, columnIndex, rowIndex) {
			expectType(element);
			expectType(header);
			expectType(columnIndex);
			expectType(rowIndex);

			if (columnIndex >= 1 && columnIndex <= 3) {
				return Number(element);
			}

			return element;
		}
	})
github sindresorhus / cli-boxes / index.test-d.ts View on Github external
import {expectType} from 'tsd';
import cliBoxes = require('.');
import {BoxStyle, Boxes} from '.';

expectType(cliBoxes);

expectType(cliBoxes.classic);
expectType(cliBoxes.double);
expectType(cliBoxes.doubleSingle);
expectType(cliBoxes.round);
expectType(cliBoxes.bold);
expectType(cliBoxes.single);
expectType(cliBoxes.singleDouble);
github aws / aws-xray-sdk-node / packages / core / test-d / index.test-d.ts View on Github external
expectType(AWSXRay.appendAWSWhitelist('/path/here'));
expectType(AWSXRay.appendAWSWhitelist({}));
expectError(AWSXRay.appendAWSWhitelist());
expectError(AWSXRay.appendAWSWhitelist(null));
expectError(AWSXRay.appendAWSWhitelist(0));

expectType(AWSXRay.setStreamingThreshold(10));

expectType(AWSXRay.setLogger(console));
AWSXRay.getLogger().debug('debug');
AWSXRay.getLogger().info({ foo: 'bar' }, 'info');
AWSXRay.getLogger().warn('warn', 123);
AWSXRay.getLogger().error('error');

expectType(AWSXRay.setDaemonAddress('192.168.0.23:8080'));

const traceId = '1-57fbe041-2c7ad569f5d6ff149137be86';
const segment = new AWSXRay.Segment('test', traceId);

expectType(AWSXRay.captureFunc('tracedFcn', () => 'OK', segment));
expectType(AWSXRay.captureFunc('tracedFcn', () => { return; }));
expectType(AWSXRay.captureFunc('tracedFcn', () => { throw new Error(); }));
let subseg: AWSXRay.Subsegment | undefined;
expectType(AWSXRay.captureFunc('tracedFcn', (sub) => { subseg = sub; }, segment));

async function fcn(seg?: AWSXRay.Subsegment) {
  if (seg) {
    seg.close();
  }
  return 'OK';
}
github sindresorhus / in-range / index.test-d.ts View on Github external
import {expectType} from 'tsd';
import inRange = require('.');

expectType(inRange(30, {end: 100}));
expectType(inRange(30, {start: 10, end: 100}));
github sindresorhus / pretty-bytes / index.test-d.ts View on Github external
import {expectType} from 'tsd';
import prettyBytes = require('.');

const options: prettyBytes.Options = {};

expectType(prettyBytes(1337));
expectType(prettyBytes(42, {signed: true}));
expectType(prettyBytes(1337, {locale: 'de'}));
expectType(prettyBytes(1337, {locale: true}));
expectType(prettyBytes(1337, {bits: true}));
github sindresorhus / active-win / index.test-d.ts View on Github external
import {expectType, expectError} from 'tsd';
import activeWin = require('.');
import {Result, LinuxResult, MacOSResult, WindowsResult} from '.';

expectType>(activeWin());

const result = activeWin.sync();

expectType(result);

if (result) {
	expectType<'macos' | 'linux' | 'windows'>(result.platform);
	expectType(result.title);
	expectType(result.id);
	expectType(result.bounds.x);
	expectType(result.bounds.y);
	expectType(result.bounds.width);
	expectType(result.bounds.height);
	expectType(result.owner.name);
	expectType(result.owner.processId);
	expectType(result.owner.path);
	expectType(result.memoryUsage);
	if (result.platform === 'macos') {
		expectType(result);
		expectType(result.owner.bundleId);
	} else if (result.platform === 'linux') {
		expectType(result);
		expectError(result.owner.bundleId);
	} else {
		expectType(result);
		expectError(result.owner.bundleId);
	}
github sindresorhus / path-key / index.test-d.ts View on Github external
import {expectType} from 'tsd';
import pathKey = require('.');

expectType(pathKey());
expectType(pathKey({env: {}}));
expectType(pathKey({platform: 'win32'}));

tsd

Check TypeScript type definitions

MIT
Latest version published 27 days ago

Package Health Score

87 / 100
Full package analysis