Skip to content

Commit 7852cf7

Browse files
authored
Merge pull request #27175 from a-tarasyuk/bug/error-using-declaration-dir-with-composite
#26862: allow using declarationDir with composite option
2 parents cd28af0 + d111178 commit 7852cf7

14 files changed

+147
-1
lines changed

Diff for: src/compiler/program.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2532,7 +2532,7 @@ namespace ts {
25322532
}
25332533

25342534
if (options.declarationDir) {
2535-
if (!options.declaration) {
2535+
if (!getEmitDeclarations(options)) {
25362536
createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "declarationDir", "declaration");
25372537
}
25382538
if (options.out || options.outFile) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//// [test.ts]
2+
interface Foo {
3+
x: number;
4+
}
5+
export default Foo;
6+
7+
8+
//// [test.js]
9+
"use strict";
10+
exports.__esModule = true;
11+
12+
13+
//// [test.d.ts]
14+
interface Foo {
15+
x: number;
16+
}
17+
export default Foo;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
=== /foo/test.ts ===
2+
interface Foo {
3+
>Foo : Symbol(Foo, Decl(test.ts, 0, 0))
4+
5+
x: number;
6+
>x : Symbol(Foo.x, Decl(test.ts, 0, 15))
7+
}
8+
export default Foo;
9+
>Foo : Symbol(Foo, Decl(test.ts, 0, 0))
10+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
=== /foo/test.ts ===
2+
interface Foo {
3+
x: number;
4+
>x : number
5+
}
6+
export default Foo;
7+
>Foo : Foo
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//// [test.ts]
2+
interface Foo {
3+
x: number;
4+
}
5+
export default Foo;
6+
7+
8+
//// [test.js]
9+
"use strict";
10+
exports.__esModule = true;
11+
12+
13+
//// [test.d.ts]
14+
interface Foo {
15+
x: number;
16+
}
17+
export default Foo;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
=== /foo/test.ts ===
2+
interface Foo {
3+
>Foo : Symbol(Foo, Decl(test.ts, 0, 0))
4+
5+
x: number;
6+
>x : Symbol(Foo.x, Decl(test.ts, 0, 15))
7+
}
8+
export default Foo;
9+
>Foo : Symbol(Foo, Decl(test.ts, 0, 0))
10+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
=== /foo/test.ts ===
2+
interface Foo {
3+
x: number;
4+
>x : number
5+
}
6+
export default Foo;
7+
>Foo : Foo
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/foo/tsconfig.json(2,26): error TS5052: Option 'declarationDir' cannot be specified without specifying option 'declaration'.
2+
3+
4+
==== /foo/tsconfig.json (1 errors) ====
5+
{
6+
"compilerOptions": { "declarationDir": "out" }
7+
~~~~~~~~~~~~~~~~
8+
!!! error TS5052: Option 'declarationDir' cannot be specified without specifying option 'declaration'.
9+
}
10+
11+
==== /foo/test.ts (0 errors) ====
12+
interface Foo {
13+
x: number;
14+
}
15+
export default Foo;
16+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//// [test.ts]
2+
interface Foo {
3+
x: number;
4+
}
5+
export default Foo;
6+
7+
8+
//// [test.js]
9+
"use strict";
10+
exports.__esModule = true;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
=== /foo/test.ts ===
2+
interface Foo {
3+
>Foo : Symbol(Foo, Decl(test.ts, 0, 0))
4+
5+
x: number;
6+
>x : Symbol(Foo.x, Decl(test.ts, 0, 15))
7+
}
8+
export default Foo;
9+
>Foo : Symbol(Foo, Decl(test.ts, 0, 0))
10+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
=== /foo/test.ts ===
2+
interface Foo {
3+
x: number;
4+
>x : number
5+
}
6+
export default Foo;
7+
>Foo : Foo
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// @composite: true
2+
// @filename: /foo/tsconfig.json
3+
{
4+
"compilerOptions": { "composite": true, "declarationDir": "out" }
5+
}
6+
7+
// @filename: /foo/test.ts
8+
interface Foo {
9+
x: number;
10+
}
11+
export default Foo;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// @declaration: true
2+
// @filename: /foo/tsconfig.json
3+
{
4+
"compilerOptions": { "declaration": true, "declarationDir": "out" }
5+
}
6+
7+
// @filename: /foo/test.ts
8+
interface Foo {
9+
x: number;
10+
}
11+
export default Foo;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// @filename: /foo/tsconfig.json
2+
{
3+
"compilerOptions": { "declarationDir": "out" }
4+
}
5+
6+
// @filename: /foo/test.ts
7+
interface Foo {
8+
x: number;
9+
}
10+
export default Foo;

0 commit comments

Comments
 (0)