question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Declaration files not identified as a RootSourceFile

See original GitHub issue

Bug 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:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
iFaxitycommented, Oct 13, 2020

Ok sweet, thanks. 😃

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found