π Search Terms
- unique property
- incremental build
- interface declaration merging
π Version & Regression Information
- Tested with 6.0.2 and 6.0.3
β― Playground Link
Playground Link
π» Code
I do not have a minimal reproductible exemple as the issue seems to come from the incremental build.
I had a class with an unique symbol property, on which I was doing interface declaration merging:
const SYMBOL: unique symbol = Symbol();
class X {
protected attr = "ok";
readonly [SYMBOL] = "ok";
protected foo() {
// use it
this[SYMBOL];
}
}
type T<N extends string> = Record<`add${N}`, () => void>;
interface X extends T<"hoc"> {}
const x = {} as X;
x.addhoc
π Actual behavior
The following error first appeared when I set some of the public attributes as protected (the error below is edited to match the provided exemple) :
ERROR in [...]
TS7053: Element implicitly has an 'any' type because expression of type 'unique symbol' can't be used to index type 'X'.
Property '[????.SYMBOL]' does not exist on type 'X'.
92 |
93 | protected foo() {
> 94 | this[SYMBOL];
| ^^^^^^^^^^^^^^^^
95 | }
I noticed that :
- The error disappear if I delete all of TS cache files.
- The error reappear if I rebuild without any changes to the files.
- The error reappear if I edit the files that defines
X.
- The error does not reappear if I change other files.
- In watch mode, the error sometimes disappear and reappear when I change the files that defines
X.
- The error doesn't appear in my VSC editor.
π Expected behavior
No TS errors.
Additional information about the issue
I also reproduced the error with tsc --noEmit, so it doesn't seem to come from my Webpack build system.
π Search Terms
π Version & Regression Information
β― Playground Link
Playground Link
π» Code
I do not have a minimal reproductible exemple as the issue seems to come from the incremental build.
I had a class with an unique symbol property, on which I was doing interface declaration merging:
π Actual behavior
The following error first appeared when I set some of the public attributes as protected (the error below is edited to match the provided exemple) :
I noticed that :
X.X.π Expected behavior
No TS errors.
Additional information about the issue
I also reproduced the error with
tsc --noEmit, so it doesn't seem to come from my Webpack build system.