Don't complain about modules
and outFile
options when
`emitDeclarationOnly` is set. Fixes #27117.
This commit is contained in:
parent
e1a4c2779f
commit
32e75e7ae7
|
@ -2577,7 +2577,7 @@ namespace ts {
|
|||
}
|
||||
|
||||
// Cannot specify module gen that isn't amd or system with --out
|
||||
if (outFile) {
|
||||
if (outFile && !options.emitDeclarationOnly) {
|
||||
if (options.module && !(options.module === ModuleKind.AMD || options.module === ModuleKind.System)) {
|
||||
createDiagnosticForOptionName(Diagnostics.Only_amd_and_system_modules_are_supported_alongside_0, options.out ? "out" : "outFile", "module");
|
||||
}
|
||||
|
|
|
@ -3265,7 +3265,7 @@ namespace ts {
|
|||
const isSourceFileFromExternalLibrary = (file: SourceFile) => host.isSourceFileFromExternalLibrary(file);
|
||||
if (options.outFile || options.out) {
|
||||
const moduleKind = getEmitModuleKind(options);
|
||||
const moduleEmitEnabled = moduleKind === ModuleKind.AMD || moduleKind === ModuleKind.System;
|
||||
const moduleEmitEnabled = options.emitDeclarationOnly || moduleKind === ModuleKind.AMD || moduleKind === ModuleKind.System;
|
||||
// Can emit only sources that are not declaration file and are either non module code or module with --module or --target es6 specified
|
||||
return filter(host.getSourceFiles(), sourceFile =>
|
||||
(moduleEmitEnabled || !isExternalModule(sourceFile)) && sourceFileMayBeEmitted(sourceFile, options, isSourceFileFromExternalLibrary));
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
//// [tests/cases/compiler/outModuleConcatCommonjsDeclarationOnly.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
export class A { }
|
||||
|
||||
//// [b.ts]
|
||||
import {A} from "./ref/a";
|
||||
export class B extends A { }
|
||||
|
||||
|
||||
|
||||
//// [all.d.ts]
|
||||
declare module "ref/a" {
|
||||
export class A {
|
||||
}
|
||||
}
|
||||
declare module "b" {
|
||||
import { A } from "ref/a";
|
||||
export class B extends A {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
=== tests/cases/compiler/ref/a.ts ===
|
||||
export class A { }
|
||||
>A : Symbol(A, Decl(a.ts, 0, 0))
|
||||
|
||||
=== tests/cases/compiler/b.ts ===
|
||||
import {A} from "./ref/a";
|
||||
>A : Symbol(A, Decl(b.ts, 0, 8))
|
||||
|
||||
export class B extends A { }
|
||||
>B : Symbol(B, Decl(b.ts, 0, 26))
|
||||
>A : Symbol(A, Decl(b.ts, 0, 8))
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
=== tests/cases/compiler/ref/a.ts ===
|
||||
export class A { }
|
||||
>A : A
|
||||
|
||||
=== tests/cases/compiler/b.ts ===
|
||||
import {A} from "./ref/a";
|
||||
>A : typeof A
|
||||
|
||||
export class B extends A { }
|
||||
>B : B
|
||||
>A : A
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
//// [tests/cases/compiler/outModuleConcatUnspecifiedModuleKindDeclarationOnly.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
export class A { } // module
|
||||
|
||||
//// [b.ts]
|
||||
var x = 0; // global
|
||||
|
||||
|
||||
|
||||
//// [out.d.ts]
|
||||
declare module "a" {
|
||||
export class A {
|
||||
}
|
||||
}
|
||||
declare var x: number;
|
|
@ -0,0 +1,8 @@
|
|||
=== tests/cases/compiler/a.ts ===
|
||||
export class A { } // module
|
||||
>A : Symbol(A, Decl(a.ts, 0, 0))
|
||||
|
||||
=== tests/cases/compiler/b.ts ===
|
||||
var x = 0; // global
|
||||
>x : Symbol(x, Decl(b.ts, 0, 3))
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
=== tests/cases/compiler/a.ts ===
|
||||
export class A { } // module
|
||||
>A : A
|
||||
|
||||
=== tests/cases/compiler/b.ts ===
|
||||
var x = 0; // global
|
||||
>x : number
|
||||
>0 : 0
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
// @target: ES5
|
||||
// @sourcemap: true
|
||||
// @declaration: true
|
||||
// @emitDeclarationOnly: true
|
||||
// @module: commonjs
|
||||
// @outFile: all.js
|
||||
|
||||
// @Filename: ref/a.ts
|
||||
export class A { }
|
||||
|
||||
// @Filename: b.ts
|
||||
import {A} from "./ref/a";
|
||||
export class B extends A { }
|
|
@ -0,0 +1,10 @@
|
|||
// @target: ES5
|
||||
// @outFile: out.js
|
||||
// @declaration: true
|
||||
// @emitDeclarationOnly: true
|
||||
|
||||
// @Filename: a.ts
|
||||
export class A { } // module
|
||||
|
||||
// @Filename: b.ts
|
||||
var x = 0; // global
|
Loading…
Reference in a new issue