簡體   English   中英

在打字稿中導入柴

[英]Importing Chai in Typescript

我正在嘗試在打字稿中使用 chai。

Chai 的 javascript 示例將其顯示為:

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

我下載了類型定義:

tsd install chai

...引用了文件,嘗試導入

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

我得到:

error TS1005: ';' expected

...知道如何做到這一點嗎?

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

chai 類型的測試執行以下操作:

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

那對你有用嗎?

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

使用expectshould

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM