1

I've enabled checkJS and allowJS in Typescript and created a simple fooInterface.d.ts file:

declare interface FooInterface {
  x();
} 

I'm trying to typecheck a JS file against this interface:

/**
 * @implements {FooInterface}
 */
class Bar {
  y() {}
}

However I can't get it to throw an error upon running tsc.

Also tried simply writing declare class, didn't work either.

How can I reuse types from .d.ts files in JSDoc+JS?

2
  • 1
    I don't think that @implements works yet but there's an issue tracking it. Try @extends Commented Nov 11, 2017 at 22:54
  • 1
    Where can I find the issue? I tried to search for this in the issue tracker with no results. @type + declare class didn't work, @extends + declare class didn't work :/ Commented Nov 11, 2017 at 23:10

1 Answer 1

2

Supporting the JSDoc @implements tag has been requested in TypeScript and is tracked by https://github.com/Microsoft/TypeScript/issues/17498

The @extends tag will be supported in the next release of TypeScript (2.7) and is already available in the nightly builds (typescript@next) which, I might add, are remarkably stable.

You can get the nightly build with your package manager of choice. For example

using npm

$ npm install typescript@next

using jspm

$ jspm install typescript@next

using yarn

$ yarn add typescript@next
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.