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

built-in javascript validator breaks on dynamic imports. #28450

Closed
serkanyersen opened this issue Jun 11, 2017 · 1 comment
Closed

built-in javascript validator breaks on dynamic imports. #28450

serkanyersen opened this issue Jun 11, 2017 · 1 comment
Assignees
Labels
javascript JavaScript support issues typescript Typescript support issues upstream Issue identified as 'upstream' component related (exists outside of VS Code)

Comments

@serkanyersen
Copy link

  • VSCode Version: 1.13.0
  • OS Version: macOS 10.12.5

Steps to Reproduce:

  1. open a new file (set syntax to javascript)
  2. paste this code in the file
import Vue from 'vue';
import Router from 'vue-router';

Vue.use(Router);

export function createRouter () {
  const router = new Router({
    mode: 'history',
    scrollBehavior: () => {
      return { y: 0 };
    },
    routes: [
      {
        name: 'home',
        path: '/',
        component: () => import('@/views/Home'),
      },
      {
        name: 'about',
        path: '/about',
        component: () => import('@/views/About'),
      },
      {
        name: 'faq',
        path: '/faq',
        component: () => import('@/views/Faq'),
      },
    ],
  });
  
  return router;
}
  1. check problems view to see the reported errors.
  2. You can see that after it failed on import( lines, validator could not recover. it keeps on failing on every statement after that.
  3. replace the contents with this code
// Fails correctly
const x = {
  foo: import('./myModule'),
  bar: 'bar string',
  x: import('./myModule2'),
  foobar: 1234,
  method() {
    return bar;
  },
  array: [{}],
  method2: () => {}
}

// fails correctly
const y = {
  x: {
    foo: import('./myModule'),
    bar: 'bar string',
    x: import('./myModule2'),
    foobar: 1234,
    method() {
      return bar;
    },
    method2: () => {}
  },
  bar: [],
  z: {
    name: 'string'
  }
}

// Fails wrong.
// Rest of the object gets effected
z = {
  x: [
    {
      foo: import('./myModule'),
      bar: 'bar string',
      x: import('./myModule2'),
      foobar: 1234,
      method() {
        return bar;
      },
      method2: () => {}
    },
  ],
  bar: {
    foo: 'this object got broken'
  }
};
  1. See that erroring on import statement sometimes works correctly
    first two examples works ok, but last example breaks the validator. seems to be related to []

Also related feature request:

Dynamic imports are still on proposal stage but they are usable with babel and I can allow them on eslint. but there is no way to allow them on default validator. I know I can simply disable javascript.validate but it's useful and I don't want to disable it for one simple feature I use.

I'm not sure if there is a way to disable validator for lines or files only, something like // eslint-disable-line?

but it would be nice to have a way to tell validator to stop validating on some files or lines.

@mjbvz mjbvz self-assigned this Jun 12, 2017
@mjbvz mjbvz added the upstream Issue identified as 'upstream' component related (exists outside of VS Code) label Jun 12, 2017
@mjbvz
Copy link
Collaborator

mjbvz commented Jun 12, 2017

Typescript 2.4 should include support for dynamic imports: microsoft/TypeScript#14495

We plan on picking up TS 2.4 for VSCode 1.14 in June and it should be available in the insiders builds soon

There is currently no way to suppress this error specifically. Normally you can add // @ts-ignore before the error line to disable error checking but this does not work for syntax errors like the dynamic imports one

@mjbvz mjbvz closed this as completed Jun 12, 2017
@mjbvz mjbvz added javascript JavaScript support issues typescript Typescript support issues labels Jun 12, 2017
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
javascript JavaScript support issues typescript Typescript support issues upstream Issue identified as 'upstream' component related (exists outside of VS Code)
Projects
None yet
Development

No branches or pull requests

2 participants