|
1 | | -/// <reference path="checker.ts"/> |
| 1 | +/// <reference path="checker.ts"/> |
2 | 2 | /// <reference path="sourcemap.ts" /> |
3 | 3 | /// <reference path="declarationEmitter.ts"/> |
4 | 4 |
|
@@ -336,7 +336,7 @@ namespace ts { |
336 | 336 | } |
337 | 337 |
|
338 | 338 | // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature |
339 | | - export function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFile: SourceFile): EmitResult { |
| 339 | + export function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFile: SourceFile, emitOnlyDtsFiles?: boolean): EmitResult { |
340 | 340 | // emit output for the __extends helper function |
341 | 341 | const extendsHelper = ` |
342 | 342 | var __extends = (this && this.__extends) || function (d, b) { |
@@ -396,7 +396,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge |
396 | 396 | const newLine = host.getNewLine(); |
397 | 397 |
|
398 | 398 | const emitJavaScript = createFileEmitter(); |
399 | | - forEachExpectedEmitFile(host, emitFile, targetSourceFile); |
| 399 | + forEachExpectedEmitFile(host, emitFile, targetSourceFile, emitOnlyDtsFiles); |
400 | 400 |
|
401 | 401 | return { |
402 | 402 | emitSkipped, |
@@ -1615,7 +1615,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge |
1615 | 1615 | else if (declaration.kind === SyntaxKind.ImportSpecifier) { |
1616 | 1616 | // Identifier references named import |
1617 | 1617 | write(getGeneratedNameForNode(<ImportDeclaration>declaration.parent.parent.parent)); |
1618 | | - const name = (<ImportSpecifier>declaration).propertyName || (<ImportSpecifier>declaration).name; |
| 1618 | + const name = (<ImportSpecifier>declaration).propertyName || (<ImportSpecifier>declaration).name; |
1619 | 1619 | const identifier = getTextOfNodeFromSourceText(currentText, name); |
1620 | 1620 | if (languageVersion === ScriptTarget.ES3 && identifier === "default") { |
1621 | 1621 | write('["default"]'); |
@@ -3254,19 +3254,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge |
3254 | 3254 | write("var "); |
3255 | 3255 | let seen: Map<string>; |
3256 | 3256 | for (const id of convertedLoopState.hoistedLocalVariables) { |
3257 | | - // Don't initialize seen unless we have at least one element. |
3258 | | - // Emit a comma to separate for all but the first element. |
3259 | | - if (!seen) { |
| 3257 | + // Don't initialize seen unless we have at least one element. |
| 3258 | + // Emit a comma to separate for all but the first element. |
| 3259 | + if (!seen) { |
3260 | 3260 | seen = createMap<string>(); |
3261 | | - } |
3262 | | - else { |
3263 | | - write(", "); |
3264 | | - } |
| 3261 | + } |
| 3262 | + else { |
| 3263 | + write(", "); |
| 3264 | + } |
3265 | 3265 |
|
3266 | 3266 | if (!(id.text in seen)) { |
3267 | | - emit(id); |
3268 | | - seen[id.text] = id.text; |
3269 | | - } |
| 3267 | + emit(id); |
| 3268 | + seen[id.text] = id.text; |
| 3269 | + } |
3270 | 3270 | } |
3271 | 3271 | write(";"); |
3272 | 3272 | writeLine(); |
@@ -7415,7 +7415,7 @@ const _super = (function (geti, seti) { |
7415 | 7415 | // - import equals declarations that import external modules are not emitted |
7416 | 7416 | continue; |
7417 | 7417 | } |
7418 | | - // fall-though for import declarations that import internal modules |
| 7418 | + // fall-though for import declarations that import internal modules |
7419 | 7419 | default: |
7420 | 7420 | writeLine(); |
7421 | 7421 | emit(statement); |
@@ -8364,24 +8364,28 @@ const _super = (function (geti, seti) { |
8364 | 8364 | } |
8365 | 8365 | } |
8366 | 8366 |
|
8367 | | - function emitFile({ jsFilePath, sourceMapFilePath, declarationFilePath}: { jsFilePath: string, sourceMapFilePath: string, declarationFilePath: string }, |
| 8367 | + function emitFile({ jsFilePath, sourceMapFilePath, declarationFilePath }: EmitFileNames, |
8368 | 8368 | sourceFiles: SourceFile[], isBundledEmit: boolean) { |
8369 | | - // Make sure not to write js File and source map file if any of them cannot be written |
8370 | | - if (!host.isEmitBlocked(jsFilePath) && !compilerOptions.noEmit) { |
8371 | | - emitJavaScript(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit); |
8372 | | - } |
8373 | | - else { |
8374 | | - emitSkipped = true; |
| 8369 | + if (!emitOnlyDtsFiles) { |
| 8370 | + // Make sure not to write js File and source map file if any of them cannot be written |
| 8371 | + if (!host.isEmitBlocked(jsFilePath) && !compilerOptions.noEmit) { |
| 8372 | + emitJavaScript(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit); |
| 8373 | + } |
| 8374 | + else { |
| 8375 | + emitSkipped = true; |
| 8376 | + } |
8375 | 8377 | } |
8376 | 8378 |
|
8377 | 8379 | if (declarationFilePath) { |
8378 | 8380 | emitSkipped = writeDeclarationFile(declarationFilePath, sourceFiles, isBundledEmit, host, resolver, emitterDiagnostics) || emitSkipped; |
8379 | 8381 | } |
8380 | 8382 |
|
8381 | 8383 | if (!emitSkipped && emittedFilesList) { |
8382 | | - emittedFilesList.push(jsFilePath); |
8383 | | - if (sourceMapFilePath) { |
8384 | | - emittedFilesList.push(sourceMapFilePath); |
| 8384 | + if (!emitOnlyDtsFiles) { |
| 8385 | + emittedFilesList.push(jsFilePath); |
| 8386 | + if (sourceMapFilePath) { |
| 8387 | + emittedFilesList.push(sourceMapFilePath); |
| 8388 | + } |
8385 | 8389 | } |
8386 | 8390 | if (declarationFilePath) { |
8387 | 8391 | emittedFilesList.push(declarationFilePath); |
|
0 commit comments