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

TypeScript "exclude" conflicts with types resolution #10285

Closed
letmaik opened this issue Aug 8, 2016 · 5 comments
Closed

TypeScript "exclude" conflicts with types resolution #10285

letmaik opened this issue Aug 8, 2016 · 5 comments

Comments

@letmaik
Copy link
Member

letmaik commented Aug 8, 2016

  • VSCode Version: 1.4.0
  • OS Version: Win 10
  • TypeScript Version: 2.0 beta (also set with "typescript.tsdk": "./node_modules/typescript/lib")

Steps to Reproduce:

  1. Create project with /src and /test folders.
  2. Create tsconfig.json with:
{
    "compilerOptions": {
        "module": "commonjs",
        "noImplicitAny": true,
        "removeComments": true,
        "preserveConstEnums": true,
        "rootDir": "src/",
        "outDir": "lib/",
        "inlineSourceMap": true,
        "inlineSources": true
    },
    "exclude": [
        "node_modules",
        "test"
    ]
}
  1. Run npm install --save @types/node
  2. Create /test/test.ts and import assert.

The assert import leads to "Cannot find module 'assert'".

The reason why I excluded test in tsconfig.json is that the tests should not become part of the lib/ folder. Also, I have a separate tsconfig.json in the test/ folder which gets used by mocha via mocha --require ./test/init.js test/**/*.ts:

{
    "compilerOptions": {
        "module": "commonjs",
        "inlineSourceMap": true,
        "inlineSources": true
    },
    "exclude": [
        "node_modules"
    ]
}

The init.js file that is require'd by mocha contains:

require('ts-node').register({
    project: 'test/',
    disableWarnings: true,
    fast: true
})
@dbaeumer dbaeumer added *question Issue represents a question, should be posted to StackOverflow (VS Code) typescript Typescript support issues labels Aug 8, 2016
@dbaeumer
Copy link
Member

dbaeumer commented Aug 8, 2016

The problem is that the test folder doesn't see the global install typings due to the existence of the tsconfig.json. You can either install the typing there are well or link to the typing using a typings.d.ts file having a content like this

/// <reference path="../typings/index.d.ts" />

@dbaeumer dbaeumer closed this as completed Aug 8, 2016
@letmaik
Copy link
Member Author

letmaik commented Aug 8, 2016

I see. Although I don't have a "typings/" folder anymore as I use the new typescript 2 way with the @types/.. npm packages. What would be the best way in that scenario?

@dbaeumer
Copy link
Member

dbaeumer commented Aug 9, 2016

Then it should work as long as the node_modules folder is above the test folder. However I tried it and I couldn't make it work. Moving to the TS team to comment on this.

@dbaeumer dbaeumer reopened this Aug 9, 2016
@dbaeumer dbaeumer removed *question Issue represents a question, should be posted to StackOverflow (VS Code) typescript Typescript support issues labels Aug 9, 2016
@dbaeumer dbaeumer removed their assignment Aug 9, 2016
@dbaeumer
Copy link
Member

dbaeumer commented Aug 9, 2016

OK. I found out what needs to be done. You need to add the typings you need to see in the test folder to the tsconfig.json file. Something like this to see the node typings installed via @types/node.

{
    "compilerOptions": {
        "module": "commonjs",
        "inlineSourceMap": true,
        "inlineSources": true,
        "types": [
            "node"
        ]
    }
}

@dbaeumer dbaeumer closed this as completed Aug 9, 2016
@dbaeumer
Copy link
Member

dbaeumer commented Aug 9, 2016

Opened microsoft/TypeScript#10221

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants