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

False positive TS1323 error about static imports in <script setup lang="ts"> #1263

Closed
micgro42 opened this issue May 5, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@micgro42
Copy link

micgro42 commented May 5, 2022

When in tsconfig.json the "module" compiler option is set to es2015, then vue-tsc produces an error for static imports inside <script setup lang="ts">

For example for this code straight from the vite scaffold:

<script setup lang="ts">
// This starter template is using Vue 3 <script setup> SFCs
// Check out https://vuejs.org/api/sfc-script-setup.html#script-setup
import HelloWorld from './components/HelloWorld.vue'
</script>

This is the error message that is produced:

src/App.vue:1:1 - error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'.

As you can see, there is no dynamic import in App.vue, only a static one.

I create a minimal failing example repository for this, reproducing the error on npm run build: https://github.com/micgro42/Minimal-Failing-Example_volar-dynamic-import

It is the repository produced by npm create vite@latest and the tsconfig.json modified as stated above.

As far as I can tell, this started with vue-tsc 0.34.x. That is, it was working fine with 0.33.9 and broke when we tried to upgrade to 0.34.11.

Please let me know if you need any further information.

micgro42 added a commit to wmde/new-lexeme-special-page that referenced this issue May 5, 2022
Can't update jest and ts-jest yet, because @vue/vue3-jest depends on
jest 27.

Changing tsconfig should get rid of the following error:

Error: src/App.vue(1,1): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'.

I think this error is a false positive/bug as we do not actually have
any dynamic imports anywhere.

As I understand it, we do not use the output of the typescript
transpilation directly, but it is an intermediate product in the vite
build process.

This issue has been reported as vuejs/language-tools#1263
@johnsoncodehk johnsoncodehk added the bug Something isn't working label May 5, 2022
@micgro42
Copy link
Author

micgro42 commented May 9, 2022

Thank you!

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

No branches or pull requests

2 participants