thinkjs / thinkjs

Use full ES2015+ features to develop Node.js applications, Support TypeScript.
https://thinkjs.org/
MIT License
5.31k stars 617 forks source link

typescript 编译时没有类型检测 #1079

Open zuoyanart opened 6 years ago

zuoyanart commented 6 years ago

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'.
SijieCai commented 5 years ago

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