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: explored-types: add 'type' to core types import, silencing webpack empty export warning #699

Merged
merged 1 commit into from
Aug 26, 2024

Conversation

telestrial
Copy link
Contributor

@telestrial telestrial commented Aug 26, 2024

In creating this PR: #698

I discovered a webpack-related warning for our import of core types in the explored-types. By doing:

import { Address, ... } from '@siafoundation/types'

this led to an avalanche of warnings like so:

export 'Address' (reexported as 'Address') was not found in '@siafoundation/types' (module has no exports)

By adding the 'type' at the top of types.ts:

import type { Address, ... } from '@siafoundation/types'

this warning no longer sounds. I believe this has to do with some bare metal typescript -> javascript transpilation + importing rules at the webpack level. There was no obvious bug/misbehavior as a result of the former implementation. The library worked, from what I tested, and types were valid/enforced, even with this warning.

In terms of where to put the type keyword, I believe from testing one could also do it here:

export type {
  Address,
  Block,
  BlockID,
  ...
}

but I like it at the import better. Everything 'up the tree' or neighboring (but also importing from) either explicitly defines a type to export, uses these core imported types, and/or uses primitives. In some sense, putting it at the import strikes at "a single source of truth"--our core types. This import is the parent of everything in this library beyond primitives, so it seems right at this spot.

For more information about the warning/solution, see this comment and the rest of the thread.

Copy link

vercel bot commented Aug 26, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

5 Skipped Deployments
Name Status Preview Comments Updated (UTC)
explorer ⬜️ Ignored (Inspect) Visit Preview Aug 26, 2024 8:07pm
explorer-zen ⬜️ Ignored (Inspect) Visit Preview Aug 26, 2024 8:07pm
hostd ⬜️ Ignored (Inspect) Visit Preview Aug 26, 2024 8:07pm
renterd ⬜️ Ignored (Inspect) Visit Preview Aug 26, 2024 8:07pm
website ⬜️ Ignored (Inspect) Visit Preview Aug 26, 2024 8:07pm

Copy link

changeset-bot bot commented Aug 26, 2024

🦋 Changeset detected

Latest commit: ff362cd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@siafoundation/explored-types Minor
@siafoundation/explored-js Patch
@siafoundation/explored-react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

.changeset/spicy-clouds-deliver.md Outdated Show resolved Hide resolved
libs/explored-types/src/types.ts Show resolved Hide resolved
@telestrial telestrial force-pushed the fix-explored-types-export-warning branch from 5aecb9a to ff362cd Compare August 26, 2024 20:06
@alexfreska alexfreska self-requested a review August 26, 2024 20:14
@telestrial telestrial merged commit aea0797 into main Aug 26, 2024
17 checks passed
@telestrial telestrial deleted the fix-explored-types-export-warning branch August 26, 2024 20:50
alexfreska pushed a commit that referenced this pull request Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants