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

How to declare types when importing within a JSDoc type? #12502

Open
jaydenseric opened this issue Oct 20, 2021 Discussed in #12404 · 2 comments
Open

How to declare types when importing within a JSDoc type? #12502

jaydenseric opened this issue Oct 20, 2021 Discussed in #12404 · 2 comments
Labels
cli related to cli/ dir suggestion suggestions for new features (yet to be agreed)

Comments

@jaydenseric
Copy link

Discussed in #12404

Originally posted by jaydenseric October 12, 2021
There is a way to declare types when importing:

// @deno-types="./coolLib.d.ts"
import * as coolLib from "./coolLib.js";

https://deno.land/[email protected]/typescript/types#providing-types-when-importing

But how do you do the same when importing within a JSDoc type?

For example in x.js:

/** @param {import("foo").Foo} foo A foo. */
function x(foo) {
  // …
}

In the above situation, if Foo is a type that comes from a .d.ts file and isn't actually a named export in the ESM module, trying to import the x.js module in a TypeScript module with type checking enabled will cause a TS error: TS2694 [ERROR]: Namespace '__' has no exported member 'Foo'..

@dsherret
Copy link
Member

I don't believe there is a way for doing this at the moment, but similar to microsoft/TypeScript#33437 we should try to get a solution in the TS compiler for doing this.

@dsherret dsherret added cli related to cli/ dir suggestion suggestions for new features (yet to be agreed) labels Oct 25, 2021
@bartlomieju
Copy link
Member

@kitsonk did #13173 somehow helped with this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli related to cli/ dir suggestion suggestions for new features (yet to be agreed)
Projects
None yet
Development

No branches or pull requests

3 participants