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

Type error: Don't use {} as a type #332

Closed
probablykasper opened this issue Aug 28, 2022 · 4 comments · Fixed by #334 or supabase/cli#427
Closed

Type error: Don't use {} as a type #332

probablykasper opened this issue Aug 28, 2022 · 4 comments · Fixed by #334 or supabase/cli#427
Labels
bug Something isn't working

Comments

@probablykasper
Copy link

probablykasper commented Aug 28, 2022

Bug report

Describe the bug

With v2 I get this error after having generated types, probably because of TS strict mode:

Don't use `{}` as a type. `{}` actually means "any non-nullish value".
- If you want a type meaning "any object", you probably want `Record<string, unknown>` instead.
- If you want a type meaning "any value", you probably want `unknown` instead.
- If you want a type meaning "empty object", you probably want `Record<string, never>` instead.

due to the generated types including this:

export interface Database {
		Functions: {}
	}
}

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

TypeScript strict mode probably needs to be enabled.
Run supabase gen types typescript --local > databaseDefinitions.ts

System information

  • OS: macOS
  • Version of supabase-js: 2.0.0-rc.6
  • Version of Node.js: 16.15.0
@probablykasper probablykasper added the bug Something isn't working label Aug 28, 2022
@soedirgo soedirgo transferred this issue from supabase/supabase-js Aug 29, 2022
@soedirgo
Copy link
Member

The error seems to be coming from typescript-eslint. What do you suggest the replacement should be? Record<string, never> is not exactly correct, see microsoft/TypeScript#47486 (comment)

@probablykasper
Copy link
Author

I don't really see why Record<string, never> doesn't fit. It doesn't seem like it's supposed to have any properties, so why would you ever need to access it's properties?

@soedirgo
Copy link
Member

It needs to give a TS error when accessing a property, whereas Record<string, never> allows accessing properties (with value of type never).

@soedirgo
Copy link
Member

Actually, Record<never, never> seems to work. It resolves to {} but seems to fool ts-eslint somehow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants