Is it in someway possible to reuse a class name that is defined in the Global objects list found here? (Like Number, String)
Lets say that I want to have my own String class. I can define it, and use it like this:
String.js
export default class String {
}
App.js
import String from './String'
let string = new String();
This actually works, but then
- PHPStorm tells me: yeah you used a primitive object wrapper (thinking it's the global object String).
- Then ESLint tells me: Disallow Primitive Wrapper Instances (no-new-wrappers)
- And lastly SonarQube tells me: The use of wrapper objects for primitive types is gratuitous, confusing and dangerous. Simple literals should be used instead.
So yeah is there a way to encapsulate my class so it doesn't get confused with the global String class?
Stringand hopefully never run into the situation where you also need to use the global constructor (although you can always set up something likeinstruments.Stringinstead). It's not very helpful to keep referring to other languages when clearly it is possible what you want.