-
Notifications
You must be signed in to change notification settings - Fork 273
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
feat: generate TS from HBS templates #6558
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There is also an issue #6394 to link |
ilhan007
approved these changes
May 3, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
HBS templates are now compiled to TypeScript
this
is bound the the component instance and usage of members and events is type checkedgenerated template signature now looks like this:
function block0 (this: Button, context: UI5Element, tags: string[], suffix: string | undefined)
context
is left for compatibility reasons, but the template usesthis
internally.new
render
methodstaitc getters are only used by the framework to retrieve the template. if writing a template by hand, it would be a class method and
this
usage would be correct. This is now also possible, a component can implement a render method, accessthis
in it and return a template literalLinking templates to components
There is no way to directly express which component is used for which template from the
.hbs
file itself. The current tooling relies on convention, so the template and the component must comply to the following rules:src
folder (not in any subfolder)example:
The tooling will generate a
.ts
file from the.hbs
file, it will be created insrc/generated/templates
which is in.gitignore
and it will have the correct import tosrc/Input.d.ts
Linking static area templates (popovers) to components
Components that have a static area template for popovers will have the following file structure
There is no way to express the connection from
InputPopover.hbs
toInput.ts
(the input component instance will be passed to the template asthis
). Instead of making up complex naming conventions, the tooling will look for aInputPopover.d.ts
file in the same folder. It is up to the developer to create this file and export theInput
type from it.and the content of
InputPopover.d.ts
fixes: #6394