我尝试在之前的帖子中寻找答案,但我还没有找到答案,所以这里是:
我目前正在尝试使用 Typescript 中 Chai 的 Expect() 来测试对象实例属性值的返回类型。到目前为止,我已经尝试过:
/* My type file */
export type customType = "one" | "two" | "three";
export default customType;
/* My test file */
import customType from '{path_to_customType}'; // 'customType' is declared but its value is never read.
const newObject = new Object({property1: value1}) //note: value1 is of type customType
describe("Class1 test", () => {
it('my tests', () => {
expect(newObject).to.have.property("property1").to.equal("value1"); //so far, this one works fine
expect(newObject).to.be.a('customType'); // not working
expect(newObject).to.be.an('customType'); // not …Run Code Online (Sandbox Code Playgroud) 我已经用 TypeScript 编写了大约一年左右的时间,并且我在 Github 上发现了一个用 Rust 编写的不错的项目,我想将其包装在 TypeScript 中。我从未用 Rust 编程,但我有 C++ 经验。我相信标题中我的问题已经很清楚了。Rust 中的结构有点像 TypeScript 中的接口吗?