Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@goloveychuk
Last active April 28, 2017 10:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goloveychuk/77b924debd948dafd7b53e6d41e48946 to your computer and use it in GitHub Desktop.
Save goloveychuk/77b924debd948dafd7b53e6d41e48946 to your computer and use it in GitHub Desktop.
[at-loader]: Child process failed to process the request: TypeError: Cannot read property 'exports' of undefined
at resolveName (/Users/badim/github/orzo/orzo-frontend/node_modules/typescript/lib/typescript.js:26110:70)
at resolveEntityName (/Users/badim/github/orzo/orzo-frontend/node_modules/typescript/lib/typescript.js:26686:26)
at Object.getTypeReferenceSerializationKind (/Users/badim/github/orzo/orzo-frontend/node_modules/typescript/lib/typescript.js:45669:31)
at serializeTypeReferenceNode (/Users/badim/github/orzo/orzo-frontend/node_modules/typescript/lib/typescript.js:50023:30)
at serializeTypeNode (/Users/badim/github/orzo/orzo-frontend/node_modules/typescript/lib/typescript.js:49967:28)
at serializeUnionOrIntersectionType (/Users/badim/github/orzo/orzo-frontend/node_modules/typescript/lib/typescript.js:49989:44)
at serializeTypeNode (/Users/badim/github/orzo/orzo-frontend/node_modules/typescript/lib/typescript.js:49970:28)
at serializeReturnTypeOfNode (/Users/badim/github/orzo/orzo-frontend/node_modules/typescript/lib/typescript.js:49898:24)
at addOldTypeMetadata (/Users/badim/github/orzo/orzo-frontend/node_modules/typescript/lib/typescript.js:49767:98)
at addTypeMetadata (/Users/badim/github/orzo/orzo-frontend/node_modules/typescript/lib/typescript.js:49755:17)
at transformAllDecoratorsOfDeclaration (/Users/badim/github/orzo/orzo-frontend/node_modules/typescript/lib/typescript.js:49594:13)
at generateClassElementDecorationExpression (/Users/badim/github/orzo/orzo-frontend/node_modules/typescript/lib/typescript.js:49641:40)
at generateClassElementDecorationExpressions (/Users/badim/github/orzo/orzo-frontend/node_modules/typescript/lib/typescript.js:49621:34)
at addClassElementDecorationStatements (/Users/badim/github/orzo/orzo-frontend/node_modules/typescript/lib/typescript.js:49606:44)
at visitClassDeclaration (/Users/badim/github/orzo/orzo-frontend/node_modules/typescript/lib/typescript.js:48966:13)
at visitTypeScript (/Users/badim/github/orzo/orzo-frontend/node_modules/typescript/lib/typescript.js:48822:28)
at visitorWorker (/Users/badim/github/orzo/orzo-frontend/node_modules/typescript/lib/typescript.js:48637:24)
at sourceElementVisitorWorker (/Users/badim/github/orzo/orzo-frontend/node_modules/typescript/lib/typescript.js:48669:28)
at saveStateAndInvoke (/Users/badim/github/orzo/orzo-frontend/node_modules/typescript/lib/typescript.js:48590:27)
at sourceElementVisitor (/Users/badim/github/orzo/orzo-frontend/node_modules/typescript/lib/typescript.js:48651:20)
at visitNodes (/Users/badim/github/orzo/orzo-frontend/node_modules/typescript/lib/typescript.js:47199:48)
at Object.visitLexicalEnvironment (/Users/badim/github/orzo/orzo-frontend/node_modules/typescript/lib/typescript.js:47232:22)
import * as ts from 'typescript';
function Transformer(context: ts.TransformationContext) {
let n = 1
function addDecorator(node: ts.Node) {
if (node.decorators === undefined) {
return undefined
}
let newDecorators = ts.createNodeArray(node.decorators.concat())
// const assign = ts.createPropertyAssignment("sd", ts.createLiteral(n))
// const value = ts.createObjectLiteral([assign])
// const decCall = ts.createCall(ts.createIdentifier('Reflect.metadata'), undefined, [ts.createLiteral("key"), value])
// const dec = ts.createDecorator(decCall)
// newDecorators.push(dec)
newDecorators = ts.setTextRange(newDecorators, node.decorators)
return newDecorators
}
function visitClassDeclaration(node: ts.ClassDeclaration) {
const newDecorators = addDecorator(node)
let newNode = ts.updateClassDeclaration(node, newDecorators, node.modifiers,
node.name, node.typeParameters, node.heritageClauses || [], node.members)
return ts.setTextRange(newNode, node)
}
function visitor(node: ts.Node): ts.VisitResult<ts.Node> {
switch (node.kind) {
case ts.SyntaxKind.ClassDeclaration:
return visitClassDeclaration(<ts.ClassDeclaration>node)
default:
return node
}
}
function transform(source: ts.SourceFile): ts.SourceFile {
if (source.isDeclarationFile) {
return source
}
const newStatements = ts.visitLexicalEnvironment(source.statements, visitor, context)
const newNode = ts.updateSourceFileNode(source, ts.setTextRange(newStatements, source.statements))
return newNode
}
return transform
}
function TranformerFactory(context: ts.TransformationContext) {
const tran = Transformer(context)
return tran;
}
export default function (): ts.CustomTransformers {
return {
before: [TranformerFactory]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment