MCPcopy Create free account
hub / github.com/CoderLine/alphaTab / fillBaseInfoFrom

Function fillBaseInfoFrom

packages/alphatab/scripts/TypeSchema.ts:160–261  ·  view source on GitHub ↗
(tsType: ts.Type)

Source from the content-addressed store, hash-verified

158 let mainType: ts.Type | undefined;
159
160 const fillBaseInfoFrom = (tsType: ts.Type) => {
161 const valueDeclaration = tsType.symbol?.valueDeclaration;
162 mainType = tsType;
163
164 typeInfo.typeAsString = checker.typeToString(tsType, undefined, undefined);
165 typeInfo.modulePath = findModule(tsType, program.getCompilerOptions());
166 typeInfo.isOwnType =
167 !!typeInfo.modulePath && (!typeInfo.modulePath.includes('node_modules') || typeInfo.modulePath.includes('@coderline/alphatab')) && !!valueDeclaration;
168
169 if (isEnumType(tsType)) {
170 typeInfo.isEnumType = true;
171 } else if (isPrimitiveType(tsType)) {
172 typeInfo.isNumberType = isNumberType(tsType);
173 typeInfo.isPrimitiveType = true;
174 } else if (typeInfo.isOwnType) {
175 typeInfo.jsDocTags = valueDeclaration ? ts.getJSDocTags(valueDeclaration) : undefined;
176 if (typeInfo.jsDocTags) {
177 typeInfo.isJsonImmutable = !!typeInfo.jsDocTags.find(t => t.tagName.text === 'json_immutable');
178 typeInfo.isCloneable = !!typeInfo.jsDocTags.find(t => t.tagName.text === 'cloneable');
179 }
180
181 if (tsType.flags & ts.ObjectFlags.Reference) {
182 typeInfo.typeArguments = (tsType as ts.TypeReference).typeArguments?.map(p =>
183 getTypeWithNullableInfo(program, p, allowUnion, false, typeArgumentMapping)
184 );
185 }
186 } else if (checker.isArrayType(tsType)) {
187 typeInfo.isArray = true;
188 typeInfo.arrayItemType = getTypeWithNullableInfo(
189 program,
190 (tsType as ts.TypeReference).typeArguments![0],
191 allowUnion,
192 false,
193 typeArgumentMapping
194 );
195 } else if (tsType.symbol) {
196 typeInfo.typeAsString = tsType.symbol.name;
197 switch (tsType.symbol.name) {
198 case 'Uint8Array':
199 case 'Uint16Array':
200 case 'Uint32Array':
201 case 'Int8Array':
202 case 'Int16Array':
203 case 'Int32Array':
204 case 'Float32Array':
205 case 'Float64Array':
206 typeInfo.isTypedArray = true;
207 typeInfo.arrayItemType = {
208 isNullable: false,
209 isOptional: false,
210 isUnionType: false,
211 isPrimitiveType: true,
212 isEnumType: false,
213 isOwnType: false,
214 isTypedArray: false,
215 typeAsString: 'number',
216 modulePath: '',
217 isCloneable: false,

Callers 1

getTypeWithNullableInfoFunction · 0.85

Calls 9

isEnumTypeFunction · 0.90
isPrimitiveTypeFunction · 0.90
isNumberTypeFunction · 0.90
findModuleFunction · 0.85
getTypeWithNullableInfoFunction · 0.85
includesMethod · 0.80
getMethod · 0.65
mapMethod · 0.45
hasMethod · 0.45

Tested by

no test coverage detected