简体   繁体   中英

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 - 在此处输入图片说明

The library in question is here: 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?

Ahh, all I had to do was add the package.json file for the json-stdio project:

  "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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM