Updated FAQs for API Consumers (markdown)

Daniel Rosenwasser 2015-02-13 18:57:52 -08:00
parent 156086d8f1
commit 2adca654fc

@ -10,7 +10,17 @@ Though lexical goals are not addressed in the TypeScript spec, there is effectiv
### Why does the lexical classifier sometimes give inaccurate results for nested template strings?
For the record, template strings did not even originally have lexical classification support prior to 1.5 for [several technical reasons](https://github.com/Microsoft/TypeScript/issues/1477#issuecomment-66907946). However, due to demand, [support was added for what we believed would be the majority of practical uses](https://github.com/Microsoft/TypeScript/pull/2026).
Template strings did not even originally have lexical classification support prior to 1.5 for [several technical reasons](https://github.com/Microsoft/TypeScript/issues/1477#issuecomment-66907946). However, due to demand, [support was added for what we believed would be the majority of practical uses](https://github.com/Microsoft/TypeScript/pull/2026).
As a precursor, template expressions are made up of several components:
Syntax Kind | Example
------|------------
`NoSubstitutionTemplateLiteral` | `` `Hello world` ``
`TemplateHead` | `` `abc ${ ``
`TemplateMiddle` | `} def ${ `
`TemplateTail` | `` } ghi ` ``
`TemplateExpression` | `` `abc ${ 0 } def ${ 1 } ghi ` ``
The lexical classifier is a rudimentary classifier that is intended to be fast and work on single lines at a time. It works through augmenting TypeScript's scanner, which itself works on a regular language grammar except when given a lexical goal in mind. Keep in mind, lexical goals can only be triggered accurately when motivated by a syntactically aware entity, while the lexical classifier only has the context of a single line with a previous line state to work with.