wix-incubator / vscode-glean

The extension provides refactoring tools for your React codebase
MIT License
1.46k stars 56 forks source link

Cannot read property 'includes' of undefined #23

Closed calebeby closed 5 years ago

calebeby commented 5 years ago

I have been unable to use the "Extract Component" functionality, because each time I tried it I got this error. Even after disabling all other extensions, I still see this error. Any ideas why this might be?

borislit commented 5 years ago

@calebeby can you provide the exact JSX string you wanted to extract? thanks

calebeby commented 5 years ago

I think it gives me this error no matter what I try to extract, one thing I tried was <div>Hi</div>.

By the way, I am using VS Code Insiders, which might be the problem?

borislit commented 5 years ago

@calebeby i was able to reproduce the issue. WIll handle ASAP

borislit commented 5 years ago

@calebeby issue resolved. Please update to the latest version. Ping me if you have any more issues :)

maxkomarychev commented 5 years ago

I have the same issue as well. It first happened to me when I tried to apply "Convert Stateful to Stateless Component", but it seems to he happening for any refactoring I'm trying to apply.

glean: 4.9.0. vscode: Version 1.32.1 (1.32.1)

Sample code:

class Test extends PureComponent {
    render() {
        return <TextInput />
    }
}

The log I captured in "Output" tab:

[2019-03-13 09:06:26.638] [exthost] [error] [wix.glean] provider FAILED
[2019-03-13 09:06:26.639] [exthost] [error] SyntaxError: Unexpected token, expected ";" (2:13)
  1 | /* @babel/template */;
> 2 |     render() {
    |             ^
  3 |         return <TextInput />
  4 |     }
  5 | }
    at _class.raise (~/.vscode/extensions/wix.glean-4.9.0/node_modules/@babel/parser/lib/index.js:3939:15)
    at _class.unexpected (~/.vscode/extensions/wix.glean-4.9.0/node_modules/@babel/parser/lib/index.js:5248:16)
    at _class.semicolon (~/.vscode/extensions/wix.glean-4.9.0/node_modules/@babel/parser/lib/index.js:5232:40)
    at _class.parseExpressionStatement (~/.vscode/extensions/wix.glean-4.9.0/node_modules/@babel/parser/lib/index.js:7665:10)
    at _class.parseExpressionStatement (~/.vscode/extensions/wix.glean-4.9.0/node_modules/@babel/parser/lib/index.js:9980:69)
    at _class.parseStatementContent (~/.vscode/extensions/wix.glean-4.9.0/node_modules/@babel/parser/lib/index.js:7264:19)
    at _class.parseStatementContent (~/.vscode/extensions/wix.glean-4.9.0/node_modules/@babel/parser/lib/index.js:9916:58)
    at _class.parseStatement (~/.vscode/extensions/wix.glean-4.9.0/node_modules/@babel/parser/lib/index.js:7145:17)
    at _class.parseBlockOrModuleBlockBody (~/.vscode/extensions/wix.glean-4.9.0/node_modules/@babel/parser/lib/index.js:7696:23)
    at _class.parseBlockBody (~/.vscode/extensions/wix.glean-4.9.0/node_modules/@babel/parser/lib/index.js:7683:10)
    at _class.parseTopLevel (~/.vscode/extensions/wix.glean-4.9.0/node_modules/@babel/parser/lib/index.js:7110:10)
    at _class.parse (~/.vscode/extensions/wix.glean-4.9.0/node_modules/@babel/parser/lib/index.js:8510:17)
    at parse (~/.vscode/extensions/wix.glean-4.9.0/node_modules/@babel/parser/lib/index.js:10465:38)
    at parseWithCodeFrame (~/.vscode/extensions/wix.glean-4.9.0/node_modules/@babel/template/lib/parse.js:145:32)
    at parseAndBuildMetadata (~/.vscode/extensions/wix.glean-4.9.0/node_modules/@babel/template/lib/parse.js:43:15)
    at arg (~/.vscode/extensions/wix.glean-4.9.0/node_modules/@babel/template/lib/string.js:21:50)
    at Function.ast (~/.vscode/extensions/wix.glean-4.9.0/node_modules/@babel/template/lib/builder.js:47:155)
    at Object.exports.templateToAst.code [as templateToAst] (~/.vscode/extensions/wix.glean-4.9.0/out/parsing.js:22:52)
    at Object.isStatelessComp (~/.vscode/extensions/wix.glean-4.9.0/out/modules/statless-to-stateful.js:20:27)
    at CompleteActionProvider.provideCodeActions (~/.vscode/extensions/wix.glean-4.9.0/out/extension.js:30:36)
    at define.provideCodeActions.a.asPromise (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:564:641)
    at t.asPromise.Promise (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:48:58)
    at new Promise (<anonymous>)
    at Object.t.asPromise (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:48:32)
    at I.provideCodeActions (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:564:612)
    at define.$provideCodeActions._withAdapter.e (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:580:417)
    at $._withAdapter (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:575:502)
    at $provideCodeActions (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:580:395)
    at h._doInvokeHandler (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:593:118)
    at h._invokeHandler (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:592:777)
    at h._receiveRequest (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:591:383)
    at h._receiveOneMessage (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:590:279)
    at define.constructor._protocol.onMessage.e (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:588:565)
    at u.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:43:254)
    at e (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:39:64)
    at u.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:43:254)
    at s (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:168:754)
    at Socket.define.constructor._socketDataListener.e (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:168:960)
    at Socket.emit (events.js:182:13)
    at addChunk (_stream_readable.js:279:12)
    at readableAddChunk (_stream_readable.js:264:11)
    at Socket.Readable.push (_stream_readable.js:219:10)
    at Pipe.onread (net.js:636:20)
borislit commented 5 years ago

Hey @maxkomarychev! Can you please try and follow the instructions in the error SyntaxError: Unexpected token, expected ";" (2:13) and add ; at the end of your JSX and try to run the refactoring again? Perhaps I need to improve error messages if the syntax is invalid. Care for PR? I can point you in the right directions

maxkomarychev commented 5 years ago

@borislit

Can you please try and follow the instructions in the error SyntaxError: Unexpected token, expected ";" (2:13) and add ; at the end of your JSX and try to run the refactoring again?

I'm not sure I really follow here but I tried semicolons wherever it would make sense (although style guide in project I'm working on forbids semicolons altogether) and it didn't help.

The piece of code in logs is not my original code, it comes from some other place.

update 1

it comes from some other place.

I meant that "babel template" thing..