You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is the behavior in every version I tried, and I reviewed the FAQ for entries about Common "Bugs" That Aren't Bugs
⏯ Playground Link
No response
💻 Code
// @filename: interface.tsexportconstsomeUniqueSymbol=Symbol.for("some-unique-symbol");exportinterfaceISomeInterface{[someUniqueSymbol]: string;}// @filename: class.tsimport{someUniqueSymbol,ISomeInterface}from"./interface";exportclassSomeClassimplementsISomeInterface{[someUniqueSymbol]="some-value";}// @filename: mixin.tsimport{SomeClass}from"./class";typeConstructor<T>=abstractnew(...args: any[])=>T;// An error occurs here:// Return type of exported function has or is using name 'someUniqueSymbol'// from external module "file:///class" but cannot be named.(4058)exportfunctionSomeMixin<TextendsConstructor<SomeClass>>(base: T){abstractclassSomeMixinextendsbase{}returnSomeMixin;}
The compiler emits an error at the definition of function SomeMixin(), saying:
Return type of exported function has or is using name 'someUniqueSymbol'
from external module "file:///class" but cannot be named.(4058)
The problem disappears if you change the definition of someUniqueSymbol to:
exportconstsomeUniqueSymbol="some-string";
I believe this is wrong for 3 reasons:
There should be no reason why the type of someUniqueSymbol cannot be named because it's exported by interface.ts.
The message is wrong. It's from interface.ts but not class.ts.
The function SomeMixin() does not mention someUniqueSymbol, or anything from interface.ts at all, so it would be wrong to emit the error at the definition site of the said function.
🙂 Expected behavior
Compiles with no errors.
Additional information about the issue
This is similar to #37888 but I'm not sure if it's the same issue.
The text was updated successfully, but these errors were encountered:
🔎 Search Terms
"unique symbol", "interface", "computed property", "mixin", "TS4058"
🕗 Version & Regression Information
⏯ Playground Link
No response
💻 Code
Workbench Repro
🙁 Actual behavior
The compiler emits an error at the definition of
function SomeMixin()
, saying:The problem disappears if you change the definition of
someUniqueSymbol
to:I believe this is wrong for 3 reasons:
someUniqueSymbol
cannot be named because it's exported byinterface.ts
.interface.ts
but notclass.ts
.SomeMixin()
does not mentionsomeUniqueSymbol
, or anything frominterface.ts
at all, so it would be wrong to emit the error at the definition site of the said function.🙂 Expected behavior
Compiles with no errors.
Additional information about the issue
This is similar to #37888 but I'm not sure if it's the same issue.
The text was updated successfully, but these errors were encountered: