Dynamic host attribute values are rejected (and two local-compilation-only transform cases)
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Start with evaluateHostExpressionBindings in annotations/directive/src/shared.ts and follow how parseHostBindings emits plain host attributes; compare that path with the [prop], (event), class, and style handling described here. The expected output is an expression in hostAttrs, matching ngc's hostAttrs: ["test", test], while cases 2 and 3 should retain their full-mode diagnostics. The linked open pull request indicates this work is already underway.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
Three Angular ngtsc specs compile with ngtsc but get a compile error from oxc, so a Vite build fails. Found by running Angular v22.0.0's ngtsc emit specs against oxc main (04cb3b2). Only case 1 is a bug in oxc. Cases 2 and 3 compile only in ngtsc's local compilation mode. That mode skips these checks because a separate full build checks them, and oxc already matches the full-mode diagnostics on purpose (#494).
1. Dynamic host attribute value (bug)
ngtsc_spec.ts: "should accept dynamic host attribute bindings"
// other.d.ts
export declare const foo: any;
// test.ts
import {Component} from '@angular/core';
import {foo} from './other';
const test = foo.bar();
@Component({selector: 'test', template: '', host: {'test': test}})
export class TestCmp {}
Actual
@Component.host depends on 'foo', which is imported from another module. OXC compiles one file at a time and cannot evaluate values from other files.
The error is the same with and without resolveImportedValues. A same-file dynamic value (host: {role: make()}) is also rejected: ... could not be determined statically. OXC does not support dynamic host attribute values.
Expected (ngc)
hostAttrs: ["test", test]
Cause
evaluateHostExpressionBindings (annotations/directive/src/shared.ts) turns a DynamicValue into new WrappedNodeExpr(value.node). parseHostBindings then emits it as is for a plain attribute, and rejects it only for [prop], (event), class and style. oxc stores host attribute values as strings, so it has no way to emit an expression.
2. Input transform from a namespace import (not a bug)
local_compilation_spec.ts: "should generate input info for transform function imported externally using namespace"
import * as n from './some_where';
// ...
@Input({transform: n.externalFunc}) x: string = '';
Actual: Input transform function could not be referenced Value is a reference to 'externalFunc'. Local mode emits inputs: { x: [2, "x", "x", n.externalFunc] }.
3. Inline transform with an untyped parameter (not a bug)
local_compilation_spec.ts: "should not check inline function param type"
@Input({transform: v => v + 'TRANSFORMED!'}) x: string = '';
Actual: Input transform function first parameter must have a type Value could not be determined statically. Local mode emits inputs: { x: [2, "x", "x", v => v + 'TRANSFORMED!'] }.
Why 2 and 3 are not bugs
parseDecoratorInputTransformFunction skips every transform check when compilationMode === LOCAL, "because usually the type check is done in a separate build which runs in full compilation mode". In full mode, which is what ng build uses, ngtsc reports both errors:
- case 3 matches
ngtsc_spec.ts"should produce a diangostic if the transform function first parameter has no arguments" (transform: (val) => 1); - for case 2, a namespace member has no identity in the file (
getIdentityInreturns null), and #494 checked this against ngtsc 22.1.7 (namespace_imported_transform_cannot_be_referenced).
oxc is the only compiler in a Vite build, so no other build would check these. Dropping the checks would let code through that ng build rejects. I left both cases as they are.
- Ngôn ngữ chính
- Rust
- Star
- 244
- Fork
- 26
- Merge trung bình
- 23 giờ 41 phút
- Pull request đã merge (30 ngày)
- 106
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của voidzero-dev/oxc-angular-compiler
-
Partial mode: NgModule-declared components get no dependencies, so their directives never matchĐang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
voidzero-dev/oxc-angular-compiler#655 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
voidzero-dev/oxc-angular-compiler#654 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Constructor param typed by a same-file interface is injected as a token (ReferenceError at runtime)Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 73/100
voidzero-dev/oxc-angular-compiler#653 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 28/100
voidzero-dev/oxc-angular-compiler#623 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Support useDefineForClassFields: false (Class Field Lowering)Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
voidzero-dev/oxc-angular-compiler#73 · 11 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của voidzero-dev/oxc-angular-compiler
Issue tương tự
-
bug dependencies kind:fix priority: P3 ready-for-agent
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
shep-pm/shep#1318 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 2 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
swc-project/swc-next#1165 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
Alive24/shea-symphony#574 ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày