microsoft / microsoft/TypeScript

Allow type-only named re-exports along with assigned export in the same file

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

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

In Discussion 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ả

Search Terms

allow export types assigned =

Suggestion

The suggestion is to allow compilation of files that do both export = and export type {}.

Use Cases

For modules that target both TypeScript and CommonJS usage it would allow consolidating all exports for both module systems in one file (albeit with the requirement of esModuleInterop being true).

Currently, in order to do that I would have to utilize @ts-ignore (see parzh/xrange#69 for details).

Examples

/person.ts:

import personValue from "./person-value";

export = personValue;

export type { default as PersonType } from "./person-type";

/person-type.ts:

export default interface Person { name: string; }

/person-value.ts:

export default { name: "John Doe" } as import("./person-type").default;
Usage:

/usage.ts:

import personValue from "./person";
import personValue, { PersonType } from "./person";
import type { PersonType } from "./person";
import personValue = require("./person");

/usage.js:

const personValue = require("./person");

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, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

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

Issue nêu tên các tệp ví dụ person.ts, person-type.ts, person-value.ts và usage.ts, nhưng không có tệp trình biên dịch hoặc bài kiểm thử nào. Hãy bắt đầu bằng việc xác định cách trình biên dịch xử lý export = cùng với các export có tên chỉ dành cho kiểu, sau đó xác minh rằng ví dụ biên dịch được và các export chỉ dành cho kiểu không làm thay đổi JavaScript được phát ra.

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

Đánh giá

Công nghệ
typescript
Lĩnh vực
compilers
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
30/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.