-
Notifications
You must be signed in to change notification settings - Fork 351
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Optional chaining (?.) #1394
Comments
I found that esprima-next handles it pretty well. Is there a reason it is not bundled with recast? |
It works fine with Babel: import { parse } from "recast";
import * as babel from "recast/parsers/babel";
const code = `ITEM?.getAsEntry?.() ?? ITEM?.webkitGetAsEntry?.()`;
console.log(parse(code, { parser: babel }));
/*
prints:
Node {
original: Node {
type: "File",
start: 0,
end: 50,
loc: SourceLocation {
…
*/ |
Babel worked 99% for my first test. It converted… |
Is it supported with any parser? Is it planned?
I get
/Library/WebServer/Documents/play/dropDir/node_modules/esprima/dist/esprima.js:1995 throw this.unexpectedTokenError(token, message); ^ Error: Line 299: Unexpected token . at ErrorHandler.constructError (/Library/WebServer/Documents/play/dropDir/node_modules/esprima/dist/esprima.js:5012:22) at ErrorHandler.createError (/Library/WebServer/Documents/play/dropDir/node_modules/esprima/dist/esprima.js:5028:27) at Parser.unexpectedTokenError (/Library/WebServer/Documents/play/dropDir/node_modules/esprima/dist/esprima.js:1985:39) at Parser.throwUnexpectedToken (/Library/WebServer/Documents/play/dropDir/node_modules/esprima/dist/esprima.js:1995:21) at Parser.parsePrimaryExpression (/Library/WebServer/Documents/play/dropDir/node_modules/esprima/dist/esprima.js:2366:38) at JSXParser.parsePrimaryExpression (/Library/WebServer/Documents/play/dropDir/node_modules/esprima/dist/esprima.js:466:97) at Parser.inheritCoverGrammar (/Library/WebServer/Documents/play/dropDir/node_modules/esprima/dist/esprima.js:2285:37) at Parser.parseLeftHandSideExpressionAllowCall (/Library/WebServer/Documents/play/dropDir/node_modules/esprima/dist/esprima.js:2899:26) at Parser.inheritCoverGrammar (/Library/WebServer/Documents/play/dropDir/node_modules/esprima/dist/esprima.js:2285:37) at Parser.parseUpdateExpression (/Library/WebServer/Documents/play/dropDir/node_modules/esprima/dist/esprima.js:3004:26) { index: 11111, lineNumber: 299, description: 'Unexpected token .' }
when I code
ITEM?.getAsEntry?.() ?? ITEM?.webkitGetAsEntry?.()
The text was updated successfully, but these errors were encountered: