mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-27 13:42:16 -05:00
Do not emit javascript files
This commit is contained in:
@@ -104,7 +104,7 @@ namespace ts {
|
||||
// Emit references corresponding to this file
|
||||
let emittedReferencedFiles: SourceFile[] = [];
|
||||
forEach(host.getSourceFiles(), sourceFile => {
|
||||
if (!isExternalModuleOrDeclarationFile(sourceFile)) {
|
||||
if (!isExternalModuleOrDeclarationFile(sourceFile) && !isJavaScript(sourceFile.fileName)) {
|
||||
// Check what references need to be added
|
||||
if (!compilerOptions.noResolve) {
|
||||
forEach(sourceFile.referencedFiles, fileReference => {
|
||||
|
||||
@@ -88,7 +88,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
let jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, host, shouldEmitJsx(targetSourceFile) ? ".jsx" : ".js");
|
||||
emitFile(jsFilePath, targetSourceFile);
|
||||
}
|
||||
else if (!isDeclarationFile(targetSourceFile) && (compilerOptions.outFile || compilerOptions.out)) {
|
||||
else if (!isDeclarationFile(targetSourceFile) &&
|
||||
!isJavaScript(targetSourceFile.fileName) &&
|
||||
(compilerOptions.outFile || compilerOptions.out)) {
|
||||
emitFile(compilerOptions.outFile || compilerOptions.out);
|
||||
}
|
||||
}
|
||||
@@ -199,7 +201,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
else {
|
||||
forEach(host.getSourceFiles(), sourceFile => {
|
||||
if (!isExternalModuleOrDeclarationFile(sourceFile)) {
|
||||
if (!isJavaScript(sourceFile.fileName) && !isExternalModuleOrDeclarationFile(sourceFile)) {
|
||||
emitSourceFile(sourceFile);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1778,7 +1778,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function shouldEmitToOwnFile(sourceFile: SourceFile, compilerOptions: CompilerOptions): boolean {
|
||||
if (!isDeclarationFile(sourceFile)) {
|
||||
if (!isDeclarationFile(sourceFile) && !isJavaScript(sourceFile.fileName)) {
|
||||
if ((isExternalModule(sourceFile) || !(compilerOptions.outFile || compilerOptions.out))) {
|
||||
// 1. in-browser single file compilation scenario
|
||||
// 2. non supported extension file
|
||||
|
||||
@@ -2,5 +2,4 @@ EmitSkipped: false
|
||||
FileName : declSingle.js
|
||||
var x = "hello";
|
||||
var x1 = 1000;
|
||||
var x2 = 1000;
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
error TS5054: Could not write file 'tests/cases/compiler/a.js' which is one of the input files.
|
||||
tests/cases/compiler/a.js(1,1): error TS8009: 'declare' can only be used in a .ts file.
|
||||
|
||||
|
||||
!!! error TS5054: Could not write file 'tests/cases/compiler/a.js' which is one of the input files.
|
||||
==== tests/cases/compiler/a.js (1 errors) ====
|
||||
declare var v;
|
||||
~~~~~~~
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
error TS5054: Could not write file 'tests/cases/compiler/a.js' which is one of the input files.
|
||||
tests/cases/compiler/a.js(1,1): error TS8017: 'decorators' can only be used in a .ts file.
|
||||
|
||||
|
||||
!!! error TS5054: Could not write file 'tests/cases/compiler/a.js' which is one of the input files.
|
||||
==== tests/cases/compiler/a.js (1 errors) ====
|
||||
@internal class C { }
|
||||
~~~~~~~~~
|
||||
|
||||
@@ -15,11 +15,8 @@ var c = (function () {
|
||||
}
|
||||
return c;
|
||||
})();
|
||||
function foo() {
|
||||
}
|
||||
|
||||
|
||||
//// [out.d.ts]
|
||||
declare class c {
|
||||
}
|
||||
declare function foo(): void;
|
||||
|
||||
@@ -19,15 +19,8 @@ var c = (function () {
|
||||
}
|
||||
return c;
|
||||
})();
|
||||
function bar() {
|
||||
}
|
||||
/// <reference path="c.js"/>
|
||||
function foo() {
|
||||
}
|
||||
|
||||
|
||||
//// [out.d.ts]
|
||||
declare class c {
|
||||
}
|
||||
declare function bar(): void;
|
||||
declare function foo(): void;
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
error TS5054: Could not write file 'tests/cases/compiler/a.js' which is one of the input files.
|
||||
tests/cases/compiler/a.js(1,6): error TS8015: 'enum declarations' can only be used in a .ts file.
|
||||
|
||||
|
||||
!!! error TS5054: Could not write file 'tests/cases/compiler/a.js' which is one of the input files.
|
||||
==== tests/cases/compiler/a.js (1 errors) ====
|
||||
enum E { }
|
||||
~
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
error TS5054: Could not write file 'tests/cases/compiler/a.js' which is one of the input files.
|
||||
tests/cases/compiler/a.js(1,1): error TS8003: 'export=' can only be used in a .ts file.
|
||||
|
||||
|
||||
!!! error TS5054: Could not write file 'tests/cases/compiler/a.js' which is one of the input files.
|
||||
==== tests/cases/compiler/a.js (1 errors) ====
|
||||
export = b;
|
||||
~~~~~~~~~~~
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
error TS5054: Could not write file 'tests/cases/compiler/a.js' which is one of the input files.
|
||||
tests/cases/compiler/a.js(1,9): error TS8005: 'implements clauses' can only be used in a .ts file.
|
||||
|
||||
|
||||
!!! error TS5054: Could not write file 'tests/cases/compiler/a.js' which is one of the input files.
|
||||
==== tests/cases/compiler/a.js (1 errors) ====
|
||||
class C implements D { }
|
||||
~~~~~~~~~~~~
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
error TS5054: Could not write file 'tests/cases/compiler/a.js' which is one of the input files.
|
||||
tests/cases/compiler/a.js(1,1): error TS8002: 'import ... =' can only be used in a .ts file.
|
||||
|
||||
|
||||
!!! error TS5054: Could not write file 'tests/cases/compiler/a.js' which is one of the input files.
|
||||
==== tests/cases/compiler/a.js (1 errors) ====
|
||||
import a = b;
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
error TS5054: Could not write file 'tests/cases/compiler/a.js' which is one of the input files.
|
||||
tests/cases/compiler/a.js(1,11): error TS8006: 'interface declarations' can only be used in a .ts file.
|
||||
|
||||
|
||||
!!! error TS5054: Could not write file 'tests/cases/compiler/a.js' which is one of the input files.
|
||||
==== tests/cases/compiler/a.js (1 errors) ====
|
||||
interface I { }
|
||||
~
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
error TS5054: Could not write file 'tests/cases/compiler/a.js' which is one of the input files.
|
||||
tests/cases/compiler/a.js(1,8): error TS8007: 'module declarations' can only be used in a .ts file.
|
||||
|
||||
|
||||
!!! error TS5054: Could not write file 'tests/cases/compiler/a.js' which is one of the input files.
|
||||
==== tests/cases/compiler/a.js (1 errors) ====
|
||||
module M { }
|
||||
~
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
error TS5054: Could not write file 'tests/cases/compiler/a.js' which is one of the input files.
|
||||
tests/cases/compiler/a.js(1,13): error TS8009: '?' can only be used in a .ts file.
|
||||
|
||||
|
||||
!!! error TS5054: Could not write file 'tests/cases/compiler/a.js' which is one of the input files.
|
||||
==== tests/cases/compiler/a.js (1 errors) ====
|
||||
function F(p?) { }
|
||||
~
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
error TS5054: Could not write file 'tests/cases/compiler/a.js' which is one of the input files.
|
||||
tests/cases/compiler/a.js(1,11): error TS8014: 'property declarations' can only be used in a .ts file.
|
||||
|
||||
|
||||
!!! error TS5054: Could not write file 'tests/cases/compiler/a.js' which is one of the input files.
|
||||
==== tests/cases/compiler/a.js (1 errors) ====
|
||||
class C { v }
|
||||
~
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
error TS5054: Could not write file 'tests/cases/compiler/a.js' which is one of the input files.
|
||||
tests/cases/compiler/a.js(2,5): error TS8009: 'public' can only be used in a .ts file.
|
||||
|
||||
|
||||
!!! error TS5054: Could not write file 'tests/cases/compiler/a.js' which is one of the input files.
|
||||
==== tests/cases/compiler/a.js (1 errors) ====
|
||||
class C {
|
||||
public foo() {
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
error TS5054: Could not write file 'tests/cases/compiler/a.js' which is one of the input files.
|
||||
tests/cases/compiler/a.js(1,23): error TS8012: 'parameter modifiers' can only be used in a .ts file.
|
||||
|
||||
|
||||
!!! error TS5054: Could not write file 'tests/cases/compiler/a.js' which is one of the input files.
|
||||
==== tests/cases/compiler/a.js (1 errors) ====
|
||||
class C { constructor(public x) { }}
|
||||
~~~~~~
|
||||
|
||||
@@ -2,4 +2,3 @@
|
||||
function foo(...a) { }
|
||||
|
||||
//// [b.js]
|
||||
function foo(...a) { }
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
error TS5054: Could not write file 'tests/cases/compiler/a.js' which is one of the input files.
|
||||
tests/cases/compiler/a.js(1,15): error TS8010: 'types' can only be used in a .ts file.
|
||||
|
||||
|
||||
!!! error TS5054: Could not write file 'tests/cases/compiler/a.js' which is one of the input files.
|
||||
==== tests/cases/compiler/a.js (1 errors) ====
|
||||
function F(): number { }
|
||||
~~~~~~
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
error TS5054: Could not write file 'tests/cases/compiler/a.js' which is one of the input files.
|
||||
tests/cases/compiler/a.js(3,6): error TS1223: 'type' tag already specified.
|
||||
|
||||
|
||||
!!! error TS5054: Could not write file 'tests/cases/compiler/a.js' which is one of the input files.
|
||||
==== tests/cases/compiler/a.js (1 errors) ====
|
||||
/**
|
||||
* @type {number}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
error TS5054: Could not write file 'tests/cases/compiler/a.js' which is one of the input files.
|
||||
tests/cases/compiler/a.js(1,1): error TS8008: 'type aliases' can only be used in a .ts file.
|
||||
|
||||
|
||||
!!! error TS5054: Could not write file 'tests/cases/compiler/a.js' which is one of the input files.
|
||||
==== tests/cases/compiler/a.js (1 errors) ====
|
||||
type a = b;
|
||||
~~~~~~~~~~~
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
error TS5054: Could not write file 'tests/cases/compiler/a.js' which is one of the input files.
|
||||
tests/cases/compiler/a.js(1,5): error TS8011: 'type arguments' can only be used in a .ts file.
|
||||
|
||||
|
||||
!!! error TS5054: Could not write file 'tests/cases/compiler/a.js' which is one of the input files.
|
||||
==== tests/cases/compiler/a.js (1 errors) ====
|
||||
Foo<number>();
|
||||
~~~~~~
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
error TS5054: Could not write file 'tests/cases/compiler/a.js' which is one of the input files.
|
||||
tests/cases/compiler/a.js(1,10): error TS8016: 'type assertion expressions' can only be used in a .ts file.
|
||||
|
||||
|
||||
!!! error TS5054: Could not write file 'tests/cases/compiler/a.js' which is one of the input files.
|
||||
==== tests/cases/compiler/a.js (1 errors) ====
|
||||
var v = <string>undefined;
|
||||
~~~~~~
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
error TS5054: Could not write file 'tests/cases/compiler/a.js' which is one of the input files.
|
||||
tests/cases/compiler/a.js(1,15): error TS8010: 'types' can only be used in a .ts file.
|
||||
|
||||
|
||||
!!! error TS5054: Could not write file 'tests/cases/compiler/a.js' which is one of the input files.
|
||||
==== tests/cases/compiler/a.js (1 errors) ====
|
||||
function F(a: number) { }
|
||||
~~~~~~
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
error TS5054: Could not write file 'tests/cases/compiler/a.js' which is one of the input files.
|
||||
tests/cases/compiler/a.js(1,9): error TS8004: 'type parameter declarations' can only be used in a .ts file.
|
||||
|
||||
|
||||
!!! error TS5054: Could not write file 'tests/cases/compiler/a.js' which is one of the input files.
|
||||
==== tests/cases/compiler/a.js (1 errors) ====
|
||||
class C<T> { }
|
||||
~
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
error TS5054: Could not write file 'tests/cases/compiler/a.js' which is one of the input files.
|
||||
tests/cases/compiler/a.js(1,12): error TS8004: 'type parameter declarations' can only be used in a .ts file.
|
||||
|
||||
|
||||
!!! error TS5054: Could not write file 'tests/cases/compiler/a.js' which is one of the input files.
|
||||
==== tests/cases/compiler/a.js (1 errors) ====
|
||||
function F<T>() { }
|
||||
~
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
error TS5054: Could not write file 'tests/cases/compiler/a.js' which is one of the input files.
|
||||
tests/cases/compiler/a.js(1,8): error TS8010: 'types' can only be used in a .ts file.
|
||||
|
||||
|
||||
!!! error TS5054: Could not write file 'tests/cases/compiler/a.js' which is one of the input files.
|
||||
==== tests/cases/compiler/a.js (1 errors) ====
|
||||
var v: () => number;
|
||||
~~~~~~~~~~~~
|
||||
|
||||
@@ -15,5 +15,3 @@ var c = (function () {
|
||||
}
|
||||
return c;
|
||||
})();
|
||||
function foo() {
|
||||
}
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
error TS5054: Could not write file 'tests/cases/compiler/b.js' which is one of the input files.
|
||||
|
||||
|
||||
!!! error TS5054: Could not write file 'tests/cases/compiler/b.js' which is one of the input files.
|
||||
==== tests/cases/compiler/a.ts (0 errors) ====
|
||||
class c {
|
||||
}
|
||||
|
||||
==== tests/cases/compiler/b.js (0 errors) ====
|
||||
function foo() {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
=== tests/cases/compiler/a.ts ===
|
||||
class c {
|
||||
>c : Symbol(c, Decl(a.ts, 0, 0))
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/b.js ===
|
||||
function foo() {
|
||||
>foo : Symbol(foo, Decl(b.js, 0, 0))
|
||||
}
|
||||
|
||||
10
tests/baselines/reference/jsFileCompilationWithoutOut.types
Normal file
10
tests/baselines/reference/jsFileCompilationWithoutOut.types
Normal file
@@ -0,0 +1,10 @@
|
||||
=== tests/cases/compiler/a.ts ===
|
||||
class c {
|
||||
>c : c
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/b.js ===
|
||||
function foo() {
|
||||
>foo : () => void
|
||||
}
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
declare var test: number;
|
||||
declare var test2: number;
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
var test = 10;
|
||||
var test2 = 10; // Should get compiled
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
declare var test: number;
|
||||
declare var test2: number;
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
var test = 10;
|
||||
var test2 = 10; // Should get compiled
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
declare var test: number;
|
||||
declare var test2: number;
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
var test = 10;
|
||||
var test2 = 10; // Should get compiled
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
declare var test: number;
|
||||
declare var test2: number;
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
var test = 10;
|
||||
var test2 = 10; // Should get compiled
|
||||
|
||||
Reference in New Issue
Block a user