Typescript: Output directory messed up if tsc is triggered as VS Code task.

Created on 26 May 2016  ·  12Comments  ·  Source: microsoft/TypeScript

This only happens if tsc is executed via Code.

TypeScript Version:

nightly (1.9.0-dev.20160525-1.0)

Code

.vscode/tasks.json

{
    "version": "0.1.0",
    "command": "node", // Using npm scripts would result the same.
    "isShellCommand": true,
    "args": ["node_modules/typescript/lib/tsc.js"],
    "showOutput": "silent",
    "problemMatcher": "$tsc"
}

tsconfig.json

{
    "compilerOptions": {
        "module": "commonjs",
        "allowJs": true,
        "outDir": "bld",
        "rootDir": "src"
    },
    "exclude": [
        "node_modules",
        "bld"
    ]
}

src/foo/bar.ts

import '../biu/pia';

src/biu/pia.js

// Empty file.

Expected behavior:

Compiles correctly.

Actual behavior:

error TS5055: Cannot write file '.../src/biu/pia.js' because it would overwrite input file.

And if you put another .ts file and import it in src/foo.bar.ts, it would be output as .js file nested to its .ts source.

Bug Fixed

Most helpful comment

@zhengbli shouldn't this be addressed in 2.0. It works in 1.8.x and is broken in @next. I am asking since it is tagged for 2.1

All 12 comments

Possibly related to Microsoft/Vscode#6719 ?

@zhengbli any thoughts?

Seems to be a VSCode task runner issue with node v6, the same as Microsoft/vscode#6719. Running tsc from command line doesn't repro the error.

The regression occurs in the cd1af127 commit.

This (L590, program.ts) seems to be the offending change. It changes the capitalisation of the Windows drive letter (lower to upper in the case of Microsoft/vscode#6719).

When run from the command line, the drive letter is already capitalised and stays capitalised.

Evidence that @Seikho has identified the problem.

After further digging, it's a change from Node v5 to Node v6 in the behaviour of fs.realpath which is used in L547 sys.ts.

In node v5:

$ node
> process.version
'v5.11.1'
> require('fs').realpathSync('c:\\projects')
'c:\\projects'
>                                     

In node v6:

$ node
> process.version
'v6.2.0'
> require('fs').realpathSync('c:\\projects')
'C:\\projects'
>

@zhengbli could the 'external' tag be removed, and this be dealt with in TypeScript? See https://github.com/Microsoft/vscode/issues/6719#issuecomment-224828922.

EDIT: See also comment from node.js contributor about this: https://github.com/nodejs/node/issues/6624#issuecomment-221558779

Important observations from https://github.com/Microsoft/vscode/issues/6719:

  • make sure the symlink code works with drive letters created with subst as well. I have such a setup where I mapped C:\users\dirkb\projects => P:\ and this seems to fail with the latest build TS with wired error messages. See comment: https://github.com/Microsoft/vscode/issues/6719#issuecomment-224296908
  • there seems to be issue with drive letter in node 6.x: See nodejs/node#6624

@Seikho Thanks for the finding! The issue should be able to address from TypeScript side.

@zhengbli shouldn't this be addressed in 2.0. It works in 1.8.x and is broken in @next. I am asking since it is tagged for 2.1

Fixing in @next would be great - We've had to disable the VSCode build task for all our affected projects since this surfaced, which is a minor hassle but still a hassle.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fwanicka picture fwanicka  ·  3Comments

kyasbal-1994 picture kyasbal-1994  ·  3Comments

siddjain picture siddjain  ·  3Comments

uber5001 picture uber5001  ·  3Comments

wmaurer picture wmaurer  ·  3Comments