TypeScript-Sublime-Plugin: Not detecting tsconfig.json (Sublime Text 3)

I have the file ./tsconfig.json in the root folder of the project, with "modules": "commonjs" set correctly.

When editing any file 2 or more folders deep (e.g. ./src/journal/module.ts), TypeScript reports an error for every import and export statement:

Cannot compile modules unless the ‘–module’ flag is provided

This error doesn’t show up for files under ./src, and there are no module/import errors when building the project.

Also mentioned in #207.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 27 (6 by maintainers)

Most upvoted comments

I’m having a similar problem with a default installation of Sublime Text 3. I’m learning Angular 2. To set up a new project, I’m using angular-cli like this:


ng new angular2_hello_world

which sets up this directory structure:

angular2_hello_world/
   src/
      app/
         app.component.ts
         ...other files
      index.html
      tsconfig.json
      ...other files

That is, my tsconfig.json is in the src/ folder, but outside the app/ folder. My source file, app.component.ts in in the app/ folder. When I open the source file, I see this error:

Experimental support for decorators is a feature that is subject to change in a future release.
Set the 'experimentalDecorators' option to remove this warning.

But that option is set to true in the tsconfig.json file, so I have to assume that my tsconfig.json is not being used.
If it matters, I was cd’s to the enclosing angular2_hello_world/ folder when I entered the command ‘subl .’.
Since this is the default directory structure created by angular-cli and I’m using a clean install of Sublime Text 3 (Build 3126), it seems to me that a lot of folks will run into this problem in the future. The web site builds and runs just fine - I’m not using Sublime Text 3 to build and run - but I’d really like that warning to go away and anticipate problems with other settings in the future if I can’t get the Sublime TypeScript plug-in to use my tsconfig.json file.

What about manually specifying path to tsconfig.json for a projects (my tsconfig.json is in the root)?

All right, I’ve resolved this. It was apparently basically the same issue face by @NeWbY100, however, the property that needed to be set has subsequently changed. Whereas @NeWbY100 set the following:

"typescript_proc_file": "/path/to/typescript/lib/tsserver.js"

The property and usage have now changed to:

"typescript_tsdk": "/path/to/typescript/lib"

Note the absence of tsserver.js. It’s now used to figure out which tsserver.js and tsc.js to use.

@NekR, I’d give this a shot and see if it works.

@SummerWish That behavior sounds correct. If you are listing the files explicitly in the tsconfig.json, and the current file isn’t one of them (or included/imported by one of them), then the current files isn’t going to use that tsconfig.json. It’s going to get its own context.

@NeWbY100 Correct. The Sublime plugin ships its own version of tsserver.js, so if you want to use a specific version (i.e. one which may have features or behavior you depend on), then that needs to be specified.

With these two issues, and the prior issue of an invalid compilerOption, that seems to be all the root causes of this issue. I’ll close now, comment for further investigation if there are further causes not covered. Thanks!

I have the same issue here.

If my tsconfig.json doesn’t contain files, or contain files and the current file name is in the list, the tsconfig.json path is resolved correctly in typescript/commands/build.py. Otherwise (contain files array but the current file name is not in the array), the body is empty:

{'success': True, 'request_seq': 22, 'type': 'response', 'seq': 0, 'command': 'projectInfo', 'body': {}}