-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
JSDoc: support @implements
tag on class
#17498
Comments
The problem with /** @import { I } from "foo.d.ts" */
/** @implements {I} */
class AClass { ... } However, in TS code we don't allow you to omit the parameter types on an override, even if they should be inferrable due to already being declared in the parent; the best link I have on that is #2000 (comment). |
Yeah, if it resolve problem, would be cool! |
@type
tag on class@implements
tag on class
The Lighthouse team uses a neat workaround to assert implementation of an interface. Here is the gist: // @file: interface.d.ts
export interface MyInterface {
foo(): string
}
// @file: implementation.js
/** @typedef {import('./interface').MyInterface} MyInterface */
export class MyClass {
constructor() {
/**
* Assert that MyClass correctly implements MyInterface.
* @type {MyInterface}
*/
const instance = this;
}
/**
* @returns {number}
*/
foo() {
return 42;
}
} |
Duplicate of #30156, which has a real code example. |
TypeScript Version: nightly (2.5.0-dev.20170728)
Code
index.d.ts
some.js
Expected behavior:
Type 'false' is not assignable to type 'number'.
Actual behavior:
Not working. Impossible to set type on class.
The text was updated successfully, but these errors were encountered: