room-js / chrome-extension-ts-starter

Chrome Extension starter built with TypeScript
https://www.youtube.com/watch?v=01vp9cYbQus
MIT License
87 stars 27 forks source link

Cannot redeclare block-scoped variable 'myinput'. #20

Open DenisTimofijuk opened 2 years ago

DenisTimofijuk commented 2 years ago

I am writing everything with vanilla JS. Somehow I am not allowed to have same variable names declared on a content and popup files. Those are independent separate files, why TS is looking in to them as a block-scope?

yurist38 commented 2 years ago

Hmmm, this looks very strange indeed. What you're describing is impossible, from what I know. I think there is something else to take into consideration. Can you please share a bit more details and maybe some screenshots?

DenisTimofijuk commented 2 years ago

I published it in to github. Please check all details here: chrome-extension-test. Error is coming from popup -> index.ts and content-> index.ts. Thei all has same myinput declared and this is causing an error for type script ts error .

yurist38 commented 2 years ago

I've managed to reproduce it here, confirming the bug. This is something related to the TS configuration I believe, don't know how to fix it so far. As a hotfix, you can follow advice from here https://stackoverflow.com/questions/35758584/cannot-redeclare-block-scoped-variable-typescript and add export {} to the file, that works. But I think there must be a better solution...

DenisTimofijuk commented 2 years ago

Thank you for looking in to this. adding empty export works for me.

yurist38 commented 2 years ago

Great! Let's keep this issue open as a reminder, maybe I'll find a better solution later on.