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.
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
.
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'
tsconfig.json
approach wrong?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?
'./disposable.ts'
Should be './disposable'
i.e. drop the .ts
extension.