Skip to content

tide does not pick up .d.ts file in tsconfig.json #37

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

Closed
NhanHo opened this issue Jun 24, 2016 · 8 comments
Closed

tide does not pick up .d.ts file in tsconfig.json #37

NhanHo opened this issue Jun 24, 2016 · 8 comments

Comments

@NhanHo
Copy link

NhanHo commented Jun 24, 2016

It seems like when I specify a .d.ts file in tsconfig.json (with "files" setting), tide doesn't pick it up and will complain (Cannot find name ...), even though tsc will work fine with such setting.

Right now, I have to manually add /// <reference path="" /> in every individual files to make it work, but it's very inconvenient, and it seems to me it will be an issue with larger project with multiple .d.ts files in the source. Is it a bug or expected behaviour by tide?

Taking a look over to other editors, I think all of them are supposedly picking up definitions in .d.ts given that is specified in "files" of tsconfig.json

@evmar
Copy link

evmar commented Jun 24, 2016

Tide just calls into the TypeScript tooling, so it should have the same
behavior as running "tsc".
I have a d.ts working in my project.

I think you should try to make a minimal example of the problem and submit
it here to diagnose it.

On Fri, Jun 24, 2016 at 8:59 AM, Nhan Ho [email protected] wrote:

It seems like when I specify a .d.ts file in tsconfig.json (with "files"
setting), tide doesn't pick it up and will complain (Cannot find name ...),
even though tsc will work fine with such setting.

Right now, I have to manually add /// in every
individual files to make it work, but it's very inconvenient, and it seems
to me it will be an issue with larger project with multiple .d.ts files in
the source. Is it a bug or expected behaviour by tide?

Taking a look over to other editors, I think all of them are supposedly
picking up definitions in .d.ts given that it's specified in "files" of
tsconfig.json


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#37, or mute the thread
https://github.com/notifications/unsubscribe/AAAPB_5erb8R2WfiXOgqvQvq12Qai8uJks5qO_7zgaJpZM4I95lv
.

@NhanHo
Copy link
Author

NhanHo commented Jun 25, 2016

File src/game-manager.ts

Game;

File src/reference.d.ts

declare var Game: number;

File tsconfig.json

{
  "compilerOptions": {
    "module": "commonjs",
    "target": "es5",
    "noResolve": false,
    "noImplicitAny": false
  },

    "files": ["./src/reference.d.ts","./src/game-manager.ts"],

  "bundles": {
    "main": {
      "files": [
        "./src/game-manager.ts"
      ]
    }
  }
}

Emacs with tide will complain "Cannot find game 'Game'". On the other hand, running tsc --outDir dist will work fine.

@ananthakumaran
Copy link
Owner

ananthakumaran commented Jun 25, 2016

I just added a .d.ts file in the example folder 9ffcab1. It works without a problem. I am not sure your tsconfig.json file is valid (There is a / at the end of the line that has noImplicityAny). Have a look at the log file and check if something else is wrong.

@NhanHo
Copy link
Author

NhanHo commented Jun 25, 2016

The extra "/" was something I accidentally added after copy and paste, it's not relevant to the issue. And I'm sorry for the bad example, it's indeed working (I did something slightly different when trying to reproduce the issue)

After looking at the log file, I think I found the reason. It happens when I open a new file in the project but have yet to add it to the files list in tsconfig.json. I'm using a gulp plugin that allows me to use filesGlob syntax (ie. src/**/*.ts, not yet supported by tsc proper), my files are not actually listed explicitly in files and causes problem with tide.

Is there any way we could support a wildcard/ filesGlob syntax in tide, or would it be better to just wait for official typescript support?

@ananthakumaran
Copy link
Owner

I think glob support is already available in TypeScript nightly build microsoft/TypeScript#8841. I haven't tested it, but it might work in typescript-2.0 branch. see #38.

@paldepind
Copy link

I am having a similar issue. Tide gives me errors about missing modules that tsc does not. My tsconfig.json looks like this:

{
  "compilerOptions": {
    "target": "es6",
    "jsx": "react",
    "noImplicitAny": true,
    "experimentalDecorators": true,
    "preserveConstEnums": true,
    "outDir": "built",
    "rootDir": "src",
    "sourceMap": true,
    "strictNullChecks": true
  },
  "filesGlob": [
    "typings/**/*.d.ts",
    "src/**/*.ts",
    "src/**/*.tsx",
    "!./node_modules/**/*.ts"
  ],
  "exclude": [
    "typings/browser.d.ts",
    "typings/browser",
    "node_modules"
  ]
}

I am using tsc version 2.0.0-dev.20160706. I.e. the most recent version from git. However on lines like this:

import * as Foo from "foo";

Tide gives me flycheck errors that I do not get when I manually run tsc. This affects errors in the rest of the file as well since the module typings are not loaded probably.

@ananthakumaran
Copy link
Owner

ananthakumaran commented Jul 6, 2016

@paldepind Just updated the tsserver to the latest version. Can you update tide and see if it solves the problem?

@paldepind
Copy link

I just updated from MELPA. I'm not seeing a difference.

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

4 participants