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.

Đá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
30/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
typescript
Lĩnh vực
compilers

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.

Mô tả

In Discussion Suggestion

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.
Ngôn ngữ chính
Go
Star
111k
Fork
14.4k
Merge trung bình
1 ngày 19 giờ
Pull request đã merge (30 ngày)
117

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.

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.