microsoft / microsoft/TypeScript

Detect Typescript in Javascript editors opened and inform developer, that he is writing different syntax and it will silently fail (probably)

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

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

Needs More Info
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ả

It would be super helpful to have something like:

Warning: TypeScript syntax detected in .jsx file. 
Would you like to:
[ ] Rename to .tsx
[ ] Remove TypeScript syntax
[ ] Ignore warning

This kind of UX improvement could save developers (especially those transitioning between JS and TS projects) a lot of time and frustration. It seems like a relatively straightforward detection that could help a lot of people!

VSCode already does similar helpful suggestions for other cases (like offering to create files that don't exist when you import them), so this would fit right in with that philosophy.

What it would solve?

It's the classic .jsx vs .tsx gotcha! 😄

This is such a common issue that even experienced developers run into it regularly. The file extension makes all the difference because:

  • .jsx files are treated as regular JavaScript/React files
  • .tsx files are treated as TypeScript/React files

So TypeScript typing just "silently fails" to work in .jsx files without any obvious error message about why the types aren't working.

It's one of those "spend an hour debugging only to realize it's a file extension" moments that every developer has experienced!

  • .CJS -> .TS, .JS -> .TS, .JSX -> .TSX

(Similar functionality could be created for CSS -> SCSS, ... .)

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

Issue không nêu tên tệp, bài kiểm thử hoặc điểm vào nào. Hãy bắt đầu bằng cách xác định nơi triển khai các chẩn đoán của trình soạn thảo hoặc các đề xuất của language service, sau đó xác định cách hoạt động phát hiện cú pháp và các thao tác đổi tên, xóa hoặc bỏ qua sẽ phù hợp; được xem là hoàn thành khi cảnh báo được đề xuất hoạt động với các phần mở rộng được liệt kê mà không làm gián đoạn JavaScript hợp lệ.

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
developer-experience, tooling
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
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.