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

declare module parsed as namespace #1284

Closed
arnog opened this issue Apr 26, 2020 · 3 comments · Fixed by #1301
Closed

declare module parsed as namespace #1284

arnog opened this issue Apr 26, 2020 · 3 comments · Fixed by #1301
Labels
bug Functionality does not match expectation

Comments

@arnog
Copy link

arnog commented Apr 26, 2020

This input:

declare module "m" {
  export function f();
}

generates this JSON output:

{
	"id": 0,
	"name": "",
	"kind": 0,
	"flags": {},
	"originalName": "",
	"children": [
		{
			"id": 1,
			"name": "\"m\"",
			"kind": 2,
			"kindString": "Namespace",
			"flags": {
				"isExported": true
			},
			"children": [
				{
					"id": 2,
					"name": "f",
					"kind": 64,
					"kindString": "Function",
					"flags": {
						"isExported": true
					},
					"signatures": [
						{
							"id": 3,
							"name": "f",
							"kind": 4096,
							"kindString": "Call signature",
							"flags": {
								"isExported": true
							},
							"type": {
								"type": "intrinsic",
								"name": "any"
							}
						}
					],
				}
			],
			"groups": [
				{
					"title": "Functions",
					"kind": 64,
					"children": [
						2
					]
				}
			],
		}
	],
	"groups": [
		{
			"title": "Namespaces",
			"kind": 2,
			"children": [
				1
			]
		}
	]
}

I was expecting reflection with id = 1 to be of kind = 1 (module), not of kind = 2 (namespace)

@arnog arnog added the bug Functionality does not match expectation label Apr 26, 2020
@Gerrit0 Gerrit0 changed the title declare module parsed as interface declare module parsed as namespace Apr 26, 2020
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Apr 26, 2020

Looks like this is because in the AST, this creates a ModuleDeclaration node, which is the same node type created by namespaces.

Should be a pretty simple fix to switch the kind argument to createDeclaration if the name of the node is a StringLiteral - https://github.com/TypeStrong/typedoc/blob/master/src/lib/converter/nodes/module.ts

@Gerrit0
Copy link
Collaborator

Gerrit0 commented May 17, 2020

v0.17.7 released with this :)

@arnog
Copy link
Author

arnog commented May 17, 2020

Awesome. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Functionality does not match expectation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants