-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add support for TypeScript class constructor in TypeScript mode #131
Comments
Thanks for the report! I will look into it. |
The construct signature with new keyword can apparently be used with arrow style too: function greet(ctor: new () => Base) {
const instance = new ctor();
instance.printName();
} https://www.typescriptlang.org/docs/handbook/2/classes.html#abstract-construct-signatures FWIW, this is a high priority for us for a PR with the purpose of generating a declaration file for espree after some jsdoc manipulations (hopefully eventually leading to the same for ESLint). |
@simonseyock : any chance of being able to take a look at this in the near future? |
@brettz9 I will look into this in the next days. |
🎉 This issue has been resolved in version 3.1.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
I'm not seeing this item from the OP work in the tester: |
Am reopening as the specific case of an object with the |
@simonseyock : Any chance you might have some time to take a look? |
the type expression would be |
ok I might not have understood that correctly. I will see what I can do. |
This might be complicated as this has to do with the whole problematic of needing a different parsing context inside object literals. This is in work, but will need some time. |
Much appreciated, thanks! This feature should be particularly handy since without defining and pointing to an actual class, it is the only way to indicate the pattern of a constructor (and define the class' static properties between the same curly brackets). In cases like the PR I'm working with, one may have a factory which produces a class rather than having any publicly exported class that can be pointed to. |
@simonseyock : I know you said it'd need some time, but just wondering if you had any status update to share? Thanks! |
I looked into this again today, but I did not find a solution that worked properly. The problem with the contexts is solvable, but no I hit some problems with the types of the results. The problem is that I use one result type for jsdoc and typescript syntax but it is at some points so different that it does not really make sense anymore. I am thinking about splitting the result types and to make the |
No worries! Appreciate all the investigations and effort... |
Describe the issue
From the TypeScript documentation: https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html
We can use class constructors in params:
But this fails to parse when using the ESLint JSDoc plugin.
The text was updated successfully, but these errors were encountered: