-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Name collision with globals in files named Object.svelte, Error.svelte, console.svelte… #2947
Comments
Looks like you run into the same problem with some other globals, e.g. |
Related issue: #2612. I think it's a reasonable solution to make Svelte avoid these well-known globals when automatically choosing a component name from the filename, but to say that you're on your own if you explicitly choose one for the component name. |
Is it acceptable if the name of the component is changed? One possibility to avoid that could be to export these globals from |
That might work, I haven't thought all the way through what would happen exactly. Running this code in Node: 'use strict';
const Map = 42;
console.log(global.Map); does display I think the only things that would need updating are places where we introduce a new dependency on a global variable in the generated code. There is already a nice mechanism in place in the code generation for importing things from
|
Since the only contract we have on the API is:
I think it'd make more sense to just mangle names that conflict with globals, or even just always add Use-cases that depend on a component having a specific class name should really define Am I missing a common pattern where |
There are other situations besides the component name colliding with a useful global that could cause issues. For example, in the keyed each example, if you add something like |
I don't know why typescript doesn't think that |
Closed by #2963 |
A component file named
Object.svelte
, causes name collisions with the globalObject
.Repro: https://svelte.dev/repl/dc1ccb7cbd8f47df8aa4ea4f3f318a0d?version=3.4.4
This wouldn't be unexpected if users explicitly named components, but when they are named by the compiler based on the file name you'd expect it to deal with this.
The text was updated successfully, but these errors were encountered: