chore: dirty TypeScript bandaid fixes

This commit is contained in:
Alessio Gravili
2023-09-01 18:29:36 +02:00
parent 63d18beb10
commit 934bae2d24
25 changed files with 79 additions and 13 deletions

View File

@@ -4,8 +4,8 @@
"declaration": true /* Generates corresponding '.d.ts' file. */,
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
"module": "NodeNext",
"moduleResolution": "NodeNext" /* Required for exports to work */,
"module": "Node16",
"moduleResolution": "Node16" /* Required for exports to work */,
"outDir": "./dist" /* Specify an output folder for all emitted files. */,
"resolveJsonModule": true,
"rootDir": "./src" /* Specify the root folder within your source files. */,

File diff suppressed because one or more lines are too long

View File

@@ -4,8 +4,8 @@
"declaration": true /* Generates corresponding '.d.ts' file. */,
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
"module": "NodeNext",
"moduleResolution": "NodeNext" /* Required for exports to work */,
"module": "Node16",
"moduleResolution": "Node16" /* Required for exports to work */,
"outDir": "./dist" /* Specify an output folder for all emitted files. */,
"resolveJsonModule": true,
"rootDir": "./src" /* Specify the root folder within your source files. */,

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -280,7 +280,6 @@
}
},
"main": "./dist/index.js",
"module": "./dist/index.js",
"registry": "https://registry.npmjs.org/",
"types": "./dist/index.d.ts"
},

View File

@@ -14,17 +14,29 @@ import Version from './views/Version'
import Versions from './views/Versions'
import List from './views/collections/List'
// @ts-expect-error Just TypeScript being broken // TODO: Open TypeScript issue
const Dashboard = lazy(() => import('./views/Dashboard'))
// @ts-expect-error Just TypeScript being broken // TODO: Open TypeScript issue
const ForgotPassword = lazy(() => import('./views/ForgotPassword'))
// @ts-expect-error Just TypeScript being broken // TODO: Open TypeScript issue
const Login = lazy(() => import('./views/Login'))
// @ts-expect-error Just TypeScript being broken // TODO: Open TypeScript issue
const Logout = lazy(() => import('./views/Logout'))
// @ts-expect-error Just TypeScript being broken // TODO: Open TypeScript issue
const NotFound = lazy(() => import('./views/NotFound'))
// @ts-expect-error Just TypeScript being broken // TODO: Open TypeScript issue
const Verify = lazy(() => import('./views/Verify'))
// @ts-expect-error Just TypeScript being broken // TODO: Open TypeScript issue
const CreateFirstUser = lazy(() => import('./views/CreateFirstUser'))
// @ts-expect-error Just TypeScript being broken // TODO: Open TypeScript issue
const Edit = lazy(() => import('./views/collections/Edit'))
// @ts-expect-error Just TypeScript being broken // TODO: Open TypeScript issue
const EditGlobal = lazy(() => import('./views/Global'))
// @ts-expect-error Just TypeScript being broken // TODO: Open TypeScript issue
const ResetPassword = lazy(() => import('./views/ResetPassword'))
// @ts-expect-error Just TypeScript being broken // TODO: Open TypeScript issue
const Unauthorized = lazy(() => import('./views/Unauthorized'))
// @ts-expect-error Just TypeScript being broken // TODO: Open TypeScript issue
const Account = lazy(() => import('./views/Account'))
const Routes: React.FC = () => {

View File

@@ -4,6 +4,7 @@ import type { Props } from './types'
import { ShimmerEffect } from '../ShimmerEffect'
// @ts-expect-error Just TypeScript being broken // TODO: Open TypeScript issue
const LazyEditor = lazy(() => import('./CodeEditor'))
export const CodeEditor: React.FC<Props> = (props) => {

View File

@@ -4,6 +4,7 @@ import type { Props } from './types'
import { ShimmerEffect } from '../ShimmerEffect'
// @ts-expect-error Just TypeScript being broken // TODO: Open TypeScript issue
const DatePicker = lazy(() => import('./DatePicker'))
const DatePickerField: React.FC<Props> = (props) => (

View File

@@ -9,6 +9,7 @@ export const Control: React.FC<ControlProps<Option, any>> = (props) => {
const {
children,
innerProps,
// @ts-expect-error // TODO Fix this - moduleResolution 16 breaks our declare module
selectProps: { customProps: { disableKeyDown, disableMouseDown } = {} } = {},
} = props

View File

@@ -15,6 +15,7 @@ export const MultiValue: React.FC<MultiValueProps<Option>> = (props) => {
data: { value },
innerProps,
isDisabled,
// @ts-expect-error // TODO Fix this - moduleResolution 16 breaks our declare module
selectProps: { customProps: { disableMouseDown } = {} } = {},
} = props

View File

@@ -10,6 +10,7 @@ import './index.scss'
const baseClass = 'multi-value-label'
export const MultiValueLabel: React.FC<MultiValueProps<Option>> = (props) => {
// @ts-expect-error // TODO Fix this - moduleResolution 16 breaks our declare module
const { selectProps: { customProps: { draggableProps } = {} } = {} } = props
return (

View File

@@ -10,6 +10,7 @@ import './index.scss'
const baseClass = 'value-container'
export const ValueContainer: React.FC<ValueContainerProps<Option, any>> = (props) => {
// @ts-expect-error // TODO Fix this - moduleResolution 16 breaks our declare module
const { selectProps: { customProps } = {} } = props
return (

View File

@@ -13,6 +13,7 @@ type CustomSelectProps = {
// augment the types for the `Select` component from `react-select`
// this is to include the `selectProps` prop at the top-level `Select` component
// @ts-expect-error // TODO Fix this - moduleResolution 16 breaks our declare module
declare module 'react-select/dist/declarations/src/Select' {
export interface Props<Option, IsMulti extends boolean, Group extends GroupBase<Option>> {
customProps?: CustomSelectProps
@@ -21,6 +22,7 @@ declare module 'react-select/dist/declarations/src/Select' {
// augment the types for the `CommonPropsAndClassName` from `react-select`
// this will include the `selectProps` prop to every `react-select` component automatically
// @ts-expect-error // TODO Fix this - moduleResolution 16 breaks our declare module
declare module 'react-select/dist/declarations/src' {
export interface CommonPropsAndClassName<
Option,

View File

@@ -18,8 +18,11 @@ export const MultiValueLabel: React.FC<MultiValueProps<Option>> = (props) => {
const {
data: { label, relationTo, value },
selectProps: {
// @ts-expect-error // TODO Fix this - moduleResolution 16 breaks our declare module
customProps: {
// @ts-expect-error // TODO Fix this - moduleResolution 16 breaks our declare module
draggableProps,
// @ts-expect-error // TODO Fix this - moduleResolution 16 breaks our declare module
setDrawerIsOpen,
// onSave,
} = {},

View File

@@ -18,6 +18,7 @@ export const SingleValue: React.FC<SingleValueProps<Option>> = (props) => {
const {
children,
data: { label, relationTo, value },
// @ts-expect-error // TODO Fix this - moduleResolution 16 breaks our declare module
selectProps: { customProps: { onSave, setDrawerIsOpen } = {} } = {},
} = props

View File

@@ -4,6 +4,7 @@ import type { Props } from './types'
import { ShimmerEffect } from '../../../elements/ShimmerEffect'
// @ts-expect-error Just TypeScript being broken // TODO: Open TypeScript issue
const RichText = lazy(() => import('./RichText'))
const RichTextField: React.FC<Props> = (props) => (

View File

@@ -4,6 +4,7 @@ import type { Props } from './types'
import { LoadingOverlayToggle } from '../../elements/Loading'
// @ts-expect-error Just TypeScript being broken // TODO: Open TypeScript issue
const VersionView = lazy(() => import('./Version'))
const Version: React.FC<Props> = (props) => (

View File

@@ -10,6 +10,13 @@ const root = createRoot(container) // createRoot(container!) if you use TypeScri
root.render(<Root />)
// Needed for Hot Module Replacement
if (typeof module.hot !== 'undefined') {
if (
typeof module !== 'undefined' &&
module &&
'hot' in module &&
typeof module.hot === 'object' &&
'accept' in module.hot &&
typeof module.hot.accept === 'function'
) {
module.hot.accept()
}

View File

@@ -1,8 +1,9 @@
import MiniCSSExtractPlugin from 'mini-css-extract-plugin'
import path from 'path'
import terser from 'terser'
import TerserJSPlugin from 'terser-webpack-plugin' // IMPORTANT - DO NOT REMOVE: This is required for pnpm's default isolated mode to work - even though the import is not used. This is due to a typescript bug: https://github.com/microsoft/TypeScript/issues/47663#issuecomment-1519138189. (tsbugisolatedmode)
const terser = import('terser') // IMPORTANT - DO NOT REMOVE: This is required for pnpm's default isolated mode to work - even though the import is not used. This is due to a typescript bug: https://github.com/microsoft/TypeScript/issues/47663#issuecomment-1519138189. (tsbugisolatedmode)
import OptimizeCSSAssetsPlugin from 'css-minimizer-webpack-plugin'
// eslint-disable-next-line @typescript-eslint/no-var-requires
const TerserPlugin = require('terser-webpack-plugin') // Needs to be require. TypeScript is too dumb to make it an import
export default {
entry: {
@@ -63,7 +64,7 @@ export default {
},
optimization: {
minimizer: [
new TerserJSPlugin({
new TerserPlugin({
extractComments: false,
}),
new OptimizeCSSAssetsPlugin({}),

View File

@@ -1,5 +1,6 @@
import type { Express, Router } from 'express'
import type { ExecutionResult, GraphQLSchema, ValidationRule } from 'graphql'
// @ts-expect-error // TODO Fix this - moduleResolution 16 breaks this import
import type { OperationArgs, Request as graphQLRequest } from 'graphql-http/lib/handler'
import type { SendMailOptions } from 'nodemailer'
import type { Config as GeneratedTypes } from 'payload/generated-types'
@@ -310,6 +311,7 @@ export class BasePayload<TGeneratedTypes extends GeneratedTypes> {
* @description Initializes Payload
* @param options
*/
// @ts-expect-error // TODO: TypeScript hallucinating again. fix later
async init(options: InitOptions): Promise<Payload> {
this.logger = Logger('payload', options.loggerOptions, options.loggerDestination)

View File

@@ -38,6 +38,7 @@ async function deleteOperation(args: PreferenceRequest): Promise<Document> {
where,
})
// @ts-expect-error // TODO: fix later
if (result.docs.length === 1) {
return result.docs[0]
}

View File

@@ -7,8 +7,8 @@
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */,
"jsx": "react" /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */,
"module": "NodeNext",
"moduleResolution": "NodeNext" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
"module": "Node16",
"moduleResolution": "Node16" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
/* Do not emit comments to output. */
"noEmit": false /* Do not emit outputs. */,
/* Concatenate and emit output to single file. */

File diff suppressed because one or more lines are too long

View File

@@ -8,8 +8,8 @@
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */,
"jsx": "react" /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */,
"lib": ["dom", "dom.iterable", "esnext"],
"module": "NodeNext",
"moduleResolution": "NodeNext" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
"module": "Node16",
"moduleResolution": "Node16" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
/* Do not emit comments to output. */
"noEmit": true /* Do not emit outputs. */,
/* Concatenate and emit output to single file. */