-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Support @implements in JSDoc #35629
Comments
@dragomirtitian you said you were interested in implementing this, so I came back and read the example again. It looks like we only need class Foo { method(): number {} }
class Bar implements Foo { method() { return 'bar' } } This will give the desired error on Bar's method saying that string isn't assignable to numbe, plus an error on Foo's method saying that it doesn't return anything. @TimvdLippe in your editor, what happens when you change Edit: from local testing, |
|
For a closure → typescript conversion, it might work just to put |
Private constructor could work fine as well. I was thinking an abstract class but not make the methods abstract : abstract class Foo {
// @ts-ignore We would need to suppress return type checks
method(): number {}
}
class Bar implements Foo{
method() {
return "bar";
}
} The error message seems better out of the box too for an abstract class: Also not sure how strict TS is with JS declared return types vs actual return types, seems to be ok with it in the playground |
@dragomirtitian I looked at the closure documentation. Here's what I'm thinking right now:
@TimvdLippe do you want to weigh in? Once we have (1) and (2), I'd like to know how much further you can get with devtools-frontend. |
Another difference is that |
@sandersn Ok, sounds like a plan, I will get started on 1 & 2 and see how it goes. Thank you for the hints about similar features, really appreciate it 😊. |
Strongly agree here, |
DevTools frontend makes heavy use of I am not sure whether 1 and 2 will be sufficient for our case. For JS/TS "bridges" that are used in both systems, should we declare them as |
@sandersn from what I gather from @TimvdLippe 's comment it sounds like the This means using a single file with classes, that clojure is meant to use as interfaces, and TS is meant to use as abstract classes is not possible without TS implementing I think there is value in implementing |
I still think it can work with just
I think (3) is a pretty good option because people aren't likely to instantiate interfaces at all, much less while porting code. [1] I think that's what you're saying you need to do @TimvdLippe |
@sandersn Yes that is correct. I think option 3 makes a lot of sense and would allow us to have a smoother migration path. Thanks for working on this! |
Sounds like a plan then. @dragomirtitian this sounds like a good feature for TS 3.9, so I assigned both you and me for that milestone. If you don't have time to implement |
@sandersn Ok, cool, I definitely have time to do it until then. I plan to have a rough PR ready by end of next week. |
Hello, |
TypeScript 3.9 or |
Seems like type import is not allowed |
@sandersn It seems like VS Code doesn't automatically pick up the Should I file a separate issue for this and if so, on which repository? Also, the implementations seems to be working correctly 😄 I still have to do a couple of more checks, but it seems to be working correctly. |
Discovered an issue that prohibits us from using this feature yet 😭: #38640 Would be great if we can figure out a workaround somehow? Downstream this is implemented in https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2207238 with TypeScript changes made in https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2207236/1 |
I've yet to see a code sample of
The docs have long-maintained that |
We are looking at migrating from Closure Compiler JavaScript to TypeScript in Chrome DevTools. In our early experiments, we discovered that TypeScript with
--checkJs
does not understand@interface
definitions. I originally commented on #33207 but was asked to create a separate issue instead.You can see the error messages it would generate for DevTools in https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/1962289 (for file https://cs.chromium.org/chromium/src/third_party/devtools-frontend/src/front_end/common/EventTarget.js?rcl=32cd3a0fcc7a34ea0c3831cd447c70f359dd9400)
TypeScript Version: 3.5.3
Search Terms: jsdoc, interface,
@interface
,Per #33207 (comment) I am creating a new issue. There is an existing issue that is closed for collaboration: #16142
Code
Expected behavior:
TypeScript understands that Foo is an interface and that Bar does not properly implement the interface
Actual behavior:
TypeScript does not support
@interface
and@implements
and will throw an error on Foo and will accept the definition of Bar.Playground Link: http://www.typescriptlang.org/play/?checkJs=true&allowJs=true&ts=3.8.0-dev.20191210&useJavaScript=true#code/PQKhAIAEEsDsBcCmAnAZgQwMaPCYAoTAG3QGdTwAxAe2vAG99xnxQJJlF4BXZWB2NwC2AIxQBfXARbghXABbUAJgAoAlA3H4t+NlGhCADkURyEFejWqS8hEuXAAhdMgZMWejl1796peMhwAOY20ixy8IqqGowyMpw8fOAARCIuyQDc7sxa4kA
Related Issues: #16142 #33207
The text was updated successfully, but these errors were encountered: