Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update babelParse to use legacy decorator syntax #21506

Merged
merged 1 commit into from
Mar 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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