Skip to content

Commit c8e4481

Browse files
committed
restore assertion
1 parent 8d3ece6 commit c8e4481

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

packages/@ember/-internals/metal/lib/tracked.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,18 @@ export function tracked(...args: any[]): ExtendedMethodDecorator | DecoratorProp
126126
_meta?: any,
127127
isClassicDecorator?: boolean
128128
): DecoratorPropertyDescriptor {
129-
assert(
130-
`You attempted to set a default value for ${key} with the @tracked({ value: 'default' }) syntax. You can only use this syntax with classic classes. For native classes, you can use class initializers: @tracked field = 'default';`,
131-
isClassicDecorator
132-
);
129+
let args = Array.from(arguments);
130+
if (isModernDecoratorArgs(args)) {
131+
assert(
132+
`You attempted to set a default value for ${args[1].name?.toString()} with the @tracked({ value: 'default' }) syntax. You can only use this syntax with classic classes. For native classes, you can use class initializers: @tracked field = 'default';`,
133+
isClassicDecorator
134+
);
135+
} else {
136+
assert(
137+
`You attempted to set a default value for ${key} with the @tracked({ value: 'default' }) syntax. You can only use this syntax with classic classes. For native classes, you can use class initializers: @tracked field = 'default';`,
138+
isClassicDecorator
139+
);
140+
}
133141

134142
let fieldDesc = {
135143
initializer: initializer || (() => value),

0 commit comments

Comments
 (0)