MCPcopy Create free account
hub / github.com/nodejs/node / addObjectLiteralProperties

Function addObjectLiteralProperties

test/fixtures/snapshot/typescript.js:155025–155040  ·  view source on GitHub ↗
(changes, context, info)

Source from the content-addressed store, hash-verified

155023 changes.replaceNode(context.sourceFile, jsxAttributesNode, jsxAttributes, options);
155024 }
155025 function addObjectLiteralProperties(changes, context, info) {
155026 var importAdder = codefix.createImportAdder(context.sourceFile, context.program, context.preferences, context.host);
155027 var quotePreference = ts.getQuotePreference(context.sourceFile, context.preferences);
155028 var target = ts.getEmitScriptTarget(context.program.getCompilerOptions());
155029 var checker = context.program.getTypeChecker();
155030 var props = ts.map(info.properties, function (prop) {
155031 var initializer = tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeOfSymbol(prop));
155032 return ts.factory.createPropertyAssignment(ts.createPropertyNameNodeForIdentifierOrLiteral(prop.name, target, quotePreference === 0 /* QuotePreference.Single */), initializer);
155033 });
155034 var options = {
155035 leadingTriviaOption: ts.textChanges.LeadingTriviaOption.Exclude,
155036 trailingTriviaOption: ts.textChanges.TrailingTriviaOption.Exclude,
155037 indentation: info.indentation
155038 };
155039 changes.replaceNode(context.sourceFile, info.parentDeclaration, ts.factory.createObjectLiteralExpression(__spreadArray(__spreadArray([], info.parentDeclaration.properties, true), props, true), /*multiLine*/ true), options);
155040 }
155041 function tryGetValueFromType(context, checker, importAdder, quotePreference, type) {
155042 if (type.flags & 3 /* TypeFlags.AnyOrUnknown */) {
155043 return createUndefined();

Callers 1

typescript.jsFile · 0.85

Calls 2

tryGetValueFromTypeFunction · 0.85
mapMethod · 0.65

Tested by

no test coverage detected