简体   繁体   English

在打字稿中导入柴

[英]Importing Chai in Typescript

I'm trying to use chai in typescript.我正在尝试在打字稿中使用 chai。

Chai's javascript example shows this as: Chai 的 javascript 示例将其显示为:

var should = require('chai').should();

I downloaded the type definition:我下载了类型定义:

tsd install chai

...referenced the file, tried to import ...引用了文件,尝试导入

/// <reference path='../typings/chai/chai.d.ts' />
import should = require('chai').should();

I get:我得到:

error TS1005: ';' expected

...any idea how to do this? ...知道如何做到这一点吗?

import { should } from 'chai';
should();

The tests for the chai typings do the following: chai 类型的测试执行以下操作:

import chai = require('chai');
var should = chai.should();

Does that work for you?那对你有用吗?

import { expect } from 'chai';
import 'chai/register-should';

to use both expect and should使用expectshould

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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