Skip to content

Commit 76c0591

Browse files
committed
fix: 🐛 do not parse model in effects
1 parent 1c327e3 commit 76c0591

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

src/parser/shared/parser/field-decorator.parser.spec.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,39 @@ describe('Field Decorator', function () {
780780
});
781781
});
782782

783+
describe('effect', () => {
784+
it('should not parse effect declarations', () => {
785+
const ast = tsquery.ast(`
786+
export class MyTestClass {
787+
/*
788+
some jsdocs
789+
*/
790+
#effectRef = effect(() => {});
791+
}
792+
`);
793+
794+
expect(parseInputsAndOutputs(ast)).toEqual({
795+
inputs: [],
796+
outputs: [],
797+
});
798+
});
799+
800+
it('should not parse afterRenderEffect declarations with model in the name', () => {
801+
const ast = tsquery.ast(`
802+
export class MyTestClass {
803+
#effectModelToDate = afterRenderEffect(() => {
804+
console.log('effect');
805+
});
806+
}
807+
`);
808+
809+
expect(parseInputsAndOutputs(ast)).toEqual({
810+
inputs: [],
811+
outputs: [],
812+
});
813+
});
814+
});
815+
783816
describe('output', () => {
784817
it('should parse the new output API', () => {
785818
const ast = tsquery.ast(`

src/parser/shared/parser/field-decorator.parser.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,10 @@ function parseDecoratedPropertyDeclarations(ast: ts.SourceFile): {
110110

111111
function parseSignalInputsAndModels(ast: ts.SourceFile): NgParselFieldDecorator[] {
112112
const inputNodes = [
113-
...tsquery(ast, 'PropertyDeclaration:has(CallExpression [name="input"], CallExpression [name="model"])'),
113+
...tsquery(
114+
ast,
115+
'PropertyDeclaration[initializer.expression.name="model"], PropertyDeclaration[initializer.expression.name="input"]'
116+
),
114117
];
115118
const signalInputs: NgParselFieldDecorator[] = [];
116119

0 commit comments

Comments
 (0)