diff --git a/integration/samples/typings/src/chalk.d.ts b/integration/samples/typings/src/chalk.ts
similarity index 100%
rename from integration/samples/typings/src/chalk.d.ts
rename to integration/samples/typings/src/chalk.ts
diff --git a/integration/samples/typings/src/nested/reference/index.ts b/integration/samples/typings/src/nested/reference/index.ts
index 9bd910d4c..998f7bc30 100644
--- a/integration/samples/typings/src/nested/reference/index.ts
+++ b/integration/samples/typings/src/nested/reference/index.ts
@@ -1,3 +1,3 @@
-///
+///
export const faz: Mocked = { foo: 'bar' };
diff --git a/integration/samples/typings/src/nested/reference/mocked.d.ts b/integration/samples/typings/src/nested/reference/mocked.ts
similarity index 100%
rename from integration/samples/typings/src/nested/reference/mocked.d.ts
rename to integration/samples/typings/src/nested/reference/mocked.ts
diff --git a/integration/samples/typings/src/validator.ts b/integration/samples/typings/src/validator.ts
index 18526c31f..eb612c3bc 100644
--- a/integration/samples/typings/src/validator.ts
+++ b/integration/samples/typings/src/validator.ts
@@ -1,4 +1,4 @@
-///
+///
import * as chalk from 'chalk';
export { chalk };
diff --git a/src/lib/ng-package/entry-point/compile-ngc.transform.ts b/src/lib/ng-package/entry-point/compile-ngc.transform.ts
index d594a8d69..f6564a7a1 100644
--- a/src/lib/ng-package/entry-point/compile-ngc.transform.ts
+++ b/src/lib/ng-package/entry-point/compile-ngc.transform.ts
@@ -8,7 +8,7 @@ import * as log from '../../utils/log';
import { isEntryPointInProgress, EntryPointNode, isEntryPoint } from '../nodes';
import { StylesheetProcessor } from '../../styles/stylesheet-processor';
-export const compileNgcTransform: Transform = transformFromPromise(async (graph) => {
+export const compileNgcTransform: Transform = transformFromPromise(async graph => {
log.info(`Compiling TypeScript sources through ngc`);
const entryPoint = graph.find(isEntryPointInProgress()) as EntryPointNode;
const entryPoints = graph.filter(isEntryPoint) as EntryPointNode[];
@@ -30,10 +30,10 @@ export const compileNgcTransform: Transform = transformFromPromise(async (graph)
stylesheetProcessor,
{
outDir: path.dirname(esm2015),
+ declarationDir: path.dirname(declarations),
declaration: true,
target: ts.ScriptTarget.ES2015,
},
- path.dirname(declarations),
ngccProcessor,
);
diff --git a/src/lib/ngc/compile-source-files.ts b/src/lib/ngc/compile-source-files.ts
index 68efb3568..f82356c5f 100644
--- a/src/lib/ngc/compile-source-files.ts
+++ b/src/lib/ngc/compile-source-files.ts
@@ -1,7 +1,6 @@
import * as ng from '@angular/compiler-cli';
import * as ts from 'typescript';
import * as log from '../utils/log';
-import { redirectWriteFileCompilerHost } from '../ts/redirect-write-file-compiler-host';
import { cacheCompilerHost } from '../ts/cache-compiler-host';
import { StylesheetProcessor } from '../styles/stylesheet-processor';
import { BuildGraph } from '../graph/build-graph';
@@ -16,7 +15,6 @@ export async function compileSourceFiles(
moduleResolutionCache: ts.ModuleResolutionCache,
stylesheetProcessor: StylesheetProcessor,
extraOptions?: Partial,
- declarationDir?: string,
ngccProcessor?: NgccProcessor,
) {
log.debug(`ngc (v${ng.VERSION.full})`);
@@ -31,9 +29,6 @@ export async function compileSourceFiles(
moduleResolutionCache,
stylesheetProcessor,
);
- if (declarationDir) {
- tsCompilerHost = redirectWriteFileCompilerHost(tsCompilerHost, tsConfigOptions.basePath, declarationDir);
- }
if (tsConfigOptions.enableIvy && ngccProcessor) {
tsCompilerHost = ngccTransformCompilerHost(tsCompilerHost, tsConfigOptions, ngccProcessor, moduleResolutionCache);
diff --git a/src/lib/ts/redirect-write-file-compiler-host.ts b/src/lib/ts/redirect-write-file-compiler-host.ts
deleted file mode 100644
index 5c56ed23d..000000000
--- a/src/lib/ts/redirect-write-file-compiler-host.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-import * as ts from 'typescript';
-import * as path from 'path';
-
-/**
- * Returns a TypeScript compiler host that redirects `writeFile` output to the given `declarationDir`.
- *
- * @param compilerHost Original compiler host
- * @param baseDir Project base directory
- * @param declarationDir Declarations target directory
- */
-export function redirectWriteFileCompilerHost(
- compilerHost: ts.CompilerHost,
- baseDir: string,
- declarationDir: string,
-): ts.CompilerHost {
- return {
- ...compilerHost,
- writeFile: (
- fileName: string,
- data: string,
- writeByteOrderMark: boolean,
- onError?: (message: string) => void,
- sourceFiles?: ReadonlyArray,
- ) => {
- let filePath = fileName;
- if (/(\.d\.ts|\.metadata\.json)$/.test(fileName)) {
- const projectRelativePath = path.relative(baseDir, fileName);
- filePath = path.resolve(declarationDir, projectRelativePath);
- }
- compilerHost.writeFile.call(this, filePath, data, writeByteOrderMark, onError, sourceFiles);
- },
- };
-}
diff --git a/src/lib/ts/tsconfig.ts b/src/lib/ts/tsconfig.ts
index 39440496a..2379b5fa2 100644
--- a/src/lib/ts/tsconfig.ts
+++ b/src/lib/ts/tsconfig.ts
@@ -87,7 +87,6 @@ export const initializeTsConfig = (defaultTsConfig: ng.ParsedConfiguration, entr
flatModuleOutFile: `${entryPoint.flatModuleFile}.js`,
basePath,
rootDir: basePath,
- declarationDir: basePath,
};
tsConfig.rootNames = [entryPoint.entryFilePath];