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

Function addJsxAttributes

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

Source from the content-addressed store, hash-verified

155005 changes.insertNodeAtEndOfScope(info.sourceFile, info.parentDeclaration, functionDeclaration);
155006 }
155007 function addJsxAttributes(changes, context, info) {
155008 var importAdder = codefix.createImportAdder(context.sourceFile, context.program, context.preferences, context.host);
155009 var quotePreference = ts.getQuotePreference(context.sourceFile, context.preferences);
155010 var checker = context.program.getTypeChecker();
155011 var jsxAttributesNode = info.parentDeclaration.attributes;
155012 var hasSpreadAttribute = ts.some(jsxAttributesNode.properties, ts.isJsxSpreadAttribute);
155013 var attrs = ts.map(info.attributes, function (attr) {
155014 var value = tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeOfSymbol(attr));
155015 var name = ts.factory.createIdentifier(attr.name);
155016 var jsxAttribute = ts.factory.createJsxAttribute(name, ts.factory.createJsxExpression(/*dotDotDotToken*/ undefined, value));
155017 // formattingScanner requires the Identifier to have a context for scanning attributes with "-" (data-foo).
155018 ts.setParent(name, jsxAttribute);
155019 return jsxAttribute;
155020 });
155021 var jsxAttributes = ts.factory.createJsxAttributes(hasSpreadAttribute ? __spreadArray(__spreadArray([], attrs, true), jsxAttributesNode.properties, true) : __spreadArray(__spreadArray([], jsxAttributesNode.properties, true), attrs, true));
155022 var options = { prefix: jsxAttributesNode.pos === jsxAttributesNode.end ? " " : undefined };
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);

Callers 1

typescript.jsFile · 0.85

Calls 3

tryGetValueFromTypeFunction · 0.85
someMethod · 0.80
mapMethod · 0.65

Tested by

no test coverage detected