1

My project is a Typescript project with a browser part and a server part. Because of that, I need to have two separate tsconfig.json in order to build the browser library and the server process using node. I am using Visual Studio Code.

The project

Here is the folder structure:

myproject
 |
 +-src
 |  |
 |  +-server
 |  |  |
 |  |  +-server.ts
 |  |  +-<several-ts-files>
 |  |  +-tsconfig.ts
 |  +-main.ts
 |  +-<several-ts-files>
 |  +-disposable.ts
 |  +-tsconfig.ts
 +-out

When building the server, I will go: tsc --project src\server, when building the client, I will go: tsc --project src.

The problem

In one of my files: src\main.ts, I have the following:

import disposable = require('./disposable.ts');

export module Browser {
  export class MyClass implements disposable.Disposable {
    // Stuff
  }
}

Since the browser side part uses AMD, I am specifying it in src/tsconfig.json: "module": "amd"! Visual Studio Code marks './disposable.ts' inside the require with a red line with error:

Cannot find module './disposable.ts'

Questions

  1. Is this two tsconfig.json approach wrong?
  2. Why can't Code find my modules?

Can it be...

I remember once somebody told me that Code needs a tsconfig.json file to understand how the developer wants to build the code. However when we have two and they are not in the root? Do all editors behave like that?

2
  • Hi Andry - I can't see the disposable.ts file listed in your project structure. Can you add it in so we can see it in your tree view you created? Commented Jul 22, 2015 at 7:52
  • Hi Steve, I was implying by the import path that the file is in src. But you're right, it is much better to be precise and clear. Edited! :) Commented Jul 22, 2015 at 8:23

1 Answer 1

2

'./disposable.ts'

Should be './disposable' i.e. drop the .ts extension.

Sign up to request clarification or add additional context in comments.

1 Comment

I even watched your video on youtube... Just missed that detail. Thanks man and sorry for the stupid mistake

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.