ts-morph
ts-morph copied to clipboard
Duplicate method declarations exists in the emitted .d.ts file of this JS file
Describe the bug
Version: 14.0.0
duplicate code exists in the .d.ts declaration file generated by ts-morph from .js file.
To Reproduce
// .js
export default {
methods: {
handleScroll() {}
}
};
// .d.ts
// handleScroll is duplicate
declare namespace _default {
namespace methods {
function handleScroll(): void;
function handleScroll(): void;
}
}
export default _default;
Expected behavior no duplicate code
@likuner could you fill in this part of the issue template to show how you reproduced the problem?
import { Project } from "ts-morph";
const project = new Project();
const sourceFile = project.createSourceFile("test.js", `export default {
methods: {
handleScroll() {}
}
};`);
// reproduce the problem here
@likuner could you fill in this part of the issue template to show how you reproduced the problem?
import { Project } from "ts-morph"; const project = new Project(); const sourceFile = project.createSourceFile("test.js", `export default { methods: { handleScroll() {} } };`); // reproduce the problem here
// reproduce the problem here
const { Project } = require("ts-morph");
const project = new Project({
compilerOptions: {
declaration: true,
emitDeclarationOnly: true,
noEmitOnError: true,
allowJs: true,
outDir: 'comp_types'
},
skipAddingFilesFromTsConfig: true
})
const sourceFile = project.createSourceFile("test.js", `export default {
methods: {
handleScroll() {}
}
};`);
project.emit();
Thanks! I can reproduce it. Most likely it is a bug in the ts compiler.
Thanks! I can reproduce it. Most likely it is a bug in the ts compiler.
OK, please let me know after the problem is solved, I need it urgently, Thanks!
@likuner well I won't be able to fix it because I don't have time and it's a bug with the TypeScript compiler. If you need this fixed then you can look into fixing this bug I opened in TS's repo: https://github.com/microsoft/TypeScript/issues/49200
I think this one is fixed now.