Skip to content

Correct usage with TS2 and @types/node #179

Closed

Description

@wclr

I've installed @types/node and ts2 beta (locally and globally)

If I do tsc path/to/file.ts (or node ./node_modules/typescript/bin/tsc path/to/file.ts) it compiles ok, so no need in placing path to node typings in files. But ts-node requires it.

I use ts-node using register hook and can not find typings for node while run. So I have to place: "node_modules/@types/node/index.d.ts" in files of tsconfig.json and then it works.

Is it expected? Why it should it be configured this way?

Activity

  1. blakeembrey commented on Aug 19, 2016

    @blakeembrey
    Member

    Can you provide the versions you're using?

  2. wclr commented on Aug 19, 2016

    @wclr
    ContributorAuthor
  3. blakeembrey commented on Aug 19, 2016

    @blakeembrey
    Member

    That would be why. You need to update.

  4. blakeembrey commented on Aug 19, 2016

    @blakeembrey
    Member

    This is the PR (#150) that should have enabled support. Let me know if that fixes things for you.

  5. blakeembrey commented on Aug 19, 2016

    @blakeembrey
    Member

    Here's a related issue also: #153.

  6. wclr commented on Aug 20, 2016

    @wclr
    ContributorAuthor

    Seems the issue persist with 1.3.0, in tsconfig I only have exclude (or files).

  7. blakeembrey commented on Sep 21, 2016

    @blakeembrey
    Member

    @whitecolor Are you using Windows? Could be the same issue as #168 - I haven't resolved that yet.

  8. wclr commented on Sep 21, 2016

    @wclr
    ContributorAuthor

    Yes i'm using windows, ts-node doesn't lookup typings in node_modules/@types (the same problem I experience with webpack's ts-loader)

  9. blakeembrey commented on Sep 22, 2016

    @blakeembrey
    Member

    It works on Unix as far as I know, so it's not that.

  10. jomcode commented on Sep 22, 2016

    @jomcode

    Hello, Windows 10 64 bit here. Using typescript 2.0.3 and ts-node 1.3.0

    I got this working by using the types key under compilerOptions in tsconfig.json

    Here is an example tsconfig.json I'm using to run mocha tests via npm with the following script: "mocha --compilers ts:ts-node/register,tsx:ts-node/register \"./src/**/*.spec.ts\""

    {
        "compilerOptions": {
            ...
            "types": [
              "node",
              "mocha",
              "chai",
              ...
            ]
        },
        "include": [
          "./src/**/*.ts",
          "./src/**/*.tsx"
        ],
        "exclude": [
          "node_modules",
          "./src/**/*.spec.ts"
        ]
    }
    
  11. wclr commented on Sep 25, 2016

    @wclr
    ContributorAuthor

    I got this working by using the types key under compilerOptions in tsconfig.json

    That works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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