목록typescript (3)
Hello World...
const paginate = (array: Product[], itemSize: number, page: number) => { return array.slice((page - 1) * itemSize, page * itemSize); }; 클라이언트 사이드에서 페이지네이션 함수를 만들 때 위와 같이 해 보았다. 대충 작동은 하는데 정확하지 않다...;
example src/lib import dayjs from 'dayjs'; import utc from 'dayjs/plugin/utc'; import timezone from 'dayjs/plugin/timezone'; dayjs.extend(utc); dayjs.extend(timezone); dayjs.tz.setDefault('Asia/Seoul'); export default dayjs.tz; 특정 페이지 또는 컴포넌트.tsx import dayjs from '@/lib/dayjs-lib'; ... const exampleDate = dayjs().format('YYYY-MM-DD HH:mm'); ...
# typescript 전역 설치 npm install -g typescript # node project 생성 npm init # tsconfig.json 생성 npx tsc --init # 자바스크립트 파일도 사용 가능하게 하기 tsconfig.json -> allowJs: true # ts -> js 파일로 변환 # 전체 npx tsc # 부분 npx tsc app.ts # ts-node 로 타입스크립트 실행하기 npm install -g ts-node ts-node app.ts - 타입스크립트 핸드북 https://www.typescriptlang.org/ko/docs/handbook/intro.html Handbook - The TypeScript Handbook Your first step t..