This repository was archived by the owner on Jan 19, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +290
-1
lines changed
fixtures/typescript/errorRecovery Expand file tree Collapse file tree 4 files changed +290
-1
lines changed Original file line number Diff line number Diff line change @@ -2101,7 +2101,14 @@ module.exports = function convert(config) {
21012101 id : convertChild ( node . name ) ,
21022102 heritage : hasImplementsClause ? interfaceHeritageClauses [ 0 ] . types . map ( convertInterfaceHeritageClause ) : [ ]
21032103 } ) ;
2104-
2104+ /**
2105+ * Semantically, decorators are not allowed on interface declarations,
2106+ * but the TypeScript compiler will parse them and produce a valid AST,
2107+ * so we handle them here too.
2108+ */
2109+ if ( node . decorators ) {
2110+ result . decorators = convertDecorators ( node . decorators ) ;
2111+ }
21052112 // check for exports
21062113 result = nodeUtils . fixExports ( node , result , ast ) ;
21072114
Original file line number Diff line number Diff line change @@ -454,6 +454,7 @@ let fixturePatternConfigsToTest = [
454454 "class-empty-extends-implements" , // babylon parse errors
455455 "class-empty-extends" , // babylon parse errors
456456 "decorator-on-enum-declaration" , // babylon parse errors
457+ "decorator-on-interface-declaration" , // babylon parse errors
457458 "interface-property-modifiers" , // babylon parse errors
458459 "enum-with-keywords" // babylon parse errors
459460 ]
Original file line number Diff line number Diff line change 1+ @deco ( )
2+ interface M { }
Original file line number Diff line number Diff line change @@ -57236,6 +57236,285 @@ Object {
5723657236}
5723757237`;
5723857238
57239+ exports[`typescript fixtures/errorRecovery/decorator-on-interface-declaration.src 1`] = `
57240+ Object {
57241+ "body": Array [
57242+ Object {
57243+ "abstract": false,
57244+ "body": Object {
57245+ "body": Array [],
57246+ "loc": Object {
57247+ "end": Object {
57248+ "column": 14,
57249+ "line": 2,
57250+ },
57251+ "start": Object {
57252+ "column": 12,
57253+ "line": 2,
57254+ },
57255+ },
57256+ "range": Array [
57257+ 20,
57258+ 22,
57259+ ],
57260+ "type": "TSInterfaceBody",
57261+ },
57262+ "decorators": Array [
57263+ Object {
57264+ "expression": Object {
57265+ "arguments": Array [],
57266+ "callee": Object {
57267+ "loc": Object {
57268+ "end": Object {
57269+ "column": 5,
57270+ "line": 1,
57271+ },
57272+ "start": Object {
57273+ "column": 1,
57274+ "line": 1,
57275+ },
57276+ },
57277+ "name": "deco",
57278+ "range": Array [
57279+ 1,
57280+ 5,
57281+ ],
57282+ "type": "Identifier",
57283+ },
57284+ "loc": Object {
57285+ "end": Object {
57286+ "column": 7,
57287+ "line": 1,
57288+ },
57289+ "start": Object {
57290+ "column": 1,
57291+ "line": 1,
57292+ },
57293+ },
57294+ "range": Array [
57295+ 1,
57296+ 7,
57297+ ],
57298+ "type": "CallExpression",
57299+ },
57300+ "loc": Object {
57301+ "end": Object {
57302+ "column": 7,
57303+ "line": 1,
57304+ },
57305+ "start": Object {
57306+ "column": 0,
57307+ "line": 1,
57308+ },
57309+ },
57310+ "range": Array [
57311+ 0,
57312+ 7,
57313+ ],
57314+ "type": "Decorator",
57315+ },
57316+ ],
57317+ "heritage": Array [],
57318+ "id": Object {
57319+ "loc": Object {
57320+ "end": Object {
57321+ "column": 11,
57322+ "line": 2,
57323+ },
57324+ "start": Object {
57325+ "column": 10,
57326+ "line": 2,
57327+ },
57328+ },
57329+ "name": "M",
57330+ "range": Array [
57331+ 18,
57332+ 19,
57333+ ],
57334+ "type": "Identifier",
57335+ },
57336+ "loc": Object {
57337+ "end": Object {
57338+ "column": 14,
57339+ "line": 2,
57340+ },
57341+ "start": Object {
57342+ "column": 0,
57343+ "line": 1,
57344+ },
57345+ },
57346+ "range": Array [
57347+ 0,
57348+ 22,
57349+ ],
57350+ "type": "TSInterfaceDeclaration",
57351+ },
57352+ ],
57353+ "loc": Object {
57354+ "end": Object {
57355+ "column": 14,
57356+ "line": 2,
57357+ },
57358+ "start": Object {
57359+ "column": 0,
57360+ "line": 1,
57361+ },
57362+ },
57363+ "range": Array [
57364+ 0,
57365+ 22,
57366+ ],
57367+ "sourceType": "script",
57368+ "tokens": Array [
57369+ Object {
57370+ "loc": Object {
57371+ "end": Object {
57372+ "column": 1,
57373+ "line": 1,
57374+ },
57375+ "start": Object {
57376+ "column": 0,
57377+ "line": 1,
57378+ },
57379+ },
57380+ "range": Array [
57381+ 0,
57382+ 1,
57383+ ],
57384+ "type": "Punctuator",
57385+ "value": "@",
57386+ },
57387+ Object {
57388+ "loc": Object {
57389+ "end": Object {
57390+ "column": 5,
57391+ "line": 1,
57392+ },
57393+ "start": Object {
57394+ "column": 1,
57395+ "line": 1,
57396+ },
57397+ },
57398+ "range": Array [
57399+ 1,
57400+ 5,
57401+ ],
57402+ "type": "Identifier",
57403+ "value": "deco",
57404+ },
57405+ Object {
57406+ "loc": Object {
57407+ "end": Object {
57408+ "column": 6,
57409+ "line": 1,
57410+ },
57411+ "start": Object {
57412+ "column": 5,
57413+ "line": 1,
57414+ },
57415+ },
57416+ "range": Array [
57417+ 5,
57418+ 6,
57419+ ],
57420+ "type": "Punctuator",
57421+ "value": "(",
57422+ },
57423+ Object {
57424+ "loc": Object {
57425+ "end": Object {
57426+ "column": 7,
57427+ "line": 1,
57428+ },
57429+ "start": Object {
57430+ "column": 6,
57431+ "line": 1,
57432+ },
57433+ },
57434+ "range": Array [
57435+ 6,
57436+ 7,
57437+ ],
57438+ "type": "Punctuator",
57439+ "value": ")",
57440+ },
57441+ Object {
57442+ "loc": Object {
57443+ "end": Object {
57444+ "column": 9,
57445+ "line": 2,
57446+ },
57447+ "start": Object {
57448+ "column": 0,
57449+ "line": 2,
57450+ },
57451+ },
57452+ "range": Array [
57453+ 8,
57454+ 17,
57455+ ],
57456+ "type": "Keyword",
57457+ "value": "interface",
57458+ },
57459+ Object {
57460+ "loc": Object {
57461+ "end": Object {
57462+ "column": 11,
57463+ "line": 2,
57464+ },
57465+ "start": Object {
57466+ "column": 10,
57467+ "line": 2,
57468+ },
57469+ },
57470+ "range": Array [
57471+ 18,
57472+ 19,
57473+ ],
57474+ "type": "Identifier",
57475+ "value": "M",
57476+ },
57477+ Object {
57478+ "loc": Object {
57479+ "end": Object {
57480+ "column": 13,
57481+ "line": 2,
57482+ },
57483+ "start": Object {
57484+ "column": 12,
57485+ "line": 2,
57486+ },
57487+ },
57488+ "range": Array [
57489+ 20,
57490+ 21,
57491+ ],
57492+ "type": "Punctuator",
57493+ "value": "{",
57494+ },
57495+ Object {
57496+ "loc": Object {
57497+ "end": Object {
57498+ "column": 14,
57499+ "line": 2,
57500+ },
57501+ "start": Object {
57502+ "column": 13,
57503+ "line": 2,
57504+ },
57505+ },
57506+ "range": Array [
57507+ 21,
57508+ 22,
57509+ ],
57510+ "type": "Punctuator",
57511+ "value": "}",
57512+ },
57513+ ],
57514+ "type": "Program",
57515+ }
57516+ `;
57517+
5723957518exports[`typescript fixtures/errorRecovery/empty-type-arguments.src 1`] = `
5724057519Object {
5724157520 "body": Array [
You can’t perform that action at this time.
0 commit comments