Skip to content

Duplicate method declarations in generated declaration file for JS file #49200

@dsherret

Description

@dsherret

Bug Report

TypeScript is producing duplicate methods in the generated declaration file of a JavaScript file.

🔎 Search Terms

emit allowJs duplicate methods

🕗 Version & Regression Information

Tried it in two:

  • 4.8.0-dev.20220521
  • 4.5.5

💻 Code

main.js (not .ts... works fine in .ts):

export default {
  methods: {
      handleScroll() {}
  }
};

tsconfig.json:

{
  "compilerOptions": {
    "target": "es2016",
    "declaration": true,
    "emitDeclarationOnly": true,
    "allowJs": true,
    "module": "commonjs",
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "strict": true,
    "skipLibCheck": true
  }
}

🙁 Actual behavior

main.d.ts:

declare namespace _default {
    namespace methods {
        function handleScroll(): void;
        function handleScroll(): void;
    }
}
export default _default;

🙂 Expected behavior

declare namespace _default {
    namespace methods {
        function handleScroll(): void;
    }
}
export default _default;

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: Declaration EmitThe issue relates to the emission of d.ts filesHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions