-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't get this to work with a simple example #3
Comments
Currently transformers work only with js files in commonjs style. export default function(/*opts?: Opts*/) Work transformer version //transform.js
'use strict';
var ts = require('typescript');
function visitor(ctx, sf, opts) {
var visitor = function(node) {
if (ts.isCallExpression(node) && ts.getTextOfNodeFromSourceText(sf.text, node.expression)) {
var target = node.arguments[0];
if (ts.isPropertyAccessExpression(target)) {
return ts.createBinary(
target.expression, // the left hand operand is the object
ts.SyntaxKind.AmpersandAmpersandToken, // the && operator
target
);
}
}
return ts.visitEachChild(node, visitor, ctx);
};
return visitor;
}
module.exports = function(ctx) {
return function(sf) {
return ts.visitNode(sf, visitor(ctx, sf, {}));
};
}; |
Thanks for your help. I copied your transform.js and changed tsconfig.json to: {
"compilerOptions": {
"customTransformers": {
"before": [
"./transform.js"
]
}
}
} But the |
I've publish new version(1.0.5) that can works with transformers written in ts |
Nice, I tried the example and it does work for me when I run (Also, I noticed you committed an out of date |
When you run |
Ah, thanks. That's kind of confusing behaviour but I haven't used |
Yeah, you right, maybe in the next version I'll add this feature |
Thanks again for this project and your help. I feel like with the addition of an example this is resolved. |
I took this simple example from this blog post but I couldn't get it to run:
tsconfig.json
I ran:
Result:
Expected:
The text was updated successfully, but these errors were encountered: