[英]How to declare a module with simple one-file project
I am trying to import my library like so: 我试图像这样导入我的库:
import jsonStdio = require('json-stdio');
I am getting this error: TS7016 - 我收到此错误: TS7016-
The library in question is here: https://github.com/ORESoftware/json-stdio/blob/master/index.ts 有问题的库在这里: https : //github.com/ORESoftware/json-stdio/blob/master/index.ts
does anyone know how I can properly create a module so that it can imported using import x = require('x')
syntax with TS? 有谁知道我如何正确创建一个模块,以便可以使用
import x = require('x')
语法和TS import x = require('x')
该模块?
Ahh, all I had to do was add the package.json
file for the json-stdio
project: 啊,我要做的就是为
json-stdio
项目添加package.json
文件:
"typings": "index.d.ts",
"types": "index.d.ts",
if there is a better/different way to do it, someone please let me know, but because I missing one of those lines (I always add both, just because), then it didn't recognized my .d.ts / declaration
file in my json-stdio
project. 如果有更好/不同的方法,请让我知道,但是因为我错过了其中一行(我总是将两者都添加,仅是因为),所以它无法识别我的
.d.ts / declaration
文件在我的json-stdio
项目中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.