如何导入Nano(couchdb)-打字稿 [英] How to import nano (couchdb) - typescript

查看:118
本文介绍了如何导入Nano(couchdb)-打字稿的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在节点应用程序中导入和使用nano时遇到问题。

I have trouble importing and using nano in my node application.

(从文档中)js方式是:

The js way (from the doc) is :

var nano = require('nano')('http://localhost:5984');

如何使用打字稿来做到这一点?

How do I do that with typescript ?

我尝试

import * as Nano from "nano";
let nano = new Nano('http://localhost:5984');

但是我得到:Nano不是对象。

But then I get : Nano is not an object.

推荐答案

通过安装@ types / nano,我们可以查看:

By installing @types/nano we can look at :

node_modules/@types/nano/index.d.ts

在其中看到以下行:

declare function nano(config: nano.Configuration | string):
 nano.ServerScope | nano.DocumentScope;

意思是Nano不是一个对象,所以答案是:

Meaning Nano is a function not an object, so the answer :

import * as Nano from "nano";
let nano = Nano('http://localhost:5984');

这篇关于如何导入Nano(couchdb)-打字稿的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