TS 自定义守卫(User-Defined Type Guards)

218 阅读1分钟

Return form: parameterName is Type

function isString(obj:any): obj is string {
    return typeof obj === 'string'
}