-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug
Description
π Search Terms
decorator, declare, accessor
π Version & Regression Information
afaict, this never worked? (it should tho)
β― Playground Link
π» Code
interface MyService{};
export class Foo {
@service accessor declare foo: MyService;
}
// spec / TC39 Decorator
function service<Value>(
target: ClassAccessorDecoratorTarget<unknown, Value>,
context: ClassAccessorDecoratorContext
): ClassAccessorDecoratorResult<unknown, Value>;
// implementation (type doesn't matter, exactly)
function service<Value>(...args: unknown[]): unknown {
return 0 as unknown as Value;
}
π Actual behavior
error here:
export class Foo {
@service accessor declare foo: MyService;
// ^
// \- Decorators are not valid here (1206)
}π Expected behavior
no error - decorators can define values on access, lazily, so declare should be allowed since declare means "TS doesn't normally know this can have a value, but I'm declaring that 'something' that TS can't see is setting that value".
where as, what does "work" is ! -- which is often linted against, and colloquially means approx "idgaf, I'm right" -- which is an appropriate thing to lint against.
Additional information about the issue
No response
Metadata
Metadata
Assignees
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug