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

Types are not bundled #94

Closed
tanguyMichardiere opened this issue Mar 6, 2022 · 4 comments · Fixed by #89
Closed

Types are not bundled #94

tanguyMichardiere opened this issue Mar 6, 2022 · 4 comments · Fixed by #89
Labels
bug Something isn't working

Comments

@tanguyMichardiere
Copy link

When using this package with TypeScript, the compiler complains about any values.
I checked the bundled package directory and there is only one .ts file:

/dist
    /index.d.ts
    /index.js
    /index.modern.js
    /index.umd.js
/package.json
/README.md

And dist/index.d.ts is:

import React from 'react';
import { ThemeProviderProps, UseThemeProps } from './types';
export declare const useTheme: () => UseThemeProps;
export declare const ThemeProvider: React.FC<ThemeProviderProps>;

It tries to import the types from ./types but this file doesn't exist, so it replaces ThemeProviderProps and UseThemeProps with any.

@laozhu
Copy link

laozhu commented Mar 16, 2022

Types have not publish to NPM

@guijiangheng
Copy link

Same issue with version 0.1.1, types not included

@kayk1m
Copy link

kayk1m commented Mar 29, 2022

I temporarily made next-themes.d.ts.

declare module 'next-themes' {
  interface ValueObject {
    [themeName: string]: string;
  }

  interface UseThemeProps {
    /** List of all available theme names */
    themes: string[];
    /** Forced theme name for the current page */
    forcedTheme?: string;
    /** Update the theme */
    setTheme: (theme: string) => void;
    /** Active theme name */
    theme?: string;
    /** If `enableSystem` is true and the active theme is "system", this returns whether the system preference resolved to "dark" or "light". Otherwise, identical to `theme` */
    resolvedTheme?: string;
    /** If enableSystem is true, returns the System theme preference ("dark" or "light"), regardless what the active theme is */
    systemTheme?: 'dark' | 'light';
  }

  interface ThemeProviderProps {
    /** List of all available theme names */
    themes?: string[];
    /** Forced theme name for the current page */
    forcedTheme?: string;
    /** Whether to switch between dark and light themes based on prefers-color-scheme */
    enableSystem?: boolean;
    /** Disable all CSS transitions when switching themes */
    disableTransitionOnChange?: boolean;
    /** Whether to indicate to browsers which color scheme is used (dark or light) for built-in UI like inputs and buttons */
    enableColorScheme?: boolean;
    /** Key used to store theme setting in localStorage */
    storageKey?: string;
    /** Default theme name (for v0.0.12 and lower the default was light). If `enableSystem` is false, the default theme is light */
    defaultTheme?: string;
    /** HTML attribute modified based on the active theme. Accepts `class` and `data-*` (meaning any data attribute, `data-mode`, `data-color`, etc.) */
    attribute?: string | 'class';
    /** Mapping of theme name to HTML attribute value. Object where key is the theme name and value is the attribute value */
    value?: ValueObject;
    /** Nonce string to pass to the inline script for CSP headers */
    nonce?: string;
  }

  export const useTheme: () => UseThemeProps;
  export const ThemeProvider: React.FC<ThemeProviderProps>;
}

@pacocoursey pacocoursey mentioned this issue May 5, 2022
Merged
@Gideon-cyber
Copy link

Gideon-cyber commented Jul 15, 2024

The next-themes.d.ts thing didn't work for me
I add to add a children type to it before it could work.

Should I paste the updated one that works?

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.

6 participants