microsoft / microsoft/TypeScript
Intellisense import suggestions - search index files only
还没有人认领这个 Issue。
- 主要语言
- Go
- 星标
- 111k
- 派生
- 14.4k
- 平均合并
- 1 天 19 小时
- 30 天内合并 PR
- 117
描述
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":
ListandDetailfrom current folderUtilsfrom/modelwithin this moduleModuleAlphaModuleBeta
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?
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先检查现有的 IntelliSense 自动导入行为,以及 TypeScript 如何解析 index 文件中的导出。比较所述 module-alpha 和 module-beta 结构的建议。完成的标准是:建议仅限于递归声明的 index 文件导出,同时手动导入仍然可用。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- react, typescript
- 领域
- developer-experience, tooling
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 28/100