Typescript 3.0 .
: https://www.typescriptlang.org/docs/handbook/project-references.html
, lib.ts ts, - 'lib'
lib tsconfig, :
{
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"rootDir": ".",
"composite": true,
},
"references": []
}
project-a, project-b lib tsconfig
{
"compilerOptions": {
"target": "es5",
"module": "es2015",
"moduleResolution": "node"
},
"references": [
{ "path": "../lib" }
]
}
lib. index.ts, , .
export * from 'lib.ts';
, , lib/lib.ts :
export const log = (message: string) => console.log(message);
log lib/lib.ts project-a, project-b.
import { log } from '../lib';
log("This is a message");
intelissense , project-a project-b, :
tsc -b
( lib), (project-a project-b).
lib. (*.d.ts), lib.
lib/tsconfig.json :
"declaration": true,
, project-a/app.ts F12 Visual Studio, .
, lib/tsconfig.json :
"declarationMap": true,
github, :
https://github.com/thdk/TS3-projects-references-example