microsoft / microsoft/TypeScript

jsconfig.json gives broken intellisense for js files with module.exports

Abierto
#33,435 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Awaiting More Feedback Suggestion
Lenguaje dominante
Go
Estrellas
111k
Forks
14.3k
Merge medio
1 d 19 h
PR fusionados (30 d)
117

Descripción

  • VSCode Version: 1.38.0
  • TS Version: 3.6.2
  • OS Version: Ubuntu 18.04 LTS bionic beaver
  • Tested with no extensions
  • Can not really find a solution to this problem after a lot of searching

I have a personal js library that I use both in browser-side and node-side for a lot of my personal projects . In fact the library itself has its own project . The js library looks like this :

const library = {};

library.foo = function() {/*browser code*/}

if (typeof module === 'object') {
 library.bar = function() {/*node code*/}
 module.exports = library;
}

For a browser project (library is used via script tag) If I try to get intellisense via jscofig.json for such a file I get broken intellisense (by typing f or b I get suggestions for foo or bar respectively , but there is no library suggestion when I type l , and even if I type library I get no suggestion about its properties ) .
For a node project everything works fine regarding intellisense using require .

The issue here is with module.exports . If I change it to var substitute = module; substitute.exports = library; then I get intellisense for browser project via jsconfig.json but broken intellisense (as described before) for node via require .

How can I get intellisense to work for both require and jsconfig.json ?

Before you attempt to check intellisense you should know the following :

I open index.js in a project that does not have any other js file and no jsconfig.json file . Then I view in the same VScode session some other , completely unrelated to my project , js files . For whatever file I view I get intellisense (of the globally scoped variables that have been defined via let , var or const) when I am editing index.js . If the unrelated js file happens to have module.exports then the intellisense that I get in index.js for that file is broken like it has been described before .
I stop getting intellisense for files that I view when I create a jsconfig.json file file in the folder of index.js . But still there is the same broken behavior with intellisense for files that are included via jsconfig.json and have module.exports .

Please restart vscode to test if intellisense really works .

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Reproduce el comportamiento en VSCode 1.38.0 con TypeScript 3.6.2 usando el index.js mostrado, jsconfig.json, el uso en el navegador y el uso de Node require. Compara IntelliSense para module.exports directo con el alias sustituto y considera terminado el issue cuando tanto jsconfig.json como require proporcionen la biblioteca y sus propiedades de forma coherente.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
javascript, typescript, vscode
Área
developer-experience, tooling
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
30/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.