MarcoS
MarcoS

Reputation: 11

Why is vscode IntelliSense only working after typing .default.?

I am trying to use VSCode IntelliSense for a function parameter.

It works with the following code. But unfortunately only after typing .default. but I want to use IntelliSense on the parentObject.

export default class Data {
    /** @param {import('./mainStore')} parentObject */
    constructor(parentObject) {
        parentObject.default.XXX //<--I get correct Intellisense for the XXX after the "default"
    }
}

Using import('./mainStore').default doesn't work.

export default class Data {
    /** @param {import('./mainStore').default} parentObject */
    constructor(parentObject) {
        parentObject.XXX //<--No IntelliSense here"
    }
}

edit: that's an shortened version of the mainStore.js. The imported classes contain some functions. I think it's not really nice style but i want to structure my functions and data.

import UserStore from "./userStore";
import DataStore from "./dataStore";

const MainStore = {
  user: new UserStore(),
  data: new DataStore()
  construct() {
    this.data = new DataStore(this);
    this.user = new UserStore(this);
    return this; 
  }
}
export default MainStore;

I've added two pictures which hopefully explain what i mean:

Image - Working IntelliSense, but only after using ".default"

Image - Not working IntelliSense with import('./mainStore').default

I've already tried a named export, but it doesn't work either.

How can I get IntelliSense working for the parentObject?

Many thanks in advance!

Upvotes: 1

Views: 362

Answers (1)

Daniel Orozco
Daniel Orozco

Reputation: 185

please check the next url https://github.com/validatorjs/validator.js/issues/1262. This solution works for me const { default: validator } = require('validator');

enter image description here

Upvotes: 1

Related Questions