Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct usage with TS2 and @types/node #179

Closed
wclr opened this issue Aug 19, 2016 · 11 comments
Closed

Correct usage with TS2 and @types/node #179

wclr opened this issue Aug 19, 2016 · 11 comments

Comments

@wclr
Copy link
Contributor

wclr commented Aug 19, 2016

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?

@blakeembrey
Copy link
Member

Can you provide the versions you're using?

@wclr
Copy link
Contributor Author

wclr commented Aug 19, 2016

ts-node@0.9.1

@blakeembrey
Copy link
Member

That would be why. You need to update.

@blakeembrey
Copy link
Member

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

@blakeembrey
Copy link
Member

Here's a related issue also: #153.

@wclr
Copy link
Contributor Author

wclr commented Aug 20, 2016

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

@blakeembrey
Copy link
Member

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

@wclr
Copy link
Contributor Author

wclr commented Sep 21, 2016

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)

@blakeembrey
Copy link
Member

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

@jomcode
Copy link

jomcode commented Sep 22, 2016

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"
    ]
}

@wclr
Copy link
Contributor Author

wclr commented Sep 25, 2016

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants