Closed mribbons closed 2 years ago
Identifier '_ßr' has already been declared
How is that even possible? It means there are multiple declarations in the same scope. Which build tool You use and what's the target, module?
I am hoping this is a known issue with a fix, but I will do my best if required.
Nope. I see this for the first time. There is an opposite issue that _ßr
is not declared after hot reloads in some build tools.
If You can create simple repro, it would be nice. 🙂
How is that even possible? It means there are multiple declarations in the same scope.
Actually your question raises an interesting point. Most of the files where the duplicates are being flagged don't import or require tst-reflect, in fact nothing in the shared package does at present. At one point when I was testing reflection to see it working within a single package, I saw the _Identifier 'ßr' has already been declared error, and it looked like an additional require had been inserted at line 0, while I had explicitly imported at line 2. Removing the comment on line 0 resolved the issue.
I have created a gist of the shared package tsconfig: https://gist.github.com/mribbons/3ad4731ba2b1ce81b5e05e0555c9c4c8
shared package build command:
tsc -p tsconfig.json --watch --preserveWatchOutput
backend package run command:
ts-node index.tsx
Repro won't appear for 18 hours or so ;)
The problem goes away when I run rimraf tsconfig.tsbuildinfo on the shared package.
I am using yarn workspaces, project structure is like this @megarepo/backend @megarepo/shared
backend imports from shared.
I have added the tst-reflect setup to both packages, and I'm using ts-patch.
My use case is reflecting the type names from shared when they are passed as generic arguments to calls in backend. Things seemed to be working OK, I can compile the shared project and use gettype(), however now it looks like require("tst-reflect") is being injected into all of the .js files in dist, the error below occurs when I try to run build backend:
Initially I was able to build and run both packages and reflect some type names, but I noticed generic type arguments didn't work so I omitted that code, and the next build failed. The line number referred to in the error doesn't contain _ßr = which may suggest an issue with the transformer.
There's a lot going on, so generating a repro may be a challenge, I am hoping this is a known issue with a fix, but I will do my best if required.