Closed
Description
Motivation
ES6 Template strings make it much easier to put blocks of HTML code inline with JavaScript. This can be leveraged in frameworks like Angular. One disadvantage to this though, is that IDEs don't know that the string block should be formatted as HTML so there is no syntax highlighting.
@Component({ selector: 'angular-demo' })
@View({
template: `<h3>My Template</h3>
<p>I can put blocks of HTML here.</p>
<p>Unfortunately, there is no syntax highlighting.</p>`
})
class Demo{ }
Proposal
I propose a simple HTMLString type that is simply an alias for string but can signal to text editors that the string should be styled as HTML and can use HTML completion. This should be implemented in lib.d.ts to standardize the use of the type.
/**
* Alias for the string type used to denote the string should be shown with
* HTML syntax highlighting
*/
type HTMLString = string;
Strengths:
- Simple to implement
- No breaking changes
- IDE support is optional
Weaknesses:
- Requires IDEs to be interested in implementing