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

A 'declare' modifier cannot be used in an already ambient context #49

Closed
whitlockjc opened this issue Aug 30, 2018 · 7 comments · Fixed by #50
Closed

A 'declare' modifier cannot be used in an already ambient context #49

whitlockjc opened this issue Aug 30, 2018 · 7 comments · Fixed by #50

Comments

@whitlockjc
Copy link

As reported in whitlockjc/json-refs#140, it seems like a declare in a module, namespace, ... causes the error thrown in the title. whitlockjc/json-refs#143 shows how to fix this and has some details.

@wehrstedt
Copy link
Collaborator

Can you give me an example of the input, the output and what you expect it should look like?

@whitlockjc
Copy link
Author

https://github.com/whitlockjc/json-refs is a perfect example. index.js and lib/typedefs.js end up creating the TypeScript definitions in index.d.ts. What happens is if you have a @typedef {object} that is a @memberof module:json-refs, when the interface is declared, it should not have a declare keyword. So declare interface JsonRefsOptions, it should just be interface JsonRefsOptions. _(Not sure if it should be export interface JsonRefsOptions, I'm new to TypeScript.

@wehrstedt
Copy link
Collaborator

Okay, I will have a look tomorrow

@wehrstedt
Copy link
Collaborator

I could easily reproduce this with the following jsdoc

/**
 * @module myModule
 */

/**
 * @interface myInterfaceInsideAModule
 * @memberof module:myModule
 */

which generates the following output

declare module 'myModule' {
    declare interface myInterfaceInsideAModule {
    }

}

The output should look like

declare module 'myModule' {
    interface myInterfaceInsideAModule {
    }

}

(the keyword "declare" is omitted for the interface)

@wehrstedt
Copy link
Collaborator

Good news: It can be fixed by just upgrading dts-dom

@wehrstedt
Copy link
Collaborator

wehrstedt commented Aug 31, 2018

@whitlockjc published v1.0.4. Can you verify it, please?

@whitlockjc
Copy link
Author

v1.0.4 fixes my issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants