Skip to content

Commit

Permalink
chore: one more test
Browse files Browse the repository at this point in the history
  • Loading branch information
John Jenkins committed Nov 21, 2024
1 parent ecc0f8e commit 8eaffb9
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/compiler/transformers/test/parse-props.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,39 @@ describe('parse props', () => {
});
});

it('should correctly parse a get / set prop with an inferred literal type', () => {
const t = transpileModule(`
@Component({tag: 'cmp-a'})
export class CmpA {
private _val: 'Something' | 'Else' = 'Something';
@Prop()
get val() {
return this._val;
};
}
`);

expect(t.properties[0]).toEqual({
name: 'val',
type: 'string',
attribute: 'val',
reflect: false,
mutable: false,
required: false,
optional: false,
defaultValue: "'Something'",
complexType: {
original: '"Something" | "Else"',
resolved: '"Else" | "Something"',
references: {},
},
docs: { tags: [], text: '' },
internal: false,
getter: true,
setter: false,
});
});

it('should not infer type from `get()` property access expression when getter type is explicit', () => {
const t = transpileModule(`
@Component({tag: 'cmp-a'})
Expand Down

0 comments on commit 8eaffb9

Please sign in to comment.