Skip to content

@ts-check Not Working in Inferred Projects or in Project With JSConfig #15200

Description

@mjbvz

TypeScript Version: 2.3.1-0414insiders

Code
In the JS file

/// @ts-check
var x = "string";
x = 0;

With a jsconfig.json:

{
     "compilerOptions": {
    },
    "exclude": [
        "node_modules"
    ],
    "include": [
        "*.js"
    ]
}

Expected behavior:
In my understanding, the /// @ts-check directive should enable checks in the js file, even though checkJs is not set in the config

Actual behavior:
This directive does not seem have any effect. Enabling checkJs enables the js error reporting. When using a tsconfig with "allowJs": true, I do see error reporting even when checkJs has not been set

Also, I'm unable to use /// @ts-check in javascript file that is part of an an inferred project in VSCode. Here are the options we send:

[Trace - 2:36:21 PM] Sending request: compilerOptionsForInferredProjects (1). Response expected: yes. Current queue length: 2
Arguments: {
    "options": {
        "module": "CommonJS",
        "target": "ES6",
        "allowSyntheticDefaultImports": true,
        "allowNonTsExtensions": true,
        "allowJs": true,
        "jsx": "Preserve"
    }
}

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issueVS Code TrackedThere is a VS Code equivalent to this issue

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions