React Auto import Inconsistency. Works for typescript with single file saved. Not in other cases

Viewed 182

Module import for typescript works, but only if I use "save" in vscode, instead of save all.

File import also works for typescript react files but inside return autocomplete is not an option, so I have to type components out.

For .js/.jsx neither works. Only importing by typing outside return works for files. If the import is deleted then it's not automatically replaced.

I could use some help because after spending hours trying to make it work, I don't even know what to try next.

This is my settings.json:

{
    //Emmet
    "emmet.triggerExpansionOnTab": true,
    "emmet.includeLanguages": {
        "javascript": "javascriptreact"
    },
    "emmet.syntaxProfiles": {
        "javascript": "javascriptreact"
    },
    "emmet.excludeLanguages": ["markdown"],

    //ESLINT
    "eslint.codeAction.showDocumentation": {
        "enable": true
    },
    "eslint.lintTask.enable": true,
    "eslint.run": "onType",
    "workbench.iconTheme": "vscode-icons",
    //Autoimport
    "javascript.suggest.autoImports": true,
    "javascript.updateImportsOnFileMove.enabled": "always",
    "typescript.suggest.autoImports": true,
    "typescript.updateImportsOnFileMove.enabled": "always",
    "explorer.confirmDragAndDrop": false,
    "explorer.compactFolders": false,
    "editor.codeActionsOnSave": {
        "source.addMissingImports": true,
        "source.organizeImports": true
    },
    //Prettier
    "prettier.arrowParens": "always",
    "prettier.trailingComma": "es5",
    "prettier.useTabs": true,

    //Activity Bar
    "workbench.activityBar.visible": true,

    "material-ui-snippets.showNotesOnStartup": false,

    "diffEditor.ignoreTrimWhitespace": false,

    "vsintellicode.modify.editor.suggestSelection": "choseToUpdateConfiguration",
    "breadcrumbs.enabled": true,

    "workbench.statusBar.visible": true,

    "gitlens.advanced.quickPick.closeOnFocusOut": false,
    "files.trimTrailingWhitespace": true,

    "workbench.colorTheme": "GitHub Dark",
    "python.languageServer": "Pylance",
    // "workbench.editorAssociations": {
    //  "*.ipynb": "jupyter.notebook.ipynb"
    // },
    "jupyter.interactiveWindowMode": "perFile",

    "gitlens.advanced.messages": {
        "suppressGitMissingWarning": true
    },

    "editor.bracketPairColorization.enabled": true,
    "editor.guides.bracketPairs": "active",
    "editor.autoClosingBrackets": "always",
    "editor.autoClosingQuotes": "always",
    "editor.formatOnSave": true,
    "editor.linkedEditing": true,
    "editor.fontLigatures": true,
    "editor.fontFamily": "Fira Code, Fira Code iScript, Consolas, 'Courier New', monospace",
    "editor.minimap.enabled": false,
    "editor.tabSize": 2,
    "editor.wordWrap": "on",
    "editor.suggestSelection": "first",
    "editor.renderWhitespace": "none",
    "editor.renderControlCharacters": false,
    "editor.snippetSuggestions": "inline",
    "editor.quickSuggestions": true,
    "editor.wordBasedSuggestions": true,


    "compilerOptions": {
        "baseUrl": "./src",
        "checkJs": true,
        "jsx": "react"
    },

    "[jsonc]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "[javascript]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "[javascriptreact]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "[typescriptreact]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "[typescript]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "files.autoSave": "afterDelay"
}

0 Answers
Related