當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript types.isString函數代碼示例

本文整理匯總了TypeScript中vs/base/common/types.isString函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript isString函數的具體用法?TypeScript isString怎麽用?TypeScript isString使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了isString函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1:

			.then(null, e => {
				if (isString(e) && /^Server returned/.test(e)) {
					return;
				}

				this.emit('update-not-available');
				this.emit('error', e);
			})
開發者ID:1833183060,項目名稱:vscode,代碼行數:8,代碼來源:auto-updater.win32.ts

示例2: getBooleanValueFromStringOrBoolean

export function getBooleanValueFromStringOrBoolean(value: any): boolean {
	if (types.isBoolean(value)) {
		return value;
	} else if (types.isString(value)) {
		return value.toLowerCase() === 'true';
	}
	return false;
}
開發者ID:burhandodhy,項目名稱:azuredatastudio,代碼行數:8,代碼來源:dialogHelper.ts

示例3: from

	export function from(value: TaskDefinition, extensionId: string, messageCollector: ExtensionMessageCollector): Tasks.TaskDefinition | undefined {
		if (!value) {
			return undefined;
		}
		let taskType = Types.isString(value.type) ? value.type : undefined;
		if (!taskType || taskType.length === 0) {
			messageCollector.error(nls.localize('TaskTypeConfiguration.noType', 'The task type configuration is missing the required \'taskType\' property'));
			return undefined;
		}
		let required: string[] = [];
		if (Array.isArray(value.required)) {
			for (let element of value.required) {
				if (Types.isString(element)) {
					required.push(element);
				}
			}
		}
		return { extensionId, taskType, required: required, properties: value.properties ? Objects.deepClone(value.properties) : {} };
	}
開發者ID:,項目名稱:,代碼行數:19,代碼來源:

示例4: Function

		return value.replace(regexp, (match: string, name: string) => {
			let config = this.configurationService.getConfiguration();
			let newValue = new Function('_', 'try {return _.' + name + ';} catch (ex) { return "";}')(config);
			if (Types.isString(newValue)) {
				// Prevent infinite recursion and also support nested references (or tokens)
				return newValue === originalValue ? '' : this.resolveString(newValue);
			} else {
				return this.resolve(newValue) + '';
			}
		});
開發者ID:GYGit,項目名稱:vscode,代碼行數:10,代碼來源:configVariables.ts

示例5: Function

		return value.replace(regexp, (match: string, name: string) => {
			let config = this.configurationService.getConfiguration();
			let newValue = new Function('_', 'try {return _.' + name + ';} catch (ex) { return "";}')(config);
			if (Types.isString(newValue)) {
				return newValue;
			}
			else {
				return this.resolve(newValue) + '';
			}
		});
開發者ID:1Hgm,項目名稱:vscode,代碼行數:10,代碼來源:configVariables.ts

示例6: toErrorMessage

export function toErrorMessage(error: any = null, verbose: boolean = false): string {
	if (!error) {
		return nls.localize('error.defaultMessage', "An unknown error occurred. Please consult the log for more details.");
	}

	if (Array.isArray(error)) {
		const errors: any[] = arrays.coalesce(error);
		const msg = toErrorMessage(errors[0], verbose);

		if (errors.length > 1) {
			return nls.localize('error.moreErrors', "{0} ({1} errors in total)", msg, errors.length);
		}

		return msg;
	}

	if (types.isString(error)) {
		return error;
	}

	if (error.detail) {
		const detail = error.detail;

		if (detail.error) {
			return exceptionToErrorMessage(detail.error, verbose);
		}

		if (detail.exception) {
			return exceptionToErrorMessage(detail.exception, verbose);
		}
	}

	if (error.stack) {
		return exceptionToErrorMessage(error, verbose);
	}

	if (error.message) {
		return error.message;
	}

	return nls.localize('error.defaultMessage', "An unknown error occurred. Please consult the log for more details.");
}
開發者ID:DonJayamanne,項目名稱:vscode,代碼行數:42,代碼來源:errorMessage.ts

示例7: test

	test('isString', () => {
		assert(!types.isString(undefined));
		assert(!types.isString(null));
		assert(!types.isString(5));
		assert(!types.isString([]));
		assert(!types.isString([1, 2, '3']));
		assert(!types.isString(true));
		assert(!types.isString({}));
		assert(!types.isString(/test/));
		assert(!types.isString(new RegExp('')));
		assert(!types.isString(new Date()));
		assert(!types.isString(assert));
		assert(!types.isString(function foo() { /**/ }));
		assert(!types.isString({ foo: 'bar' }));

		assert(types.isString('foo'));
	});
開發者ID:DonJayamanne,項目名稱:vscode,代碼行數:17,代碼來源:types.test.ts

示例8: is

	export function is(value: any): value is ShellConfiguration {
		let candidate: ShellConfiguration = value;
		return candidate && Types.isString(candidate.executable) && (candidate.args === void 0 || Types.isStringArray(candidate.args));
	}
開發者ID:yuit,項目名稱:vscode,代碼行數:4,代碼來源:taskSystem.ts

示例9: Function

		return value.replace(regexp, (match: string, name: string) => {
			let config = this.configurationService.getConfiguration();
			let newValue = new Function('_', 'try {return _.' + name + ';} catch (ex) { return "";}')(config);
			return Types.isString(newValue) ? newValue : '';
		});
開發者ID:Aarushi-Ign,項目名稱:vscode,代碼行數:5,代碼來源:configVariables.ts

示例10: is

	export function is(value: any): value is ContributedTask {
		let candidate: ContributedTask = value;
		return candidate && candidate.defines && Types.isString(candidate.defines.type) && candidate.command !== void 0;
	}
開發者ID:naturtle,項目名稱:vscode,代碼行數:4,代碼來源:tasks.ts


注:本文中的vs/base/common/types.isString函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。