timdeschryver / zod-fixture

Creating fixtures based on zod schemas
https://zod-fixture.timdeschryver.dev/
MIT License
121 stars 10 forks source link

Cannot import `createFixture` or `Fixture` #69

Closed a3957273 closed 1 year ago

a3957273 commented 1 year ago

On zod-fixture@2.1.0 it seems like neither Fixture nor createFixture are exported from the TypeScript definitions.

Screenshot 2023-07-17 at 23 15 21 Screenshot 2023-07-17 at 23 15 37

THEtheChad commented 1 year ago

Hrmmm, interesting.

Not only do I see Fixture and createFixture, but I also have all of the default generators.

Screenshot 2023-07-17 at 9 44 20 PM

Did you install a previous version or is this a fresh copy of zod-fixture@2.1.0? Also, what version of Typescript are you using? Maybe include your tsconfig as well.

THEtheChad commented 1 year ago

I'm pretty sure this is linked to our use of wildcard exports but without additional information I can't reproduce.

// public.ts
export * from '@/fixture'; // <-- for some reason, your environment doesn't like this
export { Generator } from '@/transformer/generator';
export {
    ConstrainedTransformer,
    Transformer,
    UnconstrainedTransformer,
} from '@/transformer/transformer';
drewlyton commented 1 year ago

👋 also ran into this issue on "typescript": "^5.1.6" but upgrading to "zod-fixture": "^2.1.3" solved the issue.

timdeschryver commented 1 year ago

Closing this issue, feel free to reopen with a reproduction.

significantotter commented 1 year ago

Reproduced here, TS version 5.2.2, zod-fixture version 2.5.0

https://github.com/significantotter/zod-fixture-import-error

timdeschryver commented 1 year ago

Reproduced here, TS version 5.2.2, zod-fixture version 2.5.0

https://github.com/significantotter/zod-fixture-import-error

@significantotter take a look at https://www.totaltypescript.com/relative-import-paths-need-explicit-file-extensions-in-ecmascript-imports . Do you need to be on "NodeNext" ?

significantotter commented 11 months ago

Reproduced here, TS version 5.2.2, zod-fixture version 2.5.0 https://github.com/significantotter/zod-fixture-import-error

@significantotter take a look at https://www.totaltypescript.com/relative-import-paths-need-explicit-file-extensions-in-ecmascript-imports . Do you need to be on "NodeNext" ?

Sorry for the delay in responding! Been a busy week with the holiday. I have done an insane amount of trial and error with ts import paths and build targets. It feels like every tool like knex or jest or vitest or discord.js have different configurations that are or are not valid, and NodeNext ends up being pretty much the only module resolution setting that I can get to properly work with all my tooling. Furthermore, NodeNext is the recommended module resolution by typescript, and the default for a tsconfig. So I imagine that I won't be the only one running into this issue. The ts config docs recommend against using anything other than nodenext/node16 for most purposes.

In fact, the official ts docs go so far as to say:

node16 and nodenext are the only correct module options for all apps and libraries that are intended to run in Node.js v12 or later, whether they use ES modules or not.

github-actions[bot] commented 11 months ago

:tada: This issue has been resolved in version 2.5.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

timdeschryver commented 11 months ago

@significantotter thanks for bringing this to my attention again (and thanks for the reproduction!) because I forgot about it. v2.5.1 should fix this problem.