Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Commit 503de72

Browse files
ikatyangJamesHenry
authored andcommitted
New: support TaggedTemplateExpression typeArguments (#469)
1 parent e572416 commit 503de72

File tree

5 files changed

+295
-2
lines changed

5 files changed

+295
-2
lines changed

lib/convert.js

+3
Original file line numberDiff line numberDiff line change
@@ -1237,6 +1237,9 @@ module.exports = function convert(config) {
12371237
case SyntaxKind.TaggedTemplateExpression:
12381238
Object.assign(result, {
12391239
type: AST_NODE_TYPES.TaggedTemplateExpression,
1240+
typeParameters: (node.typeArguments)
1241+
? convertTypeArgumentsToTypeParameters(node.typeArguments)
1242+
: undefined,
12401243
tag: convertChild(node.tag),
12411244
quasi: convertChild(node.template)
12421245
});

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"npm-license": "0.3.3",
3232
"shelljs": "0.8.1",
3333
"shelljs-nodecli": "0.1.1",
34-
"typescript": "~2.8.1"
34+
"typescript": "2.9.0-dev.20180421"
3535
},
3636
"keywords": [
3737
"ast",

tests/ast-alignment/fixtures-to-test.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,15 @@ let fixturePatternConfigsToTest = [
439439
createFixturePatternConfigFor("typescript/decorators/parameter-decorators", { fileType: "ts" }),
440440
createFixturePatternConfigFor("typescript/decorators/property-decorators", { fileType: "ts" }),
441441

442-
createFixturePatternConfigFor("typescript/expressions", { fileType: "ts" }),
442+
createFixturePatternConfigFor("typescript/expressions", {
443+
fileType: "ts",
444+
ignore: [
445+
/**
446+
* currently babylon not supported
447+
*/
448+
"tagged-template-expression-type-arguments"
449+
]
450+
}),
443451

444452
createFixturePatternConfigFor("typescript/errorRecovery", {
445453
fileType: "ts",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
foo<bar>`baz`;

tests/lib/__snapshots__/typescript.js.snap

+281
Original file line numberDiff line numberDiff line change
@@ -63681,6 +63681,287 @@ Object {
6368163681
}
6368263682
`;
6368363683

63684+
exports[`typescript fixtures/expressions/tagged-template-expression-type-arguments.src 1`] = `
63685+
Object {
63686+
"body": Array [
63687+
Object {
63688+
"expression": Object {
63689+
"loc": Object {
63690+
"end": Object {
63691+
"column": 13,
63692+
"line": 1,
63693+
},
63694+
"start": Object {
63695+
"column": 0,
63696+
"line": 1,
63697+
},
63698+
},
63699+
"quasi": Object {
63700+
"expressions": Array [],
63701+
"loc": Object {
63702+
"end": Object {
63703+
"column": 13,
63704+
"line": 1,
63705+
},
63706+
"start": Object {
63707+
"column": 8,
63708+
"line": 1,
63709+
},
63710+
},
63711+
"quasis": Array [
63712+
Object {
63713+
"loc": Object {
63714+
"end": Object {
63715+
"column": 13,
63716+
"line": 1,
63717+
},
63718+
"start": Object {
63719+
"column": 8,
63720+
"line": 1,
63721+
},
63722+
},
63723+
"range": Array [
63724+
8,
63725+
13,
63726+
],
63727+
"tail": true,
63728+
"type": "TemplateElement",
63729+
"value": Object {
63730+
"cooked": "baz",
63731+
"raw": "baz",
63732+
},
63733+
},
63734+
],
63735+
"range": Array [
63736+
8,
63737+
13,
63738+
],
63739+
"type": "TemplateLiteral",
63740+
},
63741+
"range": Array [
63742+
0,
63743+
13,
63744+
],
63745+
"tag": Object {
63746+
"loc": Object {
63747+
"end": Object {
63748+
"column": 3,
63749+
"line": 1,
63750+
},
63751+
"start": Object {
63752+
"column": 0,
63753+
"line": 1,
63754+
},
63755+
},
63756+
"name": "foo",
63757+
"range": Array [
63758+
0,
63759+
3,
63760+
],
63761+
"type": "Identifier",
63762+
},
63763+
"type": "TaggedTemplateExpression",
63764+
"typeParameters": Object {
63765+
"loc": Object {
63766+
"end": Object {
63767+
"column": 8,
63768+
"line": 1,
63769+
},
63770+
"start": Object {
63771+
"column": 3,
63772+
"line": 1,
63773+
},
63774+
},
63775+
"params": Array [
63776+
Object {
63777+
"loc": Object {
63778+
"end": Object {
63779+
"column": 7,
63780+
"line": 1,
63781+
},
63782+
"start": Object {
63783+
"column": 4,
63784+
"line": 1,
63785+
},
63786+
},
63787+
"range": Array [
63788+
4,
63789+
7,
63790+
],
63791+
"type": "TSTypeReference",
63792+
"typeName": Object {
63793+
"loc": Object {
63794+
"end": Object {
63795+
"column": 7,
63796+
"line": 1,
63797+
},
63798+
"start": Object {
63799+
"column": 4,
63800+
"line": 1,
63801+
},
63802+
},
63803+
"name": "bar",
63804+
"range": Array [
63805+
4,
63806+
7,
63807+
],
63808+
"type": "Identifier",
63809+
},
63810+
},
63811+
],
63812+
"range": Array [
63813+
3,
63814+
8,
63815+
],
63816+
"type": "TSTypeParameterInstantiation",
63817+
},
63818+
},
63819+
"loc": Object {
63820+
"end": Object {
63821+
"column": 14,
63822+
"line": 1,
63823+
},
63824+
"start": Object {
63825+
"column": 0,
63826+
"line": 1,
63827+
},
63828+
},
63829+
"range": Array [
63830+
0,
63831+
14,
63832+
],
63833+
"type": "ExpressionStatement",
63834+
},
63835+
],
63836+
"loc": Object {
63837+
"end": Object {
63838+
"column": 14,
63839+
"line": 1,
63840+
},
63841+
"start": Object {
63842+
"column": 0,
63843+
"line": 1,
63844+
},
63845+
},
63846+
"range": Array [
63847+
0,
63848+
14,
63849+
],
63850+
"sourceType": "script",
63851+
"tokens": Array [
63852+
Object {
63853+
"loc": Object {
63854+
"end": Object {
63855+
"column": 3,
63856+
"line": 1,
63857+
},
63858+
"start": Object {
63859+
"column": 0,
63860+
"line": 1,
63861+
},
63862+
},
63863+
"range": Array [
63864+
0,
63865+
3,
63866+
],
63867+
"type": "Identifier",
63868+
"value": "foo",
63869+
},
63870+
Object {
63871+
"loc": Object {
63872+
"end": Object {
63873+
"column": 4,
63874+
"line": 1,
63875+
},
63876+
"start": Object {
63877+
"column": 3,
63878+
"line": 1,
63879+
},
63880+
},
63881+
"range": Array [
63882+
3,
63883+
4,
63884+
],
63885+
"type": "Punctuator",
63886+
"value": "<",
63887+
},
63888+
Object {
63889+
"loc": Object {
63890+
"end": Object {
63891+
"column": 7,
63892+
"line": 1,
63893+
},
63894+
"start": Object {
63895+
"column": 4,
63896+
"line": 1,
63897+
},
63898+
},
63899+
"range": Array [
63900+
4,
63901+
7,
63902+
],
63903+
"type": "Identifier",
63904+
"value": "bar",
63905+
},
63906+
Object {
63907+
"loc": Object {
63908+
"end": Object {
63909+
"column": 8,
63910+
"line": 1,
63911+
},
63912+
"start": Object {
63913+
"column": 7,
63914+
"line": 1,
63915+
},
63916+
},
63917+
"range": Array [
63918+
7,
63919+
8,
63920+
],
63921+
"type": "Punctuator",
63922+
"value": ">",
63923+
},
63924+
Object {
63925+
"loc": Object {
63926+
"end": Object {
63927+
"column": 13,
63928+
"line": 1,
63929+
},
63930+
"start": Object {
63931+
"column": 8,
63932+
"line": 1,
63933+
},
63934+
},
63935+
"range": Array [
63936+
8,
63937+
13,
63938+
],
63939+
"type": "Template",
63940+
"value": "\`baz\`",
63941+
},
63942+
Object {
63943+
"loc": Object {
63944+
"end": Object {
63945+
"column": 14,
63946+
"line": 1,
63947+
},
63948+
"start": Object {
63949+
"column": 13,
63950+
"line": 1,
63951+
},
63952+
},
63953+
"range": Array [
63954+
13,
63955+
14,
63956+
],
63957+
"type": "Punctuator",
63958+
"value": ";",
63959+
},
63960+
],
63961+
"type": "Program",
63962+
}
63963+
`;
63964+
6368463965
exports[`typescript fixtures/namespaces-and-modules/ambient-module-declaration-with-import.src 1`] = `
6368563966
Object {
6368663967
"body": Array [

0 commit comments

Comments
 (0)