fix: fix incorrect path for types in index.d.ts
Fixs #191
Changes
Previously when the package is bundled, index.d.ts had incorrect paths for some imports. this makes the ShortestConfig from @antiwork/shortest not resolve properly.
here's the file structure of the published package ( i've removed irrelevent files from the tree )
@antiwork/shortest/
├── dist/
│ └── types/
│ └── types/
│ ├── config.d.ts
│ └── test.d.ts
└── index.d.ts
so the imports in index.d.ts had two wrong imports
-
./dist/types/test -
./dist/types/config
both will not resolve, the correct paths are
-
./dist/types/types/test -
./dist/types/types/config
this PR makes that update.
note: as discussed in the issue, there are room for improvement in the generation of index.d.ts. I'm gathering context for that. but since this is a rather important fix (imo). raising a PR.
@amk-dev is attempting to deploy a commit to the Antiwork Team on Vercel.
A member of the Team first needs to authorize it.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
| Name | Status | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| shortest | ❌ Failed (Inspect) | Dec 29, 2024 11:14am |
@amk-dev thanks for the PR. Once you have the conflicts resolved I will test your branch and let you know.
just rebased.
since the type for ShortestConfig is in effect, there are some type errors in shortest/shortest.config.ts, that's causing the CI to fail i think.
how do you want to handle it ?
@m2rads
Why do we have a types folder within a types folder?
Why do we have a types folder within a types folder?
the build:types command is building types for src into dist/types, src has another folder named types. so types/types becomes a thing.
instead of updating the index.d.ts like i did in this PR, may be we can just build the types into dist instead of dist/types, that would eliminate the double types path. but need to see if it breaks any other imports / overwrites something.
I think this error is happening because in types/config.ts we are enforcing the anthropicApiKey to be string but the type for process.env.ANTHROPIC_API_KEY is string | undefined therefore typescript is now correctly identifying the type issue here. IMO we could just directly use process.env.ANTHROPIC_API_KEY inside client.ts file where our AI implementation exists. This would remove the need for end users to specify their API key in the config file. Sort of like nextjs AI sdk where it reads the API keys internally. Same with Mailosaur. @slavingia what do you think? If not then we can just update the types to be string | undefined or instruct ts to not be strict about this somehow.
since the type for
ShortestConfigis in effect, there are some type errors inshortest/shortest.config.ts, that's causing the CI to fail i think.how do you want to handle it ?
@m2rads
Makes sense to do for Anthropic API key. Mailosaur isn't causing an issue as optional so imo better to expose in the config.
this was accidently closed when i removed the forked repo from my account not remembering this PR was open. let me know if i should reopen this. but if there are plans for #205 to auto generate index.d.ts, this PR is not needed.
I've shared some ideas on the same on #205 . not making a PR for that issue, because it was assigned to @m2rads.
how do you want to handle it ?