Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: upgrade typescript to 5.4.5 across app #7305

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
d69da27
feat: upgrade react and chakra-ui
karrui Apr 26, 2024
dd1cab3
fix: breaking changes from Chakra v2
karrui Apr 26, 2024
b186bef
fix: use React 18
karrui Apr 26, 2024
e07ccc5
feat: update framer-motion, MotionBox instantiation
karrui Apr 26, 2024
1f15fb9
feat: update changed React.FC to FCC prop type
karrui Apr 26, 2024
dd9e979
fix: sync all type-fest package types
karrui Apr 26, 2024
6265287
fix: remove unnecessary package patches
karrui Apr 26, 2024
ab11692
feat: remove unnecessary scripts and script comments
karrui Apr 26, 2024
99cc9a1
fix: correctly generate chakra theme types
karrui Apr 26, 2024
18b3382
fix: revert motionbox back to old implementation
karrui Apr 26, 2024
9625dd0
fix: upgrade serverless type-fest to sync with rest of app
karrui Apr 26, 2024
9b0ff40
fix: use updated useToken call signature
karrui Apr 26, 2024
33df09a
fix: update react-joyride for React 18 compat
karrui Apr 26, 2024
557d8c8
fix: types for allowed MyInfo types
karrui Apr 29, 2024
e7ffb4a
fix: broken types assertions or code raised by linter
karrui Apr 29, 2024
bf053b7
fix: invalid React SVG prop clip-path -> clipPath
karrui Apr 29, 2024
e6102eb
fix: replace dnd package with React 18 compatible package
karrui Apr 29, 2024
5ad7c69
fix: update package to remove console warning about deprecated calls
karrui Apr 29, 2024
8bd01f7
fix: temporary fix for menu focus color desync
karrui Apr 29, 2024
c2c4a9e
feat: update `@testing-library/*` packages
karrui Apr 29, 2024
0a47239
feat: lock storybook packages
karrui Apr 29, 2024
8712ed8
fix: correctly upgrade virus-scanner type-fest package
karrui Apr 29, 2024
2da9c45
fix: use `isDisabled` prop over disabled
karrui Apr 29, 2024
cb529c5
fix: test assertions due to RTL changes
karrui Apr 29, 2024
76315cb
fix: upgrade floating-ui package for compatibility
karrui Apr 29, 2024
bfc0f8b
fix: compat issues in ChakraUI v2
karrui Apr 29, 2024
80eaa55
feat: update input theming for ChakraUI v2
karrui Apr 29, 2024
43cbdd8
fix: NumberInput render
karrui Apr 29, 2024
d819de7
feat: update Drawer and Modal themes to have background using cssVars
karrui Apr 29, 2024
0c750d8
fix: use explicit style context required by Chakra V2
karrui Apr 29, 2024
a413df7
fix: correctly import from component Button
karrui Apr 29, 2024
6497110
fix: update margin due to flex using `gap` now
karrui Apr 29, 2024
f72359d
fix: update Rating component spacing due to flex gap change in chakra
karrui Apr 29, 2024
f98b44b
fix: update YesNo field margins due to Flex gap change
karrui Apr 29, 2024
e92f440
fix: weird margins with collaborator menu, match width
karrui Apr 29, 2024
8de50b2
fix: use __css instead of sx for FeatureBanner
karrui Apr 29, 2024
acc5c51
fix: button spacing for CreateWorkspaceModal
karrui Apr 29, 2024
25ebaed
fix: button spacing for DeleteWorkspaceModal
karrui Apr 29, 2024
a801362
fix: button spacing for RenameWorkspaceModal
karrui Apr 29, 2024
c3d480e
fix: spacing on LandingPage sections
karrui Apr 29, 2024
095983d
feat: update ParagraphField story to catch multiline changes too
karrui Apr 29, 2024
9c5ef77
feat: remove unnecessary focus-visible package
karrui Apr 29, 2024
c35c9a1
feat: update `isTruncated` -> `noOfLines`
karrui Apr 29, 2024
9164989
feat: fix width of PermissionDropdown for consistent widths
karrui Apr 29, 2024
d8ad6ae
fix: align ViewOnlyPermission row margins
karrui Apr 29, 2024
593bec8
fix: SingleSelect theme breaking because of Menu
karrui Apr 29, 2024
a7b54c1
fix: add padding to prefill lock icon
karrui Apr 29, 2024
9a332c5
fix: add correct msw handlers for workspace page
karrui Apr 29, 2024
7c9f4c6
fix: add back missing margins
karrui Apr 29, 2024
1102d41
fix: make AvatarMenu have automatic height
karrui Apr 29, 2024
9dca35a
fix: add back missing menuitem padding for SingleSelect
karrui Apr 29, 2024
cad2e85
fix: update imported lottie file type
karrui Apr 29, 2024
70d62e0
fix: correct modal story color scheme for cancel button
karrui Apr 29, 2024
7a3fba9
fix: set minH of TagInput to input's var
karrui Apr 29, 2024
a44ab0d
fix: use input exported css variables for styling TagInput
karrui Apr 29, 2024
1358f1a
fix: move combobox input to the top when focused
karrui Apr 29, 2024
9f35e8e
feat: use mockdate decorator so skeleton width fixed in snapshot
karrui Apr 29, 2024
9fcd6ce
fix: spacing of collaborator list view again
karrui Apr 29, 2024
60e949a
fix: landing page margins
karrui Apr 29, 2024
d18f4fb
fix: avatarmenudivider margins
karrui Apr 30, 2024
6d16f3c
fix: remove removed patches copy in dockerfile
karrui May 2, 2024
4c43914
remove ineffective white bg on style header
KenLSM Jun 11, 2024
081915f
feat: upgrade typescript to 5.4.5 across app
karrui Apr 30, 2024
a1f0f7d
fix: all frontend type errors after typescript upgrade
karrui May 2, 2024
cacf238
fix: backend type errors after upgrading typescript
karrui May 2, 2024
7f5103e
Merge branch '04-23-feat_add_initial_vite_config_and_new_eslint_rules…
KenLSM Jul 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"stripe": "^11.1.0",
"timezone-mock": "^1.3.6",
"type-fest": "^4.17.0",
"typescript": "^4.5.3",
"typescript": "^5.4.5",
"use-debounce": "^7.0.1",
"use-draggable-scroll": "^0.1.0",
"validator": "^13.7.0",
Expand All @@ -94,7 +94,7 @@
"postinstall": "npm run gen:theme-typings && npm --prefix ../shared install",
"gen:theme-typings": "chakra-cli tokens --template augmentation src/theme/index.ts || true",
"start": "vite",
"build": "vite build",
"build": "npx tsc && vite build",
"test": "cross-env SKIP_PREFLIGHT_CHECK=true vitest",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build",
Expand Down
7 changes: 0 additions & 7 deletions frontend/src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,13 @@ import {
IconProps,
} from '@chakra-ui/react'

import { ThemeColorScheme } from '~theme/foundations/colours'

import Spinner from '../Spinner'

export interface ButtonProps extends ChakraButtonProps {
/**
* Loading spinner font size. Defaults to `1.5rem`.
*/
spinnerFontSize?: IconProps['fontSize']

/**
* Color scheme of button.
*/
colorScheme?: ThemeColorScheme
/**
* Base color intensity of button.
*/
Expand Down
5 changes: 2 additions & 3 deletions frontend/src/components/Calendar/Calendar.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import {
Box,
forwardRef,
ThemingProps,
useControllableState,
useMultiStyleConfig,
} from '@chakra-ui/react'

import { ThemeColorScheme } from '~theme/foundations/colours'

import { CalendarStylesProvider } from './CalendarBase/CalendarStyleProvider'
import {
CalendarAria,
Expand All @@ -33,7 +32,7 @@ export interface CalendarProps extends CalendarBaseProps {
/** Function to determine whether a date should be made unavailable. */
isDateUnavailable?: (d: Date) => boolean
/** Color scheme for component */
colorScheme?: ThemeColorScheme
colorScheme?: ThemingProps<'Calendar'>['colorScheme']
}

export const Calendar = forwardRef<CalendarProps, 'input'>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
useMemo,
useState,
} from 'react'
import { ThemingProps } from '@chakra-ui/react'
import cuid from 'cuid'
import {
addMonths,
Expand All @@ -18,8 +19,6 @@
import { inRange } from 'lodash'
import { useKey } from 'rooks'

import { ThemeColorScheme } from '~theme/foundations/colours'

import { CalendarProps } from '../Calendar'

import { DateRangeValue } from './types'
Expand Down Expand Up @@ -71,7 +70,10 @@
/**
* Color scheme of date input
*/
colorScheme?: ThemeColorScheme
colorScheme?: ThemingProps<'Calendar'>['colorScheme']

/** Size of the component */
size?: ThemingProps<'Calendar'>['size']
}
export type UseProvideCalendarProps = Pick<DayzedProps, 'monthsToDisplay'> &
PassthroughProps
Expand Down Expand Up @@ -112,7 +114,7 @@
)
}

export const useCalendar = (): CalendarContextProps => {

Check warning on line 117 in frontend/src/components/Calendar/CalendarBase/CalendarContext.tsx

View workflow job for this annotation

GitHub Actions / frontend_lint

Fast refresh only works when a file only exports components. Use a new file to share constants or functions between components
const context = useContext(CalendarContext)

if (!context) {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Calendar/CalendarBase/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { UseProvideCalendarProps } from './CalendarContext'

export type CalendarBaseProps = Pick<
UseProvideCalendarProps,
'colorScheme' | 'isDateUnavailable' | 'monthsToDisplay'
'colorScheme' | 'isDateUnavailable' | 'monthsToDisplay' | 'size'
>

export type DateRangeValue = [null, null] | [Date, null] | [Date, Date]
4 changes: 2 additions & 2 deletions frontend/src/components/DatePicker/DatePickerContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import {
CSSObject,
FormControlProps,
ThemingProps,
useControllableState,
useDisclosure,
UseDisclosureReturn,
Expand All @@ -21,7 +22,6 @@
} from '@chakra-ui/react'
import { format, isValid, parse } from 'date-fns'

import { ThemeColorScheme } from '~theme/foundations/colours'
import { useIsMobile } from '~hooks/useIsMobile'

import { DatePickerProps } from './DatePicker'
Expand All @@ -42,7 +42,7 @@
closeCalendarOnChange: boolean
placeholder: string
allowManualInput: boolean
colorScheme: ThemeColorScheme
colorScheme?: ThemingProps<'DatePicker'>['colorScheme']
isDateUnavailable?: (date: Date) => boolean
disclosureProps: UseDisclosureReturn
monthsToDisplay?: number
Expand All @@ -62,7 +62,7 @@
)
}

export const useDatePicker = () => {

Check warning on line 65 in frontend/src/components/DatePicker/DatePickerContext.tsx

View workflow job for this annotation

GitHub Actions / frontend_lint

Fast refresh only works when a file only exports components. Use a new file to share constants or functions between components
const context = useContext(DatePickerContext)
if (!context) {
throw new Error('useDatePicker must be used within a DatePickerProvider')
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/DatePicker/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { InputProps } from '@chakra-ui/react'
export interface DatePickerBaseProps
extends Omit<
InputProps,
'value' | 'defaultValue' | 'onChange' | 'colorScheme'
'value' | 'defaultValue' | 'onChange' | 'colorScheme' | 'size'
> {
/**
* The `date-fns` format to display the date.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import {
CSSObject,
FormControlProps,
ThemingProps,
useControllableState,
useDisclosure,
UseDisclosureReturn,
Expand All @@ -22,7 +23,6 @@
} from '@chakra-ui/react'
import { format, isValid, parse } from 'date-fns'

import { ThemeColorScheme } from '~theme/foundations/colours'
import { useIsMobile } from '~hooks/useIsMobile'
import { DateRangeValue } from '~components/Calendar'

Expand Down Expand Up @@ -51,7 +51,7 @@
isDateUnavailable?: (date: Date) => boolean
disclosureProps: UseDisclosureReturn
labelSeparator: string
colorScheme: ThemeColorScheme
colorScheme?: ThemingProps<'DatePicker'>['colorScheme']
monthsToDisplay?: number
}

Expand All @@ -70,7 +70,7 @@
)
}

export const useDateRangePicker = () => {

Check warning on line 73 in frontend/src/components/DateRangePicker/DateRangePickerContext.tsx

View workflow job for this annotation

GitHub Actions / frontend_lint

Fast refresh only works when a file only exports components. Use a new file to share constants or functions between components
const context = useContext(DateRangePickerContext)
if (!context) {
throw new Error(
Expand All @@ -96,7 +96,7 @@
allowManualInput = true,
allowInvalidDates = true,
closeCalendarOnChange = true,
onBlur,

Check warning on line 99 in frontend/src/components/DateRangePicker/DateRangePickerContext.tsx

View workflow job for this annotation

GitHub Actions / frontend_lint

'onBlur' is defined but never used
onClick,
colorScheme = 'primary',
monthsToDisplay,
Expand Down Expand Up @@ -181,7 +181,7 @@
})

const handleInputBlur: FocusEventHandler<HTMLInputElement> = useCallback(
(e) => {

Check warning on line 184 in frontend/src/components/DateRangePicker/DateRangePickerContext.tsx

View workflow job for this annotation

GitHub Actions / frontend_lint

'e' is defined but never used
const startDate = parse(startInputDisplay, dateFormat, new Date())
const endDate = parse(endInputDisplay, dateFormat, new Date())
// Clear if input is invalid on blur if invalid dates are not allowed.
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/components/Field/YesNo/YesNoOption.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
Box,
forwardRef,
Icon,
ThemingProps,
useMultiStyleConfig,
useRadio,
UseRadioGroupReturn,
Expand Down Expand Up @@ -40,6 +41,8 @@ interface YesNoOptionProps extends UseRadioProps {
* instead of the default event-only argument.
*/
onChange?: UseRadioGroupReturn['onChange']

size?: ThemingProps<'Radio'>['size']
}

/**
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/components/NumberInput/NumberInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export interface NumberInputProps extends ChakraNumberInputProps {
* Whether to prevent default on user pressing the 'Enter' key.
*/
preventDefaultOnEnter?: boolean

placeholder?: string
}

export const NumberInput = forwardRef<NumberInputProps, 'input'>(
Expand Down
8 changes: 7 additions & 1 deletion frontend/src/components/Toast/Toast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ import { BxsCheckCircle, BxsErrorCircle } from '~assets/icons'
import { useMdComponents } from '~hooks/useMdComponents'
import { MarkdownText } from '~components/MarkdownText'

export type ToastStatus = 'danger' | 'success' | 'warning'
export type ToastStatus =
| 'info'
| 'danger'
| 'success'
| 'warning'
| 'error'
| 'loading'

export interface ToastProps
extends Omit<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export const EditTable = ({ field }: EditTableProps): JSX.Element => {
// Must be greater than minimum rows
validate: (value) =>
!value ||
value > getValues('minimumRows') ||
value > (getValues('minimumRows') || 0) ||
'Maximum rows must be greater than minimum rows',
}}
control={control}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
Controller,
ControllerRenderProps,
UseFormReturn,
Validate,
} from 'react-hook-form'
import { BiTrash } from 'react-icons/bi'
import {
Expand Down Expand Up @@ -185,7 +186,9 @@ export const EditConditionBlock = ({
return ifValueTypeValue === LogicIfValue.MultiSelect ? '0px' : 'auto'
}, [ifValueTypeValue])

const validateValueInputComponent = useCallback(
const validateValueInputComponent: Validate<
string | number | string[] | number[]
> = useCallback(
(val) => {
switch (ifValueTypeValue) {
case LogicIfValue.Number: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { HttpError } from '~services/ApiService'
import { FormFieldValues } from '~templates/Field'

import NotFoundErrorPage from '~pages/NotFoundError'
import { SubmitEmailFormArgs } from '~features/public-form/PublicFormService'

import { useEnv } from '../../env/queries'
import { axiosDebugFlow } from '../../public-form/utils'
Expand Down Expand Up @@ -51,7 +52,7 @@ export const PreviewFormProvider = ({
useCommonFormProvider(formId)

const showErrorToast = useCallback(
(error) => {
(error: unknown) => {
toast({
status: 'danger',
description:
Expand Down Expand Up @@ -119,11 +120,10 @@ export const PreviewFormProvider = ({
async (formInputs) => {
const { form } = data ?? {}
if (!form) return

const formData = {
const formData: Omit<SubmitEmailFormArgs, 'formId'> = {
formFields: form.form_fields,
formLogics: form.form_logics,
formInputs,
formInputs: formInputs,
}

const logMeta = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export const ResponsesTable = () => {
}, [currentPage, gotoPage])

const handleRowClick = useCallback(
(submissionId: string, responseNumber) => {
(submissionId: string, responseNumber: number) => {
onRowClick()
return navigate(submissionId, {
state: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const ndjsonStream = (
let data_buf = ''

const processResult = (
result?: ReadableStreamDefaultReadResult<Uint8Array>,
result?: ReadableStreamReadResult<Uint8Array>,
): Promise<void> | undefined => {
if (!result || (result.done && shouldCancel)) {
return
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/features/public-form/PublicFormProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ export const PublicFormProvider = ({
}, [data, toast, t])

const showErrorToast = useCallback(
(error, form: PublicFormDto) => {
(error: unknown, form: PublicFormDto) => {
toast({
status: 'danger',
description:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ export const CompleteWithoutReceipt = Template(
min_amount: 50,
max_amount: 200,
}}
paymentDate={new Date(Date.now())}
/>,
).bind({})
CompleteWithoutReceipt.parameters = {
Expand All @@ -119,7 +118,6 @@ export const CompleteWithReceipt = Template(
min_amount: 50,
max_amount: 200,
}}
paymentDate={new Date(Date.now())}
/>,
).bind({})
CompleteWithReceipt.parameters = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const PaymentQuantityModal = ({
variant="clear"
aria-label="Decrement"
colorScheme="secondary"
isDisabled={quantity <= minQty}
isDisabled={(quantity || 0) <= minQty}
onClick={() => {
setValue('quantity', quantity ? quantity - 1 : minQty)
trigger('quantity')
Expand Down Expand Up @@ -133,7 +133,7 @@ const PaymentQuantityModal = ({
variant="clear"
aria-label="Increment"
colorScheme="secondary"
isDisabled={quantity >= maxQty}
isDisabled={(quantity || 0) >= maxQty}
onClick={() => {
setValue('quantity', quantity ? quantity + 1 : minQty)
trigger('quantity')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type BillingColumnData = Pick<
'formName' | 'adminEmail' | 'authType' | 'total'
>

const AUTHTYPE_TO_TEXT = {
const AUTHTYPE_TO_TEXT: { [K in FormAuthType]?: string } = {
[FormAuthType.NIL]: '-',
[FormAuthType.SP]: 'Singpass',
[FormAuthType.SGID]: 'sgID',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ export const StorageModeAckScreen = () => {
Promise.resolve(console.log('create storage mode form')),
secretKey,
register,
handleCreateStorageModeOrMultirespondentForm: () =>
Promise.resolve(
console.log('create storage mode or multirespondent form'),
),
}
}, [handleCopyKey, hasCopiedKey, register])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ export const WorkspaceRowsProvider = ({
}}
>
<DuplicateFormModal
formId={activeFormMeta?._id ?? ''}
isOpen={dupeFormModalDisclosure.isOpen}
onClose={dupeFormModalDisclosure.onClose}
/>
Expand Down
Loading
Loading