-
-
Notifications
You must be signed in to change notification settings - Fork 745
Description
Search Terms
declaration merging declare global script module
Problem
(Yeah, I know, globals again. I would also like to use modules, but that's hard to impossible for large existing projects. primefaces/primefaces#12717)
When you have a global script file (without import / export) and a module file that both amend a namspace in the global scope, typedoc seems to consider these as different.
When using the plugin typedoc-plugin-merge-modules
, that results in the namespaces not getting merged. But I think the issue is not with the plugin, as it seems to happen even without the plugin. For example:
// base.ts
namespace PrimeFaces {
export interface WindowExtensions{}
}
interface Window extends PrimeFaces.WindowExtensions {}
// src/a.ts
import "./module.js"; // make this a module file
declare global {
namespace PrimeFaces {
export interface WindowExtensions{
a: string;
}
}
}
// src/b.ts
// similar a.ts
// src/c.ts
namespace PrimeFaces {
export interface WindowExtensions{
c: string;
}
}
// src/d.ts
// similar to c.ts
// index.ts
console.log(window.a, window.b, window.c, window.d);
Now when generate docs from that, d/PrimeFaces
is marked as a re-export of c/PrimeFaces
. But a/PrimeFaces
and b/PrimeFaces
are not and contain only a
and b
, respectively. Interestingly enough though, c/PrimeFaces
contains all of a
, b
, c
and d
.
With typedoc-plugin-merge-modules
, that then results in duplicates:
Repro
git clone https://github.com/blutorange/primefaces-js-refactor-test.git
cd primefaces-js-refactor-test/
git checkout demo-typedoc-merge-script-module
yarn install
yarn tsc # note that this compiles, so all interfaces point to the same thing
yarn typedoc --out docs src/index.ts src/a.ts src/b.ts src/c.ts src/d.ts src/module.ts
open docs/index.html