Skip to content

Commit 63c8809

Browse files
committed
bug #2562 [Map][Translator][Turbo] Ensure TypeScript code is valid (Kocal)
This PR was squashed before being merged into the 2.x branch. Discussion ---------- [Map][Translator][Turbo] Ensure TypeScript code is valid | Q | A | ------------- | --- | Bug fix? | yes | 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 This PR aims to fail the build (and the CI) when TypeScript code contain issues. I also fixed existing issues in Map, Translator, and Turbo code. Before: ``` Cleaning up the "/home/runner/work/ux/ux/src/Chartjs/assets/dist" directory... Building JavaScript files from `@symfony`/ux-chartjs package... Done in 3.175 seconds. Cleaning up the "/home/runner/work/ux/ux/src/Autocomplete/assets/dist" directory... Building JavaScript files from `@symfony`/ux-autocomplete package... Done in 3.179 seconds. Cleaning up the "/home/runner/work/ux/ux/src/Cropperjs/assets/dist" directory... Building JavaScript files from `@symfony`/ux-cropperjs package... Minifying CSS... Done in 2.377 seconds. Cleaning up the "/home/runner/work/ux/ux/src/Dropzone/assets/dist" directory... Building JavaScript files from `@symfony`/ux-dropzone package... Minifying CSS... Done in 2.434 seconds. Cleaning up the "/home/runner/work/ux/ux/src/LazyImage/assets/dist" directory... Building JavaScript files from `@symfony`/ux-lazy-image package... Done in 2.438 seconds. Cleaning up the "/home/runner/work/ux/ux/src/LiveComponent/assets/dist" directory... Building JavaScript files from `@symfony`/ux-live-component package... Minifying CSS... Done in 3.861 seconds. Cleaning up the "/home/runner/work/ux/ux/src/Map/assets/dist" directory... Building JavaScript files from `@symfony`/ux-map package... Done in 2.515 seconds. Cleaning up the "/home/runner/work/ux/ux/src/Map/src/Bridge/Google/assets/dist" directory... Building JavaScript files from `@symfony`/ux-google-map package... Done in 2.509 seconds. [plugin typescript] src/map_controller.ts (12:35): `@rollup`/plugin-typescript TS2307: Cannot find module '`@symfony`/ux-map' or its corresponding type declarations. [plugin typescript] src/map_controller.ts (19:8): `@rollup`/plugin-typescript TS2307: Cannot find module '`@symfony`/ux-map' or its corresponding type declarations. [plugin typescript] src/map_controller.ts (78:21): `@rollup`/plugin-typescript TS7053: Element implicitly has an 'any' type because expression of type 'Library' can't be used to index type 'typeof maps'. Property 'streetView' does not exist on type 'typeof maps'. [plugin typescript] src/map_controller.ts (80:55): `@rollup`/plugin-typescript TS2698: Spread types may only be created from object types. [plugin typescript] src/map_controller.ts (89:30): `@rollup`/plugin-typescript TS2339: Property 'hasCenterValue' does not exist on type 'default'. [plugin typescript] src/map_controller.ts (89:53): `@rollup`/plugin-typescript TS2339: Property 'centerValue' does not exist on type 'default'. [plugin typescript] src/map_controller.ts (90:37): `@rollup`/plugin-typescript TS2339: Property 'centerValue' does not exist on type 'default'. [plugin typescript] src/map_controller.ts (95:30): `@rollup`/plugin-typescript TS2339: Property 'hasZoomValue' does not exist on type 'default'. [plugin typescript] src/map_controller.ts (95:51): `@rollup`/plugin-typescript TS2339: Property 'zoomValue' does not exist on type 'default'. [plugin typescript] src/map_controller.ts (96:35): `@rollup`/plugin-typescript TS2339: Property 'zoomValue' does not exist on type 'default'. [plugin typescript] src/map_controller.ts (101:14): `@rollup`/plugin-typescript TS2339: Property 'dispatch' does not exist on type 'default'. [plugin typescript] src/map_controller.ts (125:42): `@rollup`/plugin-typescript TS2339: Property 'element' does not exist on type 'default'. [plugin typescript] src/map_controller.ts (148:18): `@rollup`/plugin-typescript TS2551: Property 'createInfoWindow' does not exist on type 'default'. Did you mean 'doCreateInfoWindow'? [plugin typescript] src/map_controller.ts (176:18): `@rollup`/plugin-typescript TS2551: Property 'createInfoWindow' does not exist on type 'default'. Did you mean 'doCreateInfoWindow'? [plugin typescript] src/map_controller.ts (204:18): `@rollup`/plugin-typescript TS2551: Property 'createInfoWindow' does not exist on type 'default'. Did you mean 'doCreateInfoWindow'? [plugin typescript] src/map_controller.ts (264:18): `@rollup`/plugin-typescript TS2339: Property 'markers' does not exist on type 'default'. [plugin typescript] src/map_controller.ts (269:14): `@rollup`/plugin-typescript TS2339: Property 'markers' does not exist on type 'default'. [plugin typescript] src/map_controller.ts (269:31): `@rollup`/plugin-typescript TS7006: Parameter 'marker' implicitly has an 'any' type. [plugin typescript] src/map_controller.ts (296:14): `@rollup`/plugin-typescript TS2339: Property 'infoWindows' does not exist on type 'default'. [plugin typescript] src/map_controller.ts (296:35): `@rollup`/plugin-typescript TS7006: Parameter 'otherInfoWindow' implicitly has an 'any' type. Cleaning up the "/home/runner/work/ux/ux/src/Map/src/Bridge/Leaflet/assets/dist" directory... Building JavaScript files from `@symfony`/ux-leaflet-map package... Done in 2.459 seconds. "leaflet/dist/leaflet.min.css" is imported by "src/map_controller.ts", but could not be resolved – treating it as an external dependency. Cleaning up the "/home/runner/work/ux/ux/src/Notify/assets/dist" directory... Building JavaScript files from `@symfony`/ux-notify package... Done in 2.381 seconds. Cleaning up the "/home/runner/work/ux/ux/src/React/assets/dist" directory... Building JavaScript files from `@symfony`/ux-react package... Done in 2.498 seconds. Cleaning up the "/home/runner/work/ux/ux/src/StimulusBundle/assets/dist" directory... Building JavaScript files from `@symfony`/stimulus-bundle package... Done in 2.444 seconds. Cleaning up the "/home/runner/work/ux/ux/src/Svelte/assets/dist" directory... Building JavaScript files from `@symfony`/ux-svelte package... Done in 2.453 seconds. Cleaning up the "/home/runner/work/ux/ux/src/Swup/assets/dist" directory... Building JavaScript files from `@symfony`/ux-swup package... Done in 2.254 seconds. Cleaning up the "/home/runner/work/ux/ux/src/TogglePassword/assets/dist" directory... Building JavaScript files from `@symfony`/ux-toggle-password package... Minifying CSS... Done in 2.489 seconds. Cleaning up the "/home/runner/work/ux/ux/src/Translator/assets/dist" directory... Building JavaScript files from `@symfony`/ux-translator package... Done in 2.351 seconds. [plugin typescript] src/formatters/intl-formatter.ts (26:5): `@rollup`/plugin-typescript TS2[32](https://github.com/symfony/ux/actions/runs/13231659169/job/36929714748#step:5:37)2: Type 'string | number | (string | number)[]' is not assignable to type 'string'. Type 'number' is not assignable to type 'string'. [plugin typescript] src/translator.ts (152:57): `@rollup`/plugin-typescript TS2[34](https://github.com/symfony/ux/actions/runs/13231659169/job/36929714748#step:5:39)5: Argument of type 'ParametersType' is not assignable to parameter of type 'Record<string, string | number>'. Type 'Record<string, string | number | Date>' is not assignable to type 'Record<string, string | number>'. 'string' index signatures are incompatible. Type 'string | number | Date' is not assignable to type 'string | number'. [plugin typescript] src/translator.ts (166:49): `@rollup`/plugin-typescript TS2345: Argument of type 'ParametersType' is not assignable to parameter of type 'Record<string, string | number>'. Type 'Record<string, string | number | Date>' is not assignable to type 'Record<string, string | number>'. Cleaning up the "/home/runner/work/ux/ux/src/Turbo/assets/dist" directory... Building JavaScript files from `@symfony`/ux-turbo package... Done in 2.2[49](https://github.com/symfony/ux/actions/runs/13231659169/job/36929714748#step:5:54) seconds. [plugin typescript] src/turbo_stream_controller.ts (11:61): `@rollup`/plugin-typescript TS7016: Could not find a declaration file for module '`@hotwired`/turbo'. '/home/runner/work/ux/ux/node_modules/`@hotwired`/turbo/dist/turbo.es2017-umd.js' implicitly has an 'any' type. Try `npm i --save-dev `@types`/hotwired__turbo` if it exists or add a new declaration (.d.ts) file containing `declare module '`@hotwired`/turbo';` Cleaning up the "/home/runner/work/ux/ux/src/Typed/assets/dist" directory... Building JavaScript files from `@symfony`/ux-typed package... Done in 2.228 seconds. Cleaning up the "/home/runner/work/ux/ux/src/Vue/assets/dist" directory... Building JavaScript files from `@symfony`/ux-vue package... Done in 1.970 seconds. Done in 30s 328ms ``` After: ``` Cleaning up the "/home/runner/work/symfony-ux/symfony-ux/src/Chartjs/assets/dist" directory... Building JavaScript files from `@symfony`/ux-chartjs package... Done in 2.830 seconds. Cleaning up the "/home/runner/work/symfony-ux/symfony-ux/src/Autocomplete/assets/dist" directory... Building JavaScript files from `@symfony`/ux-autocomplete package... Done in 2.967 seconds. Cleaning up the "/home/runner/work/symfony-ux/symfony-ux/src/Cropperjs/assets/dist" directory... Building JavaScript files from `@symfony`/ux-cropperjs package... Minifying CSS... Done in 2.[39](https://github.com/Kocal/symfony-ux/actions/runs/13252531380/job/36993303948?pr=2562#step:5:44)2 seconds. Cleaning up the "/home/runner/work/symfony-ux/symfony-ux/src/Dropzone/assets/dist" directory... Building JavaScript files from `@symfony`/ux-dropzone package... Minifying CSS... Done in 2.[42](https://github.com/Kocal/symfony-ux/actions/runs/13252531380/job/36993303948?pr=2562#step:5:47)8 seconds. Cleaning up the "/home/runner/work/symfony-ux/symfony-ux/src/LazyImage/assets/dist" directory... Building JavaScript files from `@symfony`/ux-lazy-image package... Done in 2.472 seconds. Cleaning up the "/home/runner/work/symfony-ux/symfony-ux/src/LiveComponent/assets/dist" directory... Building JavaScript files from `@symfony`/ux-live-component package... Minifying CSS... Done in 3.855 seconds. Cleaning up the "/home/runner/work/symfony-ux/symfony-ux/src/Map/assets/dist" directory... Building JavaScript files from `@symfony`/ux-map package... Done in 2.[47](https://github.com/Kocal/symfony-ux/actions/runs/13252531380/job/36993303948?pr=2562#step:5:52)1 seconds. Cleaning up the "/home/runner/work/symfony-ux/symfony-ux/src/Notify/assets/dist" directory... Building JavaScript files from `@symfony`/ux-notify package... Done in 2.392 seconds. Cleaning up the "/home/runner/work/symfony-ux/symfony-ux/src/React/assets/dist" directory... Building JavaScript files from `@symfony`/ux-react package... Done in 2.597 seconds. Cleaning up the "/home/runner/work/symfony-ux/symfony-ux/src/StimulusBundle/assets/dist" directory... Building JavaScript files from `@symfony`/stimulus-bundle package... Done in 2.[48](https://github.com/Kocal/symfony-ux/actions/runs/13252531380/job/36993303948?pr=2562#step:5:53)4 seconds. Cleaning up the "/home/runner/work/symfony-ux/symfony-ux/src/Svelte/assets/dist" directory... Building JavaScript files from `@symfony`/ux-svelte package... Done in 2.470 seconds. Cleaning up the "/home/runner/work/symfony-ux/symfony-ux/src/Swup/assets/dist" directory... Building JavaScript files from `@symfony`/ux-swup package... Done in 2.264 seconds. Cleaning up the "/home/runner/work/symfony-ux/symfony-ux/src/TogglePassword/assets/dist" directory... Building JavaScript files from `@symfony`/ux-toggle-password package... Minifying CSS... Done in 2.[57](https://github.com/Kocal/symfony-ux/actions/runs/13252531380/job/36993303948?pr=2562#step:5:62)2 seconds. Cleaning up the "/home/runner/work/symfony-ux/symfony-ux/src/Translator/assets/dist" directory... Building JavaScript files from `@symfony`/ux-translator package... Done in 2.[58](https://github.com/Kocal/symfony-ux/actions/runs/13252531380/job/36993303948?pr=2562#step:5:63)1 seconds. Cleaning up the "/home/runner/work/symfony-ux/symfony-ux/src/Turbo/assets/dist" directory... Building JavaScript files from `@symfony`/ux-turbo package... Done in 2.296 seconds. Cleaning up the "/home/runner/work/symfony-ux/symfony-ux/src/Typed/assets/dist" directory... Building JavaScript files from `@symfony`/ux-typed package... Done in 2.273 seconds. Cleaning up the "/home/runner/work/symfony-ux/symfony-ux/src/Vue/assets/dist" directory... Building JavaScript files from `@symfony`/ux-vue package... Done in 2.083 seconds. Cleaning up the "/home/runner/work/symfony-ux/symfony-ux/src/Map/src/Bridge/Google/assets/dist" directory... Building JavaScript files from `@symfony`/ux-google-map package... Done in 2.579 seconds. Cleaning up the "/home/runner/work/symfony-ux/symfony-ux/src/Map/src/Bridge/Leaflet/assets/dist" directory... Building JavaScript files from `@symfony`/ux-leaflet-map package... Done in 2.742 seconds. "leaflet/dist/leaflet.min.css" is imported by "src/map_controller.ts", but could not be resolved – treating it as an external dependency. Done in 30s [68](https://github.com/Kocal/symfony-ux/actions/runs/13252531380/job/36993303948?pr=2562#step:5:73)6ms ``` Commits ------- ddbabd6 [Map] Fix TypeScript errors 975628b [Translator] Fix types definition, allow `Date` as parameter type 07b5078 Stop packages build when TypeScript code is invalid 795f2ad [Turbo] Install missing ``@hotwired`/turbo` definition types 863ba8c Fix ``@symfony`/ux-*-map` dev dependency, use `--topological-dev` to ensure `build` and `test` scripts respect workspaces topoligy
2 parents 3e99eb2 + ddbabd6 commit 63c8809

File tree

14 files changed

+34
-12
lines changed

14 files changed

+34
-12
lines changed

bin/rollup.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ function getRollupConfiguration({ packageRoot, inputFiles }) {
108108
typescript({
109109
filterRoot: '.',
110110
tsconfig: path.join(__dirname, '..', 'tsconfig.json'),
111+
noEmitOnError: true,
111112
include: [
112113
'src/**/*.ts',
113114
// TODO: Remove for the next major release

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"src/*/src/Bridge/*/assets"
77
],
88
"scripts": {
9-
"build": "yarn workspaces foreach -Apt run build",
10-
"test": "yarn workspaces foreach -Apt run test",
9+
"build": "yarn workspaces foreach -Ap --topological-dev run build",
10+
"test": "yarn workspaces foreach -Ap --topological-dev run test",
1111
"check": "biome check",
1212
"ci": "biome ci"
1313
},

src/Map/src/Bridge/Google/assets/dist/map_controller.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ class map_controller extends default_1 {
113113
libraries = ['core', ...libraries.filter((library) => library !== 'core')];
114114
const librariesImplementations = await Promise.all(libraries.map((library) => loader.importLibrary(library)));
115115
librariesImplementations.map((libraryImplementation, index) => {
116+
if (typeof libraryImplementation !== 'object' || libraryImplementation === null) {
117+
return;
118+
}
116119
const library = libraries[index];
117120
if (['marker', 'places', 'geometry', 'journeySharing', 'drawing', 'visualization'].includes(library)) {
118121
_google.maps[library] = libraryImplementation;

src/Map/src/Bridge/Google/assets/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"devDependencies": {
4141
"@googlemaps/js-api-loader": "^1.16.6",
4242
"@hotwired/stimulus": "^3.0.0",
43+
"@symfony/ux-map": "workspace:*",
4344
"@types/google.maps": "^3.55.9"
4445
}
4546
}

src/Map/src/Bridge/Google/assets/src/map_controller.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,16 @@ export default class extends AbstractMapController<
7171
libraries.map((library) => loader.importLibrary(library))
7272
);
7373
librariesImplementations.map((libraryImplementation, index) => {
74+
if (typeof libraryImplementation !== 'object' || libraryImplementation === null) {
75+
return;
76+
}
77+
7478
const library = libraries[index];
7579

7680
// The following libraries are in a sub-namespace
7781
if (['marker', 'places', 'geometry', 'journeySharing', 'drawing', 'visualization'].includes(library)) {
78-
_google.maps[library] = libraryImplementation;
82+
// @ts-ignore
83+
_google.maps[library] = libraryImplementation as any;
7984
} else {
8085
_google.maps = { ..._google.maps, ...libraryImplementation };
8186
}

src/Map/src/Bridge/Leaflet/assets/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
},
4040
"devDependencies": {
4141
"@hotwired/stimulus": "^3.0.0",
42+
"@symfony/ux-map": "workspace:*",
4243
"@types/leaflet": "^1.9.12",
4344
"leaflet": "^1.9.4"
4445
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export declare function format(id: string, parameters: Record<string, string | number>, locale: string): string;
1+
export declare function format(id: string, parameters: Record<string, string | number | Date>, locale: string): string;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export declare function formatIntl(id: string, parameters: Record<string, string | number>, locale: string): string;
1+
export declare function formatIntl(id: string, parameters: Record<string, string | number | Date>, locale: string): string;

src/Translator/assets/dist/utils.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export declare function strtr(string: string, replacePairs: Record<string, string | number>): string;
1+
export declare function strtr(string: string, replacePairs: Record<string, string | number | Date>): string;

src/Translator/assets/src/formatters/formatter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ import { strtr } from '../utils';
4747
* @param parameters An array of parameters for the message
4848
* @param locale The locale
4949
*/
50-
export function format(id: string, parameters: Record<string, string | number>, locale: string): string {
50+
export function format(id: string, parameters: Record<string, string | number | Date>, locale: string): string {
5151
if (null === id || '' === id) {
5252
return '';
5353
}

0 commit comments

Comments
 (0)