Currently, I'm attempting to integrate into my Angular project built on the latest version.
After discovering this definition file:
// Type definitions for Hashids.js 1.x
// Project: https://github.com/ivanakimov/hashids.node.js
// Definitions by: Paulo Cesar <https://github.com/pocesar>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
export default class Hashids {
private version: string;
private minAlphabetLength: number;
private sepDiv: number;
private guardDiv: number;
private errorAlphabetLength: string;
private errorAlphabetSpace: string;
private alphabet: string[];
private seps: string;
private minHashLength: number;
private salt: string;
constructor(salt: string, minHashLength?: number, alphabet?: string);
public decode(hash: string): number[];
public encode(arg: number): string;
public encode(arg: number[]): string;
public encode(...args: number[]): string;
public encodeHex(str: string): string;
public decodeHex(hash: string): string;
public hash(input: number, alphabet: string): string;
public unhash(input: string[], alphabet: string): number;
}
When trying to implement it in my Angular project using the following code snippet:
import * as Hashids from 'hashids';
export abstract class BaseService {
protected getId(id: any) {
const x = new Hashids('somesecretec');
return x.encode(id);
}
}
An error message is displayed:
Error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
While testing locally, everything works fine. However, when I attempted to compile in a production environment, the issue arose.