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

Function applyNullableAndUndefined

packages/alphatab/scripts/TypeSchema.ts:325–340  ·  view source on GitHub ↗
(type: ts.TypeNode)

Source from the content-addressed store, hash-verified

323 }
324
325 const applyNullableAndUndefined = (type: ts.TypeNode): ts.TypeNode => {
326 if (typeInfo.isNullable || typeInfo.isOptional) {
327 const types: ts.TypeNode[] = [type];
328
329 if (typeInfo.isNullable) {
330 types.push(ts.factory.createLiteralTypeNode(ts.factory.createNull()));
331 }
332 if (typeInfo.isOptional) {
333 types.push(ts.factory.createKeywordTypeNode(ts.SyntaxKind.UndefinedKeyword));
334 }
335
336 return ts.factory.createUnionTypeNode(types);
337 }
338
339 return type;
340 };
341
342 if (typeInfo.unionTypes) {
343 typeInfo.createTypeNode = () => {

Callers 1

getTypeWithNullableInfoFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected