-
-
Notifications
You must be signed in to change notification settings - Fork 943
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
Cannot directly import _Date #778
Comments
Yeah, we could export it, but we should then name it like ... But when we do that, we need to export all module classes as types 🤔 |
@JontyMC As a workaround, try |
Thanks for workaround. The type is in the public API, so it is really external. What would be the downside in exporting it? |
You should probably use the Another workaround: |
Using the _Date instance creates a nicer API, as you would ony ever want to use that module in this case. |
I like both the But I'm unsure whether these names are really easier to use then |
I don't see a downside to exporting the types (probably prefer FakerDate), it might stop someone raising the same issue. Workarounds are fine now I know them. |
faker/src/definitions/definitions.ts Line 69 in b34ef46
So <Thing>Module would be a much better name. I would also not explicitly rename the _Date class, but all modules consistently.
Could you explain what you mean by this? |
The faker.date API is externally facing and has a contract in terms of the functions and properties it provides. I assume these won't change without deprecation and version bump, so in that sense the "type" is officially supported. Given this contract has a type already, it may as well be exported (perhaps it would be better as a typescript type or interface). Also, the typescript _Date class is exported in the dist folder and visual studio auto imports @faker-js/faker/date when I used it. |
Accessing |
Note: The import will probably stop working in v6.2 because we intend to move the modules from |
Describe the bug
After importing the _Date class like this:
import { _Date } from '@faker-js/faker/date';
When running, I get the following error:
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './date' is not defined by "exports" in ******\node_modules\@faker-js\faker\package.json
Reproduction
import { _Date } from '@faker-js/faker/date';
Additional Info
I want to import _Date because I want to use it in a delegate for configuring a test data builder:
date?: (date: _Date) => Date;
The text was updated successfully, but these errors were encountered: