MCPcopy
hub / github.com/alibaba/lowcode-engine / getShapeFromArray

Function getShapeFromArray

modules/material-parser/src/parse/ts/index.ts:141–210  ·  view source on GitHub ↗
(symbolArr: ts.Symbol[], _type: ts.Type)

Source from the content-addressed store, hash-verified

139 }
140
141 function getShapeFromArray(symbolArr: ts.Symbol[], _type: ts.Type) {
142 const shape: Array<{
143 key:
144 | {
145 name: string;
146 }
147 | string;
148 value: any;
149 }> = symbolArr.map((prop) => {
150 const propType = checker.getTypeOfSymbolAtLocation(
151 prop,
152 // @ts-ignore
153 prop.valueDeclaration || (prop.declarations && prop.declarations[0]) || {},
154 );
155 return {
156 key: prop.getName(),
157
158 value: getDocgenTypeHelper(
159 checker,
160 propType,
161 false,
162 // @ts-ignore
163 getNextParentIds(parentIds, _type),
164 // @ts-ignore
165 !prop?.valueDeclaration?.questionToken,
166 ),
167 };
168 });
169 // @ts-ignore use internal methods
170 if (checker.isArrayLikeType(_type)) {
171 return shape;
172 }
173 if (_type.getStringIndexType()) {
174 // @ts-ignore use internal methods
175 if (!_type.stringIndexInfo) {
176 return shape;
177 }
178 shape.push({
179 key: {
180 name: 'string',
181 },
182 value: getDocgenTypeHelper(
183 checker,
184 // @ts-ignore use internal methods
185 _type.stringIndexInfo.type,
186 false,
187 getNextParentIds(parentIds, _type),
188 ),
189 });
190 } else if (_type.getNumberIndexType()) {
191 // @ts-ignore use internal methods
192 if (!_type.numberIndexInfo) {
193 return shape;
194 }
195 shape.push({
196 key: {
197 name: 'number',
198 },

Callers 1

getShapeFunction · 0.85

Calls 5

getDocgenTypeHelperFunction · 0.85
getNextParentIdsFunction · 0.85
pushMethod · 0.80
mapMethod · 0.65
getNameMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…