GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Support for ES6 Templates by DanielRosenwasser · Pull Request #960 · microsoft/TypeScript

Conversation

@DanielRosenwasser

@DanielRosenwasser Daniel Rosenwasser (DanielRosenwasser) commented Oct 25, 2014

Copy link
Copy Markdown
Member

This pull request is meant to add support for ECMAScript 6 templates and address suggestion #13.

Right now this branch supports:

  • Both simple and substitution templates for all emit targets
  • Tagged template parse/emit solely for ES6 (and above) targets.
  • Syntactic highlighting in the LS for template literals
  • Completion lists in substitution position.

Things that will be done in a separate commit:

  • Type checking for tagged template expressions by checking assignability of substitution expressions to respective tag parameters.
  • Add typings for the "cooked strings" parameter of tags.
  • Patch up parts of the languages service that don't account for templates.
  • Better parse errors for places that expect string literals.
  • Experiment with brace matching on substitution templates.
  • Experiment with indentation in the language service.

Questions worth asking:

  • Do we want to accept simple (non-substitution) templates in places we accept string literals (i.e. module names, overloading on string constants, etc.)? On one hand, it would seem more consistent with the rest of our language, but ECMAScript 6 does not accept them in property names.
  • When indexing with a template literal, should we try to perform a static property lookup?
  • Are void-typed items allowed to be in substitution position? Are there any restrictions on what can be go in a substitution expression?
  • Do we want type arguments on a tagged template?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Daniel Rosenwasser (DanielRosenwasser) added 8 commits October 23, 2014 14:57
@DanielRosenwasser
Rudimentary template support, excluding tagging.
518a5d3
@DanielRosenwasser
Added tests and baselines for templates.
c0893e1
@DanielRosenwasser
Merge branch 'letAndConst' into templates
b704f19
Conflicts:
	src/compiler/diagnosticInformationMap.generated.ts
	src/compiler/diagnosticMessages.json
@DanielRosenwasser
Added support for tagged template strings, updated baselines.
e709628
Still need to implement some error recovery and add tests.
@DanielRosenwasser
Better test coverage for templates in object literals.
0d1a46d
These tests still need to be fixed.
@DanielRosenwasser
Added tests for tagged templates. Some should fail when we do typeche…
a5b77c6
…cking.
@DanielRosenwasser
Tests for tagged templates.
799609c
@DanielRosenwasser
Added syntactic classification for templates; also made 'spans' a Nod…
c03dc10
…eArray.
CyrusNajmabadi
CyrusNajmabadi reviewed Oct 25, 2014
View reviewed changes
Comment thread src/compiler/checker.ts Outdated

@CyrusNajmabadi Cyrus Najmabadi (CyrusNajmabadi) Oct 25, 2014

Copy link
Copy Markdown
Contributor

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.

Explain why this is correct. I believe it's because we rewrite this to string addition, and string addition allows the other side to be of any type. So we don't need to check for things like void types, etc. But it would be good to comment this bit.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@JsonFreeman

Jason Freeman (JsonFreeman) commented Oct 27, 2014

Copy link
Copy Markdown
Contributor

"Do we want to accept simple (non-substitution) templates in places we accept string literals (i.e. module names, overloading on string constants, etc.)? On one hand, it would seem more consistent with the rest of our language, but ECMAScript 6 does not accept them in property names."

I would say no. I'm not sure we have a reason to be more lenient than ES6.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@DanielRosenwasser

Daniel Rosenwasser (DanielRosenwasser) commented Oct 27, 2014

Copy link
Copy Markdown
Member Author

Jason Freeman (@JsonFreeman) I agree; what about indexing?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@JsonFreeman

Jason Freeman (JsonFreeman) commented Oct 27, 2014

Copy link
Copy Markdown
Contributor

I think we can type an index expression with literal, yes.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Daniel Rosenwasser (DanielRosenwasser) added 7 commits October 28, 2014 18:43
@DanielRosenwasser
Merge branch 'master' into templates
7fad769
@DanielRosenwasser
Addressed CR feedback.
4aafe1d
@DanielRosenwasser
Changed Debug.assert's first parameter to a boolean.
8786d30
@DanielRosenwasser
Renamed certain functions in the parser to more accurately reflect be…
d45fb77
…havior.
@DanielRosenwasser
Missed a use when fixing Debug.assert
64097a3
@DanielRosenwasser
Fixed emit for parenthesized template expressions.
aabfebd
@DanielRosenwasser
Omit empty template tail literals.
b8535d3
Daniel Rosenwasser (DanielRosenwasser) added 3 commits October 28, 2014 18:49
@DanielRosenwasser
Merge branch 'master' into templates
d522c88
Conflicts:
	src/compiler/checker.ts
	src/services/services.ts
