当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript tsd.expectType函数代码示例

本文整理汇总了TypeScript中tsd.expectType函数的典型用法代码示例。如果您正苦于以下问题:TypeScript expectType函数的具体用法?TypeScript expectType怎么用?TypeScript expectType使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了expectType函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1:

    mapValues: ({ header, index, value }) => {
      expectType<string>(header);
      expectType<number>(index);
      expectType<any>(value);

      return value.toLowerCase();
    },
开发者ID:mafintosh,项目名称:csv-parser,代码行数:7,代码来源:index.test-d.ts

示例2: constructor

	constructor(props: object) {
		super(props);

		expectType<Bar>(autoBind.react(this));
		expectType<Bar>(autoBind.react(this, {include: ['foo', /bar/]}));
		expectType<Bar>(autoBind.react(this, {exclude: ['foo', /bar/]}));
	}
开发者ID:sindresorhus,项目名称:auto-bind,代码行数:7,代码来源:index.test-d.ts

示例3: cpy

	cpy('foo.js', 'destination').on('progress', progress => {
		expectType<ProgressData>(progress);

		expectType<number>(progress.completedFiles);
		expectType<number>(progress.totalFiles);
		expectType<number>(progress.completedSize);
		expectType<number>(progress.percent);
	})
开发者ID:sindresorhus,项目名称:cpy,代码行数:8,代码来源:index.test-d.ts

示例4:

		data => {
			expectType<ProgressData>(data);

			expectType<string>(data.src);
			expectType<string>(data.dest);
			expectType<number>(data.size);
			expectType<number>(data.written);
			expectType<number>(data.percent);
		}
开发者ID:sindresorhus,项目名称:cp-file,代码行数:9,代码来源:index.test-d.ts

示例5:

	(error, chunk, encoding, callback) => {
		expectType<Error | null>(error);
		expectType<Buffer>(chunk);
		expectType<string>(encoding);
		expectType<
			(
				error?: Error | null,
				buffer?: string | Buffer | Uint8Array,
				encoding?: string
			) => void
		>(callback);

		callback();
		callback(null);
		callback(error);
		callback(null, chunk.toString(encoding).toUpperCase());
		callback(null, Buffer.from(chunk.toString(encoding).toUpperCase()));
		callback(
			null,
			new Uint8Array(Buffer.from(chunk.toString(encoding).toUpperCase()))
		);
		callback(null, chunk.toString(encoding).toUpperCase(), 'utf8');
		callback(null, chunk.toString(encoding).toUpperCase(), encoding);
	}
开发者ID:sindresorhus,项目名称:first-chunk-stream,代码行数:24,代码来源:index.test-d.ts

示例6: require

import {expectType} from 'tsd';
import pathExists = require('.');

expectType<Promise<boolean>>(pathExists('foo.ts'));
expectType<boolean>(pathExists.sync('foo.ts'));
开发者ID:sindresorhus,项目名称:path-exists,代码行数:5,代码来源:index.test-d.ts

示例7: require

import {expectType} from 'tsd';
import imageType = require('.');
import {ImageTypeResult, ImageType} from '.';

imageType(new Buffer([0xff, 0xd8, 0xff]));
imageType(new Uint8Array([0xff, 0xd8, 0xff]));

expectType<ImageTypeResult | null>(imageType(new Buffer([0xff, 0xd8, 0xff])));
expectType<ImageTypeResult | null>(
	imageType(new Uint8Array([0xff, 0xd8, 0xff]))
);

const result = imageType(new Buffer([0xff, 0xd8, 0xff]));
if (result != null) {
	expectType<ImageType>(result.ext);
	expectType<string>(result.mime);
}

expectType<number>(imageType.minimumBytes);
开发者ID:sindresorhus,项目名称:image-type,代码行数:19,代码来源:index.test-d.ts

示例8: require

import {expectType} from 'tsd';
import arrayUniq = require('.');

expectType<number[]>(arrayUniq([1, 2, 3]));
开发者ID:sindresorhus,项目名称:array-uniq,代码行数:4,代码来源:index.test-d.ts

示例9: require

import {expectType} from 'tsd';
import mapObject = require('.');

const options: mapObject.Options = {};

const newObject = mapObject({foo: 'bar'}, (key, value) => [value, key]);
expectType<{[key: string]: 'foo'}>(newObject);
expectType<'foo'>(newObject.bar);

const object = mapObject({foo: 'bar'}, (key, value) => [value, key], {
	target: {baz: 'baz'}
});
expectType<{baz: string} & {[x: string]: 'foo'}>(object);
expectType<'foo'>(object.bar);
expectType<string>(object.baz);

const object1 = mapObject({foo: 'bar'}, (key, value) => [value, key], {
	target: {baz: 'baz'},
	deep: false
});
expectType<{baz: string} & {[x: string]: 'foo'}>(object1);
expectType<'foo'>(object1.bar);
expectType<string>(object1.baz);

const object2 = mapObject({foo: 'bar'}, (key, value) => [value, key], {
	deep: true
});
expectType<{[key: string]: unknown}>(object2);
const object3 = mapObject({foo: 'bar'}, (key, value) => [value, key], {
	deep: true,
	target: {bar: 'baz' as const}
开发者ID:sindresorhus,项目名称:map-obj,代码行数:31,代码来源:index.test-d.ts

示例10: require

import {expectType} from 'tsd';
import superb = require('.');

expectType<readonly string[]>(superb.all);
expectType<string>(superb.random());
开发者ID:sindresorhus,项目名称:superb,代码行数:5,代码来源:index.test-d.ts


注:本文中的tsd.expectType函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。