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

Inconsistent JavaScript Intellisense / not working #30291

Closed
mudrz opened this issue Jul 8, 2017 · 4 comments
Closed

Inconsistent JavaScript Intellisense / not working #30291

mudrz opened this issue Jul 8, 2017 · 4 comments
Assignees
Labels
javascript JavaScript support issues

Comments

@mudrz
Copy link

mudrz commented Jul 8, 2017

  • VSCode Version: Version 1.13.1
  • OS Version: macOS Sierra 10.12.5 (same on Win10)

Steps to Reproduce:

What I am trying to do:
I am using webpack aliases and want to utilize VS Code Intellisense for them
webpack.config.js

...
alias: {
...
App: path.resolve(__dirname, 'ClientApp'),
...
}
...

ClientApp Folder structure
screen shot 2017-07-08 at 19 50 53

jsconfig.json

{
  "compilerOptions": {
    "target": "es6",
    "baseUrl": ".",
    "paths": {
      "App": ["./"]
    }
  },
  "exclude": ["dist"]
}

Some functions like deleteProperty are not recognized if using alias App
screen shot 2017-07-08 at 19 15 10

but are recognized if using relative paths
screen shot 2017-07-08 at 19 15 45

other functions are recognized (in same folder, completely same format used)
screen shot 2017-07-08 at 19 44 54

additionally using index.js with re-exports
screen shot 2017-07-08 at 19 24 13

does not work even with relative paths (IOptions.js has a default export object, recognized only in the last format)
screen shot 2017-07-08 at 19 19 28

import { IOptions } from 'App/models';
screen shot 2017-07-08 at 19 20 51

import { IOptions as IOptions2 } from './models';
screen shot 2017-07-08 at 19 21 02

import IOptions3 from 'App/models/IOptions';
screen shot 2017-07-08 at 19 21 15
import IOptions4 from './models/IOptions';
screen shot 2017-07-08 at 19 21 26

Are these configuration issues or?

@vscodebot vscodebot bot added the javascript JavaScript support issues label Jul 8, 2017
@zanza00
Copy link

zanza00 commented Jul 10, 2017

I had a similar problem #30122

my solution is the following jsconfig.json

{
  "compilerOptions": {
    "target": "ES6",
    "allowSyntheticDefaultImports": true,
    "jsx": "react",
    "module": "commonjs",
    "baseUrl": ".",
    "paths": {
      "*": [
        "*",
        "app/*"
      ]
    }
  },
  "include": [
    "app/**/*.js"
  ]
}

the important bits are module, baseurl and path

Hope this helps 😄

@mudrz
Copy link
Author

mudrz commented Jul 10, 2017

@zanza00 , thanks zanza, unfortunately the result was the same (I tested quite a few jsconfig.json configurations)

I created a repo with test files to illustrate the issue (with 2 folders with different jsconfig.json files)
https://github.com/mudrz/js-intellisense-tests.git

There was no difference (this time I tested it on Windows 10)

@mjbvz
Copy link
Collaborator

mjbvz commented Jul 10, 2017

@mudrz We don't fully support the proposed export from syntax yet. This is being tracked upstream by microsoft/TypeScript#4813

I believe you also have to use globs in the paths. Try something like this:

{
  "compilerOptions": {
    "target": "ES6",
    "allowSyntheticDefaultImports": true,
    "jsx": "react",
    "module": "commonjs",
    "baseUrl": ".",
    "paths": {
      "App/*": [
        "./*"
      ]
    }
  },
  "include": ["**/*.js"]
}

@mudrz
Copy link
Author

mudrz commented Jul 11, 2017

@mjbvz , nice, thanks, I wasted so much time on this trying different jsconfig combinations, didn't know that the key also needs to use globs

I tested both configurations and can confirm that Intellisense works in this case (-the export from syntax)

{
  "compilerOptions": {
    "target": "es6",
    "baseUrl": ".",
    "paths": {
      "App/*": ["./*"]
    }
  },
  "exclude": ["dist"]
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
javascript JavaScript support issues
Projects
None yet
Development

No branches or pull requests

3 participants