Skip to content

Conversation

@danielfdsilva
Copy link
Member

exclude: ['**/*.test.ts'],
outDir: 'dist',
insertTypesEntry: true,
copyDtsFiles: true,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the essential fix. The .d.ts files are not copied by default, that's why the types are missing.

Comment on lines +24 to +26
beforeWriteFile(filePath, content) {
return filePath.match(/\/(vite|jest)\./) ? false : { filePath, content };
},
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This parts just removes the types created for the config files to keep things clean. They're not needed for anything

@AliceR
Copy link
Member

AliceR commented Dec 18, 2025

Thanks for working on this @danielfdsilva! I've tested this approach and unfortunately the copyDtsFiles: true configuration doesn't solve the interface inheritance bundling issue.

The generated type declarations still contain interface inheritance:

// dist/src/hooks/useItem.d.ts
interface StacItemHook extends StacHook {
    item?: Item;
    refetch: StacRefetchFn<Item>;
}

While the StacHook interface is copied to dist/src/types/index.d.ts, consumers still can't see the inherited properties (isLoading, isFetching, error) when using the hooks. The bundler doesn't flatten the inheritance, leading to TypeScript errors like Property 'isLoading' does not exist on type 'StacItemHook'.

How to Reproduce

# Checkout this branch
git checkout fix/ts.d

# Build the package
yarn build

# Check the generated type declarations
cat dist/src/hooks/useItem.d.ts
# You'll see: interface StacItemHook extends StacHook

# The base interface exists but isn't flattened
cat dist/src/types/index.d.ts
# You'll see the StacHook interface definition

The issue is that interface inheritance isn't being flattened in the declaration files, which causes problems for consuming projects.

Alternative Solution

PR #44 takes a different approach by removing the interface inheritance pattern entirely and using explicit type definitions. This ensures all properties are visible inline in the generated .d.ts files.

What Should Be Kept from This PR

This PR has two valuable changes that should be preserved:

  1. Commit 7b46663: Fix item assets property of stac types

    • Changes assets from array to Record<string, ItemAsset> for STAC spec compliance
    • This is a legitimate bug fix independent of the type bundling issue
  2. Commit fab8e46: Export stac types

    • Adds export * from './types/stac.d' to make types available to consumers
    • Allows consumers to import types like Collection, Item, etc.

I'd suggest we merge PR #44 to fix the inheritance issue, then cherry-pick these two commits in a follow-up PR.

@danielfdsilva
Copy link
Member Author

@AliceR This does keep the inheritance interface. That is intentional. It is a standard feature of typescript and I'd say it is working well.

I had the error you're mentioning as well and this fixes it.
What I did:

  • build the library
  • copy the dist folder to node_modules/@developmentseed/stac-react of the code editor.
  • The isLoading error is gone.

@danielfdsilva danielfdsilva merged commit 65ecf2d into main Dec 18, 2025
4 checks passed
@danielfdsilva danielfdsilva deleted the fix/ts.d branch December 18, 2025 21:30
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