Repository: storybook
Issue: [Bug]: Storybook with vite doesn't transpile *.ts files but works good with *.tsx
Labels: bug,needs triage,builder-vite

### Describe the bug

Babel tries to treat TS files with *.ts extension as JS files

![issue](https://github.com/storybookjs/storybook/assets/6917580/a2ad5c32-d9e5-4de3-9c53-6b6256e14e0c)

I used default config with minimum changes

I have a few old reducers written in JS, and new with TS
when I don't use any *.ts import everything works fine, it add at least one *.ts file to the bundle, build fails

maybe I missed something
thanks a lot foy any clue

here my files that I used.
main.ts
``` 
import type { StorybookConfig } from '@storybook/react-vite';

const config: StorybookConfig = {
    stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
    addons: [
        '@storybook/addon-links',
        '@storybook/addon-essentials',
        '@storybook/addon-onboarding',
        '@storybook/addon-interactions',
        {
            name: '@storybook/addon-postcss',
            options: {
                cssLoaderOptions: {
                    // When you have splitted your css over multiple files
                    // and use @import('./other-styles.css')
                    importLoaders: 1,
                },
                postcssLoaderOptions: {
                    // When using postCSS 8
                    implementation: require('postcss'),
                },
            },
        },
    ],
    framework: {
        name: '@storybook/react-vite',
        options: {},
    },
    docs: {
        autodocs: 'tag',
    },
    viteFinal: (config) => {
        if (config.resolve?.alias) {
            config.resolve.alias = {
                ...config.resolve.alias,
                src: '../src',
            };
        }
        return config;
    },
};
export default config;
```

Story
```
import type { Meta, StoryObj } from '@storybook/react';
import { CommunityCard } from 'src/components/community/card';
import { withStore } from '../decorators/withStore';
import { Layout } from '../helpers';

const meta = {
    title: 'Community/Card',
    component: CommunityCard,
    parameters: {
        layout: Layout.Centered,
    },
    tags: ['autodocs'],
    decorators: [withStore],
} satisfies Meta<typeof CommunityCard>;

export default meta;
type Story = StoryObj<typeof meta>;

export const Main: Story = {
    args: {
        cover: 'https://via.placeholder.com/678x452',
    },
};
```

Decorator

```
import React, { ElementType } from 'react';
import { Provider } from 'react-redux';
import store from 'src/redux/store';

export const withStore = (Story: ElementType) => {
    return (
        <Provider store={store}>
            <Story />
        </Provider>
    );
};
```

Component

```
import React from 'react';

type Props = {
    cover: string;
};

export const CommunityCard: React.FC<Props> = ({ cover }) => {
    // const isMobile = useAppSelector(selectIsMobile);
    return (
        <div className="grid w-full max-w-[678px] flex-col overflow-hidden rounded-xl shadow-sm">
            <img loading="lazy" src={cover} className="h-[21.2rem] w-full object-cover" />
            <div className="flex min-h-[367px] w-full flex-col overflow-hidden max-md:max-w-full">
                Title
            </div>
        </div>
    );
};
```

### To Reproduce

_No response_

### System

```bash
Storybook Environment Info:

  System:
    OS: macOS 14.2.1
    CPU: (11) arm64 Apple M3 Pro
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 16.20.2 - ~/.local/share/mise/installs/node/16/bin/node
    npm: 8.19.4 - ~/.local/share/mise/installs/node/16/bin/npm <----- active
    pnpm: 8.14.0 - /opt/homebrew/bin/pnpm
  Browsers:
    Edge: 121.0.2277.106
    Safari: 17.2.1
  npmPackages:
    @storybook/addon-essentials: ^7.6.13 => 7.6.13 
    @storybook/addon-interactions: ^7.6.13 => 7.6.13 
    @storybook/addon-links: ^7.6.13 => 7.6.13 
    @storybook/addon-onboarding: ^1.0.11 => 1.0.11 
    @storybook/addon-postcss: ^2.0.0 => 2.0.0 
    @storybook/blocks: ^7.6.13 => 7.6.13 
    @storybook/react: ^7.6.13 => 7.6.13 
    @storybook/react-vite: ^7.6.13 => 7.6.13 
    @storybook/test: ^7.6.13 => 7.6.13 
    eslint-plugin-storybook: ^0.6.15 => 0.6.15 
    storybook: ^7.6.13 => 7.6.13 
    storybook-addon-sass-postcss: ^0.1.4 => 0.1.4
```


### Additional context

_No response_