microsoft / microsoft/TypeScript

tsc includes previous output in result when allowJs is enabled and "exclude" is non-empty

Đang mở
#20,862 5 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

In Discussion Suggestion
Ngôn ngữ chính
Go
Star
111k
Fork
14.4k
Merge trung bình
1 ngày 19 giờ
Pull request đã merge (30 ngày)
117

Mô tả

TypeScript Version: 2.7.0-dev.20171222

Code

For easy access, clone this gist: https://gist.github.com/WasabiFan/6922d6eb6224945ac809c216fdc37089

test.ts:

// Source code here

tsconfig.json:

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "outDir": "out",
    "allowJs": true
  },
  "exclude": [
    "node_modules"
  ]
}

Removing the exclude block or disabling allowJs avoids the issue.

Note that this is an easy state to get into: in my case, I generated a VSCode extension with their official templates and then enabled allowJs. I didn't realize what was going on until my PC ran out of RAM, as it automatically ran the watch task and the depth grew every time I saved.

Expected behavior:

I can compile the project with tsc as many times as I'd like.

Actual behavior:

PS D:\...> git clone https://gist.github.com/WasabiFan/6922d6eb6224945ac809c216fdc37089 tsc-recursion-demo-gist
Cloning into 'tsc-recursion-demo-gist'...
remote: Counting objects: 7, done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 7 (delta 1), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (7/7), done.
PS D:\...> cd .\tsc-recursion-demo-gist\
PS D:\...\tsc-recursion-demo-gist> tsc -p .
PS D:\...\tsc-recursion-demo-gist> tsc -p .
error TS5055: Cannot write file 'D:/.../tsc-recursion-demo-gist/out/test.js' because it would overwrite input file.
PS D:\...\tsc-recursion-demo-gist> tsc -p .
error TS5055: Cannot write file 'D:/.../tsc-recursion-demo-gist/out/out/test.js' because it would overwrite input file.
error TS5055: Cannot write file 'D:/.../tsc-recursion-demo-gist/out/test.js' because it would overwrite input file.
PS D:\...\tsc-recursion-demo-gist> tsc -p .
error TS5055: Cannot write file 'D:/.../tsc-recursion-demo-gist/out/out/out/test.js' because it would overwrite input file.
error TS5055: Cannot write file 'D:/.../tsc-recursion-demo-gist/out/out/test.js' because it would overwrite input file.
error TS5055: Cannot write file 'D:/.../tsc-recursion-demo-gist/out/test.js' because it would overwrite input file.
PS D:\...\tsc-recursion-demo-gist> tsc -p .
error TS5055: Cannot write file 'D:/.../tsc-recursion-demo-gist/out/out/out/out/test.js' because it would overwrite input file.
error TS5055: Cannot write file 'D:/.../tsc-recursion-demo-gist/out/out/out/test.js' because it would overwrite input file.
error TS5055: Cannot write file 'D:/.../tsc-recursion-demo-gist/out/out/test.js' because it would overwrite input file.
error TS5055: Cannot write file 'D:/.../tsc-recursion-demo-gist/out/test.js' because it would overwrite input file.
PS D:\...\tsc-recursion-demo-gist> tsc -p .
error TS5055: Cannot write file 'D:/.../tsc-recursion-demo-gist/out/out/out/out/out/test.js' because it would overwrite input file.
error TS5055: Cannot write file 'D:/.../tsc-recursion-demo-gist/out/out/out/out/test.js' because it would overwrite input file.
error TS5055: Cannot write file 'D:/.../tsc-recursion-demo-gist/out/out/out/test.js' because it would overwrite input file.
error TS5055: Cannot write file 'D:/.../tsc-recursion-demo-gist/out/out/test.js' because it would overwrite input file.
error TS5055: Cannot write file 'D:/.../tsc-recursion-demo-gist/out/test.js' because it would overwrite input file.

The fix (and the best option) is to exclude the output directory. But given that existing templates don't do that, I think this is a significant issue. I don't understand why this doesn't happen when the exclude block is removed; I assume there's an internal safety to prevent this problem that's overridden.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Clone gist được liên kết và tái hiện sự cố với test.ts và tsconfig.json, sử dụng allowJs, một exclude không rỗng và outDir. Bắt đầu bằng cách theo dõi việc phát hiện đầu vào của dự án và hành vi khi chạy lặp lại tsc -p. Hoàn tất khi các lần biên dịch lặp lại không còn đưa các đầu ra trước đó bên dưới out/ vào làm đầu vào mới hoặc tạo ra các đường dẫn đầu ra đệ quy.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
javascript, typescript
Lĩnh vực
compilers
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
30/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.