4

I wonder how to sucessfully configure type checking in VSCode for LWC. VSCode has JS/TS compiler that support type checking when we set jsconfig.json with compilerOptions like below:

"compilerOptions": {
    "experimentalDecorators": true,
    "target": "es6",
    "checkJs": true
    "baseUrl": ".",
    "paths": {
        "c/sharedCode": [
            "sharedCode/sharedCode.js"
        ]
    } // Do I need to provide paths for all my components explicitly?
}

with VSCode settings.json "js/ts.implicitProjectConfig.checkJs": true,. Funcionality of type checking gets correct types from JSDoc comments placed in code.

Type checking works as expected but imports ends with some problems:

In Jest Tests:

import { createElement } from "lwc";

Module '"lwc"' has no exported member 'createElement'.ts(2305)

Is it connected with this?

When compiler path is not set:

import SharedCode from "c/sharedCode";

Cannot find module 'c/sharedCode'. Did you mean to set the 'moduleResolution' option to 'node', or to add aliases to the 'paths' option? ts(2792)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.