Skip to content

excludeNotExported with default export declaration separate from variable creation not working #393

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

Closed
nicknisi opened this issue Jan 26, 2017 · 11 comments

Comments

@nicknisi
Copy link
Collaborator

In a module where the default export is defined separate from the creation of the exported value, TypeDoc can't seem to map the exported value back to the internal variable.

Example module:

// keys.ts 

/**
 * A list of special keys
 */
const keys = {
    foo: 'foo',
    bar: true
};

export default keys;

This generates a page that looks like this:

screen shot 2017-01-26 at 3 08 00 pm

@nicknisi nicknisi changed the title excludeNotExported with default export declaration separate from variable creation excludeNotExported with default export declaration separate from variable creation not working Jan 26, 2017
@aciccarello aciccarello added the bug label Feb 3, 2017
nicknisi added a commit to nicknisi/typedoc that referenced this issue Feb 22, 2017
Fix issue where default exports are separated across two statements such
as

```
const foo = {};
export default foo;
```

* remove the short-circuit in the declaration factory so all reflections
exist after converter#convert is run
* in converter#resolve, add check for excludeNotExported and then prune
the references list and children in the project structure whose
isExported flag is false

fixes TypeStrong#393
nicknisi added a commit to nicknisi/typedoc that referenced this issue Feb 22, 2017
Fix issue where default exports are separated across two statements such
as

```
const foo = {};
export default foo;
```

* remove the short-circuit in the declaration factory so all reflections
exist after converter#convert is run
* in converter#resolve, add check for excludeNotExported and then prune
the references list and children in the project structure whose
isExported flag is false

fixes TypeStrong#393
nicknisi added a commit to nicknisi/typedoc that referenced this issue Feb 27, 2017
Fix issue where default exports are separated across two statements such
as

```
const foo = {};
export default foo;
```

* remove the short-circuit in the declaration factory so all reflections
exist after converter#convert is run
* in converter#resolve, add check for excludeNotExported and then prune
the references list and children in the project structure whose
isExported flag is false

fixes TypeStrong#393
@paztis
Copy link

paztis commented Jan 16, 2020

What the final status for this? Problem is still present and not resolved since 2 years?
On my side I still see it

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Jan 16, 2020

Yes, it's still broken. Most cases with exports separate from declarations were fixed in 0.16, but default exports and export = haven't been resolved yet. We need a clearer way of presenting that a symbol is exported under default or with export = in the themes. Once that's done, it should be relatively easy to update the converter.

Nobody works on TypeDoc full time, I've been lucky enough to get a lot done the past month or so, but will soon have much less time to dedicate to it.

@paztis
Copy link

paztis commented Jan 16, 2020

To well understand, the problem is present in the rendering part or the introspection part ?

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Jan 16, 2020

I believe both need to be updated to properly fix this.

  • The themes need to be updated to clearly mark if some reflection is the default export
  • The converter needs to be updated to mark a reflection as a default export even if it isn't in that declaration.

@paztis
Copy link

paztis commented Jan 16, 2020

But seems the typescript reflection detect it. In this case the problem is fully internal.
Why the previous PR was not accepted ? Will try to look for a better solution if I we'll understand the problem.

@paztis
Copy link

paztis commented Jan 16, 2020

as I see in the code, the exports are not checked at the good level.
The SourceFile object itself containt all the correct references to the exports.
You are searching for ExportAssignment and ExportDeclaration that are only present when a variable is declared inside an export
export const x = 1

On an existing variable export no node exist
cosnt x = 1; export default x

Will try to rewrite it

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Jan 17, 2020

Why the previous PR was not accepted ?

I'm not sure, I wasn't involved much then, based on the comments it looks like it never solved the issue of telling if a reflection was the default export.

You are searching for ExportAssignment and ExportDeclaration that are only present when a variable is declared inside an export

I think it should be possible to check the source file exports map (exported under "default") and mark a node exported if its symbol is the same symbol.

@benmccann
Copy link

@Gerrit0 highlighting default exports sounds like a reasonable feature, but is really orthogonal to this bug. Do you think you could chime in on #431 to encourage the author to continue with his PR?

@paztis
Copy link

paztis commented Feb 19, 2020

I've works on a for of typedoc that correctly supports the lib management

There's a PR over this branch: #1196
The typedoc module is also available in @paztis/typedoc over npm (https://www.npmjs.com/package/@paztis/typedoc).

This is globally working with the new 'library' mode of typedoc

You can try if you want

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Feb 22, 2020

Yea, I'm with paztis here, I don't really want to pick this up when it should be fixed properly by library mode (which should replace most if not all uses of the other modes)

You can also install typedoc@next to try it now, I haven't had time to look at paztis' additional work on it yet.

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Dec 29, 2020

This works properly in 0.20:

image

@Gerrit0 Gerrit0 closed this as completed Dec 29, 2020
@Gerrit0 Gerrit0 removed the bug label Feb 2, 2025
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.

5 participants