Skip to content

'DEFAULT_EXTENSIONS' is referenced directly or indirectly in its own type annotation. #476

Answered by fabian-hiller
babakfp asked this question in Q&A
Discussion options

You must be logged in to vote

The problem is that you are defining a type with itself. The interdependency cannot be resolved by the TypeScript language server. Here is a simple fix:

import * as v from 'valibot';

const abc: string[] = ['.svelte.md'];

const ConfigSchema = v.optional(
  v.object({
    extensions: v.optional(
      v.array(v.string([v.regex(/^\.[a-z]+(\.[a-z]+)?$/)]), [v.minLength(1)]),
      abc
    ),
  }),
  {}
);

type Config = v.Output<typeof ConfigSchema>;

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by fabian-hiller
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants