Skip to content

tsconfig.json options not applied if files section doesn't use extensions #11194

@waderyan

Description

@waderyan

Copied from microsoft/vscode#12547
Reported by @nomaed

  • VSCode Version: 1.5.3 (5be4091987a98e3870d89d630eb87be6d9bafd27)
  • OS Version: macOS Sierra 10.12

Steps to Reproduce:

  • Create an empty directory
  • Run npm init and then npm i --save-dev typescript
  • Run tsc --init (or ./node_modules/.bin/tsc --init)
  • Create test.ts and add code that's using Map and Set:
const foo = new Map();
const bar = new Set();
  • Edit tsconfig.json, set target to be es2015, and add files section with the test script (test) without its extension:
{
    "compilerOptions": {
        "module": "commonjs",
        "target": "es2015",
        "noImplicitAny": false,
        "sourceMap": false
    },
    "files": [ "test" ]
}
  • Run tsc (or ./node_modules/.bin/tsc), see that test.js is created with exactly the same code, as expected, and no warnings or errors have been seen.

At this point, tsc compiled the file test while adding the default .ts extension when resolving.

Now adding VSCode into the picture:

  • Run code . to open VSCode with the current testing directory loaded. Either that, or from GUI go to Files > Open and loaded the current directory.
  • Open test.ts file. At this point VSCode may ask about TypeScript version, if TypeScript 2.0 was installed by npm. It doesn't matter whether you choose TS 2.0 or TS 1.8, both produce the same behavior.
  • Observe Map and Set being unrecognized:
    screen shot 2016-09-23 at 22 31 53

The observed behavior is inconsistent with tsc.

Now, to "fix" it:

  • Open tsconfig.json and change the files section to have the full file-name with its extension test.ts.
  • Reload TypeScript project or reload VSCode, and open test.ts. Everything is fine now.
    screen shot 2016-09-23 at 22 30 14

However, I would expect vscode behavior in this to be the same as of tsc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions