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

import NodeTypes from '@vue/compiler-core', NodeTypes is undefined #1650

Closed
6 tasks done
xusyang opened this issue Jul 16, 2022 · 2 comments
Closed
6 tasks done

import NodeTypes from '@vue/compiler-core', NodeTypes is undefined #1650

xusyang opened this issue Jul 16, 2022 · 2 comments
Labels

Comments

@xusyang
Copy link

xusyang commented Jul 16, 2022

Describe the bug

import { describe, expect, it } from 'vitest';
import { NodeTypes } from '@vue/compiler-core';

describe('suite name', () => {
  it('import NodeTypes', () => {
   // TypeError: Cannot read properties of undefined (reading 'ATTRIBUTE')
    expect(NodeTypes.ATTRIBUTE).toMatchInlineSnapshot();
  });
});

why NodeTypes is undefined? I can't sure that is vite's reason.

Reproduction

https://stackblitz.com/edit/vitest-dev-vitest-ycjtaj?file=test/suite.test.ts

System Info

System:
    OS: macOS 12.2.1
    CPU: (8) x64 Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
    Memory: 94.02 MB / 8.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.13.0 - ~/.nvm/versions/node/v16.13.0/bin/node
    npm: 8.1.0 - ~/.nvm/versions/node/v16.13.0/bin/npm
  Browsers:
    Chrome: 103.0.5060.114
    Safari: 15.3
  npmPackages:
    vitest: ^0.17.0 => 0.17.0

Used Package Manager

pnpm

Validations

@Demivan
Copy link
Member

Demivan commented Jul 16, 2022

NodeTypes is a const enum, it exists only in Typescript. It is compiled out of Vue, every instance is replaced with appropriate value. That is why you cannot import it.

And from Vite docs: https://vitejs.dev/guide/features.html#typescript

.. because esbuild only performs transpilation without type information, it doesn't support certain features like const enum and implicit type-only imports.

@xusyang
Copy link
Author

xusyang commented Jul 16, 2022

em, thks.

@xusyang xusyang closed this as completed Jul 16, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Jun 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants