This repository was archived by the owner on Dec 1, 2019. It is now read-only.
File tree 4 files changed +12
-12
lines changed
4 files changed +12
-12
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ spec(__filename, async function() {
15
15
` ) ;
16
16
17
17
tsconfig ( {
18
+ declarationDir : 'decl' ,
18
19
declaration : true
19
20
} ) ;
20
21
@@ -24,11 +25,11 @@ spec(__filename, async function() {
24
25
25
26
expectErrors ( stats , 0 ) ;
26
27
27
- checkOutput ( 'src /index.d.ts' , `
28
+ checkOutput ( '../decl /index.d.ts' , `
28
29
export { default as sum } from './utils/sum'
29
30
` ) ;
30
31
31
- checkOutput ( 'src /utils/sum.d.ts' , `
32
+ checkOutput ( '../decl /utils/sum.d.ts' , `
32
33
export default function sum(a: number, b: number): number
33
34
` ) ;
34
35
@@ -45,11 +46,11 @@ spec(__filename, async function() {
45
46
46
47
await watcher . wait ( ) ;
47
48
48
- checkOutput ( 'src /utils/mul.d.ts' , `
49
+ checkOutput ( '../decl /utils/mul.d.ts' , `
49
50
export default function mul(a: number, b: number): number
50
51
` ) ;
51
52
52
- checkOutput ( 'src /index.d.ts' , `
53
+ checkOutput ( '../decl /index.d.ts' , `
53
54
export { default as sum } from './utils/sum';
54
55
export { default as mul } from './utils/mul';
55
56
` ) ;
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ export function toUnix(fileName: string): string {
14
14
}
15
15
16
16
function withoutExt ( fileName : string ) : string {
17
- return path . join ( path . dirname ( fileName ) , path . basename ( fileName ) . split ( '.' ) [ 0 ] ) ;
17
+ return path . basename ( fileName ) . split ( '.' ) [ 0 ] ;
18
18
}
19
19
20
20
function isFileEmit ( fileName , outputFileName , sourceFileName ) {
Original file line number Diff line number Diff line change 1
1
import * as _ from 'lodash' ;
2
2
import * as path from 'path' ;
3
+ import * as fs from 'fs' ;
3
4
4
5
import { findCompiledModule , cache } from './cache' ;
5
6
import * as helpers from './helpers' ;
@@ -8,6 +9,7 @@ import { PathPlugin } from './paths-plugin';
8
9
import { CheckerPlugin as _CheckerPlugin } from './watch-mode' ;
9
10
10
11
const loaderUtils = require ( 'loader-utils' ) ;
12
+ const mkdirp = require ( 'mkdirp' ) ;
11
13
12
14
function loader ( text ) {
13
15
try {
@@ -163,13 +165,9 @@ function transform(
163
165
}
164
166
165
167
if ( emitResult . declaration ) {
166
- const declPath = path . relative (
167
- instance . context ,
168
- emitResult . declaration . name
169
- ) ;
170
-
171
- webpack . emitFile (
172
- declPath ,
168
+ mkdirp . sync ( path . dirname ( emitResult . declaration . name ) ) ;
169
+ fs . writeFileSync (
170
+ emitResult . declaration . name ,
173
171
emitResult . declaration . text
174
172
) ;
175
173
}
Original file line number Diff line number Diff line change @@ -235,6 +235,7 @@ function applyDefaults(
235
235
_ . defaults ( compilerConfig . options , {
236
236
sourceMap : true ,
237
237
verbose : false ,
238
+ declarationDir : compilerConfig . options . outDir ,
238
239
skipDefaultLibCheck : true ,
239
240
suppressOutputPathCheck : true
240
241
} ) ;
You can’t perform that action at this time.
0 commit comments