-
Notifications
You must be signed in to change notification settings - Fork 21
Using this plugin gives me typescript compile errors #34
Comments
TypeScript reports an error because there is no module named To illustrate this, imagine we are using There are two work arounds which mitigate this issue.
declare module 'app/components/footer/FooterComponent.html!text' {
export default '';
} Now you can import your template without errors with
export default ''; Personally, while the second approach requires creating more files and is a bit more noisy, I find it to be more maintainable. |
By the way, the TypeScript team is looking to make this easier. See microsoft/TypeScript#6615 |
@dfgkzhang, @guybedford TypeScript 2.0 (2.0.3) was officially released yesterday. It contains new ambient module declaration syntax specifically to handle importing files such as html templates. declare module "*.html" {
const html: string;
export default html;
} // allows importing any .html file and gives it type string
declare module "*.json" {
var json: any[] | { [key: string]: any; };
export default json;
} These wildcards work for any extension. This is no longer an issue for SystemJS users. |
@aluanhaddad I am still having an issue when I try to bundle. I have created an ambient module declaration like this And in my imports var DLATemplate = require('/Template/activity/ActivityDla.html') @component({ This builds fine and works fine unbundled but I am having issues when trying to bundle I also have this line in my system.config
|
That's an odd error, but it's not related to this issue. This issue regards the TypeScript compiler displaying error messages because it did not understand that the HTML files are transformed into modules by the loader. It never had any effect on SystemJS runtime behavior or builder behavior. |
Adding this import to my component, import template as "./FooterComponent.html!text", will cause the typescript compiler to log an error TS2307: Cannot find module './FooterComponent.html!text'. This happens for all html imports, but doesn't happen for css imports using plugin-css. Is it possible to fix this as it causes a lot of noise when compiling typescript.
The text was updated successfully, but these errors were encountered: