feathersjs / feathers

The API and real-time application framework
https://feathersjs.com
MIT License
15.03k stars 748 forks source link

React typescript compilation error when importing Static<typeof userSchema> as type #3133

Closed pipwarrior closed 1 year ago

pipwarrior commented 1 year ago

Steps to reproduce

  1. On my React app, i imported all interfaces from the FeathersJS webserver into a server-interface.ts file export type User = import('../../../../webserver/src/services/users/users.schema').User;

  2. Imported the User interface import { User } from '../server-interface'; export const createUser = (data: Partial<User>): Promise<User> => ( userFeathersService.create(data) );

React compilation error:

TypeScript Errors

Expected behavior

Tell us what should happen

Actual behavior

Tell us what happens instead

System configuration

Tell us about the applicable parts of your setup.

Module versions (especially the part that's not working):

NodeJS version:

Operating System:

Browser Version:

React Native Version:

Module Loader:

daffl commented 1 year ago

It looks like your bundler is pulling in the actual file. This shouldn't happen when importing the typed client itself which also re-exports your application types so you can do:

import type { UserData, User } from 'my-app'