本文整理汇总了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);
})
示例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;
}
示例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) : {} };
}
示例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) + '';
}
});
示例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) + '';
}
});
示例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.");
}
示例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'));
});
示例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));
}
示例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 : '';
});
示例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;
}