Skip to content

Typescript definition file? #22

@charlesr1971

Description

@charlesr1971

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions