Frontend rejects decorators with `SC0001: Decorators are not valid here.`

Đang mở
#238 0 bình luận 2 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
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
compilers

Hướng nghiên cứu

Bắt đầu bằng cách tái tạo ví dụ TypeScript tối thiểu với @scriptc/compiler 0.0.35 và so sánh hành vi của nó với tsc khi sử dụng experimentalDecorators và emitDecoratorMetadata. Truy vết đường dẫn của compiler phát ra SC0001 cho decorator của tham số constructor. Công việc được xem là hoàn tất khi các decorator được hỗ trợ của class, method, property, accessor và parameter biên dịch với metadata runtime cần thiết, hoặc khi giới hạn này được ghi lại nếu việc hỗ trợ nằm ngoài phạm vi.

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

Mô tả

Description

scriptc rejects decorator syntax with SC0001: Decorators are not valid here. instead of compiling it. This makes it impossible to build any codebase that relies on decorators — including NestJS apps, which use them pervasively for dependency injection, controllers, providers, and parameter injection.

In the case below, a standard NestJS constructor parameter decorator (@InjectPinoLogger from nestjs-pino) is rejected, even though it is valid TypeScript and compiles fine with tsc.

Minimal Demo
import { Injectable } from "@nestjs/common";
import { InjectPinoLogger, PinoLogger } from "nestjs-pino";

@Injectable()
export class FileValidationService {
  constructor(
    @InjectPinoLogger(FileValidationService.name)
    private readonly logger: PinoLogger,
  ) {}
}
Output
src/server/shared/modules/filesystem/file-validation.service.ts:31:5 - error SC0001: Decorators are not valid here.

  30 |   constructor(
  31 |     @InjectPinoLogger(FileValidationService.name)
     |     ^
  32 |     private readonly logger: PinoLogger,
Expected

Decorators should be supported (class, method, property, accessor, and parameter decorators), compiling to their equivalent runtime form and preserving metadata — matching TS experimentalDecorators + emitDecoratorMetadata semantics that frameworks like NestJS depend on.

If full decorator support is out of scope, the limitation should be clearly documented, since SC0001 currently blocks entire categories of TypeScript projects.

Environment
  • @scriptc/compiler version: 0.0.35
  • OS: MacOS
Notes

This same file compiles without errors under tsc with experimentalDecorators and emitDecoratorMetadata enabled.

Ngôn ngữ chính
TypeScript
Star
6.7k
Fork
229
Merge trung bình
14 giờ 29 phút
Pull request đã merge (30 ngày)
787

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

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 vercel-labs/scriptc

Tất cả issue của vercel-labs/scriptc

Issue tương tự

Thêm issue về TypeScript

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.