-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Add declarationDir option #7170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3879fe6
Add sample files for testcases
masaeedu 0d54e54
Add testcases
masaeedu 2bf6456
Accept baselines
masaeedu ba63a48
Add declarationDir option
masaeedu c8aedbf
Address PR feedback: expand ternary return into if block, add check t…
masaeedu dea1372
Update baselines to make declarationDir invalid alongside out or outFile
masaeedu f251768
Make declarationDir invalid alongside out or outFile
masaeedu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| define(["require", "exports"], function (require, exports) { | ||
| "use strict"; | ||
| var A = (function () { | ||
| function A() { | ||
| } | ||
| return A; | ||
| }()); | ||
| exports.A = A; | ||
| }); |
26 changes: 26 additions & 0 deletions
26
tests/baselines/reference/project/declarationDir/amd/declarationDir.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| { | ||
| "scenario": "declarationDir: specify declarationDir only", | ||
| "projectRoot": "tests/cases/projects/declarationDir", | ||
| "inputFiles": [ | ||
| "a.ts", | ||
| "subfolder/b.ts", | ||
| "subfolder/c.ts" | ||
| ], | ||
| "declaration": true, | ||
| "declarationDir": "declarations", | ||
| "baselineCheck": true, | ||
| "resolvedInputFiles": [ | ||
| "lib.d.ts", | ||
| "subfolder/b.ts", | ||
| "a.ts", | ||
| "subfolder/c.ts" | ||
| ], | ||
| "emittedFiles": [ | ||
| "subfolder/b.js", | ||
| "declarations/subfolder/b.d.ts", | ||
| "a.js", | ||
| "declarations/a.d.ts", | ||
| "subfolder/c.js", | ||
| "declarations/subfolder/c.d.ts" | ||
| ] | ||
| } |
4 changes: 4 additions & 0 deletions
4
tests/baselines/reference/project/declarationDir/amd/declarations/a.d.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| import { B } from './subfolder/b'; | ||
| export declare class A { | ||
| b: B; | ||
| } |
2 changes: 2 additions & 0 deletions
2
tests/baselines/reference/project/declarationDir/amd/declarations/subfolder/b.d.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| export declare class B { | ||
| } |
4 changes: 4 additions & 0 deletions
4
tests/baselines/reference/project/declarationDir/amd/declarations/subfolder/c.d.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| import { A } from '../a'; | ||
| export declare class C { | ||
| a: A; | ||
| } |
9 changes: 9 additions & 0 deletions
9
tests/baselines/reference/project/declarationDir/amd/subfolder/b.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| define(["require", "exports"], function (require, exports) { | ||
| "use strict"; | ||
| var B = (function () { | ||
| function B() { | ||
| } | ||
| return B; | ||
| }()); | ||
| exports.B = B; | ||
| }); |
9 changes: 9 additions & 0 deletions
9
tests/baselines/reference/project/declarationDir/amd/subfolder/c.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| define(["require", "exports"], function (require, exports) { | ||
| "use strict"; | ||
| var C = (function () { | ||
| function C() { | ||
| } | ||
| return C; | ||
| }()); | ||
| exports.C = C; | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| "use strict"; | ||
| var A = (function () { | ||
| function A() { | ||
| } | ||
| return A; | ||
| }()); | ||
| exports.A = A; |
26 changes: 26 additions & 0 deletions
26
tests/baselines/reference/project/declarationDir/node/declarationDir.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| { | ||
| "scenario": "declarationDir: specify declarationDir only", | ||
| "projectRoot": "tests/cases/projects/declarationDir", | ||
| "inputFiles": [ | ||
| "a.ts", | ||
| "subfolder/b.ts", | ||
| "subfolder/c.ts" | ||
| ], | ||
| "declaration": true, | ||
| "declarationDir": "declarations", | ||
| "baselineCheck": true, | ||
| "resolvedInputFiles": [ | ||
| "lib.d.ts", | ||
| "subfolder/b.ts", | ||
| "a.ts", | ||
| "subfolder/c.ts" | ||
| ], | ||
| "emittedFiles": [ | ||
| "subfolder/b.js", | ||
| "declarations/subfolder/b.d.ts", | ||
| "a.js", | ||
| "declarations/a.d.ts", | ||
| "subfolder/c.js", | ||
| "declarations/subfolder/c.d.ts" | ||
| ] | ||
| } |
4 changes: 4 additions & 0 deletions
4
tests/baselines/reference/project/declarationDir/node/declarations/a.d.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| import { B } from './subfolder/b'; | ||
| export declare class A { | ||
| b: B; | ||
| } |
2 changes: 2 additions & 0 deletions
2
tests/baselines/reference/project/declarationDir/node/declarations/subfolder/b.d.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| export declare class B { | ||
| } |
4 changes: 4 additions & 0 deletions
4
tests/baselines/reference/project/declarationDir/node/declarations/subfolder/c.d.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| import { A } from '../a'; | ||
| export declare class C { | ||
| a: A; | ||
| } |
7 changes: 7 additions & 0 deletions
7
tests/baselines/reference/project/declarationDir/node/subfolder/b.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| "use strict"; | ||
| var B = (function () { | ||
| function B() { | ||
| } | ||
| return B; | ||
| }()); | ||
| exports.B = B; |
7 changes: 7 additions & 0 deletions
7
tests/baselines/reference/project/declarationDir/node/subfolder/c.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| "use strict"; | ||
| var C = (function () { | ||
| function C() { | ||
| } | ||
| return C; | ||
| }()); | ||
| exports.C = C; |
27 changes: 27 additions & 0 deletions
27
tests/baselines/reference/project/declarationDir2/amd/declarationDir2.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| { | ||
| "scenario": "declarationDir: specify declarationDir with outDir", | ||
| "projectRoot": "tests/cases/projects/declarationDir", | ||
| "inputFiles": [ | ||
| "a.ts", | ||
| "subfolder/b.ts", | ||
| "subfolder/c.ts" | ||
| ], | ||
| "outDir": "out", | ||
| "declaration": true, | ||
| "declarationDir": "declarations", | ||
| "baselineCheck": true, | ||
| "resolvedInputFiles": [ | ||
| "lib.d.ts", | ||
| "subfolder/b.ts", | ||
| "a.ts", | ||
| "subfolder/c.ts" | ||
| ], | ||
| "emittedFiles": [ | ||
| "out/subfolder/b.js", | ||
| "declarations/subfolder/b.d.ts", | ||
| "out/a.js", | ||
| "declarations/a.d.ts", | ||
| "out/subfolder/c.js", | ||
| "declarations/subfolder/c.d.ts" | ||
| ] | ||
| } |
4 changes: 4 additions & 0 deletions
4
tests/baselines/reference/project/declarationDir2/amd/declarations/a.d.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| import { B } from './subfolder/b'; | ||
| export declare class A { | ||
| b: B; | ||
| } |
2 changes: 2 additions & 0 deletions
2
tests/baselines/reference/project/declarationDir2/amd/declarations/subfolder/b.d.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| export declare class B { | ||
| } |
4 changes: 4 additions & 0 deletions
4
tests/baselines/reference/project/declarationDir2/amd/declarations/subfolder/c.d.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| import { A } from '../a'; | ||
| export declare class C { | ||
| a: A; | ||
| } |
9 changes: 9 additions & 0 deletions
9
tests/baselines/reference/project/declarationDir2/amd/out/a.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| define(["require", "exports"], function (require, exports) { | ||
| "use strict"; | ||
| var A = (function () { | ||
| function A() { | ||
| } | ||
| return A; | ||
| }()); | ||
| exports.A = A; | ||
| }); |
9 changes: 9 additions & 0 deletions
9
tests/baselines/reference/project/declarationDir2/amd/out/subfolder/b.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| define(["require", "exports"], function (require, exports) { | ||
| "use strict"; | ||
| var B = (function () { | ||
| function B() { | ||
| } | ||
| return B; | ||
| }()); | ||
| exports.B = B; | ||
| }); |
9 changes: 9 additions & 0 deletions
9
tests/baselines/reference/project/declarationDir2/amd/out/subfolder/c.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| define(["require", "exports"], function (require, exports) { | ||
| "use strict"; | ||
| var C = (function () { | ||
| function C() { | ||
| } | ||
| return C; | ||
| }()); | ||
| exports.C = C; | ||
| }); |
27 changes: 27 additions & 0 deletions
27
tests/baselines/reference/project/declarationDir2/node/declarationDir2.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| { | ||
| "scenario": "declarationDir: specify declarationDir with outDir", | ||
| "projectRoot": "tests/cases/projects/declarationDir", | ||
| "inputFiles": [ | ||
| "a.ts", | ||
| "subfolder/b.ts", | ||
| "subfolder/c.ts" | ||
| ], | ||
| "outDir": "out", | ||
| "declaration": true, | ||
| "declarationDir": "declarations", | ||
| "baselineCheck": true, | ||
| "resolvedInputFiles": [ | ||
| "lib.d.ts", | ||
| "subfolder/b.ts", | ||
| "a.ts", | ||
| "subfolder/c.ts" | ||
| ], | ||
| "emittedFiles": [ | ||
| "out/subfolder/b.js", | ||
| "declarations/subfolder/b.d.ts", | ||
| "out/a.js", | ||
| "declarations/a.d.ts", | ||
| "out/subfolder/c.js", | ||
| "declarations/subfolder/c.d.ts" | ||
| ] | ||
| } |
4 changes: 4 additions & 0 deletions
4
tests/baselines/reference/project/declarationDir2/node/declarations/a.d.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| import { B } from './subfolder/b'; | ||
| export declare class A { | ||
| b: B; | ||
| } |
2 changes: 2 additions & 0 deletions
2
tests/baselines/reference/project/declarationDir2/node/declarations/subfolder/b.d.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| export declare class B { | ||
| } |
4 changes: 4 additions & 0 deletions
4
tests/baselines/reference/project/declarationDir2/node/declarations/subfolder/c.d.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| import { A } from '../a'; | ||
| export declare class C { | ||
| a: A; | ||
| } |
7 changes: 7 additions & 0 deletions
7
tests/baselines/reference/project/declarationDir2/node/out/a.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| "use strict"; | ||
| var A = (function () { | ||
| function A() { | ||
| } | ||
| return A; | ||
| }()); | ||
| exports.A = A; |
7 changes: 7 additions & 0 deletions
7
tests/baselines/reference/project/declarationDir2/node/out/subfolder/b.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| "use strict"; | ||
| var B = (function () { | ||
| function B() { | ||
| } | ||
| return B; | ||
| }()); | ||
| exports.B = B; |
7 changes: 7 additions & 0 deletions
7
tests/baselines/reference/project/declarationDir2/node/out/subfolder/c.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| "use strict"; | ||
| var C = (function () { | ||
| function C() { | ||
| } | ||
| return C; | ||
| }()); | ||
| exports.C = C; |
19 changes: 19 additions & 0 deletions
19
tests/baselines/reference/project/declarationDir3/amd/declarationDir3.errors.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| error TS5053: Option 'declarationDir' cannot be specified with option 'out'. | ||
|
|
||
|
|
||
| !!! error TS5053: Option 'declarationDir' cannot be specified with option 'out'. | ||
| ==== b.ts (0 errors) ==== | ||
| export class B { | ||
|
|
||
| } | ||
| ==== a.ts (0 errors) ==== | ||
| import {B} from './subfolder/b'; | ||
| export class A { | ||
| b: B; | ||
| } | ||
| ==== subfolder/c.ts (0 errors) ==== | ||
| import {A} from '../a'; | ||
|
|
||
| export class C { | ||
| a: A; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since --declarationDir is ignored here, it should be an error to specify --out/--outFile + --declarationDir
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DanielRosenwasser suggests that the
declarationDiroption be respected when specified alongsideout/outFile. I think this means I should simply put the bundled declaration file indeclarationDir.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i do not think this is correct.
declarationDirshould behave likeoutDir, we can add in the future adeclarationOutFileto behave likeoutFile