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

Typescript definition file? #22

Open
charlesr1971 opened this issue Feb 14, 2024 · 0 comments
Open

Typescript definition file? #22

charlesr1971 opened this issue Feb 14, 2024 · 0 comments

Comments

@charlesr1971
Copy link

charlesr1971 commented Feb 14, 2024

This is an absolutely fantastic library! 👏🏻

I was just wondering whether you could create a typescript definition file:

index.d.ts

I want to use this with my node project, which is written in typescript, but when I try and run it, I get:

internal/modules/cjs/loader.js:883
  throw err;
  ^

Error: Cannot find module 'indent'

I am importing it like:

import indent from 'indent.js';

I have also tried:

const indent = require('indent');

And then:

indentCode(code, options) {
    var indented = indent.js(code, options);
    return indented;
}

I think the error is being thrown, because it cannot find a type definition?

UPDATE: 15.02.2024

I have attached the index.d.ts file to this comment.
If you want to add more type definitions, please feel free to do so. I just wanted to provide a quick, easy solution, to allow this library to work with typescript projects.

Add this file to your the following folder:

/lib

And then add this to the top of your js/ts file:

const indent = require(‘indent.js’);

index.d.zip

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

1 participant