any-date-parser icon indicating copy to clipboard operation
any-date-parser copied to clipboard

Wrong Typescript exports

Open jhmen opened this issue 1 year ago • 4 comments

Hi, I have tried to import the Parser and format classes. But I'm getting an error that the any-date-parser package does not export the classes. I think that in the index.d.ts file, the exports in the declare module "any-date-parser" section are missing.

Used import Syntax: import { Parser, Format } from 'any-date-parser'; Error: Vue: Module  'any-date-parser'  has no exported member  Parser

I think this might be a solution:

declare module "any-date-parser" {
    export default parser;
    export = { Parser, Format };
    const parser: Parser;
    import Parser = require("src/Parser/Parser");
    import Format = require("src/Format/Format");
}

But I don't know if this is best practice

jhmen avatar Nov 16 '23 12:11 jhmen

I can also confirm the faulty typescript declarations.

mohsentaleb avatar Mar 27 '24 12:03 mohsentaleb

There are multiple ways to tackle this issue:

  1. Use the typeof operator
  2. Import the classes from those files directly

These typings aren't faulty at all. BTW, using the export = syntax, you can only have a default export and nothing else. This is probably why the developer didn't export those classes.

NanderTGA avatar Jun 18 '24 18:06 NanderTGA

Faulty as hell. Type definitions are not good at all. I cannot import dayMonthYear for example, since typing defines location "src/formats/dayMonthYear/dayMonthYear" but this location is absolute, not relative to the module, so cannot be resolved on compile time.

uhrb avatar Jun 28 '24 14:06 uhrb

Yeah I agree now

NanderTGA avatar Jul 02 '24 09:07 NanderTGA