thinkjs icon indicating copy to clipboard operation
thinkjs copied to clipboard

typescript 编译时没有类型检测

Open zuoyanart opened this issue 7 years ago • 1 comments

DESC

typescript 编译时没有类型检测

ENV

OS Platform: win7, centos

Node.js Version: 8.9.1 ThinkJS Version: think-cli 2.2.1

code

创建命令

thinkjs new xxx typescript

##js代码,controller/index.ts

import Base from './base.js';
export default class extends Base {
    indexAction() {
        let a: number = 'a';
        return this.display();
    }
}

编译

[2018-02-01T10:50:19.740] [17192] [INFO] - transpile file controller\index.ts success
[2018-02-01T10:50:21.201] [17192] [INFO] - transpile file controller\index.ts success

tsc编译

tsc src\controller\index.ts
src/controller/index.ts(4,13): error TS2322: Type '"a"' is not assignable to type 'number'.
src/controller/index.ts(5,21): error TS2339: Property 'display' does not exist on type 'default'.

zuoyanart avatar Feb 01 '18 02:02 zuoyanart

检查一下你的 development.js 里面的transpiler 的配置,看看和你的 tsconfig.json 的配置是否一致。@zuoyanart

SijieCai avatar Jan 10 '19 06:01 SijieCai