-
Notifications
You must be signed in to change notification settings - Fork 402
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(engine): fixes issue #710 - add better error for invalid template #718
Conversation
|
||
export function isTemplateRegistered(tmpl: Template) { | ||
if (!VERIFIED_TEMPLATE_SET.has(tmpl)) { | ||
throw new TypeError('Unknown template'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moving the throwing logic to the invoker of this method to we have access to the vm, and other details of the component to provide better message.
@@ -1,14 +1,14 @@ | |||
import { Template } from "./template"; | |||
|
|||
const VERIFIED_TEMPLATE_SET = new Set(); | |||
const signedTemplateSet: Set<Template> = new Set(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just renaming and typing
* List of property names that are accessed of the component instance | ||
* from the template. | ||
*/ | ||
ids?: string[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this interface was incompleted, surfaced the issue after adding the proper type to the html argument in validateFields
isTemplateRegistered(html); | ||
// Check that the template was built by the compiler | ||
if (!isTemplateRegistered(html)) { | ||
throw new ReferenceError(`The template rendered by ${vm} must return an imported template tag (e.g.: \`import html from "./${vm.def.name}.html"\`) or undefined, instead, it has returned a function.`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to add the component stack here since the invocation of this function is inside a try/catch in invoker, that's the one that will add the error details.
Benchmark resultsBase commit: lwc-engine-benchmark
|
Details
Follow up PR after PR #693
Does this PR introduce a breaking change?