MCPcopy Index your code
hub / github.com/nodejs/node / createEmptyObjectTypeFromStringLiteral

Function createEmptyObjectTypeFromStringLiteral

test/fixtures/snapshot/typescript.js:68170–68187  ·  view source on GitHub ↗

Create an object with properties named in the string literal type. Every property has type `any`

(type)

Source from the content-addressed store, hash-verified

68168 }
68169 /** Create an object with properties named in the string literal type. Every property has type `any` */
68170 function createEmptyObjectTypeFromStringLiteral(type) {
68171 var members = ts.createSymbolTable();
68172 forEachType(type, function (t) {
68173 if (!(t.flags & 128 /* TypeFlags.StringLiteral */)) {
68174 return;
68175 }
68176 var name = ts.escapeLeadingUnderscores(t.value);
68177 var literalProp = createSymbol(4 /* SymbolFlags.Property */, name);
68178 literalProp.type = anyType;
68179 if (t.symbol) {
68180 literalProp.declarations = t.symbol.declarations;
68181 literalProp.valueDeclaration = t.symbol.valueDeclaration;
68182 }
68183 members.set(name, literalProp);
68184 });
68185 var indexInfos = type.flags & 4 /* TypeFlags.String */ ? [createIndexInfo(stringType, emptyObjectType, /*isReadonly*/ false)] : ts.emptyArray;
68186 return createAnonymousType(undefined, members, ts.emptyArray, ts.emptyArray, indexInfos);
68187 }
68188 /**
68189 * Infer a suitable input type for a homomorphic mapped type { [P in keyof T]: X }. We construct
68190 * an object type with the same set of properties as the source type, where the type of each

Callers 1

inferFromTypesFunction · 0.85

Calls 5

forEachTypeFunction · 0.85
createSymbolFunction · 0.85
createIndexInfoFunction · 0.85
createAnonymousTypeFunction · 0.85
setMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…