From 93b77ba4f02574fd7e387d735000f7e019d64aaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E7=88=B1=E5=90=83=E7=99=BD=E8=90=9D?= =?UTF-8?q?=E5=8D=9C?= Date: Wed, 27 Sep 2023 16:06:21 +0800 Subject: [PATCH] chore: adjust ts (#48) --- docs/examples/show-count.tsx | 5 ++--- src/interface.ts | 2 +- tests/count.test.tsx | 4 +--- tsconfig.json | 2 +- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/docs/examples/show-count.tsx b/docs/examples/show-count.tsx index 91be3a2..8d1be49 100644 --- a/docs/examples/show-count.tsx +++ b/docs/examples/show-count.tsx @@ -40,8 +40,7 @@ const Demo: FC = () => { count={{ show: true, max: 5, - strategy: (val) => - [...new (Intl as any).Segmenter().segment(val)].length, + strategy: (val) => [...new Intl.Segmenter().segment(val)].length, }} />

Customize exceedFormatter

@@ -53,7 +52,7 @@ const Demo: FC = () => { show: true, max: 5, exceedFormatter: (val, { max }) => { - const segments = [...new (Intl as any).Segmenter().segment(val)]; + const segments = [...new Intl.Segmenter().segment(val)]; return segments .filter((seg) => seg.index + seg.segment.length <= max) diff --git a/src/interface.ts b/src/interface.ts index ecb4b7a..736bfaa 100644 --- a/src/interface.ts +++ b/src/interface.ts @@ -114,7 +114,7 @@ export interface InputProps string >; onPressEnter?: KeyboardEventHandler; - /** @deprecated Use `count` instead */ + /** @deprecated Use `count.show` instead */ showCount?: | boolean | { diff --git a/tests/count.test.tsx b/tests/count.test.tsx index 9975b8f..2f3ca0e 100644 --- a/tests/count.test.tsx +++ b/tests/count.test.tsx @@ -2,9 +2,7 @@ import { fireEvent, render } from '@testing-library/react'; import React from 'react'; import Input from '../src'; -const getSegments = (val: string) => [ - ...new (Intl as any).Segmenter().segment(val), -]; +const getSegments = (val: string) => [...new Intl.Segmenter().segment(val)]; describe('Input.Count', () => { it('basic emoji take length', () => { diff --git a/tsconfig.json b/tsconfig.json index f8e6324..540895d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,7 +4,7 @@ "module": "ESNext", "moduleResolution": "node", "baseUrl": "./", - "lib": ["dom", "es2017"], + "lib": ["dom", "es2017", "es2022"], "jsx": "react", "strict": true, "esModuleInterop": true,