microsoft / microsoft/TypeScript

typesVersions should support aliasing specific files (or document this will not be supported)

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

@rbuckton đang làm issue này rồi.

Từ ngày 7/5/2021.

Needs Investigation Rescheduled
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ả

Suggestion

🔍 Search Terms

typesVersions, backwards compatibility, path alias

✅ Viability Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

⭐ Suggestion

Enable aliasing a single file with Advanced Types or document this isn't possible. The language on the docs currently says:

File redirects

When you want to only change the resolution for a single file at a time, you can tell TypeScript the file to resolve differently by passing in the exact filenames:

However, passing any exact filename doesn't seem to work. For example, if dist/index.d.ts imports dist/helpers/advanced-types.d.ts, which should fall back to helpers/legacy-types.d.ts for older TS versions, this doesn't seem to work. I've tried:

  • dist/helpers/advanced-types.d.ts
  • dist/helpers/advanced-types
  • helpers/advanced-types.d.ts
  • helpers/advanced-types
  • */advanced-types.d.ts
  • */advanced-types
  • advanced-types.d.ts
  • advanced-types

📃 Motivating Example

Using something like template literals, I would like to create a single file that contains these, with some fallbacks with legacy code for TypeScript users who do not have the ability to update right away.

💻 Use Cases

The only workaround I've found is to create another package which exports a different index.d.ts to be used with the main project. There would be too many different uses of the types exported to re-create the entire project with the different imports.

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.

Đánh giá

Issue này chưa được đánh giá.

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.