microsoft / microsoft/TypeScript

Import assignment should work with esnext targets

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

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

Needs Proposal
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

import assignment

Suggestion

#22321 was closed by a bot that thought the issue was addressed, but it wasn't.

Import assignment should work with esnext targets

Use Cases

JS modules loaders for Node might not support importing CJS with import statements, so you would use require to import them. But we'd still like to bring in their types. This is what import assignment is designed for, it's just disallowed with esnext targets.

Examples

This:

import * as m from './a-module.js';
import cjs = require('some-cjs');

should emit:

import * as m from './a-module.js';
const cjs = require('some-cjs');

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. new expression-level syntax)

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

Không có tệp hoặc bài kiểm thử nào được nêu tên. Hãy bắt đầu bằng cách lần theo cách TypeScript xử lý import-assignment cho các đích esnext, sau đó so sánh đầu ra hiện tại với ví dụ trong issue; công việc hoàn tất khi phép gán phát ra một khai báo dựa trên require mà vẫn giữ lại import hiện có.

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

Đánh giá

Công nghệ
javascript, typescript
Lĩnh vực
compilers
Loại issue
Tính năng
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
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.