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

Angular: Emit decorator metadata by default #9701

Merged
merged 2 commits into from
Feb 3, 2020

Conversation

kroeder
Copy link
Member

@kroeder kroeder commented Feb 2, 2020

Issue: #7544

What I did

I added emitDecoratorMetadata: true as default value to the ts compiler options. Angular dependency injection does not work correctly without it

How to test

  • ng new test-app
  • sb init
  • create demo component with
@Component({
  selector: 'app-test',
  template: 'test.component.html'
})

export class TestComponent implements OnInit {
  constructor(private elementRef: ElementRef) {
    console.log(elementRef);
  }

  ngOnInit() {
  }
}
  • add this component to a story
  • It should fail now.
  • modify ts_config.js in node_modules/@storybook/angular/server/ts_config.js
function default_1(configDir) {
    var configFilePath = resolveTsConfig(path_1.default.resolve(configDir, 'tsconfig.json'));
    return {
        transpileOnly: true,
        compilerOptions: {
          emitDecoratorMetadata: true
        },
        configFile: configFilePath || undefined,
    };
}
  • it should work now

This fixes dependency injection error SomeComponent(?, ?)
@shilman shilman added the patch:yes Bugfix & documentation PR that need to be picked to main branch label Feb 3, 2020
Copy link
Member

@shilman shilman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@shilman
Copy link
Member

shilman commented Feb 3, 2020

@kroeder can you update the failing test?

@kroeder
Copy link
Member Author

kroeder commented Feb 3, 2020

I can. Haven't seen the failing tests because of the permanent false-positive A11y 😞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
angular bug patch:done Patch/release PRs already cherry-picked to main/release branch patch:yes Bugfix & documentation PR that need to be picked to main branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants