Skip to content

Commit ce9e00c

Browse files
bug #735 Fix TypeScript warnings (bocharsky-bw, weaverryan)
This PR was merged into the 2.x branch. Discussion ---------- Fix TypeScript warnings | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Tickets | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT If you run `yarn build` there are quite a few TS warnings. This happened because we originally didn't use TypeScript, so when we switched, a lot of "types" were missing. I'm not sure how to fix the last one remaining here: ``` src/Notify/assets/src/controller.ts → src/Notify/assets/dist/controller.js... (!) Plugin typescript: `@rollup`/plugin-typescript TS2769: No overload matches this call. Overload 1 of 3, '(type: "message", listener: (this: EventSource, ev: MessageEvent<any>) => any, options?: boolean | EventListenerOptions | undefined): void', gave the following error. Argument of type '(content: string | undefined) => void' is not assignable to parameter of type '(this: EventSource, ev: MessageEvent<any>) => any'. Types of parameters 'content' and 'ev' are incompatible. Type 'MessageEvent<any>' is not assignable to type 'string'. Overload 2 of 3, '(type: string, listener: (this: EventSource, event: MessageEvent<any>) => any, options?: boolean | EventListenerOptions | undefined): void', gave the following error. Argument of type '(content: string | undefined) => void' is not assignable to parameter of type '(this: EventSource, event: MessageEvent<any>) => any'. Types of parameters 'content' and 'event' are incompatible. Type 'MessageEvent<any>' is not assignable to type 'string'. Overload 3 of 3, '(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions | undefined): void', gave the following error. Argument of type '(content: string | undefined) => void' is not assignable to parameter of type 'EventListenerOrEventListenerObject'. Type '(content: string | undefined) => void' is not assignable to type 'EventListener'. Types of parameters 'content' and 'evt' are incompatible. Type 'Event' is not assignable to type 'string'. src/Notify/assets/src/controller.ts: (61:56) 61 eventSource.removeEventListener('message', this._notify); ~~~~~~~~~~~~ created src/Notify/assets/dist/controller.js in 926ms ``` If anyone has ideas how to fix - please, share :) Depreciations like "(!) Plugin commonjs: The namedExports option from "`@rollup`/plugin-commonjs" is deprecated. Named exports are now handled automatically." were fixed in symfony/ux#734 Commits ------- 5c585f22 [Notify] Fixing bug where disconnecting was not precisely disconnecting the correct thing 50ecc6f6 Fix TypeScript warnings
2 parents de91b6e + e241935 commit ce9e00c

File tree

10 files changed

+489
-440
lines changed

10 files changed

+489
-440
lines changed

.github/workflows/test.yaml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ jobs:
1515
run: ./vendor/bin/php-cs-fixer fix --dry-run --diff
1616

1717
coding-style-js:
18+
name: JavaScript Coding Style
1819
runs-on: ubuntu-latest
1920
steps:
2021
- uses: actions/checkout@master
@@ -33,6 +34,7 @@ jobs:
3334
- run: yarn check-format
3435

3536
js-dist-current:
37+
name: Check for UnBuilt JS Dist Files
3638
runs-on: ubuntu-latest
3739
steps:
3840
- uses: actions/checkout@master
@@ -49,12 +51,18 @@ jobs:
4951
- run: yarn && yarn build
5052
- name: Check if js dist files are current
5153
id: changes
52-
uses: UnicornGlobal/[email protected]
54+
run: |
55+
echo "STATUS=$(git status --porcelain)" >> $GITHUB_OUTPUT
5356
54-
- name: Ensure no changes
55-
if: steps.changes.outputs.changed == 1
57+
- name: No changes found
58+
if: steps.changes.outputs.STATUS == ''
59+
run: |
60+
echo "git status is clean"
61+
- name: Changes were found
62+
if: steps.changes.outputs.STATUS != ''
5663
run: |
5764
echo "JS dist files need to be rebuilt"
65+
echo "${{ steps.changes.outputs.STATUS }}"
5866
exit 1
5967
6068
tests-php-low-deps:

src/Autocomplete/assets/dist/controller.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
import { Controller } from '@hotwired/stimulus';
22
import TomSelect from 'tom-select';
33

4-
/******************************************************************************
5-
Copyright (c) Microsoft Corporation.
6-
7-
Permission to use, copy, modify, and/or distribute this software for any
8-
purpose with or without fee is hereby granted.
9-
10-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
11-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
12-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
13-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
14-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
15-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16-
PERFORMANCE OF THIS SOFTWARE.
17-
***************************************************************************** */
18-
19-
function __classPrivateFieldGet(receiver, state, kind, f) {
20-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
21-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
22-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
4+
/******************************************************************************
5+
Copyright (c) Microsoft Corporation.
6+
7+
Permission to use, copy, modify, and/or distribute this software for any
8+
purpose with or without fee is hereby granted.
9+
10+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
11+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
12+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
13+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
14+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
15+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16+
PERFORMANCE OF THIS SOFTWARE.
17+
***************************************************************************** */
18+
19+
function __classPrivateFieldGet(receiver, state, kind, f) {
20+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
21+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
22+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
2323
}
2424

2525
var _default_1_instances, _default_1_getCommonConfig, _default_1_createAutocomplete, _default_1_createAutocompleteWithHtmlContents, _default_1_createAutocompleteWithRemoteData, _default_1_stripTags, _default_1_mergeObjects, _default_1_createTomSelect;
@@ -193,7 +193,7 @@ class default_1 extends Controller {
193193
this.resetTomSelect();
194194
}
195195
if (changeDisabledState) {
196-
this.changeTomSelectDisabledState((this.formElement.disabled));
196+
this.changeTomSelectDisabledState(this.formElement.disabled);
197197
}
198198
if (changePlaceholder) {
199199
this.updateTomSelectPlaceholder();

src/Chartjs/assets/dist/controller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class default_1 extends Controller {
3030
const parentElement = this.element.parentElement;
3131
if (parentElement && this.chart.options.responsive) {
3232
const originalWidth = parentElement.style.width;
33-
parentElement.style.width = (parentElement.offsetWidth + 1) + 'px';
33+
parentElement.style.width = parentElement.offsetWidth + 1 + 'px';
3434
setTimeout(() => {
3535
parentElement.style.width = originalWidth;
3636
}, 0);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import Component from './Component';
2+
declare class ComponentRegistry {
3+
private components;
4+
registerComponent(element: HTMLElement, definition: Component): void;
5+
unregisterComponent(element: HTMLElement): void;
6+
getComponent(element: HTMLElement): Promise<Component>;
7+
}
8+
declare const _default: ComponentRegistry;
9+
export default _default;

0 commit comments

Comments
 (0)