Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: "vscode.Uri.file" is not a constructor #69533

Closed
Gruntfuggly opened this issue Feb 27, 2019 · 3 comments
Closed

Error: "vscode.Uri.file" is not a constructor #69533

Gruntfuggly opened this issue Feb 27, 2019 · 3 comments
Assignees
Labels
*dev-question VS Code Extension Development Question

Comments

@Gruntfuggly
Copy link

My extension uses vscode.Uri.file to construct a resource with a file path:

treeItem.resourceUri = new vscode.Uri.file( node.fsPath );

https://code.visualstudio.com/api/references/vscode-api#Uri

This works correctly in the stable build, but in the insiders build (1.32.0-insider, 7d0c9e6 ) I get the error:

vscode.Uri.file is not a constructor

Am I doing something wrong?

@jrieken jrieken added the *dev-question VS Code Extension Development Question label Feb 27, 2019
@vscodebot
Copy link

vscodebot bot commented Feb 27, 2019

We have a great developer community over on slack where extension authors help each other. This is a great place for you to ask questions and find support.

Happy Coding!

@vscodebot vscodebot bot closed this as completed Feb 27, 2019
@jrieken
Copy link
Member

jrieken commented Feb 27, 2019

Am I doing something wrong?

Yes ;-) It's not a constructor function but a static function. Use vscode.Uri.file(node.fsPath)

@jrieken
Copy link
Member

jrieken commented Feb 27, 2019

This works correctly in the stable build, but in the insiders build (1.32.0-insider, 7d0c9e6 )

This is likely because we now compile to ES6, meaning the URI-class is now actually a class and not functions/prototypes anymore. The latter, functions, allow using new in more relaxed ways but it's likely not what you wanted. The ES6 world is more strict.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*dev-question VS Code Extension Development Question
Projects
None yet
Development

No branches or pull requests

2 participants