Import types from seperate file without typescript generation export

So I am working on a project and want to import my types from a seperate file, but if I do that, typescript will generate this at the bottom of my js file. export {}; Is there any way to circumvent that without defining the types in the same file?
5 Replies
glutonium
glutonium5mo ago
whats the issue with export {};
RedCommander
RedCommanderOP5mo ago
SyntaxError: export declarations may only appear at top level of a module I am trying to write a browser extension. I guess I could remove it manually, but that would be really annoying when always recompiling while modifing the code
glutonium
glutonium5mo ago
idk too much about ts but i do have a ts project and here in the image u can see i am showing the ts and the js file . i am using this js file export some common enums and below in the js file u can see there are no export {} unlike yours
No description
glutonium
glutonium5mo ago
not sure why also since you r exporting file of types, is it nescessary to be compiled? if not just tell ts compiler to ignote the file ig
RedCommander
RedCommanderOP5mo ago
You have a different es compile version (its the object.defineProperty(exports [...])) and there is still an import at the top of my file :)
import { Webframe } from "../types/core/Webframe";

document.body.style.border = "5px solid green";

const frame: Webframe = XPCNativeWrapper.unwrap(window).webframe;
import { Webframe } from "../types/core/Webframe";

document.body.style.border = "5px solid green";

const frame: Webframe = XPCNativeWrapper.unwrap(window).webframe;
Ok, in my case it seems that setting the module type to 'preserve' seemed to do the trick
Want results from more Discord servers?
Add your server