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

Uri.isUri return type is problematic #66478

Closed
joaomoreno opened this issue Jan 14, 2019 · 1 comment
Closed

Uri.isUri return type is problematic #66478

joaomoreno opened this issue Jan 14, 2019 · 1 comment
Assignees
Labels

Comments

@joaomoreno
Copy link
Member

https://github.com/Microsoft/vscode/blob/fe9539a05ffb89bea781e7a4e7f7029980b30686/src/vs/base/common/uri.ts#L100

The return type of Uri.isUri being uri is Uri is problematic since it can have us write code like this:

const obj = { authority: '', fragment: '', path: '', query: '', scheme: '' };
if (isUri(obj)) {
  console.log(obj.fsPath.length);
}

TypeScript will gladly compile this without errors, yet the end result will be an NPE.

We should change that return type to simply boolean.

@jrieken
Copy link
Member

jrieken commented Jan 15, 2019

good catch

@vscodebot vscodebot bot locked and limited conversation to collaborators Mar 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants