-
Notifications
You must be signed in to change notification settings - Fork 8
CTS v3内测
Xuan Wu edited this page May 12, 2019
·
2 revisions
VS Code 1.33.1下, 安装以下插件(搜索"htwx"):
@htwx 建议后两个插件名称改为中文
新建项目文件夹0511_测试
,用VS Code打开此文件夹.
在命令行中,在0511_测试
下,输入:
tsc - init
生成文件tsconfig.json
, 在文件中的compilerOptions
部分添加选项:
"cts": true
创建问好.cts
文件. 输入以下内容:
@htwx 这里无法调出内置输入法, 直接粘贴了
函数 问好(那谁) {
返回 "吃了么, " + 那谁;
}
变量 路人 = "打酱油的";
运行vsc命令"cts:构建"
@htwx 构建时报错:
> Executing task: cts -p /Users/xuanwu/work/cts-apps/0511_测试/tsconfig.json <
../../../node_modules/@types/node/index.d.ts:931:26 - error TS2304: Cannot find name 'Infinity'.
931 Infinity: typeof Infinity;
~~~~~~~~
../../../node_modules/@types/node/index.d.ts:6809:15 - error TS2420: Class 'AssertionError' incorrectly implements interface '错误_'.
Type 'AssertionError' is missing the following properties from type '错误_': 名称, 消息
6809 class AssertionError implements Error {
~~~~~~~~~~~~~~
问好.cts:1:7 - error TS7006: Parameter '那谁' implicitly has an '任意' type.
1 函数 问好(那谁) {
~~
Found 3 errors.
The terminal process terminated with exit code: 2
Terminal will be reused by tasks, press any key to close it.
生成问好.js
文件如下:
"use strict";
function 问好(那谁) {
return "吃了么, " + 那谁;
}
var 路人 = "打酱油的";
- 将
ctsscript
目录拷贝到/usr/local/lib/node_modules/
下 - 在
/usr/local/bin
下创建链接指向cts
,ctsserver
:
$ ln -s /usr/local/lib/node_modules/ctsscript/bin/cts /usr/local/bin/cts
$ ln -s /usr/local/lib/node_modules/ctsscript/bin/ctsserver /usr/local/bin/ctsserver