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

Function shouldConvertDeclaration

test/fixtures/snapshot/typescript.js:151179–151202  ·  view source on GitHub ↗
(_target, source)

Source from the content-addressed store, hash-verified

151177 }
151178 return memberElements;
151179 function shouldConvertDeclaration(_target, source) {
151180 // Right now the only thing we can convert are function expressions, get/set accessors and methods
151181 // other values like normal value fields ({a: 1}) shouldn't get transformed.
151182 // We can update this once ES public class properties are available.
151183 if (ts.isAccessExpression(_target)) {
151184 if (ts.isPropertyAccessExpression(_target) && isConstructorAssignment(_target))
151185 return true;
151186 return ts.isFunctionLike(source);
151187 }
151188 else {
151189 return ts.every(_target.properties, function (property) {
151190 // a() {}
151191 if (ts.isMethodDeclaration(property) || ts.isGetOrSetAccessorDeclaration(property))
151192 return true;
151193 // a: function() {}
151194 if (ts.isPropertyAssignment(property) && ts.isFunctionExpression(property.initializer) && !!property.name)
151195 return true;
151196 // x.prototype.constructor = fn
151197 if (isConstructorAssignment(property))
151198 return true;
151199 return false;
151200 });
151201 }
151202 }
151203 function createClassElement(symbol, modifiers, members) {
151204 // Right now the only thing we can convert are function expressions, which are marked as methods
151205 // or { x: y } type prototype assignments, which are marked as ObjectLiteral

Callers 1

createClassElementFunction · 0.85

Calls 2

isConstructorAssignmentFunction · 0.85
everyMethod · 0.80

Tested by

no test coverage detected