any-date-parser
any-date-parser copied to clipboard
Wrong Typescript exports
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
I can also confirm the faulty typescript declarations.
There are multiple ways to tackle this issue:
- Use the
typeof operator
- 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.
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.
Yeah I agree now