microsoft / microsoft/TypeScript

Intellisense import suggestions - search index files only

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

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

Awaiting More Feedback 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ả

Hi guys, in large codebases I often encounter following issue:

I work with React/TypeScript combo. If I export something from a file, it's visible to the entire project and Intellisense auto-import feature suggests me all functions/classes/... exported. It's overwhelming to list through all exports, especially in large projects, where different entities can have the same name. I would love to create some sort of hierarchy with use of index files. Auto-import would implicitly "see" only exports within the same folder or siblings of current folder (recursively) if they have exports declared in index file.

Example:

/src
   /module-alpha
      /components
         Alpha.tsx
         List.tsx
         Detail.tsx
         index.ts --> export {default} from './Alpha.tsx'
      /model
         utils.ts
         index.ts --> export * as Utils from './utils'
      ModuleAlpha.tsx
      index.ts --> export {default} from './ModuleAlpha.tsx'
   /module-beta
      /components
         Beta.tsx
         List.tsx
         Detail.tsx
         index.ts --> export {default} from './Beta.tsx'
      /model
         utils.ts
         index.ts --> export * as Utils from './utils'     
      ModuleBeta.tsx
      index.ts --> export {default} from './ModuleBeta.tsx'

If I am in file /src/module-alpha/components/Alpha.tsx and I type Detail, I want the auto-import to suggest me just Detail within the current folder. In this context I would be able to "see":

  • List and Detail from current folder
  • Utils from /model within this module
  • ModuleAlpha
  • ModuleBeta

In other words - folder will behave like a file. If you want the entity to be visible outside the folder, you would have to explicitly define the export in the index file (recursively). I hope that it's clear.

I don't want to change the ES6 module system, and we could still import the entity manually. I just want the intellisense to suggest me only relevant things.

Is this something that can be done?

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 xem xét hành vi tự động import hiện có của IntelliSense và cách TypeScript phân giải các export từ các tệp index. So sánh các gợi ý cho cấu trúc module-alpha và module-beta được mô tả. Được coi là hoàn thành khi các gợi ý bị giới hạn bởi các export được khai báo đệ quy trong các tệp index, trong khi các import thủ công vẫn khả dụng.

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

Đánh giá

Công nghệ
react, 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
Khá rõ ràng
Mức phù hợp với người mới
28/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.