我正在尝试为我的 RESTAPI 服务器设置一些测试。我使用打字稿。我尝试导入chai
和chai-http
使用 ES6 语法,但显然不支持(此处为 Github 问题)。我收到一个错误,所以我不得不require
直接访问文件。
var chai = require('chai')
, chaiHttp = require('chai-http');
import * from '@types/chai-http';
/*
* Both librairies have limited support of ES6 import.
* See https://github.com/DefinitelyTyped/DefinitelyTyped/issues/19480
*/
chai.use(chaiHttp);
import { expect } from 'chai' ;
import 'mocha';
现在的事情是打字稿由于某种原因没有导入@types/chai-http
,所以当我尝试使用时expect(res).to.have.status(201);
,我得到一个错误,编译器抱怨
Error TS2339: Property status does not exist on type Assertion
如何直接导入类型声明?
谢谢