-
-
Notifications
You must be signed in to change notification settings - Fork 218
Closed
Labels
questionA user questionA user question
Description
Describe the bug
If you use a const enum
in the <script>
tag it will still generate a runtime object.
To Reproduce
- use official template and run the official script for TS support
- disable
terser
rollup plugin (to have readable output). Also, even though the default state ofpreserveConstEnums
isfalse
, you can set it just to be sure. - replace
App.svelte
contents with this:
<script lang='ts'>
const enum State {
opened,
closed,
}
let state = State.opened;
// We add this so it is not moved into module context
state++
</script>
- run
npm build
or just look into IDE tab with the pre-built version of the component. It will look like this:
/* generated by Svelte v3.29.7 */
import { SvelteComponent, init, safe_not_equal } from "svelte/internal";
function instance($$self) {
var State;
(function (State) {
State[State["opened"] = 0] = "opened";
State[State["closed"] = 1] = "closed";
})(State || (State = {}));
let state = State.opened;
// We add this so it is not moved into module context
state++;
return [];
}
class Component extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance, null, safe_not_equal, {});
}
}
export default Component;
Expected behavior
Should be built into something like this:
/* generated by Svelte v3.29.7 */
import { SvelteComponent, init, safe_not_equal } from "svelte/internal";
function instance($$self) {
let state = 0;
// We add this so it is not moved into module context
state++;
return [];
}
class Component extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance, null, safe_not_equal, {});
}
}
export default Component;
Metadata
Metadata
Assignees
Labels
questionA user questionA user question