Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 28, 2025

  • Understand the issue: TypeScript definitions file has invalid syntax
    • export = Bowser; conflicts with ES6 named exports (TS2309)
    • Constants are declared twice (module level and inside namespace) (TS2451)
  • Reproduce the issue by compiling with skipLibCheck: false
  • Fix the TypeScript definitions file:
    • Removed export = Bowser; line (resolves TS2309)
    • Changed declare namespace Bowser with inner namespace Parser to export namespace Parser (resolves TS2451)
    • Removed duplicate constant declarations from the former Bowser namespace
    • Removed duplicate method declarations in Parser interface (isBrowser, isEngine, isOS, isPlatform)
  • Test the fix with TypeScript compiler
  • Run code review and address feedback
  • Run security checks (no vulnerabilities found)
  • Revert package.json changes (removed TypeScript dev dependency)
Original prompt

This section details on the original issue you should resolve

<issue_title>typescript definitions are invalid</issue_title>
<issue_description>In a bare angular 20 app with skipLibCheck set to false in tsconfig, bowser 2.13.0 generates these build errors:

✘ [ERROR] TS2309: An export assignment cannot be used in a module with other exported elements. [plugin angular-compiler]

    node_modules/bowser/index.d.ts:5:0:
      5 │ export = Bowser;
        ╵ ~~~~~~~~~~~~~~~~


✘ [ERROR] TS2451: Cannot redeclare block-scoped variable 'BROWSER_MAP'. [plugin angular-compiler]

    node_modules/bowser/index.d.ts:10:13:
      10 │ export const BROWSER_MAP: Record<string, string>;
         ╵              ~~~~~~~~~~~

  'BROWSER_MAP' was also declared here.

    node_modules/bowser/index.d.ts:35:8:
      35 │   const BROWSER_MAP: Record<string, string>;
         ╵         ~~~~~~~~~~~


✘ [ERROR] TS2451: Cannot redeclare block-scoped variable 'ENGINE_MAP'. [plugin angular-compiler]

    node_modules/bowser/index.d.ts:11:13:
      11 │ export const ENGINE_MAP: Record<string, string>;
         ╵              ~~~~~~~~~~

  'ENGINE_MAP' was also declared here.

    node_modules/bowser/index.d.ts:36:8:
      36 │   const ENGINE_MAP: Record<string, string>;
         ╵         ~~~~~~~~~~


✘ [ERROR] TS2451: Cannot redeclare block-scoped variable 'OS_MAP'. [plugin angular-compiler]

    node_modules/bowser/index.d.ts:12:13:
      12 │ export const OS_MAP: Record<string, string>;
         ╵              ~~~~~~

  'OS_MAP' was also declared here.

    node_modules/bowser/index.d.ts:37:8:
      37 │   const OS_MAP: Record<string, string>;
         ╵         ~~~~~~


✘ [ERROR] TS2451: Cannot redeclare block-scoped variable 'PLATFORMS_MAP'. [plugin angular-compiler]

    node_modules/bowser/index.d.ts:13:13:
      13 │ export const PLATFORMS_MAP: Record<string, string>;
         ╵              ~~~~~~~~~~~~~

  'PLATFORMS_MAP' was also declared here.

    node_modules/bowser/index.d.ts:38:8:
      38 │   const PLATFORMS_MAP: Record<string, string>;
         ╵         ~~~~~~~~~~~~~


✘ [ERROR] TS2451: Cannot redeclare block-scoped variable 'BROWSER_MAP'. [plugin angular-compiler]

    node_modules/bowser/index.d.ts:35:8:
      35 │   const BROWSER_MAP: Record<string, string>;
         ╵         ~~~~~~~~~~~

  'BROWSER_MAP' was also declared here.

    node_modules/bowser/index.d.ts:10:13:
      10 │ export const BROWSER_MAP: Record<string, string>;
         ╵              ~~~~~~~~~~~


✘ [ERROR] TS2451: Cannot redeclare block-scoped variable 'ENGINE_MAP'. [plugin angular-compiler]

    node_modules/bowser/index.d.ts:36:8:
      36 │   const ENGINE_MAP: Record<string, string>;
         ╵         ~~~~~~~~~~

  'ENGINE_MAP' was also declared here.

    node_modules/bowser/index.d.ts:11:13:
      11 │ export const ENGINE_MAP: Record<string, string>;
         ╵              ~~~~~~~~~~


✘ [ERROR] TS2451: Cannot redeclare block-scoped variable 'OS_MAP'. [plugin angular-compiler]

    node_modules/bowser/index.d.ts:37:8:
      37 │   const OS_MAP: Record<string, string>;
         ╵         ~~~~~~

  'OS_MAP' was also declared here.

    node_modules/bowser/index.d.ts:12:13:
      12 │ export const OS_MAP: Record<string, string>;
         ╵              ~~~~~~


✘ [ERROR] TS2451: Cannot redeclare block-scoped variable 'PLATFORMS_MAP'. [plugin angular-compiler]

    node_modules/bowser/index.d.ts:38:8:
      38 │   const PLATFORMS_MAP: Record<string, string>;
         ╵         ~~~~~~~~~~~~~

  'PLATFORMS_MAP' was also declared here.

    node_modules/bowser/index.d.ts:13:13:
      13 │ export const PLATFORMS_MAP: Record<string, string>;
         ╵              ~~~~~~~~~~~~~
```</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
<comment_new><author>@naorpeled</author><body>
Investigating this 🙏 </body></comment_new>
</comments>


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Fix invalid TypeScript definitions in bowser package Fix invalid TypeScript definitions causing TS2309 and TS2451 errors Nov 28, 2025
Copilot AI requested a review from naorpeled November 28, 2025 23:56
@naorpeled
Copy link
Collaborator

@copilot please revert package.json changes

Copy link
Contributor Author

Copilot AI commented Nov 29, 2025

@copilot please revert package.json changes

Reverted in 50faa20. Removed the TypeScript dev dependency that was added during testing.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.

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 this pull request may close these issues.

typescript definitions are invalid

2 participants