From 44c005ae63af725e38d4788c5425a9516c5c3073 Mon Sep 17 00:00:00 2001 From: wangyong Date: Fri, 24 Jun 2022 15:21:50 +0800 Subject: [PATCH] Add TS constraint to the example of docs file Description: 1.Add TS constraint to the example of docs file 2.correct some errors function in the docs example #I5DZD6:Add TS constraint to the example of docs file Signed-off-by: wangyong --- .../reference/apis/js-apis-arraylist.md | 8 ++++---- .../application-dev/reference/apis/js-apis-list.md | 14 +++++++------- .../reference/apis/js-apis-vector.md | 10 +++++----- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/zh-cn/application-dev/reference/apis/js-apis-arraylist.md b/zh-cn/application-dev/reference/apis/js-apis-arraylist.md index a0004ab25d..dd9a810be7 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-arraylist.md +++ b/zh-cn/application-dev/reference/apis/js-apis-arraylist.md @@ -319,10 +319,10 @@ arrayList.add(2); arrayList.add(4); arrayList.add(5); arrayList.add(4); -arrayList.replaceAllElements((value, index) => { +arrayList.replaceAllElements((value: number, index: number)=> { return value = 2 * value; }); -arrayList.replaceAllElements((value, index) => { +arrayList.replaceAllElements((value: number, index: number) => { return value = value - 2; }); ``` @@ -393,8 +393,8 @@ arrayList.add(2); arrayList.add(4); arrayList.add(5); arrayList.add(4); -arrayList.sort((a, b) => a - b); -arrayList.sort((a, b) => b - a); +arrayList.sort((a: number, b: number) => a - b); +arrayList.sort((a: number, b: number) => b - a); arrayList.sort(); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-list.md b/zh-cn/application-dev/reference/apis/js-apis-list.md index bbb62d162d..18e8871473 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-list.md +++ b/zh-cn/application-dev/reference/apis/js-apis-list.md @@ -363,10 +363,10 @@ list.add(2); list.add(4); list.add(5); list.add(4); -list.replaceAllElements((value, index) => { +list.replaceAllElements((value: number, index: number) => { return value = 2 * value; }); -list.replaceAllElements((value, index) => { +list.replaceAllElements((value: number, index: number) => { return value = value - 2; }); ``` @@ -438,8 +438,8 @@ list.add(2); list.add(4); list.add(5); list.add(4); -list.sort((a, b) => a - b); -list.sort((a, b) => b - a); +list.sort((a: number, b: number) => a - b); +list.sort((a: number, b: number) => b - a); ``` ### getSubList @@ -471,9 +471,9 @@ list.add(2); list.add(4); list.add(5); list.add(4); -let result = list.subList(2, 4); -let result1 = list.subList(4, 3); -let result2 = list.subList(2, 6); +let result = list.getSubList(2, 4); +let result1 = list.getSubList(4, 3); +let result2 = list.getSubList(2, 6); ``` ### clear diff --git a/zh-cn/application-dev/reference/apis/js-apis-vector.md b/zh-cn/application-dev/reference/apis/js-apis-vector.md index d45bb5612d..c57bbca6de 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-vector.md +++ b/zh-cn/application-dev/reference/apis/js-apis-vector.md @@ -318,10 +318,10 @@ vector.add(2); vector.add(4); vector.add(5); vector.add(4); -vector.replaceAllElements((value, index) => { +vector.replaceAllElements((value: number, index: number) => { return value = 2 * value; }); -vector.replaceAllElements((value, index) => { +vector.replaceAllElements((value: number, index: number) => { return value = value - 2; }); ``` @@ -393,8 +393,8 @@ vector.add(2); vector.add(4); vector.add(5); vector.add(4); -vector.sort((a, b) => a - b); -vector.sort((a, b) => b - a); +vector.sort((a: number, b: number) => a - b); +vector.sort((a: number, b: number) => b - a); vector.sort(); ``` @@ -619,7 +619,7 @@ vector.add(2); vector.add(4); vector.add(5); vector.add(4); -let result = vector.toSting(); +let result = vector.toString(); ``` ### copyToArray -- GitLab