diff --git a/src/parser/shared/parser/field-decorator.parser.spec.ts b/src/parser/shared/parser/field-decorator.parser.spec.ts index db2c920..05f9c9c 100644 --- a/src/parser/shared/parser/field-decorator.parser.spec.ts +++ b/src/parser/shared/parser/field-decorator.parser.spec.ts @@ -84,6 +84,52 @@ describe('Field Decorator', function () { }); }); + it('should parse a signal input with a union type', () => { + const ast = tsquery.ast(` + export class MyTestClass { + test = input(); + } + `); + + const expectedInputs = [ + { + decorator: 'input', + name: 'test', + initialValue: '', + type: 'myIcon | string', + required: false, + field: 'test = input();', + }, + ]; + expect(parseInputsAndOutputs(ast)).toEqual({ + inputs: expectedInputs, + outputs: [], + }); + }); + + it('should parse a signal input with a intersection type', () => { + const ast = tsquery.ast(` + export class MyTestClass { + test = input(); + } + `); + + const expectedInputs = [ + { + decorator: 'input', + name: 'test', + initialValue: '', + type: 'myIcon & string', + required: false, + field: 'test = input();', + }, + ]; + expect(parseInputsAndOutputs(ast)).toEqual({ + inputs: expectedInputs, + outputs: [], + }); + }); + it('should parse signal inputs with initial string value', () => { const ast = tsquery.ast(` export class MyTestClass { diff --git a/src/parser/shared/parser/field-decorator.parser.ts b/src/parser/shared/parser/field-decorator.parser.ts index cbdcb79..65c3caf 100644 --- a/src/parser/shared/parser/field-decorator.parser.ts +++ b/src/parser/shared/parser/field-decorator.parser.ts @@ -118,7 +118,7 @@ function parseSignalInputsAndModels(ast: ts.SourceFile): NgParselFieldDecorator[ [ ...tsquery( field, - 'CallExpression > :matches(BooleanKeyword, AnyKeyword, TypeReference, StringKeyword, LiteralType, TypeLiteral, NullKeyword, UndefinedKeyword, Identifier[name=Array], ArrayType)' + 'CallExpression > :matches(BooleanKeyword, AnyKeyword, TypeReference, StringKeyword, LiteralType, TypeLiteral, NullKeyword, UndefinedKeyword, Identifier[name=Array], ArrayType, UnionType, IntersectionType)' ), ][0]?.getText() || 'inferred';