loggly / loggly-jslogger

Client-side (browser) logger to use with Loggly v2
79 stars 52 forks source link

Could not find a declaration file for module 'loggly-jslogger' #60

Closed anurag55555 closed 3 years ago

anurag55555 commented 3 years ago

I have been trying to send my logs to Loggly using loggly-jslogger, but I am unable to do so. I installed the package using npm-- 'npm i loggly-jslogger'.

I created the logger as shown :

import { LogglyTracker } from 'loggly-jslogger';

const logger = new LogglyTracker();

logger.push({ 'logglyKey': 'MY_CUSTOMER_TOKEN' });

export default logger;

but the error due to very first line of the code states- "Could not find a declaration file for module 'loggly-jslogger'. '/home/Desktop/LOgginAttempt/node_modules/loggly-jslogger/index.js' implicitly has an 'any' type. Try npm i --save-dev @types/loggly-jslogger if it exists or add a new declaration (.d.ts) file containing declare module 'loggly-jslogger';"

can you please suggest as to why I am facing this issue?

kevineaton commented 3 years ago

That is a general error for any library in a Typescript environment that does not come with a type declaration file. I haven't seen one for this library (just started trying it out today) so I had to add a generic module declaration in my app. This isn't strictly a loggly error, as you will see that message for any untyped-library. Loggly could fix it by providing a type declaration, but in the meantime you can bypass it either in your typescript configuration or adding a declared module, similar to:

declare module 'loggly-jslogger';

I put that in a types.d.ts then referenced it by adding the following line to the top of my index.tsx file:

/// <reference path="../types.d.ts" />

Hope that helps!

anurag55555 commented 3 years ago

Thank you that solved my issue.