Last active
October 15, 2024 11:53
-
-
Save floatrx/e191fee08498aff5c138e1243b1b2fde to your computer and use it in GitHub Desktop.
Global type definitions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
// .env | |
declare namespace NodeJS { | |
interface ProcessEnv { | |
NODE_ENV: 'development' | 'production' | 'test'; | |
} | |
} | |
// Global type declarations for React components | |
declare global { | |
// Just empty object | |
type EmptyObj = Record<string, unknown>; | |
// Any object | |
type AnyObj = Record<string, any>; | |
// React fn component with children | |
type FC<T = object> = React.FunctionComponent<React.PropsWithChildren<T>>; | |
// React fn component without children | |
type RC<T = object> = React.FunctionComponent<T>; | |
// Get available props from element (e.g. button, input, div, etc.) | |
type ComponentProps<T> = React.ComponentProps<T>; | |
// Next page props | |
type PageProps<Params = EmptyObj, SearchParams = EmptyObj> = { | |
params: Partial<Params>; | |
searchParams: Partial<SearchParams>; | |
}; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"compilerOptions": { | |
"target": "ES2020", | |
"useDefineForClassFields": true, | |
"lib": ["ES2020", "DOM", "DOM.Iterable"], | |
"module": "ESNext", | |
"skipLibCheck": true, | |
/* Bundler mode */ | |
"moduleResolution": "bundler", | |
"allowImportingTsExtensions": true, | |
"resolveJsonModule": true, | |
"isolatedModules": true, | |
"noEmit": true, | |
"jsx": "react-jsx", | |
/* Linting */ | |
"strict": true, | |
"noUnusedLocals": true, | |
"noUnusedParameters": true, | |
"noFallthroughCasesInSwitch": true | |
}, | |
"include": ["src", "./global.d.ts"], | |
"references": [{ "path": "./tsconfig.node.json" }] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"compilerOptions": { | |
"composite": true, | |
"skipLibCheck": true, | |
"module": "ESNext", | |
"moduleResolution": "bundler", | |
"allowSyntheticDefaultImports": true, | |
"strict": true | |
}, | |
"include": ["vite.config.ts"] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import react from '@vitejs/plugin-react'; | |
import { defineConfig } from 'vite'; | |
// https://vitejs.dev/config/ | |
export default defineConfig({ | |
plugins: [react()], | |
server: { | |
port: 3001, | |
proxy: | |
process.env.NODE_ENV === 'development' | |
? { | |
'/api': { | |
target: 'http://localhost:3000', // for example | |
changeOrigin: true, | |
}, | |
} | |
: {}, | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment