- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是 TS 新手,但一直在使用 TS 编写一些小型服务。我正在开发基于 node-redis 构建的 CLI 工具.很棒的 Redis 客户端。
以下代码段中客户端
的类型是什么?
import { createClient } from "redis";
let client; // what is type of `client`?
client = createClient();
根据用法推断类型给出以下结果。有没有办法清理这个?提前致谢。
import { createClient, RedisClientType, RedisScripts } from "redis";
let client: RedisClientType<{ json: { ARRAPPEND: typeof import("@node-redis/json/dist/commands/ARRAPPEND"); arrAppend: typeof import("@node-redis/json/dist/commands/ARRAPPEND"); ARRINDEX: typeof import("@node-redis/json/dist/commands/ARRINDEX"); arrIndex: typeof import("@node-redis/json/dist/commands/ARRINDEX"); ARRINSERT: typeof import("@node-redis/json/dist/commands/ARRINSERT"); arrInsert: typeof import("@node-redis/json/dist/commands/ARRINSERT"); ARRLEN: typeof import("@node-redis/json/dist/commands/ARRLEN"); arrLen: typeof import("@node-redis/json/dist/commands/ARRLEN"); ARRPOP: typeof import("@node-redis/json/dist/commands/ARRPOP"); arrPop: typeof import("@node-redis/json/dist/commands/ARRPOP"); ARRTRIM: typeof import("@node-redis/json/dist/commands/ARRTRIM"); arrTrim: typeof import("@node-redis/json/dist/commands/ARRTRIM"); DEBUG_MEMORY: typeof import("@node-redis/json/dist/commands/DEBUG_MEMORY"); debugMemory: typeof import("@node-redis/json/dist/commands/DEBUG_MEMORY"); DEL: typeof import("@node-redis/json/dist/commands/DEL"); del: typeof import("@node-redis/json/dist/commands/DEL"); FORGET: typeof import("@node-redis/json/dist/commands/FORGET"); forget: typeof import("@node-redis/json/dist/commands/FORGET"); GET: typeof import("@node-redis/json/dist/commands/GET"); get: typeof import("@node-redis/json/dist/commands/GET"); MGET: typeof import("@node-redis/json/dist/commands/MGET"); mGet: typeof import("@node-redis/json/dist/commands/MGET"); NUMINCRBY: typeof import("@node-redis/json/dist/commands/NUMINCRBY"); numIncrBy: typeof import("@node-redis/json/dist/commands/NUMINCRBY"); NUMMULTBY: typeof import("@node-redis/json/dist/commands/NUMMULTBY"); numMultBy: typeof import("@node-redis/json/dist/commands/NUMMULTBY"); OBJKEYS: typeof import("@node-redis/json/dist/commands/OBJKEYS"); objKeys: typeof import("@node-redis/json/dist/commands/OBJKEYS"); OBJLEN: typeof import("@node-redis/json/dist/commands/OBJLEN"); objLen: typeof import("@node-redis/json/dist/commands/OBJLEN"); RESP: typeof import("@node-redis/json/dist/commands/RESP"); resp: typeof import("@node-redis/json/dist/commands/RESP"); SET: typeof import("@node-redis/json/dist/commands/SET"); set: typeof import("@node-redis/json/dist/commands/SET"); STRAPPEND: typeof import("@node-redis/json/dist/commands/STRAPPEND"); strAppend: typeof import("@node-redis/json/dist/commands/STRAPPEND"); STRLEN: typeof import("@node-redis/json/dist/commands/STRLEN"); strLen: typeof import("@node-redis/json/dist/commands/STRLEN"); TYPE: typeof import("@node-redis/json/dist/commands/TYPE"); type: typeof import("@node-redis/json/dist/commands/TYPE"); }; ft: { _LIST: typeof import("@node-redis/search/dist/commands/_LIST"); _list: typeof import("@node-redis/search/dist/commands/_LIST"); ALTER: typeof import("@node-redis/search/dist/commands/ALTER"); alter: typeof import("@node-redis/search/dist/commands/ALTER"); AGGREGATE: typeof import("@node-redis/search/dist/commands/AGGREGATE"); aggregate: typeof import("@node-redis/search/dist/commands/AGGREGATE"); ALIASADD: typeof import("@node-redis/search/dist/commands/ALIASADD"); aliasAdd: typeof import("@node-redis/search/dist/commands/ALIASADD"); ALIASDEL: typeof import("@node-redis/search/dist/commands/ALIASDEL"); aliasDel: typeof import("@node-redis/search/dist/commands/ALIASDEL"); ALIASUPDATE: typeof import("@node-redis/search/dist/commands/ALIASUPDATE"); aliasUpdate: typeof import("@node-redis/search/dist/commands/ALIASUPDATE"); CONFIG_GET: typeof import("@node-redis/search/dist/commands/CONFIG_GET"); configGet: typeof import("@node-redis/search/dist/commands/CONFIG_GET"); CONFIG_SET: typeof import("@node-redis/search/dist/commands/CONFIG_SET"); configSet: typeof import("@node-redis/search/dist/commands/CONFIG_SET"); CREATE: typeof import("@node-redis/search/dist/commands/CREATE"); create: typeof import("@node-redis/search/dist/commands/CREATE"); DICTADD: typeof import("@node-redis/search/dist/commands/DICTADD"); dictAdd: typeof import("@node-redis/search/dist/commands/DICTADD"); DICTDEL: typeof import("@node-redis/search/dist/commands/DICTDEL"); dictDel: typeof import("@node-redis/search/dist/commands/DICTDEL"); DICTDUMP: typeof import("@node-redis/search/dist/commands/DICTDUMP"); dictDump: typeof import("@node-redis/search/dist/commands/DICTDUMP"); DROPINDEX: typeof import("@node-redis/search/dist/commands/DROPINDEX"); dropIndex: typeof import("@node-redis/search/dist/commands/DROPINDEX"); EXPLAIN: typeof import("@node-redis/search/dist/commands/EXPLAIN"); explain: typeof import("@node-redis/search/dist/commands/EXPLAIN"); EXPLAINCLI: typeof import("@node-redis/search/dist/commands/EXPLAINCLI"); explainCli: typeof import("@node-redis/search/dist/commands/EXPLAINCLI"); INFO: typeof import("@node-redis/search/dist/commands/INFO"); info: typeof import("@node-redis/search/dist/commands/INFO"); PROFILESEARCH: typeof import("@node-redis/search/dist/commands/PROFILE_SEARCH"); profileSearch: typeof import("@node-redis/search/dist/commands/PROFILE_SEARCH"); PROFILEAGGREGATE: typeof import("@node-redis/search/dist/commands/PROFILE_AGGREGATE"); profileAggregate: typeof import("@node-redis/search/dist/commands/PROFILE_AGGREGATE"); SEARCH: typeof import("@node-redis/search/dist/commands/SEARCH"); search: typeof import("@node-redis/search/dist/commands/SEARCH"); SPELLCHECK: typeof import("@node-redis/search/dist/commands/SPELLCHECK"); spellCheck: typeof import("@node-redis/search/dist/commands/SPELLCHECK"); SUGADD: typeof import("@node-redis/search/dist/commands/SUGADD"); sugAdd: typeof import("@node-redis/search/dist/commands/SUGADD"); SUGDEL: typeof import("@node-redis/search/dist/commands/SUGDEL"); sugDel: typeof import("@node-redis/search/dist/commands/SUGDEL"); SUGGET_WITHPAYLOADS: typeof import("@node-redis/search/dist/commands/SUGGET_WITHPAYLOADS"); sugGetWithPayloads: typeof import("@node-redis/search/dist/commands/SUGGET_WITHPAYLOADS"); SUGGET_WITHSCORES_WITHPAYLOADS: typeof import("@node-redis/search/dist/commands/SUGGET_WITHSCORES_WITHPAYLOADS"); sugGetWithScoresWithPayloads: typeof import("@node-redis/search/dist/commands/SUGGET_WITHSCORES_WITHPAYLOADS"); SUGGET_WITHSCORES: typeof import("@node-redis/search/dist/commands/SUGGET_WITHSCORES"); sugGetWithScores: typeof import("@node-redis/search/dist/commands/SUGGET_WITHSCORES"); SUGGET: typeof import("@node-redis/search/dist/commands/SUGGET"); sugGet: typeof import("@node-redis/search/dist/commands/SUGGET"); SUGLEN: typeof import("@node-redis/search/dist/commands/SUGLEN"); sugLen: typeof import("@node-redis/search/dist/commands/SUGLEN"); SYNDUMP: typeof import("@node-redis/search/dist/commands/SYNDUMP"); synDump: typeof import("@node-redis/search/dist/commands/SYNDUMP"); SYNUPDATE: typeof import("@node-redis/search/dist/commands/SYNUPDATE"); synUpdate: typeof import("@node-redis/search/dist/commands/SYNUPDATE"); TAGVALS: typeof import("@node-redis/search/dist/commands/TAGVALS"); tagVals: typeof import("@node-redis/search/dist/commands/TAGVALS"); }; ts: { ADD: typeof import("@node-redis/time-series/dist/commands/ADD"); add: typeof import("@node-redis/time-series/dist/commands/ADD"); ALTER: typeof import("@node-redis/time-series/dist/commands/ALTER"); alter: typeof import("@node-redis/time-series/dist/commands/ALTER"); CREATE: typeof import("@node-redis/time-series/dist/commands/CREATE"); create: typeof import("@node-redis/time-series/dist/commands/CREATE"); CREATERULE: typeof import("@node-redis/time-series/dist/commands/CREATERULE"); createRule: typeof import("@node-redis/time-series/dist/commands/CREATERULE"); DECRBY: typeof import("@node-redis/time-series/dist/commands/DECRBY"); decrBy: typeof import("@node-redis/time-series/dist/commands/DECRBY"); DEL: typeof import("@node-redis/time-series/dist/commands/DEL"); del: typeof import("@node-redis/time-series/dist/commands/DEL"); DELETERULE: typeof import("@node-redis/time-series/dist/commands/DELETERULE"); deleteRule: typeof import("@node-redis/time-series/dist/commands/DELETERULE"); GET: typeof import("@node-redis/time-series/dist/commands/GET"); get: typeof import("@node-redis/time-series/dist/commands/GET"); INCRBY: typeof import("@node-redis/time-series/dist/commands/INCRBY"); incrBy: typeof import("@node-redis/time-series/dist/commands/INCRBY"); INFO_DEBUG: typeof import("@node-redis/time-series/dist/commands/INFO_DEBUG"); infoDebug: typeof import("@node-redis/time-series/dist/commands/INFO_DEBUG"); INFO: typeof import("@node-redis/time-series/dist/commands/INFO"); info: typeof import("@node-redis/time-series/dist/commands/INFO"); MADD: typeof import("@node-redis/time-series/dist/commands/MADD"); mAdd: typeof import("@node-redis/time-series/dist/commands/MADD"); MGET: typeof import("@node-redis/time-series/dist/commands/MGET"); mGet: typeof import("@node-redis/time-series/dist/commands/MGET"); MGET_WITHLABELS: typeof import("@node-redis/time-series/dist/commands/MGET_WITHLABELS"); mGetWithLabels: typeof import("@node-redis/time-series/dist/commands/MGET_WITHLABELS"); QUERYINDEX: typeof import("@node-redis/time-series/dist/commands/QUERYINDEX"); queryIndex: typeof import("@node-redis/time-series/dist/commands/QUERYINDEX"); RANGE: typeof import("@node-redis/time-series/dist/commands/RANGE"); range: typeof import("@node-redis/time-series/dist/commands/RANGE"); REVRANGE: typeof import("@node-redis/time-series/dist/commands/REVRANGE"); revRange: typeof import("@node-redis/time-series/dist/commands/REVRANGE"); MRANGE: typeof import("@node-redis/time-series/dist/commands/MRANGE"); mRange: typeof import("@node-redis/time-series/dist/commands/MRANGE"); MRANGE_WITHLABELS: typeof import("@node-redis/time-series/dist/commands/MRANGE_WITHLABELS"); mRangeWithLabels: typeof import("@node-redis/time-series/dist/commands/MRANGE_WITHLABELS"); MREVRANGE: typeof import("@node-redis/time-series/dist/commands/MREVRANGE"); mRevRange: typeof import("@node-redis/time-series/dist/commands/MREVRANGE"); MREVRANGE_WITHLABELS: typeof import("@node-redis/time-series/dist/commands/MREVRANGE_WITHLABELS"); mRevRangeWithLabels: typeof import("@node-redis/time-series/dist/commands/MREVRANGE_WITHLABELS"); }; bf: { ADD: typeof import("@node-redis/bloom/dist/commands/bloom/ADD"); add: typeof import("@node-redis/bloom/dist/commands/bloom/ADD"); EXISTS: typeof import("@node-redis/bloom/dist/commands/bloom/EXISTS"); exists: typeof import("@node-redis/bloom/dist/commands/bloom/EXISTS"); INFO: typeof import("@node-redis/bloom/dist/commands/bloom/INFO"); info: typeof import("@node-redis/bloom/dist/commands/bloom/INFO"); INSERT: typeof import("@node-redis/bloom/dist/commands/bloom/INSERT"); insert: typeof import("@node-redis/bloom/dist/commands/bloom/INSERT"); LOADCHUNK: typeof import("@node-redis/bloom/dist/commands/bloom/LOADCHUNK"); loadChunk: typeof import("@node-redis/bloom/dist/commands/bloom/LOADCHUNK"); MADD: typeof import("@node-redis/bloom/dist/commands/bloom/MADD"); mAdd: typeof import("@node-redis/bloom/dist/commands/bloom/MADD"); MEXISTS: typeof import("@node-redis/bloom/dist/commands/bloom/MEXISTS"); mExists: typeof import("@node-redis/bloom/dist/commands/bloom/MEXISTS"); RESERVE: typeof import("@node-redis/bloom/dist/commands/bloom/RESERVE"); reserve: typeof import("@node-redis/bloom/dist/commands/bloom/RESERVE"); SCANDUMP: typeof import("@node-redis/bloom/dist/commands/bloom/SCANDUMP"); scanDump: typeof import("@node-redis/bloom/dist/commands/bloom/SCANDUMP"); }; cms: { INCRBY: typeof import("@node-redis/bloom/dist/commands/count-min-sketch/INCRBY"); incrBy: typeof import("@node-redis/bloom/dist/commands/count-min-sketch/INCRBY"); INFO: typeof import("@node-redis/bloom/dist/commands/count-min-sketch/INFO"); info: typeof import("@node-redis/bloom/dist/commands/count-min-sketch/INFO"); INITBYDIM: typeof import("@node-redis/bloom/dist/commands/count-min-sketch/INITBYDIM"); initByDim: typeof import("@node-redis/bloom/dist/commands/count-min-sketch/INITBYDIM"); INITBYPROB: typeof import("@node-redis/bloom/dist/commands/count-min-sketch/INITBYPROB"); initByProb: typeof import("@node-redis/bloom/dist/commands/count-min-sketch/INITBYPROB"); MERGE: typeof import("@node-redis/bloom/dist/commands/count-min-sketch/MERGE"); merge: typeof import("@node-redis/bloom/dist/commands/count-min-sketch/MERGE"); QUERY: typeof import("@node-redis/bloom/dist/commands/count-min-sketch/QUERY"); query: typeof import("@node-redis/bloom/dist/commands/count-min-sketch/QUERY"); }; cf: { ADD: typeof import("@node-redis/bloom/dist/commands/cuckoo/ADD"); add: typeof import("@node-redis/bloom/dist/commands/cuckoo/ADD"); ADDNX: typeof import("@node-redis/bloom/dist/commands/cuckoo/ADDNX"); addNX: typeof import("@node-redis/bloom/dist/commands/cuckoo/ADDNX"); COUNT: typeof import("@node-redis/bloom/dist/commands/cuckoo/COUNT"); count: typeof import("@node-redis/bloom/dist/commands/cuckoo/COUNT"); DEL: typeof import("@node-redis/bloom/dist/commands/cuckoo/DEL"); del: typeof import("@node-redis/bloom/dist/commands/cuckoo/DEL"); EXISTS: typeof import("@node-redis/bloom/dist/commands/cuckoo/EXISTS"); exists: typeof import("@node-redis/bloom/dist/commands/cuckoo/EXISTS"); INFO: typeof import("@node-redis/bloom/dist/commands/cuckoo/INFO"); info: typeof import("@node-redis/bloom/dist/commands/cuckoo/INFO"); INSERT: typeof import("@node-redis/bloom/dist/commands/cuckoo/INSERT"); insert: typeof import("@node-redis/bloom/dist/commands/cuckoo/INSERT"); INSERTNX: typeof import("@node-redis/bloom/dist/commands/cuckoo/INSERTNX"); insertNX: typeof import("@node-redis/bloom/dist/commands/cuckoo/INSERTNX"); LOADCHUNK: typeof import("@node-redis/bloom/dist/commands/cuckoo/LOADCHUNK"); loadChunk: typeof import("@node-redis/bloom/dist/commands/cuckoo/LOADCHUNK"); RESERVE: typeof import("@node-redis/bloom/dist/commands/cuckoo/RESERVE"); reserve: typeof import("@node-redis/bloom/dist/commands/cuckoo/RESERVE"); SCANDUMP: typeof import("@node-redis/bloom/dist/commands/cuckoo/SCANDUMP"); scanDump: typeof import("@node-redis/bloom/dist/commands/cuckoo/SCANDUMP"); }; topK: { ADD: typeof import("@node-redis/bloom/dist/commands/top-k/ADD"); add: typeof import("@node-redis/bloom/dist/commands/top-k/ADD"); COUNT: typeof import("@node-redis/bloom/dist/commands/top-k/COUNT"); count: typeof import("@node-redis/bloom/dist/commands/top-k/COUNT"); INCRBY: typeof import("@node-redis/bloom/dist/commands/top-k/INCRBY"); incrBy: typeof import("@node-redis/bloom/dist/commands/top-k/INCRBY"); INFO: typeof import("@node-redis/bloom/dist/commands/top-k/INFO"); info: typeof import("@node-redis/bloom/dist/commands/top-k/INFO"); LIST: typeof import("@node-redis/bloom/dist/commands/top-k/LIST"); list: typeof import("@node-redis/bloom/dist/commands/top-k/LIST"); QUERY: typeof import("@node-redis/bloom/dist/commands/top-k/QUERY"); query: typeof import("@node-redis/bloom/dist/commands/top-k/QUERY"); RESERVE: typeof import("@node-redis/bloom/dist/commands/top-k/RESERVE"); reserve: typeof import("@node-redis/bloom/dist/commands/top-k/RESERVE"); }; }, RedisScripts>;
client = createClient();
最佳答案
您可以使用类型实用程序 ReturnType<FunctionType>
派生出你需要的类型,像这样:
import { createClient } from "redis";
let client: ReturnType<typeof createClient>;
关于typescript - createClient 返回的类型是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70718824/
我正在尝试编写一个相当多态的库。我遇到了一种更容易表现出来却很难说出来的情况。它看起来有点像这样: {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE
谁能解释一下这个表达式是如何工作的? type = type || 'any'; 这是否意味着如果类型未定义则使用“任意”? 最佳答案 如果 type 为“falsy”(即 false,或 undef
我有一个界面,在IAnimal.fs中, namespace Kingdom type IAnimal = abstract member Eat : Food -> unit 以及另一个成功
这个问题在这里已经有了答案: 关闭 10 年前。 Possible Duplicate: What is the difference between (type)value and type(va
在 C# 中,default(Nullable) 之间有区别吗? (或 default(long?) )和 default(long) ? Long只是一个例子,它可以是任何其他struct类型。 最
假设我有一个案例类: case class Foo(num: Int, str: String, bool: Boolean) 现在我还有一个简单的包装器: sealed trait Wrapper[
这个问题在这里已经有了答案: Create C# delegate type with ref parameter at runtime (1 个回答) 关闭 2 年前。 为了即时创建委托(dele
我正在尝试获取图像的 dct。一开始我遇到了错误 The function/feature is not implemented (Odd-size DCT's are not implemented
我正在尝试使用 AFNetworking 的 AFPropertyListRequestOperation,但是当我尝试下载它时,出现错误 预期的内容类型{( “应用程序/x-plist” )}, 得
我在下面收到错误。我知道这段代码的意思,但我不知道界面应该是什么样子: Element implicitly has an 'any' type because index expression is
我尝试将 SignalType 从 ReactiveCocoa 扩展为自定义 ErrorType,代码如下所示 enum MyError: ErrorType { // .. cases }
我无法在任何其他问题中找到答案。假设我有一个抽象父类(super class) Abstract0,它有两个子类 Concrete1 和 Concrete1。我希望能够在 Abstract0 中定义类
我想知道为什么这个索引没有用在 RANGE 类型中,而是用在 INDEX 中: 索引: CREATE INDEX myindex ON orders(order_date); 查询: EXPLAIN
我正在使用 RxJava,现在我尝试通过提供 lambda 来订阅可观察对象: observableProvider.stringForKey(CURRENT_DELETED_ID) .sub
我已经尝试了几乎所有解决问题的方法,其中包括。为 提供类型使用app.use(express.static('public'))还有更多,但我似乎无法为此找到解决方案。 index.js : imp
以下哪个 CSS 选择器更快? input[type="submit"] { /* styles */ } 或 [type="submit"] { /* styles */ } 只是好
我不知道这个设置有什么问题,我在 IDEA 中获得了所有注释(@Controller、@Repository、@Service),它在行号左侧显示 bean,然后转到该 bean。 这是错误: 14-
我听从了建议 registering java function as a callback in C function并且可以使用“简单”类型(例如整数和字符串)进行回调,例如: jstring j
有一些 java 类,加载到 Oracle 数据库(版本 11g)和 pl/sql 函数包装器: create or replace function getDataFromJava( in_uLis
我已经从 David Walsh 的 css 动画回调中获取代码并将其修改为 TypeScript。但是,我收到一个错误,我不知道为什么: interface IBrowserPrefix { [
我是一名优秀的程序员,十分优秀!