Skip to content

Commit

Permalink
Update babelParse to use legacy decorator syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinpalkovic committed Mar 9, 2023
1 parent 0d4810b commit f083759
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
27 changes: 27 additions & 0 deletions code/lib/csf-tools/src/CsfFile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,33 @@ describe('CsfFile', () => {
__id: foo-bar--a
`);
});

it('support for parameter decorators', () => {
expect(
parse(dedent`
import { Component, Input, Output, EventEmitter, Inject, HostBinding } from '@angular/core';
import { CHIP_COLOR } from './chip-color.token';
@Component({
selector: 'storybook-chip',
})
export class ChipComponent {
// The error occurs on the Inject decorator used on a parameter
constructor(@Inject(CHIP_COLOR) chipColor: string) {
this.backgroundColor = chipColor;
}
}
export default {
title: 'Chip',
}
`)
).toMatchInlineSnapshot(`
meta:
title: Chip
stories: []
`);
});
});

describe('error handling', () => {
Expand Down
7 changes: 1 addition & 6 deletions code/lib/csf-tools/src/babelParse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@ import type { ParserOptions } from '@babel/parser';
export const parserOptions: ParserOptions = {
sourceType: 'module',
// FIXME: we should get this from the project config somehow?
plugins: [
'jsx',
'typescript',
['decorators', { decoratorsBeforeExport: true }],
'classProperties',
],
plugins: ['jsx', 'typescript', 'decorators-legacy', 'classProperties'],
tokens: true,
};

Expand Down

0 comments on commit f083759

Please sign in to comment.