Skip to content

[Suggestion] HTML string type for IDEs #4856

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

Closed
aciccarello opened this issue Sep 18, 2015 · 1 comment
Closed

[Suggestion] HTML string type for IDEs #4856

aciccarello opened this issue Sep 18, 2015 · 1 comment
Labels
Declined The issue was declined as something which matches the TypeScript vision Out of Scope This idea sits outside of the TypeScript language design constraints Suggestion An idea for TypeScript Too Complex An issue which adding support for may be too complex for the value it adds

Comments

@aciccarello
Copy link

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
@mhegazy
Copy link
Contributor

mhegazy commented Sep 18, 2015

I do not think the type is that helpful here for two reasons, 1. it requires the editors to be interested, involved and aware, and if so why not do it on their own, and 2. all syntactic operations are not type aware, changing this would add a huge perf overhead and would delay operations that today users expect to be instantaneous (e.g. colorization/highlighting)

I would say this is a valid issue for https://github.com/Microsoft/TypeScript-Sublime-Plugin, colorizing this should be doable in string template positions, and you would get that all the time not only in specified places.

@mhegazy mhegazy added Suggestion An idea for TypeScript Out of Scope This idea sits outside of the TypeScript language design constraints Too Complex An issue which adding support for may be too complex for the value it adds Declined The issue was declined as something which matches the TypeScript vision labels Sep 18, 2015
@mhegazy mhegazy closed this as completed Sep 18, 2015
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Declined The issue was declined as something which matches the TypeScript vision Out of Scope This idea sits outside of the TypeScript language design constraints Suggestion An idea for TypeScript Too Complex An issue which adding support for may be too complex for the value it adds
Projects
None yet
Development

No branches or pull requests

2 participants