Problem sharing TS code files between different Visual Studio projects
I've been trying to make 2 Visual Studio 2015 CE web app projects share the same TypeScript file, but could not find a way to do this. I am using the AMD module system with require.
While coding VS seems to be fine with the require("......") statement for the common code file. However, when running, I get an exception from require.
I have more details on the general problem in this SO post: http://stackoverflow.com/questions/35506086/using-typescript-files-in-different-web-apps-with-require-amd
and the repository with a self-contained example that reproduces the problem can be found here: https://bitbucket.org/KoenT_IM/typescripttests
Just build and run the project under Applications/CodeSharingApp1 to reproduce this.
Perhaps the fact that the relative path "climbs out" of the project path to reference the common TS file, is what causes the problem. But then I'm not sure how to share a folder with common TS code files between different projects...
what version of TS are you using?
I'm using TypeScript 1.7.6 (in VS2015 CE).
hi, I have the same problem. Both vscode and vs2015 can't handle shared files in multipy projects. For example, I have files:
/a/a.ts -> import {x} from "../shared/x"
/a/tsconfig.json
/b/b.ts -> import {x} from "../shared/x"
/b/tsconfig.json
/x/x.ts -> export var x = 1;
The "Find All Reference" doesn't find 'x' in both a.ts and b.ts
The "Find All Reference" doesn't find 'x' in both a.ts and b.ts
@heroboy, looks like this is a diffrent issue. this is fixed in https://github.com/Microsoft/TypeScript/pull/7353
@KoenT-IM consider specifing a require configuration (http://requirejs.org/docs/api.html#config) to map the location of your shared module.
the other option, is to drop all your modules into a single output location, and use baseURL (a TS 2.0 feature, available now in typescript@next).
so your sources would look like:
projectA\
a.ts => `import foo from "b"`
projectB\
b.ts
with tsconfig.json as:
{
"compilerOptions": {
"baseURL" : "./out",
"outDir": "./out"
}
}
see https://github.com/Microsoft/TypeScript-Handbook/blob/release-2.0/pages/Module%20Resolution.md#base-url for more details.
the original issue seems to be addressed. please reopen if this is not the case.
Thanks mhegazy. Will verify and come back to this if needed soon (working towards a release now).