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 with codeInput() in sanity.config.ts #105

Open
leeuwd opened this issue Jun 15, 2024 · 2 comments
Open

Type Error with codeInput() in sanity.config.ts #105

leeuwd opened this issue Jun 15, 2024 · 2 comments

Comments

@leeuwd
Copy link

leeuwd commented Jun 15, 2024

Describe the bug

I'm encountering a type error when using the codeInput() function in my Sanity configuration file (sanity.config.ts).

import { defineConfig } from 'sanity'
import { schemas } from './schemas'
import { codeInput } from '@sanity/code-input'

export default defineConfig({
  name: 'default',
  title: 'Something',
  projectId: '123',
  dataset: 'production',
  schema: {
    types: schemas,
  },
  plugins: [codeInput()],
})

Error

Types of property schema are incompatible.
Type 'import("[redacted]/node_modules/sanity/lib/index", { with: { "resolution-mode": "import" } }).SchemaPluginOptions | undefined' is not assignable to type 'import("[redacted]/node_modules/sanity/lib/index").SchemaPluginOptions | undefined'.
Type 'import("[redacted]/node_modules/sanity/lib/index", { with: { "resolution-mode": "import" } }).SchemaPluginOptions' is not assignable to type 'import("[redacted]/node_modules/sanity/lib/index").SchemaPluginOptions'.
Types of property types are incompatible.
Type 'import("[redacted]/node_modules/@sanity/types/lib/index", { with: { "resolution-mode": "import" } }).SchemaTypeDefinition[] | import("[redacted]/node_modules/sanity/lib/index", { with: { "resolution-mode": "import" } }).ComposableOption<import("[redacted]/node_modules/supe...' is not assignable to type 'import("[redacted]/node_modules/@sanity/types/lib/index").SchemaTypeDefinition[] | import("[redacted]/node_modules/sanity/lib/index").ComposableOption<import("[redacted]/node_modules/@sanity/types/lib/index").SchemaTypeDefinition[], Omit<...>> | un...'.
Type SchemaTypeDefinition[] is not assignable to type
SchemaTypeDefinition[] | ComposableOption<SchemaTypeDefinition[], Omit<ConfigContext, 'schema' | 'i18n' | 'currentUser' | 'getClient' | 'client'>> | undefined
Type 'import("[redacted]/node_modules/@sanity/types/lib/index", { with: { "resolution-mode": "import" } }).SchemaTypeDefinition[]' is not assignable to type 'import("[redacted]/node_modules/@sanity/types/lib/index").SchemaTypeDefinition[]'.
Type 'import("[redacted]/node_modules/@sanity/types/lib/index", { with: { "resolution-mode": "import" } }).SchemaTypeDefinition' is not assignable to type 'import("[redacted]/node_modules/@sanity/types/lib/index").SchemaTypeDefinition'.
Type StringDefinition is not assignable to type SchemaTypeDefinition
Type StringDefinition is not assignable to type
StringDefinition | TypeAliasDefinition<string, "string" | "number" | "boolean" | "object" | "document" | "array" | "block" | "date" | "datetime" | "file" | "geopoint" | "image" | ... 5 more ... | "email">
Type 'import("[redacted]/node_modules/@sanity/types/lib/index", { with: { "resolution-mode": "import" } }).StringDefinition' is not assignable to type 'import("[redacted]/node_modules/@sanity/types/lib/index").StringDefinition'.
Types of property validation are incompatible.
Type 'import("[redacted]/node_modules/@sanity/types/lib/index", { with: { "resolution-mode": "import" } }).ValidationBuilder<import("[redacted]/node_modules/@sanity/types/lib/index", { with: { "resolution-mode": "import" } }).StringRule, string> | undefined' is not assignable to type 'import("[redacted]/node_modules/@sanity/types/lib/index").ValidationBuilder<import("[redacted]/node_modules/@sanity/types/lib/index").StringRule, string> | undefined'.
Type 'import("[redacted]/node_modules/@sanity/types/lib/index", { with: { "resolution-mode": "import" } }).ValidationBuilder<import("[redacted]/node_modules/@sanity/types/lib/index", { with: { "resolution-mode": "import" } }).StringRule, string>' is not assignable to type 'import("[redacted]/node_modules/@sanity/types/lib/index").ValidationBuilder<import("[redacted]/node_modules/@sanity/types/lib/index").StringRule, string>'.
Types of parameters rule and rule are incompatible.
Type 'import("[redacted]/node_modules/@sanity/types/lib/index").StringRule' is not assignable to type 'import("[redacted]/node_modules/@sanity/types/lib/index", { with: { "resolution-mode": "import" } }).StringRule'.
Types of property regex are incompatible.
Type '{ (pattern: RegExp, name: string, options: { name?: string | undefined; invert?: boolean | undefined; }): import("[redacted]/node_modules/@sanity/types/lib/index").StringRule; (pattern: RegExp, options: { ...; }): import("[redacted]/node_modules/@sanity/types/lib/index")...' is not assignable to type '{ (pattern: RegExp, name: string, options: { name?: string | undefined; invert?: boolean | undefined; }): import("[redacted]/node_modules/@sanity/types/lib/index", { with: { "resolution-mode": "import" } }).StringRule; (pattern: RegExp, options: { ...; }): import("[redacted]/node_modules/superco...'.
Target signature provides too few arguments. Expected 3 or more, but got 2

Which versions of Sanity are you using?

@sanity/cli (global)          3.46.1 (up to date)
@sanity/code-input             4.1.4 (up to date)
@sanity/eslint-config-studio   4.0.0 (up to date)
@sanity/icons                  3.2.0 (up to date)
@sanity/ui                     2.3.6 (up to date)
@sanity/vision                3.46.1 (up to date)
sanity                        3.46.1 (up to date)

What operating system are you using?

macOS

Which versions of Node.js / npm are you running?

10.2.4
v20.11.1

Additional context

Turborepo monorepo.

@leeuwd
Copy link
Author

leeuwd commented Jun 15, 2024

In addition, the import:

TS1479: The current file is a CommonJS module whose imports will produce require calls; however, the referenced file is an ECMAScript module and cannot be imported with require. Consider writing a dynamic import(@sanity/code-input)' call instead.
To convert this file to an ECMAScript module, change its file extension to .mts, or add the field `type: module` to

@leeuwd
Copy link
Author

leeuwd commented Aug 9, 2024

@snorrees, is this plugin EOL? Tagging you since you seem to be the main contributor.

The type issue is still present.

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

No branches or pull requests

1 participant