microsoft / microsoft/TypeScript

Path based Code navigation to /index.js seems broken

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

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

Experience Enhancement Suggestion
Ngôn ngữ chính
Go
Star
111k
Fork
14.3k
Merge trung bình
2 ngày 4 giờ
Pull request đã merge (30 ngày)
132

Mô tả

  • VSCode Version: 1.42.1
  • OS Version: Mac OS

Steps to Reproduce:
Code navigation seems broken when you import by path and the file is actually in an index.js file.
There are a couple of scenarios relevant to developing in react-native

  1. import from another package in a monorepo import SomeComponent from 'common-lib/Router, when the file is packages/common-lib/src/Router/index.js
  2. import in the same package import SomeComponent from 'modules/Router, when the file is src/modules/Router/index.js
  3. import SomeComponent from 'modules/Router, when the file is not actually index.js src/modules/Router/index.ios.js and src/modules/Router/index.android.js

In general, what works is loading a file name by name (not an index.js file)
What doesn't work is loading a file by path that is actually an index.js, index.native.js, index.ios.js, index.android.js etc file

My code structure is

root
    packages
           mobile
           server
                src
                       server
                       shared
           common-lib

There is some history here that is not ideal. But ok.

packages/server jsconfig.json

{
	"compilerOptions": {
		"target": "es2017",
		"allowSyntheticDefaultImports": false,
		"baseUrl": ".",
		"paths": {
			"common-lib/*": ["../common-lib/*"],
			"mobile/*": ["../mobile/*"],
			"modules/*": ["./src/shared/modules/*"],
			"components/*": ["./src/shared/components/*"],
			"router/*": ["./src/shared/router/*"],
			"server/*": ["./src/server*"],
			"App": ["./src/App"]
		}
	},
	"exclude": ["node_modules", "../../node_modules", "build"]
}

Does this issue occur when all extensions are disabled?: Yes

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

Bắt đầu bằng cách tái hiện ba trường hợp import với packages/server jsconfig.json được cung cấp, bao gồm index.js và các tệp index dành riêng cho từng nền tảng. Theo dõi việc điều hướng mã nguồn đối với các import dựa trên đường dẫn và so sánh với các import tệp được chỉ định tên; hoàn thành khi việc điều hướng đến được module đã được phân giải trong mỗi kịch bản được liệt kê.

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, devtools
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
35/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.