You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I'm working on a project where I need to convert snippets of code to AST. I have two simple examples of functions using Typescript:
exportconstarrowFunction=(value: any): string=>{const{ type }=valuereturntype}exportfunctionregularFunction(value: any): string{// this is a regular functionconst{ type }=valuereturntype}
For the case of regularFunction I don't have any problem, but when I use the parse function in arrowFunction I get the error below:
<rootDir>/node_modules/meriyah/dist/meriyah.cjs:187
throw new ParseError(parser.index, parser.line, parser.column, type, ...params);
^
ParseError [SyntaxError]: [1:10]: Function declaration must have a name in this context
at report (<rootDir>/node_modules/meriyah/dist/meriyah.cjs:187:11)
at parseFunctionDeclaration (<rootDir>/node_modules/meriyah/dist/meriyah.cjs:6592:13)
at parseStatementListItem (<rootDir>/node_modules/meriyah/dist/meriyah.cjs:4853:20)
at parseModuleItem (<rootDir>/node_modules/meriyah/dist/meriyah.cjs:4840:26)
at parseModuleItemList (<rootDir>/node_modules/meriyah/dist/meriyah.cjs:4825:25)
at parseSource (<rootDir>/node_modules/meriyah/dist/meriyah.cjs:4769:16)
at Object.parseModule (<rootDir>/node_modules/meriyah/dist/meriyah.cjs:8780:12)
at parse (<rootDir>/node_modules/abstract-syntax-tree/src/parse.js:4:18)
at parse (<rootDir>/node_modules/abstract-syntax-tree/index.js:75:12)
at Object.<anonymous> (<rootDir>/dist/clones/arrow-and-regular/index.js:10:43) {
index: 10,
line: 1,
column: 10,
description: '[1:10]: Function declaration must have a name in this context',
loc: { line: 1, column: 10 }
}
I realized that it can be related to the newer syntaxes of the language and remembering that I only have this error when using Typescript.
hey @felipelealdefaria, thanks for using the library. Are you trying to parse the output that's compiled via typescript? How does the compiled output look like?
I was trying to parse the typescript code directly. However, today I got the answer that the library meriyah doesn't understand Typescript syntax, only Javascript.
Sorry for the misunderstanding, I will follow the project using only Javascript :)
Hi, I'm working on a project where I need to convert snippets of code to AST. I have two simple examples of functions using Typescript:
For the case of regularFunction I don't have any problem, but when I use the parse function in arrowFunction I get the error below:
I realized that it can be related to the newer syntaxes of the language and remembering that I only have this error when using Typescript.
The text was updated successfully, but these errors were encountered: