Skip to content

Commit

Permalink
chore(js): stricter types
Browse files Browse the repository at this point in the history
  • Loading branch information
tchak committed Feb 18, 2025
1 parent 7f6dd52 commit 00b2197
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@ import { useMapLibre, ReactControl } from '../../shared/maplibre/MapLibre';
import {
useEvent,
useMapEvent,
EventHandler
type EventHandler
} from '../../shared/maplibre/hooks';
import {
filterFeatureCollection,
findFeature
} from '../../shared/maplibre/utils';

import { SOURCE_CADASTRE, CreateFeatures, DeleteFeatures } from '../hooks';
import {
SOURCE_CADASTRE,
type CreateFeatures,
type DeleteFeatures
} from '../hooks';

export function CadastreLayer({
featureCollection,
Expand Down
6 changes: 3 additions & 3 deletions app/javascript/components/MapEditor/components/DrawLayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import {
} from '../../shared/maplibre/utils';
import {
SOURCE_SELECTION_UTILISATEUR,
CreateFeatures,
UpdateFatures,
DeleteFeatures
type CreateFeatures,
type UpdateFatures,
type DeleteFeatures
} from '../hooks';

export function DrawLayer({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { useState, useCallback, MouseEvent, ChangeEvent } from 'react';
import {
useState,
useCallback,
type MouseEvent,
type ChangeEvent
} from 'react';
import type { FeatureCollection } from 'geojson';
import invariant from 'tiny-invariant';

import { readGeoFile } from '../readGeoFile';
import { generateId } from '../../shared/maplibre/utils';
import { CreateFeatures, DeleteFeatures } from '../hooks';
import type { CreateFeatures, DeleteFeatures } from '../hooks';

export function ImportFileInput({
featureCollection,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { useCallback, useEffect, useMemo } from 'react';
import { Popup, LngLatBoundsLike, LngLatLike } from 'maplibre-gl';
import { Popup, type LngLatBoundsLike, type LngLatLike } from 'maplibre-gl';
import type { Feature, FeatureCollection, Point } from 'geojson';

import { useMapLibre } from '../../shared/maplibre/MapLibre';
import {
useFitBounds,
useEvent,
EventHandler,
type EventHandler,
useMapEvent,
useFlyTo
} from '../../shared/maplibre/hooks';
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/components/react-aria/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { matchSorter, MatchSorterOptions } from 'match-sorter';
import { matchSorter, type MatchSorterOptions } from 'match-sorter';
import type { Key } from 'react';
import { useEffect, useMemo, useRef, useState } from 'react';
import type {
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/components/shared/maplibre/MapLibre.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
useRef,
useEffect,
useMemo,
ReactNode,
type ReactNode,
createContext,
useCallback
} from 'react';
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/components/shared/maplibre/StyleControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { MapIcon } from '@heroicons/react/outline';
import { Slider } from '@reach/slider';
import '@reach/slider/styles.css';

import { LayersMap, NBS } from './styles';
import { type LayersMap, NBS } from './styles';

const STYLES = {
ortho: 'Satellite',
Expand Down
20 changes: 10 additions & 10 deletions app/javascript/components/shared/maplibre/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import type { Feature, Geometry } from 'geojson';
import type {
LngLat,
LngLatBoundsLike,
LngLatLike,
MapLayerEventType,
StyleSpecification
} from 'maplibre-gl';
import {
useCallback,
useEffect,
useState,
useMemo,
useState,
type RefObject
} from 'react';
import type {
LngLatBoundsLike,
LngLat,
MapLayerEventType,
StyleSpecification,
LngLatLike
} from 'maplibre-gl';
import type { Feature, Geometry } from 'geojson';

import { getMapStyle, getLayerName, LayersMap } from './styles';
import { useMapLibre } from './MapLibre';
import { getLayerName, getMapStyle, type LayersMap } from './styles';

export function useFitBounds() {
const map = useMapLibre();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export class CheckboxSelectAll extends ApplicationController {
declare readonly checkboxTargets: HTMLInputElement[];
declare readonly checkboxAllTarget: HTMLInputElement;

static targets: string[] = ['checkboxAll', 'checkbox'];
static targets = ['checkboxAll', 'checkbox'];

initialize() {
this.toggle = this.toggle.bind(this);
Expand Down
16 changes: 8 additions & 8 deletions app/javascript/controllers/email_france_connect_controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ export class EmailFranceConnectController extends ApplicationController {
'form'
];

emailFieldTarget!: HTMLElement;
useFranceConnectEmailTargets!: HTMLInputElement[];
submitTarget!: HTMLButtonElement;
emailInputTarget!: HTMLInputElement;
formTarget!: HTMLFormElement;

fcEmailPathValue!: string;
customEmailPathValue!: string;
declare readonly emailFieldTarget: HTMLElement;
declare readonly useFranceConnectEmailTargets: HTMLInputElement[];
declare readonly submitTarget: HTMLButtonElement;
declare readonly emailInputTarget: HTMLInputElement;
declare readonly formTarget: HTMLFormElement;

declare readonly fcEmailPathValue: string;
declare readonly customEmailPathValue: string;

static values = {
fcEmailPath: String,
Expand Down
10 changes: 5 additions & 5 deletions app/javascript/controllers/lazy/lightbox_controller.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { ApplicationController } from '../application_controller';
import lightGallery from 'lightgallery';
import { LightGallery } from 'lightgallery/lightgallery';
import 'lightgallery/css/lightgallery-bundle.css';
import type { LightGallery } from 'lightgallery/lightgallery';
import lgHash from 'lightgallery/plugins/hash';
import lgRotate from 'lightgallery/plugins/rotate';
import lgThumbnail from 'lightgallery/plugins/thumbnail';
import lgZoom from 'lightgallery/plugins/zoom';
import lgRotate from 'lightgallery/plugins/rotate';
import lgHash from 'lightgallery/plugins/hash';
import 'lightgallery/css/lightgallery-bundle.css';
import { ApplicationController } from '../application_controller';

export default class extends ApplicationController {
lightGallery?: LightGallery;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { matchInputElement } from '@coldwired/utils';
import { ActionEvent } from '@hotwired/stimulus';
import type { ActionEvent } from '@hotwired/stimulus';
import { getConfig, httpRequest } from '@utils';

import { AutoUpload } from '../shared/activestorage/auto-upload';
Expand Down
12 changes: 8 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
{
"include": ["app/javascript/**/*.ts", "app/javascript/**/*.tsx"],
"compilerOptions": {
"lib": ["DOM", "DOM.Iterable", "ES2019"],
"target": "ES2019",
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "node",
"module": "es2020",
"moduleDetection": "force",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"jsx": "react-jsx",
"esModuleInterop": true,
"experimentalDecorators": true,
"isolatedModules": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"types": ["vite/client"],
"paths": {
"~/*": ["./app/javascript/*"],
Expand Down

0 comments on commit 00b2197

Please sign in to comment.