microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
101.04k stars 12.5k forks source link

compilerOptions:outDir is warning if set to null inside VSCode #35642

Open boomsaas-customers opened 4 years ago

boomsaas-customers commented 4 years ago

TypeScript Version: 3.7.2 Search Terms: Unset outDir in extended tsconfig outDir null outDir Type Code

{
    "extends": "./tsconfig",
    "compilerOptions": {
//...
        "outDir": null,
    }
}

Expected behavior: No warning inside VSCode.

Actual behavior:

{
    "resource": "/home/jogo/dev/boomsaas/tsconfig.single.json",
    "owner": "_generated_diagnostic_collection_name_#0",
    "severity": 4,
    "message": "Incorrect type. Expected \"string\".",
    "startLineNumber": 6,
    "startColumn": 13,
    "endLineNumber": 6,
    "endColumn": 17
}

I want to unset the outDir configuration inside my extended config to have the transpiled files next to their source files. Adding a string like "" would instead make them appear in the root folder though. Null seems to work fine.

RyanCavanaugh commented 4 years ago

We need to fix this at https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/tsconfig.json

I don't think setting null here is an intended thing, but probably you're not the only one relying on that behavior now, so we should add some explicit tests too

sheetalkamat commented 4 years ago

We also need to fix it in the commandLineParser as well

a-tarasyuk commented 4 years ago

@boomsaas-customers It seems, in your example, you missed "rootDir" option, because without "rootDir", "outDir": "" works correctly.

`"outDir": ""` example

```shell 35642 - a - index.ts - tsconfig.json - b - index.ts - tsconfig.json - tsconfig.base.json ``` ```json // tsconfig.base.json { "compilerOptions": { "target": "es5", "module": "commonjs", "outDir": "dist" } } ``` --- ```ts // index.ts const a = null; ``` ```json // a/tsconfig.json { "extends": "../tsconfig.base" } ``` ```shell tsc -p ./a/tsconfig.json ``` ```shell cat dist/index.js "use strict"; var a = null; ``` --- ```ts // index.ts const b = null; ``` ```json // b/tsconfig.json { "extends": "../tsconfig.base", "outDir": "" } ``` ```shell tsc -p ./b/tsconfig.json ``` **Puts** results to **`b`** folder no to **`dist`** ```shell cat b/index.js "use strict"; var b = null; ```

@sheetalkamat Do you mean changing outDir -" type" from "string "to" string" | null?

cc @RyanCavanaugh