Closed DiamondYuan closed 5 years ago
Merging #17 into master will not change coverage. The diff coverage is
n/a
.
@@ Coverage Diff @@
## master #17 +/- ##
======================================
Coverage 98.1% 98.1%
======================================
Files 19 19
Lines 527 527
======================================
Hits 517 517
Misses 10 10
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update b9b137d...b352142. Read the comment docs.
是否能写个单元测试验证一下你的定义是正确的?
是否能写个单元测试验证一下你的定义是正确的?
我建一个一次性的测试项目试试看。如果是要在原本项目上加的话还要装 ts-node 或 typescript 等依赖。
查了一下 egg 文档,egg bin 自带 ts-node.似乎不用新项目。
@DiamondYuan 在 devDeps 里加依赖就行,不一定要用 ts-node 来跑,你可以在 fixtures 下建个 ts 使用以下你写的每个声明,然后用 tsc 编译一下无误,然后再 js 运行一下无误即可。
@DiamondYuan 在 devDeps 里加依赖就行,不一定要用 ts-node 来跑,你可以在 fixtures 下建个 ts 使用以下你写的每个声明,然后用 tsc 编译一下无误,然后再 js 运行一下无误即可。
我试了一下,把原来全部的测试改成 ts 后缀。然后改动一下依赖
const compressing = require('../..');
=> import * as compressing from '../../index'
真正测试之前用 tsc 编译一下。再运行测试。
否则需要把之前的 js 的 测试用 ts 再重写一遍。
@DiamondYuan js 和 ts 的单测还是得区分开,毕竟这是个 js 项目,不需要把 js 的测试重写一遍的,你就只需要写一个 ts 文件保证每个定义的声明,都能被正常取到,并且 tsc 编辑没毛病就行,可以参考一下 vue 的 types 的单测: https://github.com/vuejs/vue/blob/dev/types/test/options-test.ts
@DiamondYuan js 和 ts 的单测还是得区分开,毕竟这是个 js 项目,不需要把 js 的测试重写一遍的,你就只需要写一个 ts 文件保证每个定义的声明,都能被正常取到,并且 tsc 编辑没毛病就行,可以参考一下 vue 的 types 的单测: https://github.com/vuejs/vue/blob/dev/types/test/options-test.ts
写了一部分的测试了,你觉得怎么样。
@DiamondYuan 我觉得没问题,不过可以将 test/types/index.ts 挪到 test/fixtures 下,然后在当前的单测里,加一个用 tsc 编译加执行这个 ts 的用例即可 ,用例可以加到 test/ts.test.js
@DiamondYuan 我觉得没问题,不过可以将 test/types/index.ts 挪到 test/fixtures 下,然后在当前的单测里,加一个用 tsc 编译加执行这个 ts 的用例即可 ,用例可以加到 test/ts.test.js
写完了 package.json里加了编译的命令 tsc test/fixtures/types/*.ts
不过可能需要对着源码再看一遍 API
ci 跪了
error TS6053: File 'test/fixtures/types/*.ts' not found.
npm ERR! Windows_NT 6.3.9600
ci 跪了
error TS6053: File 'test/fixtures/types/*.ts' not found. npm ERR! Windows_NT 6.3.9600
加了一个 tsconfig.json 后可以了。本地明明不加也行的。。
是否能写个单元测试验证一下你的定义是正确的?
测试加好了。
1.4.0
增加类型声明,支持 typescript 。