V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
maxssy
V2EX  ›  问与答

typescript 的 tsconfig.json 不起作用?

  •  
  •   maxssy · Apr 26, 2020 · 4209 views
    This topic created in 2193 days ago, the information mentioned may be changed or developed.

    最近上班比较闲, 开始学 ts, 跟着教程生成 tsconfig.json 后发现修改里面的设置却不起作用, 只能用命令行参数

    ts 文件代码如下:

    function Hello(person: string){  
        return `Hello ${person}`;
    }
    
    const user= "sdfsdf";
    console.log(Hello(user));
    

    生成的 js 文件如下:

    function Hello(person) {
        return "Hello " + person;  //tsconfig.json 的 target 改为 es6 无效果, 然后用 tsc hello.ts -t es6 则正常
    }
    var user = "sdfsdf";
    console.log(Hello(user));
    

    tsc -p ./tsconfig.json 命令试过了, 没有用

    请问是什么原因呢?

    2 replies    2020-04-26 11:17:26 +08:00
    wszgrcy
        1
    wszgrcy  
       Apr 26, 2020 via Android   ❤️ 1
    tsconfig 发下。。。
    maxssy
        2
    maxssy  
    OP
       Apr 26, 2020
    @wszgrcy 已解决了,多谢
    我发现要设置 include 或者 files, 编译单个文件配置文件好像用不了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5988 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 56ms · UTC 02:15 · PVG 10:15 · LAX 19:15 · JFK 22:15
    ♥ Do have faith in what you're doing.