Skip to content

Commit f5b1413

Browse files
committed
minor #1987 chore(typescript): upgrade target from es2017 to es2021 (Kocal)
This PR was squashed before being merged into the 2.x branch. Discussion ---------- chore(typescript): upgrade target from es2017 to es2021 | Q | A | ------------- | --- | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Issues | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT <!-- Replace this notice by a description of your feature/bugfix. This will help reviewers and should be a good start for the documentation. Additionally (see https://symfony.com/releases): - Always add tests and ensure they pass. - For new features, provide some code snippets to help understand usage. - Features and deprecations must be submitted against branch main. - Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry - Never break backward compatibility (see https://symfony.com/bc). --> We are in 2024, but we still targets ES2017 which requires TypeScript to import some helper functions (to handle `const {a, ...b} = c` and private class methods), which then ship Microsoft license (cc #1937 (comment)). Since those `dist/` files are: - either handled by Symfony AssetMapper/ImportMap, which requires browsers to have `importmap` support (if a browser supports `importmap`, it supports rest operator and private class methods) - either handled by Symfony Webpack Encore, which can polyfill if necessary through Babel/core-js IMO we can configure an highest TypeScript target. We will have the following benefits: - no more Microsoft license - no more useless functions calls, so small performance improvments - lighter `dist` files WDYT? Commits ------- ca94369 chore(typescript): upgrade target from es2017 to es2021
2 parents 2b35ecb + ca94369 commit f5b1413

File tree

6 files changed

+28
-32
lines changed

6 files changed

+28
-32
lines changed

src/Autocomplete/assets/dist/controller.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ _default_1_instances = new WeakSet(), _default_1_getCommonConfig = function _def
256256
score: (search) => {
257257
const scoringFunction = this.tomSelect.getScoreFunction(search);
258258
return (item) => {
259-
return scoringFunction(Object.assign(Object.assign({}, item), { text: __classPrivateFieldGet(this, _default_1_instances, "m", _default_1_stripTags).call(this, item.text) }));
259+
return scoringFunction({ ...item, text: __classPrivateFieldGet(this, _default_1_instances, "m", _default_1_stripTags).call(this, item.text) });
260260
};
261261
},
262262
render: {
@@ -326,7 +326,7 @@ _default_1_instances = new WeakSet(), _default_1_getCommonConfig = function _def
326326
}, _default_1_stripTags = function _default_1_stripTags(string) {
327327
return string.replace(/(<([^>]+)>)/gi, '');
328328
}, _default_1_mergeObjects = function _default_1_mergeObjects(object1, object2) {
329-
return Object.assign(Object.assign({}, object1), object2);
329+
return { ...object1, ...object2 };
330330
}, _default_1_createTomSelect = function _default_1_createTomSelect(options) {
331331
const preConnectPayload = { options };
332332
this.dispatchEvent('pre-connect', preConnectPayload);

src/LiveComponent/assets/dist/live_controller.js

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -441,16 +441,16 @@ class ValueStore {
441441
return true;
442442
}
443443
getOriginalProps() {
444-
return Object.assign({}, this.props);
444+
return { ...this.props };
445445
}
446446
getDirtyProps() {
447-
return Object.assign({}, this.dirtyProps);
447+
return { ...this.dirtyProps };
448448
}
449449
getUpdatedPropsFromParent() {
450-
return Object.assign({}, this.updatedPropsFromParent);
450+
return { ...this.updatedPropsFromParent };
451451
}
452452
flushDirtyPropsToPending() {
453-
this.pendingProps = Object.assign({}, this.dirtyProps);
453+
this.pendingProps = { ...this.dirtyProps };
454454
this.dirtyProps = {};
455455
}
456456
reinitializeAllProps(props) {
@@ -459,7 +459,7 @@ class ValueStore {
459459
this.pendingProps = {};
460460
}
461461
pushPendingPropsBackToDirty() {
462-
this.dirtyProps = Object.assign(Object.assign({}, this.pendingProps), this.dirtyProps);
462+
this.dirtyProps = { ...this.pendingProps, ...this.dirtyProps };
463463
this.pendingProps = {};
464464
}
465465
storeNewPropsFromParent(props) {
@@ -1905,11 +1905,10 @@ class Component {
19051905
this.id = id;
19061906
this.listeners = new Map();
19071907
listeners.forEach((listener) => {
1908-
var _a;
19091908
if (!this.listeners.has(listener.event)) {
19101909
this.listeners.set(listener.event, []);
19111910
}
1912-
(_a = this.listeners.get(listener.event)) === null || _a === void 0 ? void 0 : _a.push(listener.action);
1911+
this.listeners.get(listener.event)?.push(listener.action);
19131912
});
19141913
this.valueStore = new ValueStore(props);
19151914
this.unsyncedInputsTracker = new UnsyncedInputsTracker(this, elementDriver);
@@ -2040,14 +2039,13 @@ class Component {
20402039
this.valueStore.flushDirtyPropsToPending();
20412040
this.isRequestPending = false;
20422041
this.backendRequest.promise.then(async (response) => {
2043-
var _a;
20442042
const backendResponse = new BackendResponse(response);
20452043
const html = await backendResponse.getBody();
20462044
for (const input of Object.values(this.pendingFiles)) {
20472045
input.value = '';
20482046
}
20492047
const headers = backendResponse.response.headers;
2050-
if (!((_a = headers.get('Content-Type')) === null || _a === void 0 ? void 0 : _a.includes('application/vnd.live-component+html')) && !headers.get('X-Live-Redirect')) {
2048+
if (!headers.get('Content-Type')?.includes('application/vnd.live-component+html') && !headers.get('X-Live-Redirect')) {
20512049
const controls = { displayError: true };
20522050
this.valueStore.pushPendingPropsBackToDirty();
20532051
this.hooks.triggerHook('response:error', backendResponse, controls);
@@ -2427,9 +2425,8 @@ class LoadingPlugin {
24272425
targetedModels.push(modifier.value);
24282426
});
24292427
directive.modifiers.forEach((modifier) => {
2430-
var _a;
24312428
if (validModifiers.has(modifier.name)) {
2432-
const callable = (_a = validModifiers.get(modifier.name)) !== null && _a !== void 0 ? _a : (() => { });
2429+
const callable = validModifiers.get(modifier.name) ?? (() => { });
24332430
callable(modifier);
24342431
return;
24352432
}
@@ -2764,7 +2761,7 @@ function toQueryString(data) {
27642761
}
27652762
else if (null !== iValue) {
27662763
if (typeof iValue === 'object') {
2767-
entries = Object.assign(Object.assign({}, entries), buildQueryStringEntries(iValue, entries, key));
2764+
entries = { ...entries, ...buildQueryStringEntries(iValue, entries, key) };
27682765
}
27692766
else {
27702767
entries[key] = encodeURIComponent(iValue)
@@ -2913,16 +2910,14 @@ class LazyPlugin {
29132910
this.intersectionObserver = null;
29142911
}
29152912
attachToComponent(component) {
2916-
var _a;
2917-
if ('lazy' !== ((_a = component.element.attributes.getNamedItem('loading')) === null || _a === void 0 ? void 0 : _a.value)) {
2913+
if ('lazy' !== component.element.attributes.getNamedItem('loading')?.value) {
29182914
return;
29192915
}
29202916
component.on('connect', () => {
29212917
this.getObserver().observe(component.element);
29222918
});
29232919
component.on('disconnect', () => {
2924-
var _a;
2925-
(_a = this.intersectionObserver) === null || _a === void 0 ? void 0 : _a.unobserve(component.element);
2920+
this.intersectionObserver?.unobserve(component.element);
29262921
});
29272922
}
29282923
getObserver() {
@@ -2976,7 +2971,7 @@ class LiveControllerDefault extends Controller {
29762971
throw new Error(`No action name provided on element: ${getElementAsTagText(event.currentTarget)}. Did you forget to add the "data-live-action-param" attribute?`);
29772972
}
29782973
const rawAction = params.action;
2979-
const actionArgs = Object.assign({}, params);
2974+
const actionArgs = { ...params };
29802975
delete actionArgs.action;
29812976
const directives = parseDirectives(rawAction);
29822977
let debounce = false;
@@ -3003,9 +2998,8 @@ class LiveControllerDefault extends Controller {
30032998
}
30042999
});
30053000
directive.modifiers.forEach((modifier) => {
3006-
var _a;
30073001
if (validModifiers.has(modifier.name)) {
3008-
const callable = (_a = validModifiers.get(modifier.name)) !== null && _a !== void 0 ? _a : (() => { });
3002+
const callable = validModifiers.get(modifier.name) ?? (() => { });
30093003
callable(modifier);
30103004
return;
30113005
}
@@ -3056,7 +3050,7 @@ class LiveControllerDefault extends Controller {
30563050
throw new Error(`No event name provided on element: ${getElementAsTagText(event.currentTarget)}. Did you forget to add the "data-live-event-param" attribute?`);
30573051
}
30583052
const eventInfo = params.event;
3059-
const eventArgs = Object.assign({}, params);
3053+
const eventArgs = { ...params };
30603054
delete eventArgs.event;
30613055
const directives = parseDirectives(eventInfo);
30623056
const emits = [];
@@ -3133,7 +3127,6 @@ class LiveControllerDefault extends Controller {
31333127
this.updateModelFromElementEvent(target, 'change');
31343128
}
31353129
updateModelFromElementEvent(element, eventName) {
3136-
var _a;
31373130
if (!elementBelongsToThisComponent(element, this.component)) {
31383131
return;
31393132
}
@@ -3142,7 +3135,7 @@ class LiveControllerDefault extends Controller {
31423135
}
31433136
if (element instanceof HTMLInputElement && element.type === 'file') {
31443137
const key = element.name;
3145-
if ((_a = element.files) === null || _a === void 0 ? void 0 : _a.length) {
3138+
if (element.files?.length) {
31463139
this.pendingFiles[key] = element;
31473140
}
31483141
else if (this.pendingFiles[key]) {

src/Svelte/assets/dist/render_controller.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ import { Controller } from '@hotwired/stimulus';
22

33
class default_1 extends Controller {
44
connect() {
5-
var _a, _b;
65
this.element.innerHTML = '';
7-
this.props = (_a = this.propsValue) !== null && _a !== void 0 ? _a : undefined;
8-
this.intro = (_b = this.introValue) !== null && _b !== void 0 ? _b : undefined;
6+
this.props = this.propsValue ?? undefined;
7+
this.intro = this.introValue ?? undefined;
98
this.dispatchEvent('connect');
109
const Component = window.resolveSvelteComponent(this.componentValue);
1110
this._destroyIfExists();
@@ -30,7 +29,12 @@ class default_1 extends Controller {
3029
}
3130
}
3231
dispatchEvent(name, payload = {}) {
33-
const detail = Object.assign({ componentName: this.componentValue, props: this.props, intro: this.intro }, payload);
32+
const detail = {
33+
componentName: this.componentValue,
34+
props: this.props,
35+
intro: this.intro,
36+
...payload,
37+
};
3438
this.dispatch(name, { detail, prefix: 'svelte' });
3539
}
3640
}

src/Translator/assets/dist/translator_controller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ function formatIntl(id, parameters = {}, locale) {
55
return '';
66
}
77
const intlMessage = new IntlMessageFormat(id, [locale.replace('_', '-')], undefined, { ignoreTag: true });
8-
parameters = Object.assign({}, parameters);
8+
parameters = { ...parameters };
99
Object.entries(parameters).forEach(([key, value]) => {
1010
if (key.includes('%') || key.includes('{')) {
1111
delete parameters[key];

src/Vue/assets/dist/render_controller.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ import { createApp } from 'vue';
33

44
class default_1 extends Controller {
55
connect() {
6-
var _a;
7-
this.props = (_a = this.propsValue) !== null && _a !== void 0 ? _a : null;
6+
this.props = this.propsValue ?? null;
87
this.dispatchEvent('connect', { componentName: this.componentValue, props: this.props });
98
const component = window.resolveVueComponent(this.componentValue);
109
this.app = createApp(component, this.props);

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"rootDir": "src",
88
"strict": true,
99
"strictPropertyInitialization": false,
10-
"target": "es2017",
10+
"target": "es2021",
1111
"removeComments": true,
1212
"outDir": "types",
1313
"baseUrl": ".",

0 commit comments

Comments
 (0)