From df9a0a794dfb60c381959b8eab6961948c4dd3ae Mon Sep 17 00:00:00 2001 From: zhaojunxia Date: Mon, 26 Sep 2022 02:22:34 -0700 Subject: [PATCH] Fix: func para map value string[] error Signed-off-by: zhaojunxia --- src/gen/tools/common.js | 8 ++++++++ test/storytest/test_map/@ohos.test.d.ts | 10 ++++++++++ test/storytest/test_map/test.js | 2 +- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/gen/tools/common.js b/src/gen/tools/common.js index 85280728..68b85913 100644 --- a/src/gen/tools/common.js +++ b/src/gen/tools/common.js @@ -186,6 +186,10 @@ function getMapType(type) { let ttValue = re.search(",([a-zA-Z_0-9<>]+)>", type) let ttMap = re.search(",([a-zA-Z_0-9]+)>>", type) let ttArray = re.search("Array<([a-zA-Z_0-9]+)>", type) + + if(ttArray == null) { + ttArray = re.search("([a-zA-Z_0-9]+)\\[\\]>", type) + } let valueType let valueMapType @@ -195,7 +199,11 @@ function getMapType(type) { ttValue = re.search(":([a-zA-Z_0-9]+)}", type) ttMap = re.search(":([a-zA-Z_0-9]+)}}", type) ttArray = re.search("Array<([a-zA-Z_0-9]+)>", type) + if (ttArray == null) { + ttArray = re.search(":([a-zA-Z_0-9]+)\\[\\]}", type) + } } + if (ttValue != null) { valueType = re.getReg(type, ttValue.regs[1]) if (valueType.indexOf("Array<") == 0) { diff --git a/test/storytest/test_map/@ohos.test.d.ts b/test/storytest/test_map/@ohos.test.d.ts index e05e7fe1..b4afc8f0 100644 --- a/test/storytest/test_map/@ohos.test.d.ts +++ b/test/storytest/test_map/@ohos.test.d.ts @@ -38,5 +38,15 @@ declare namespace napitest { fun9(v: {[key: string]: Human}): number; fun10(v: Map): number; } + + function fun13(v: {[key: string]: string[]}): number; + function fun18(v: Map): number; + + + /* + function fun14(v: number): {[key: string]: string[]}; --暂时不支持 + function fun15(v: number):Map --暂时不支持 + */ + } export default napitest; \ No newline at end of file diff --git a/test/storytest/test_map/test.js b/test/storytest/test_map/test.js index 94590d48..14b469c5 100644 --- a/test/storytest/test_map/test.js +++ b/test/storytest/test_map/test.js @@ -82,5 +82,5 @@ describe('Map', function () { {"peter":{"age":666,"name":"peter","isTrue":true}, "jane":{"age":666,"name":"jane","isTrue":false}}); assert.strictEqual(ret, 0); - }); + }); }); \ No newline at end of file -- Gitee