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

Defining vite config using @tamagui/config - ts errors #2481

Open
SamuraiF0x opened this issue Mar 28, 2024 · 0 comments · May be fixed by #2556
Open

Defining vite config using @tamagui/config - ts errors #2481

SamuraiF0x opened this issue Mar 28, 2024 · 0 comments · May be fixed by #2556

Comments

@SamuraiF0x
Copy link
Contributor

Current Behavior

I tried using the simplest config following docs for intro/installation and vite guide by using:
import { config } from "@tamagui/config/v3"

I get typescript errors in vite.config.ts:

ts error for config in const tamaguiConfig = tamaguiExtractPlugin(config):

Type '{ animations: AnimationDriver<{ '75ms': string; '100ms': string; '200ms': string; bouncy: string; superBouncy: string; lazy: string; medium: string; slow: string; quick: string; quicker: string; quickest: string; tooltip: string; }>; ... 9 more ...; selectionStyles: (theme: any) => { ...; } | null; }' has no properties in common with type 'Partial<TamaguiOptions>'.ts(2559)

ts error for tamaguiConfig.options in tamaguiPlugin(tamaguiConfig.options):

Argument of type 'ObjectHook<(this: MinimalPluginContext, options: InputOptions) => InputOptions | NullValue | Promise<InputOptions | NullValue>, {}> | undefined' is not assignable to parameter of type 'TamaguiOptions | undefined'.
  Type '(this: MinimalPluginContext, options: InputOptions) => InputOptions | NullValue | Promise<InputOptions | NullValue>' has no properties in common with type 'TamaguiOptions'.ts(2345)

or

ts error for config in:

tamaguiPlugin({
	config: config,
	components: ["tamagui"],
}),

Everything works fine though, it loads in browser without errors.

Expected Behavior

There should be a way to configure vite config without adding custom tamagui.config.ts to root by using only @tamagui/config/v3, without getting typescript errors.

In other words, this:

tamaguiPlugin({
	config: config,
	components: ["tamagui"],
}),

or this:
const tamaguiConfig = tamaguiExtractPlugin(config)

should be without typescript errors when using "@tamagui/config/v3"` only.

Tamagui Version

"tamagui": "^1.93.2"

Platform (Web, iOS, Android)

Windows 11, Web, Vite

Reproduction

In vite starter:

`App.tsx` :

import { config } from "@tamagui/config/v3";
import { TamaguiProvider, createTamagui } from "tamagui";

// you usually export this from a tamagui.config.ts file
const tamaguiConfig = createTamagui(config);

// make TypeScript type everything based on your config
type Conf = typeof tamaguiConfig;
declare module "@tamagui/core" {
    interface TamaguiCustomConfig extends Conf {}
}

function App() {
	return (
		<TamaguiProvider config={tamaguiConfig}>
                   ...
		</TamaguiProvider>
	);
}

export default App;

vite.config.ts:

import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { tamaguiExtractPlugin, tamaguiPlugin } from "@tamagui/vite-plugin";
import { config } from "@tamagui/config/v3";

const tamaguiConfig = tamaguiExtractPlugin(config);

export default defineConfig({
    plugins: [
        react(),
        tamaguiPlugin(tamaguiConfig.options),

        // OR THIS SETUP

  	tamaguiPlugin({
	    config: config,
	    components: ["tamagui"],
	}),
    ],
});


### System Info

```markdown
System:
    OS: Windows 11 10.0.22631
    CPU: (12) x64 AMD Ryzen 5 3600 6-Core Processor
    Memory: 2.93 GB / 15.93 GB
  Binaries:
    Node: 20.11.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.22 - C:\Program Files\nodejs\yarn.CMD
    npm: 10.5.0 - C:\Program Files\nodejs\npm.CMD
    pnpm: 8.15.5 - C:\Program Files\nodejs\pnpm.CMD
  Browsers:
    Chrome: 123.0.6312.86
    Edge: Chromium (122.0.2365.92)
  npmPackages:
    @tamagui/config: ^1.93.2 => 1.93.2 
    @tamagui/lucide-icons: ^1.93.2 => 1.93.2 
    @tamagui/vite-plugin: ^1.93.2 => 1.93.2 
    @types/react: ^18.2.66 => 18.2.72 
    @types/react-dom: ^18.2.22 => 18.2.22 
    @typescript-eslint/eslint-plugin: ^7.2.0 => 7.4.0 
    @typescript-eslint/parser: ^7.2.0 => 7.4.0
    @vitejs/plugin-react: ^4.2.1 => 4.2.1
    eslint: ^8.57.0 => 8.57.0
    eslint-plugin-react-hooks: ^4.6.0 => 4.6.0
    eslint-plugin-react-refresh: ^0.4.6 => 0.4.6
    prettier: ^3.2.5 => 3.2.5
    react: ^18.2.0 => 18.2.0
    react-dom: ^18.2.0 => 18.2.0
    tamagui: ^1.93.2 => 1.93.2
    typescript: ^5.2.2 => 5.4.3
    vite: ^5.2.0 => 5.2.6
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

Successfully merging a pull request may close this issue.

1 participant