Skip to content

Not able to import defineConfig from Vite #904

Closed
@mxschmitt

Description

@mxschmitt
Member
➜  vite-import-tsc git:(main) npx tsc -p .                                                        
➜  vite-import-tsc git:(main) /Users/maxschmitt/Developer/tmp/typescript-go/built/local/tsgo  -p .
vite.config.ts:17:10 - error TS2305: Module '"/Users/maxschmitt/Developer/tmp/vite-import-tsc/node_modules/vite/index"' has no exported member 'defineConfig'.

17 import { defineConfig } from 'vite';
            ~~~~~~~~~~~~

Found 1 error in vite.config.ts:17

➜  vite-import-tsc git:(main) 

Reproduction: https://github.com/mxschmitt/typescript-go-issue-vite-defineConfig-types.git

tsc works while tsgo does not.

Commit: 5cae442

Extracted minimal reproduction from #895.

Activity

jrmyio

jrmyio commented on May 23, 2025

@jrmyio

Possibly related to #518

Andarist

Andarist commented on Jun 19, 2025

@Andarist
Contributor

Does the issue persist with the recent builds? I can't repro it

wojtekmaj

wojtekmaj commented on Jun 19, 2025

@wojtekmaj

It does not!

PS C:\server> yarn tsc
vitest.config.ts:9:18 - error TS7006: Parameter 'id' implicitly has an 'any' type.

9       async load(id) {
                   ~~

Found 1 error in 1 file.

Errors  Files
     1  vitest.config.ts:9

PS C:\server> yarn up @typescript/native-preview -R
➤ YN0000: · Yarn 4.9.1
➤ YN0000: ┌ Resolution step
➤ YN0085: │ + @typescript/native-preview@npm:7.0.0-dev.20250619.1, and 7 more.
➤ YN0085: │ - @typescript/native-preview-darwin-arm64@npm:7.0.0-dev.20250528.1, and 7 more.
➤ YN0000: └ Completed in 1s 967ms
➤ YN0000: ┌ Fetch step
➤ YN0013: │ 7 packages were added to the project, and 7 were removed (+ 11.24 MiB).
➤ YN0000: └ Completed in 2s 268ms
➤ YN0000: ┌ Link step
➤ YN0008: │ server@workspace:. must be rebuilt because its dependency tree changed
➤ YN0000: └ Completed in 1s 283ms
➤ YN0000: · Done in 5s 610ms
PS C:\server> yarn tsc
PS C:\server>
mxschmitt

mxschmitt commented on Jun 19, 2025

@mxschmitt
MemberAuthor

Closing as fixed - Thanks!

Marsup

Marsup commented on Jun 20, 2025

@Marsup

I'm personally still seeing it on 7.0.0-dev.20250620.1.

EDIT: it looks like it happens on project configured in commonjs or with commonjs set as module in tsconfig. It seems to only be fixed if the module system is set as ESM for both the project and tsconfig.

smaccoun

smaccoun commented on Jun 20, 2025

@smaccoun

Was fixed for me about a week ago and I've been routinely updating. Not sure what PR fixed it but has been good for me

Andarist

Andarist commented on Jun 20, 2025

@Andarist
Contributor

@Marsup please provide a repro case so somebody could investigate further

Marsup

Marsup commented on Jun 20, 2025

@Marsup

Here it is: https://github.com/Marsup/typescript-go-issue-904
Just run npm ci && npm test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @Marsup@jrmyio@DanielRosenwasser@smaccoun@wojtekmaj

        Issue actions

          Not able to import defineConfig from Vite · Issue #904 · microsoft/typescript-go