nextui-org / tailwind-variants

🦄 Tailwindcss first-class variant API
https://tailwind-variants.org
MIT License
2.42k stars 68 forks source link

Typescript type V TVVariantsDefault errors. #103

Closed cythrawll closed 1 year ago

cythrawll commented 1 year ago

Describe the bug Typescript shows a number of errors

node_modules/tailwind-variants/dist/index.d.ts:216:35 - error TS2344: Type 'V' does not satisfy the constraint 'TVVariantsDefault<S, undefined>'.
  Type 'TVVariants<S, B, EV, undefined>' is not assignable to type 'TVVariantsDefault<S, undefined>'.
    Type 'TVVariantsDefault<S, B> | { [K in keyof EV]?: { [K2 in keyof EV[K]]?: (S extends TVSlots ? ClassValue | SlotsClassValue<S, B> : ClassValue) | undefined; } | undefined; }' is not assignable to type 'TVVariantsDefault<S, undefined>'.
      Type '{ [K in keyof EV]?: { [K2 in keyof EV[K]]?: (S extends TVSlots ? ClassValue | SlotsClassValue<S, B> : ClassValue) | undefined; } | undefined; }' is not assignable to type 'TVVariantsDefault<S, undefined>'.
        Type '{ [K2 in keyof EV[K]]?: (S extends TVSlots ? ClassValue | SlotsClassValue<S, B> : ClassValue) | undefined; } | undefined' is not assignable to type '{ [key: string]: S extends TVSlots ? ClassValue | SlotsClassValue<S, undefined> : ClassValue; }'.
          Type 'undefined' is not assignable to type '{ [key: string]: S extends TVSlots ? ClassValue | SlotsClassValue<S, undefined> : ClassValue; }'.
            Type 'TVVariants<S, B, TVVariants<ES, B, E["variants"], ES>, undefined>' is not assignable to type 'TVVariantsDefault<S, undefined>'.
              Type 'TVVariantsDefault<S, B> | { [K in keyof TVVariants<ES, B, E["variants"], ES>]?: { [K2 in keyof TVVariants<ES, B, E["variants"], ES>[K]]?: (S extends TVSlots ? ClassValue | SlotsClassValue<...> : ClassValue) | undefined; } | undefined; }' is not assignable to type 'TVVariantsDefault<S, undefined>'.
                Type '{ [K in keyof TVVariants<ES, B, E["variants"], ES>]?: { [K2 in keyof TVVariants<ES, B, E["variants"], ES>[K]]?: (S extends TVSlots ? ClassValue | SlotsClassValue<...> : ClassValue) | undefined; } | undefined; }' is not assignable to type 'TVVariantsDefault<S, undefined>'.
                  Type '{ [K2 in keyof TVVariants<ES, B, E["variants"], ES>[K]]?: (S extends TVSlots ? ClassValue | SlotsClassValue<S, B> : ClassValue) | undefined; } | undefined' is not assignable to type '{ [key: string]: S extends TVSlots ? ClassValue | SlotsClassValue<S, undefined> : ClassValue; }'.
                    Type 'undefined' is not assignable to type '{ [key: string]: S extends TVSlots ? ClassValue | SlotsClassValue<S, undefined> : ClassValue; }'.
                      Type 'TVVariantsDefault<S, B> | { [x: string]: { [x: string]: (S extends TVSlots ? ClassValue | SlotsClassValue<S, B> : ClassValue) | undefined; } | undefined; }' is not assignable to type 'TVVariantsDefault<S, undefined>'.
                        Type '{ [x: string]: { [x: string]: (S extends TVSlots ? ClassValue | SlotsClassValue<S, B> : ClassValue) | undefined; } | undefined; }' is not assignable to type 'TVVariantsDefault<S, undefined>'.
                          'string' index signatures are incompatible.
                            Type '{ [x: string]: (S extends TVSlots ? ClassValue | SlotsClassValue<S, B> : ClassValue) | undefined; } | undefined' is not assignable to type '{ [key: string]: S extends TVSlots ? ClassValue | SlotsClassValue<S, undefined> : ClassValue; }'.
                              Type 'undefined' is not assignable to type '{ [key: string]: S extends TVSlots ? ClassValue | SlotsClassValue<S, undefined> : ClassValue; }'.

216     CV extends TVCompoundVariants<V, S, B, EV, ES>,
                                      ~

node_modules/tailwind-variants/dist/index.d.ts:217:34 - error TS2344: Type 'V' does not satisfy the constraint 'TVVariantsDefault<S, undefined>'.

217     DV extends TVDefaultVariants<V, S, EV, ES>,
                                     ~

node_modules/tailwind-variants/dist/index.d.ts:223:7 - error TS2344: Type 'V' does not satisfy the constraint 'TVVariantsDefault<S, undefined>'.

223       V,
          ~

node_modules/tailwind-variants/dist/index.d.ts:263:39 - error TS2344: Type 'V' does not satisfy the constraint 'TVVariantsDefault<S, undefined>'.

263       compoundSlots?: TVCompoundSlots<V, S, B>;
                                          ~

node_modules/tailwind-variants/dist/index.d.ts:275:19 - error TS2344: Type 'V' does not satisfy the constraint 'TVVariantsDefault<S, undefined>'.

275   ): TVReturnType<V, S, B, C, EV, ES, E>;
                      ~

Found 7 errors in 2 files.

To Reproduce Typescript 4.8.4 use react-aria and tsc

tsconfig:

"compilerOptions": {
    "esModuleInterop": true,
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "jsx": "react-jsx",
    "target": "ES2019",
    "module": "ES2022",
    "strict": true,
    "allowJs": true,
}

Expected behavior Not have typescript errors

Additional context Add any other context about the problem here.

mskelton commented 1 year ago

What version of tailwind-variants are you using? There shouldn't be any TypeScript errors in the latest version.

mskelton commented 1 year ago

Closing due to lack of response.