@DanielRosenwasser
Disabled completion list entries in template literal parts for the LS.
ead3c1b
@DanielRosenwasser
Merge branch 'master' into templates
35cf95c
Conflicts:
	src/compiler/diagnosticInformationMap.generated.ts
	src/compiler/diagnosticMessages.json
	src/compiler/types.ts
	src/services/utilities.ts
@DanielRosenwasser
Daniel Rosenwasser (DanielRosenwasser) force-pushed the templates branch from 66cb969 to 35cf95c Compare October 29, 2014 02:11
Daniel Rosenwasser (DanielRosenwasser) added 3 commits October 30, 2014 15:26
@DanielRosenwasser
Merge branch 'master' into templates
76c0381
@DanielRosenwasser
Addressed CR feedback.
63340a0
@DanielRosenwasser
Merge branch 'master' into templates
3e8978f
Daniel Rosenwasser (DanielRosenwasser) added a commit that referenced this pull request Oct 31, 2014
@DanielRosenwasser
Merge pull request #960 from Microsoft/templates
0a97f5f
Support for ES6 Templates
@DanielRosenwasser
Daniel Rosenwasser (DanielRosenwasser) merged commit 0a97f5f into master Oct 31, 2014
@DanielRosenwasser
Daniel Rosenwasser (DanielRosenwasser) deleted the templates branch October 31, 2014 22:19
@vvakame

Masahiro Wakame (vvakame) commented Nov 10, 2014

Copy link
Copy Markdown
Contributor

Ryan Cavanaugh (@RyanCavanaugh) excuse me. please add es6 label to this issue.
I want to check es6 feature on this url https://github.com/Microsoft/TypeScript/issues?q=label%3AES6

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@danquirk Dan Quirk (danquirk) added the ES6 Relates to the ES6 Spec label Nov 10, 2014
@Vadorequest

Vadorequest (Vadorequest) commented Nov 19, 2014

Copy link
Copy Markdown

I just noticed that this ES6 feature is still a proposal, so why implement it already? Not that it isn't great and useful, just wondering why focusing on things that are still status: Draft on ES6 specs. I guess you have your reasons, just wonder what they are ;)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@DanielRosenwasser

Daniel Rosenwasser (DanielRosenwasser) commented Nov 20, 2014

Copy link
Copy Markdown
Member Author

It's actually pretty much nailed down, and it's very unlikely that it will be removed/modified drastically. If anything does change, we'll be very mindful in addressing that. =)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Vadorequest

Vadorequest (Vadorequest) commented Nov 20, 2014

Copy link
Copy Markdown

Ok, nice then, it's a nice feature btw, looking forward for 1.4. :)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@DanielRosenwasser Daniel Rosenwasser (DanielRosenwasser) mentioned this pull request Nov 21, 2014
Suggestion: string interpolation #13
Closed
@topherfangio

Topher Fangio (topherfangio) commented Dec 12, 2014

Copy link
Copy Markdown

Hi there, I realize that this is on the Roadmap for 1.4. I'm curious though if we might see it sooner as perhaps an experimental option. My team and I would certainly love to start using this sooner rather than later to clean up our code :-)

Cheers!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@DanielRosenwasser

Daniel Rosenwasser (DanielRosenwasser) commented Dec 12, 2014

Copy link
Copy Markdown
Member Author

Hey Topher Fangio (@topherfangio), glad to hear you're enthusiastic about this feature.

If you're dying to try it out, you can clone our repo and use our release-1.4 branch, but 1.4 is largely on the horizon, just be patient. =)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@DanielRosenwasser Daniel Rosenwasser (DanielRosenwasser) mentioned this pull request Jan 3, 2015
Alternative syntax for type assertions to allow XML-like syntax extensions #296
Closed
@microsoft Microsoft (microsoft) locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

ES6 Relates to the ES6 Spec

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

9 participants

@DanielRosenwasser @JsonFreeman @vvakame @Vadorequest @topherfangio @DickvdBrink @CyrusNajmabadi @RyanCavanaugh @danquirk
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.