Skip to content
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

Problem: Cannot use angular2-template-loader with webpack-env.d.ts #23

Open
lacolaco opened this issue Sep 5, 2016 · 4 comments
Open

Comments

@lacolaco
Copy link

lacolaco commented Sep 5, 2016

For use webpack APIs (like require.context()), webpack-env.d.ts is needed.
The definition includes its own require.

https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/webpack/webpack-env.d.ts#L21

It returns a value as T. so require() returns the type {}.

error TS2345: Argument of type '{ selector: string; template: {}; }' is not assignable to parameter of type 'ComponentMetadataType'.
  Types of property 'template' are incompatible.
    Type '{}' is not assignable to type 'string'.

idea

Maybe, The loader should replace templateUrl to <string>require(...).

@lacolaco lacolaco changed the title Problem: Cannot use with webpack-env.d.ts Problem: Cannot use angular2-template-loader with webpack-env.d.ts Sep 5, 2016
@TheLarkInn
Copy link
Owner

Oh interesting. I'll welcome a pr and tests for this absolutely.

@DethAriel
Copy link

Does anyone have a workaround for that?

I also feel that replacing stuff with <string>require(...) might interfere with tslint (and tslint-loader) setting of treating such constructs an error. But not sure about this last piece

@DethAriel
Copy link

@TheLarkInn I also think that given the fact that this project's primary consumers are Webpack users, you should really be recommending to install @types/webpack-env

@nertzy
Copy link

nertzy commented Feb 26, 2017

The correct way to require a string with webpack-env.d.ts is

require<string>(...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants