Skip to content

TypeScript: compilerOptions.types not respected when using project references #27372

@mjbvz

Description

@mjbvz

From @OliverJAsh on September 26, 2018 13:23

  • VSCode Version: 10.27.2
  • OS Version: macOS 10.13.6

Steps to Reproduce:

Full reproduction case

  1. Given a tsconfig.json that has project references, where the referenced TS projects specify a custom compilerOptions.types
  2. Open a file inside one of the referenced projects

Expected: VSCode should respect compilerOption.types.

Actual: VSCode appears to ignore compilerOption.types.

For example, I have three TS projects:

  • tsconfig-src.json which should not have jest types (compilerOption.types is set to [])
  • tsconfig-tests.json which should have jest types (compilerOption.types is set to ["jest"])
  • tsconfig.json which references both of the above

The following file is part of the tsconfig-src.json project:

// src/sum.ts

test('foo', () => {})
// Expected: error in VSCode and when running `tsc -b`
// Actual: no error in VSCode, error when running `tsc -b`

export function sum(a: number, b: number) {
  return a + b;
}

When I run tsc -b -f tsconfig.json, I get the expected error:

src/sum.ts:3:1 - error TS2304: Cannot find name 'test'.

3 test('foo', () => {})
  ~~~~

(test is a global type provided by the jest types.)

However, VSCode has no error. Instead, the types appear to be available, even when they shouldn't:

image

You can try this for yourself with the provided full reproduction case.

Copied from original issue: microsoft/vscode#59466

Metadata

Metadata

Assignees

Labels

Fix AvailableA PR has been opened for 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