1

I am attempting to use an npm module, pretty-file-icons, within my Ionic/Angular app. From what I can tell, this module does not have typings.

I tried adding declare module 'pretty-file-icons' to src/typings.d.ts and then, within a component using:

import * as prettyFileIcons from 'pretty-file-icons';
export class HandoutsPage {
  constructor(public fileIcons: prettyFileIcons) {}
}

Using this, I get the error Can't resolve all parameters for Handouts Page. I have found several help articles online for this, but they all seem to be for SystemJS but, as I understand it, that has been replaced by Webpack.

How do I import this module so that I can use it within components?

1 Answer 1

1
import * as prettyFileIcons from 'pretty-file-icons';

You should't inject it in the constructor, use it directly:

console.log(prettyFileIcons.getIcon('test.csv'));
console.log(prettyFileIcons.getIcon('test.csv', 'svg'));
console.log(prettyFileIcons.getIcon('.test', 'svg'));

// Prints:
// csv
// csv.svg
// unknown.svg
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.