Skip to content

[TypeScript 2] Relative paths in typeRoots not resolved (tsconfig.json) #1055

Closed
@elisabethallan

Description

@elisabethallan

Hi,

I'm having trouble with type definitions being picked up using TypeScript 2/atom-typescript when the tsconfig.json is not in the same directory as node_modules. I have a src folder containing tsconfig.json, refrencing ../node_modules/@types in the typeRoots, and a Jasmine test in src/app. atom-typescript does not pick up the Jasmine declarations (e.g. describe, it etc) and highlights them as errors.

My folder structure is as follows (some folders removed):

- node_modules
-- @types
- src
-- tsconfig.json
-- app
--- app.component.spec.ts
--- app.component.ts

My tsconfig.json in src is as follows:

{
  "compilerOptions": {
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": ["es6", "dom"],
    "mapRoot": "./",
    "module": "es6",
    "moduleResolution": "node",
    "outDir": "../dist/out-tsc",
    "sourceMap": true,
    "target": "es5",
    "typeRoots": [
      "../node_modules/@types"
    ],
    "types": [
      "jasmine"
    ]
  }
}

app.component.spec.ts:

import { AppComponent } from './app.component';

describe('Example', () => {
  beforeEach(() => {
    // Stuff
  });

  it('should create the app', () => {
    expect(true).toBeTruthy();
  });
});

Environment info:

OS: OS X El Capitan 10.11.6
Node.js: 6.3.1
Typescript: 2.0.0
Atom: 1.9.8
atom-typescript: 10.1.6

This configuration works with tsc on the command line (either tsc -p src in the project root, or tsc -p . in src). It also works in atom-typescript if I put the entire path in typeRoots - e.g. /Users/sean/someProject/node_modules/@types - which makes me think that this is an atom-typescript specific issue in resolving relative paths.

Is this a bug or just something I'm doing wrong with my config?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions