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

fix(compiler): check entry component metadata #14335

Conversation

bowenni
Copy link
Contributor

@bowenni bowenni commented Feb 7, 2017

Throw a proper error when a non-component is added to module's bootstrap list.
This avoids adding non-components to entry components and avoids printing stack traces.

Please check if the PR fulfills these requirements

What kind of change does this PR introduce? (check one with "x")

[x] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Other... Please describe:

Does this PR introduce a breaking change? (check one with "x")

[ ] Yes
[x] No

@bowenni bowenni assigned bowenni and tbosch and unassigned tbosch and bowenni Feb 7, 2017
@bowenni bowenni requested a review from tbosch February 7, 2017 04:00
@@ -949,6 +950,10 @@ export class CompileMetadataResolver {
return {componentType: dirType, componentFactory: dirSummary.componentFactory};
}
}

if (throwIfNotFound) {
throw new SyntaxError(`${dirType.name} is not an entry component.`);
Copy link
Contributor

Choose a reason for hiding this comment

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

Or ... can not be used as an entry component.

.toThrowError(SyntaxError, `SimpleService is not an entry component.`);
}));

it(`should not throw an error when a Directive is added to module's bootstrap list`,
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually it should throw in this case as well!

if (entry) {
components.push(entry);
}
});
return components;
}

private _getEntryComponentMetadata(dirType: any): cpl.CompileEntryComponentMetadata {
private _getEntryComponentMetadata(dirType: any, throwIfNotFound = true):
cpl.CompileEntryComponentMetadata {
const dirMeta = this.getNonNormalizedDirectiveMetadata(dirType);
if (dirMeta) {
Copy link
Contributor

Choose a reason for hiding this comment

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

check DirMeta.isComponent / dirSummary.isComponent to be truthy...

@tbosch tbosch added the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Feb 7, 2017
@bowenni bowenni force-pushed the throw-an-error-if-no-component-metadata-found branch from 4869fd4 to 59ef923 Compare February 7, 2017 18:50
Throw a proper error when a non-component is added to module's bootstrap list
@bowenni bowenni force-pushed the throw-an-error-if-no-component-metadata-found branch from 4f3524c to 02130f6 Compare February 7, 2017 19:06
@bowenni
Copy link
Contributor Author

bowenni commented Feb 8, 2017

@tbosch PTAL

@tbosch tbosch removed the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Feb 9, 2017
@mhevery mhevery added the action: merge The PR is ready for merge by the caretaker label Feb 9, 2017
mhevery pushed a commit to mhevery/angular that referenced this pull request Feb 9, 2017
mhevery pushed a commit to mhevery/angular that referenced this pull request Feb 9, 2017
mhevery pushed a commit to mhevery/angular that referenced this pull request Feb 9, 2017
@mhevery mhevery closed this in ac6f8e3 Feb 9, 2017
@bowenni bowenni deleted the throw-an-error-if-no-component-metadata-found branch February 24, 2017 22:39
asnowwolf pushed a commit to asnowwolf/angular that referenced this pull request Aug 11, 2017
juleskremer pushed a commit to juleskremer/angular that referenced this pull request Aug 28, 2017
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants