Skip to content
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

fix: fix incorrect path for types in index.d.ts #193

Closed
wants to merge 1 commit into from

Conversation

amk-dev
Copy link
Contributor

@amk-dev amk-dev commented Dec 27, 2024

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.

Copy link

vercel bot commented Dec 27, 2024

@amk-dev is attempting to deploy a commit to the Antiwork Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

vercel bot commented Dec 27, 2024

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

@m2rads
Copy link
Contributor

m2rads commented Dec 27, 2024

@amk-dev thanks for the PR. Once you have the conflicts resolved I will test your branch and let you know.

@amk-dev amk-dev force-pushed the fix/incorrect-types branch from 8688d16 to 6684b32 Compare December 27, 2024 22:28
@amk-dev
Copy link
Contributor Author

amk-dev commented Dec 27, 2024

just rebased.

@amk-dev
Copy link
Contributor Author

amk-dev commented Dec 27, 2024

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.

image

how do you want to handle it ?

@m2rads

@slavingia
Copy link
Contributor

Why do we have a types folder within a types folder?

@amk-dev
Copy link
Contributor Author

amk-dev commented Dec 28, 2024

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.

image

@m2rads
Copy link
Contributor

m2rads commented Dec 29, 2024

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.

image

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.

image how do you want to handle it ?

@m2rads

@slavingia
Copy link
Contributor

Makes sense to do for Anthropic API key. Mailosaur isn't causing an issue as optional so imo better to expose in the config.

@amk-dev amk-dev closed this by deleting the head repository Dec 30, 2024
@amk-dev
Copy link
Contributor Author

amk-dev commented Dec 30, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants