-
Notifications
You must be signed in to change notification settings - Fork 74
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
making it possible to include html and jade files #98
Comments
Hi, I got the following transform: the problem is that if I output the module body with the es5 syntax, typescript gives me errors. "use strict";
var through = require("through");
var jade = require("jade");
module.exports = function (fileName, options) {
if (!/\.jade$/i.test(fileName)) {
return through();
}
options.runtimePath = options.runtimePath === undefined ? "jade/runtime" : options.runtimePath;
var inputString = "";
return through(
function (chunk) {
inputString += chunk;
},
function () {
var self = this;
options.filename = fileName;
var result;
try {
result = jade.render(inputString, options);
} catch (e) {
self.emit("error", e);
return;
}
var moduleBody = "" +
"" +
"module.exports = {" +
" html: `" + result + "`\n" +
"};";
//"class Template {\n" +
//" private html:String = `" + result + "`;\n" +
//"}\n" +
//"export Template;"
//"module.exports = function Template () {\n" +
//" return `" + result + "`;\n" +
//"};";
self.queue(moduleBody);
self.queue(null);
}
);
};
|
Hi, I modified the tsify index.js file a little, to insert transforms before setting up the pipeline, but I'm still getting typescript errors saying that: { [TypeScript error: src/components/login-register/login.ts(9,27): Error TS2307: Cannot find module './login.jade'.]
message: 'src/components/login-register/login.ts(9,27): Error TS2307: Cannot find module \'./login.jade\'.',
fileName: 'src/components/login-register/login.ts',
line: 9,
column: 27,
name: 'TypeScript error' }
If I want to make it possible to the following in my ts files:
How can I do this? Thanks! |
You can't make TypeScript know about non-JS imports, but you can sorta hack
That can be in some shared definition file or something. Then you can use
Or whatever. Note the const instead of import. Hopefully that's all valid code, I'm typing this on my phone. On Fri, Nov 27, 2015, 8:12 AM Ge Yang [email protected] wrote:
|
Thanks @smrq! I ended up adding a template.jade.d.ts file for each one of the jade template file, and modify the jadeify transformer to export a module. |
Cool, no problem. Glad it's working out for you. |
Hi,
Thanks for this great module!
I am interested in writing a plugin/transformer to include
.jade
files inside typescript.There is currently a transform called
jadeify
, but it does not work withtsify
.How can I get started?
There is an issue I filed there: using with tsify plugin, only jade in the index.ts file is interpolated
Thanks!
The text was updated successfully, but these errors were encountered: