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

fix glob-to-regexp d.ts #49

Merged
merged 1 commit into from
Feb 3, 2018
Merged

fix glob-to-regexp d.ts #49

merged 1 commit into from
Feb 3, 2018

Conversation

AlexTugarev
Copy link
Contributor

Signed-off-by: Alex Tugarev alex.tugarev@typefox.io

@AlexTugarev
Copy link
Contributor Author

The issue is, that DocumentFilters like { pattern: ".*"} cannot be used, as the type definition refers to an ES6 module, but glob-to-regexp is not a such. Also, the function is only called if only pattern is provided.

@@ -1,7 +1,9 @@
declare module "glob-to-regexp" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to delcare module then at all? https://www.typescriptlang.org/docs/handbook/declaration-files/templates/module-function-d-ts.html looks like we should be able to declare a function and export it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

module declaration is needed if import ... from "module" syntax should stay, cf. microsoft/TypeScript#5073.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we use import x = require('module') then it should not be necessary

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, it's still required.

[ts]
Could not find a declaration file for module 'glob-to-regexp'. '/Users/tugarev/Projects/monaco-languageclient/node_modules/glob-to-regexp/index.js' implicitly has an 'any' type.
Try npm install @types/glob-to-regexp if it exists or add a new declaration (.d.ts) file containing declare module 'glob-to-regexp';

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I double-checked that, it's required if types should be imported, right? module-function.d.ts seems to be misleading.

src/languages.ts Outdated
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
import globToRegExp from "glob-to-regexp";
import * as globToRegExp from 'glob-to-regexp';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import globToRegExp = require('glob-to-regexp') should be used

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should I change it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, please, I think it is bogus to use es6 syntax to import not es6 modules

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Signed-off-by: Alex Tugarev <alex.tugarev@typefox.io>
@akosyakov
Copy link
Contributor

@AlexTugarev I've sent you an invitation, please accept it and merge the PR

@AlexTugarev AlexTugarev merged commit 1050734 into master Feb 3, 2018
@AlexTugarev AlexTugarev deleted the at/fix-typedefinition branch February 3, 2018 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants