Associate companion files with `ProjectService` without Content Mappers

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

Maintainer thường phản hồi trong vòng 1 ngày

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

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
angular, go, typescript

Hướng nghiên cứu

Start by tracing ProjectService handling for getDefaultProjectForFile, extraFileExtensions, and Content Mappers. Compare how include globs and companion files are associated with projects, then define how a lightweight registration could avoid content transformation and virtual .ts AST generation. Done means an external HTML template can discover its project on cold start without the fake open workaround.

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

Mô tả

Suggestion
🔍 Search Terms

extraFileExtensions
ScriptKind.Unknown
getDefaultProjectForFile
companion files
cold start project
openProjects

✅ Viability Checklist
⭐ Suggestion

Something like content mappers for registering extra extensions as included in the project but without the requirement of actually doing content mapping

📃 Motivating Example

We're currently prototyping the new Angular Language Service against TS-Go (tsgo --lsp with the API session pipe). In our setup, our extension manages a separate language server to handle Angular-specific template features, and uses TS-Go as the backend semantic and type-checking engine.

Because we manage our own compiler instance per tsconfig.json, we need to know which project owns a file when it's opened. We're running into a cold-start discovery problem when a user opens an external template first (e.g. app.component.html): getDefaultProjectForFile returns nothing because TS doesn't recognize .html as belonging to any configured project. Since Angular hasn't compiled yet, we don't know the TS ↔ HTML association either, so we don't know which tsconfig to load.

To work around this today, we do a "fake open dance" where we guess a sibling app.component.ts file, send a synthetic didOpen to TS-Go just to spin up the project and discover the tsconfig path, and then boot our compiler.

Content Mappers don't really fit here because they require transforming foreign files into virtual .ts ASTs and generating .ts output. For Angular, HTML files are external companion templates—our template type-checking code is generated out-of-band in separate .ngtypecheck.ts files. Forcing a Content Mapper onto .html files just introduces unwanted .ts AST generation and emit overhead.

Previously, extraFileExtensions with ScriptKind.Unknown kept projects active when matched by include globs. Since non-TS extensions in include globs are more standard now with content mappers, we're fine requiring .html in include. A lightweight extension registration (or a no-transform companion mode that lets include globs associate .html with ProjectService without generating virtual .ts ASTs) would eliminate the cold-start issue and the fake open workaround.

💻 Use Cases
  1. What do you want to use this for?
    Angular language service

  2. What shortcomings exist with current approaches?
    Mentioned above

  3. What workarounds are you using in the meantime?
    attempting to open a ts file with the same name

Ngôn ngữ chính
Go
Star
112k
Fork
15.4k
Merge trung bình
3 ngày 6 giờ
Pull request đã merge (30 ngày)
136

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

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.

Issue khác của microsoft/TypeScript

Tất cả issue của microsoft/TypeScript

Issue tương tự

Thêm issue về Go

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.