Declaration files not identified as a RootSourceFile
See original GitHub issueBug report
Hi, i could not really glance from the documentation how to deal with including external declarations files, ive put
From debugging on my own i can see the file is being correctly parsed, but seems to be flagged as a non root source file (the flags property on the SourceFileObject is 8388672).
Is this intended and which other way can i add external declaration types other than using the triple slash reference?
Input code
// from my build script
const typings = generateDtsBundle([
{ filePath: path.resolve('globals.d.ts'), },
{ filePath: path.resolve('src/index.ts'), },
], {
preferredConfigPath: path.resolve(__dirname, '../tsconfig.json'),
externalTypes: [ 'node', '@vue/reactivity' ],
externalImports: [ '@vue/reactivity' ],
});
// globals.d.ts
interface ShadyCSS {
nativeCss: boolean;
nativeShadow: boolean;
styleElement(host: Element, properties?: Record<string, string>): void;
styleSubtree(element: HTMLElement, properties?: Record<string, string>): void;
prepareTemplateDom(template: HTMLTemplateElement, name: string): void;
prepareTemplate(template: HTMLTemplateElement, name: string, elementExtends?: string): void;
prepareTemplateStyles(template: HTMLTemplateElement, name: string, elementExtends?: string): void;
ScopingShim?: {
prepareAdoptedCssText(cssText: string[], name: string): void;
};
}
interface ShadyDOM {
inUse: boolean;
flush: () => void;
}
interface CSSStyleSheet {
replaceSync(cssText: string): void;
replace(cssText: string): Promise<unknown>;
}
interface ShadowRoot {
adoptedStyleSheets: CSSStyleSheet[];
}
declare var ShadowRoot: { prototype: ShadowRoot; new (): ShadowRoot; };
interface Window {
ShadyCSS?: ShadyCSS;
ShadyDOM?: ShadyDOM;
ShadowRoot: typeof ShadowRoot;
}
// Globals for identifying versions in builds
declare var __DEV__: boolean;
declare var __BROWSER__: boolean;
declare var __NODE_JS__: boolean;
declare var __VERSION__: string;
Expected output
Expected file to be generated without errors (hopefully).
Actual output
Error from console:
Error: Symbol for root source file <project>/packages/globals.d.ts not found
at <project>/node_modules/dts-bundle-generator/dist/bundle-generator.js:45:19
at Array.map (<anonymous>)
at generateDtsBundle (<project>/node_modules/dts-bundle-generator/dist/bundle-generator.js:36:20)
at build (<project>/bin/build:151:23)
at async run (<project>//bin/build:188:7) {stack: 'Error: Symbol for root source file <project>/bin/build:188:7)', message: 'Symbol for root source file <project>/packages/globals.d.ts not found'}
Additional context
I’m using the JS api version dts-bundle-generator
versions: Node: v14.13.1 dts-bundle-generator: v5.4.0 OS: Ubuntu 20.04 (WSL 2), Windows 10 (build 19041.508)
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
dts-bundle-generator/bundle-generator.ts at master - GitHub
Tool to generate a single bundle of dts. Contribute to timocov/dts-bundle-generator development by creating an account on GitHub.
Read more >Typescript: .d.ts file not recognized - Stack Overflow
We declared "include": ["src"] in our tsconfig.json and this caused declarations.d.ts in root ( "/" ) to not be detected.
Read more >Zig Language Reference
When a Zig source file is not built using the zig test tool, the test declarations are omitted from the build. Test declarations...
Read more >GN Reference - Google Git
--check-generated Generated files are normally not checked since they do not exist until after a build. With this flag, those generated files that...
Read more >How to fix error TS7016: Could not find a declaration file for ...
The second part of the error says: Try `npm install @types/XYZ` if it exists or add a new declaration (.d.ts) file containing `declare...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ok sweet, thanks. 😃
You can see how it’s done in test cases https://github.com/timocov/dts-bundle-generator/tree/fd0b12a4e1900cb1a92e7fecd4e054c80a5b7f40/tests/e2e/test-cases/inline-declare-global.