8000 Compilation of Js Files by sheetalkamat · Pull Request #5345 · microsoft/TypeScript · GitHub
[go: up one dir, main page]

Skip to content

Compilation of Js Files #5345

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

Closed
wants to merge 72 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
0a67ac3
Add .js as supported extension
sheetalkamat Sep 9, 2015
74a3f67
Emit the diagnostics for javascript file instead of doing semantic check
sheetalkamat Sep 9, 2015
279018d
Baseline updates
sheetalkamat Sep 9, 2015
e9688dd
Allow the js files to emit output
sheetalkamat Sep 9, 2015
fad0db2
Report error if output file is among the input files
sheetalkamat Sep 10, 2015
d3dfd2a
Add test cases for simple js file compilations
sheetalkamat Sep 10, 2015
1dc3414
Javascript files will emit declarations too so get declaration diagno…
sheetalkamat Sep 10, 2015
63de162
Let harness to name file even when single unit data specified but th…
sheetalkamat Sep 10, 2015
57e17d2
Test cases for different typescript syntax not supported errors durin…
sheetalkamat Sep 10, 2015
7e30827
Test for rest parameters(copied from language service tests)
sheetalkamat Sep 10, 2015
2252354
Verify syntax error in js file are reported
sheetalkamat Sep 10, 2015
3107bbb
Let tsconfig to pick up js files
sheetalkamat Sep 10, 2015
885babc
Merge branch 'master' into tscJsFiles
sheetalkamat Sep 14, 2015
60f295f
Cleanup of options of project runner
sheetalkamat Sep 14, 2015
8da3bd2
Project testcase to run tsconfig file
sheetalkamat Sep 15, 2015
8aeff92
Add tests when same named .ts and .js file exist with tsconfig file s…
sheetalkamat Sep 16, 2015
bc48c7c
Merge branch 'master' into tscJsFiles
sheetalkamat Sep 16, 2015
9daf635
Verify and fix scenario when .js and .ts files with same name are pre…
sheetalkamat Sep 16, 2015
70d3de4
When same named .d.ts and .js files are present and tscconfig contain…
sheetalkamat Sep 16, 2015
0f73c16
When folder contains .d.ts as well as .js of same name and tsconfig d…
sheetalkamat Sep 16, 2015
dbb2772
Tests when the .ts and .js files are mixed in compilation with tsccon…
sheetalkamat Sep 16, 2015
14b6082
Tests when the .ts and .js files are mixed in compilation with tsccon…
sheetalkamat Sep 16, 2015
2860435
Do not emit javascript files
sheetalkamat Sep 16, 2015
68c65cd
Test case when one of the input file is output file name
sheetalkamat Sep 16, 2015
fce9f32
When tsconfig file doesnt contain file names, consume .js files of di…
sheetalkamat Sep 16, 2015
e32c920
Corrected scenario names in the test cases
sheetalkamat Sep 16, 2015
60e15b2
Report error when emitting declarations if the reference is to .js file
sheetalkamat Sep 16, 2015
400b353
Merge branch 'master' into tscJsFiles
sheetalkamat Sep 18, 2015
c30104e
Add option --jsExtensions to handle extensions to treat as javascript
sheetalkamat Sep 21, 2015
1df341b
Merge branch 'master' into tscJsFilesxt
sheetalkamat Sep 21, 2015
7f09c81
Syntax changes if the extensions to treat as javascript change
sheetalkamat Sep 22, 2015
607564f
Parse all the javascript files with JSX grammer
sheetalkamat Sep 22, 2015
e044d3e
Merge branch 'master' into tscJsFiles
sheetalkamat Sep 22, 2015
0fe282e
Update the type assertion errors to jsx syntax error as we are treati…
sheetalkamat Sep 22, 2015
ce652dc
Fixing few code review comments
sheetalkamat Oct 5, 2015
460c597
Changes in harness to emit expected and actual
sheetalkamat Oct 5, 2015
108f856
Remove tsconfig files of failing testcases
sheetalkamat Oct 5, 2015
b3e4f8e
Create new tscconfig files for the failing testcases
sheetalkamat Oct 5, 2015
db9faf6
Temp change to investigate test failure
sheetalkamat Oct 5, 2015
938c533
Remove the failing testcases
sheetalkamat Oct 5, 2015
567d71c
Add new test cases
sheetalkamat Oct 5, 2015
756052a
Removing console logs that were for debugging
sheetalkamat Oct 5, 2015
b580c55
Merge branch 'master' into tscJsFiles
sheetalkamat Oct 5, 2015
17fca98
Fix tslint error
sheetalkamat Oct 6, 2015
242eb8b
Taken feedback into account and simplified the getFileNames logic to …
sheetalkamat Oct 6, 2015
f7b7204
Remove extension for emitting output should remove any of supported e…
sheetalkamat Oct 8, 2015
2d083f7
Use compilation options to get extensions to remove to get module name
sheetalkamat Oct 8, 2015
2c3c321
Merge branch 'master' into tscJsFiles
sheetalkamat Oct 8, 2015
5e14edb
Verify the emit file name is unique and doesnt overwrite input file
sheetalkamat Oct 12, 2015
a87dae1
Verify that when emit blocking error occurs rest of the emit occurs a…
sheetalkamat Oct 12, 2015
6882035
Verify if one or more files are emitting into same output file we pro…
sheetalkamat Oct 12, 2015
f28fbfd
Merge branch 'master' into tscJsFiles
sheetalkamat Oct 12, 2015
286fb3e
Fix the lint error
sheetalkamat Oct 12, 2015
b38a81b
Emit enabled for JS files
sheetalkamat Oct 12, 2015
d4d6e48
Adding test case for scenario in which error reported depends on orde…
sheetalkamat Oct 12, 2015
9f96f47
Added scenario when duplicate function implementation is reported
sheetalkamat Oct 12, 2015
11b270f
Add testcase - generating declaration file results in more errors in …
sheetalkamat Oct 12, 2015
8176354
Fix the duplicate function implementation error that depended on orde…
sheetalkamat Oct 14, 2015
5aa7086
Use ts.indexOf instead of Array.indexOf method
sheetalkamat Oct 15, 2015
1ae1464
Test cases for let declaration and its use order
sheetalkamat Oct 15, 2015
acf7de7
Merge branch 'master' into tscJsFiles
sheetalkamat Oct 15, 2015
0496bfe
Merge branch 'master' into tscJsFiles
sheetalkamat Oct 19, 2015
a571bcb
Merge branch 'javaScriptModules' into tscJsFiles
sheetalkamat Oct 19, 2015
fe63067
Refactoring to fix build issues
sheetalkamat Oct 19, 2015
87b5618
Dont emit declaration file if there are errors in the source file
sheetalkamat Oct 20, 2015
0dc1a27
Tests update for emitting declarations if no errors
sheetalkamat Oct 20, 2015
16becda
Do not emit declarations file if we reported error about inaccessible…
sheetalkamat Oct 20, 2015
34706df
Check source map files are being overwritten
sheetalkamat Oct 20, 2015
89a313e
Populate if emit was skipped correctly as part of emit result
sheetalkamat Oct 20, 2015
e4110c3
Some test cases to verify that declaration file overwrite is reported…
sheetalkamat Oct 20, 2015
a7b08dd
Test cases to verify that declaration file is not emitted if any of t…
sheetalkamat Oct 20, 2015
6024266
Some tests to cover transpilation of different syntax
sheetalkamat Oct 21, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Populate if emit was skipped correctly as part of emit result
  • Loading branch information
sheetalkamat committed Oct 20, 2015
commit 89a313ed83139132ebfd30f3623dca9b18fcf94e
4 changes: 3 additions & 1 deletion src/compiler/declarationEmitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1608,12 +1608,14 @@ namespace ts {
/* @internal */
export function writeDeclarationFile(declarationFilePath: string, sourceFile: SourceFile, host: EmitHost, resolver: EmitResolver, diagnostics: Diagnostic[]) {
let emitDeclarationResult = emitDeclarations(host, resolver, diagnostics, declarationFilePath, sourceFile);
if (!emitDeclarationResult.reportedDeclarationError && !host.isDeclarationEmitBlocked(declarationFilePath, sourceFile)) {
let emitSkipped = emitDeclarationResult.reportedDeclarationError || host.isDeclarationEmitBlocked(declarationFilePath, sourceFile);
if (!emitSkipped) {
let declarationOutput = emitDeclarationResult.referencePathsOutput
+ getDeclarationOutput(emitDeclarationResult.synchronousDeclarationOutput, emitDeclarationResult.moduleElementDeclarationEmitInfo);
let compilerOptions = host.getCompilerOptions();
writeFile(host, diagnostics, declarationFilePath, declarationOutput, compilerOptions.emitBOM);
}
return emitSkipped;

function getDeclarationOutput(synchronousDeclarationOutput: string, moduleElementDeclarationEmitInfo: ModuleElementDeclarationEmitInfo[]) {
let appliedSyncOutputPos = 0;
Expand Down
18 changes: 11 additions & 7 deletions src/compiler/emitter.ts
Original file line number< 8000 /th> Diff line number Diff line change
Expand Up @@ -323,35 +323,36 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
let modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === ScriptTarget.ES6 ? ModuleKind.ES6 : ModuleKind.None;
let sourceMapDataList: SourceMapData[] = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined;
let diagnostics: Diagnostic[] = [];
let emitSkipped = false;
let newLine = host.getNewLine();

if (targetSourceFile === undefined) {
forEach(host.getSourceFiles(), sourceFile => {
if (shouldEmitToOwnFile(sourceFile, compilerOptions)) {
emitFile(getEmitFileNames(sourceFile, host), sourceFile);
emitSkipped = emitFile(getEmitFileNames(sourceFile, host), sourceFile) || emitSkipped;
}
});

if (compilerOptions.outFile || compilerOptions.out) {
emitFile(getBundledEmitFileNames(compilerOptions));
emitSkipped = emitFile(getBundledEmitFileNames(compilerOptions)) || emitSkipped;
}
}
else {
// targetSourceFile is specified (e.g calling emitter from language service or calling getSemanticDiagnostic from language service)
if (shouldEmitToOwnFile(targetSourceFile, compilerOptions)) {
emitFile(getEmitFileNames(targetSourceFile, host), targetSourceFile);
emitSkipped = emitFile(getEmitFileNames(targetSourceFile, host), targetSourceFile) || emitSkipped;
}
else if (!isDeclarationFile(targetSourceFile) &&
(compilerOptions.outFile || compilerOptions.out)) {
emitFile(getBundledEmitFileNames(compilerOptions));
emitSkipped = emitFile(getBundledEmitFileNames(compilerOptions)) || emitSkipped;
}
}

// Sort and make the unique list of diagnostics
diagnostics = sortAndDeduplicateDiagnostics(diagnostics);

return {
emitSkipped: false,
emitSkipped,
diagnostics,
sourceMaps: sourceMapDataList
};
Expand Down Expand Up @@ -7597,13 +7598,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi

function emitFile({ jsFilePath, sourceMapFilePath, declarationFilePath}: { jsFilePath: string, sourceMapFilePath: string, declarationFilePath: string }, sourceFile?: SourceFile) {
// Make sure not to write js File and source map file if any of them cannot be written
if (!host.isEmitBlocked(jsFilePath) && (!sourceMapFilePath || !host.isEmitBlocked(sourceMapFilePath))) {
let emitSkipped = host.isEmitBlocked(jsFilePath) || (sourceMapFilePath && host.isEmitBlocked(sourceMapFilePath));
if (!emitSkipped) {
emitJavaScript(jsFilePath, sourceMapFilePath, sourceFile);
}

if (compilerOptions.declaration) {
writeDeclarationFile(declarationFilePath, sourceFile, host, resolver, diagnostics);
emitSkipped = writeDeclarationFile(declarationFilePath, sourceFile, host, resolver, diagnostics) || emitSkipped;
}

return emitSkipped;
}
}
}
2 changes: 1 addition & 1 deletion src/compiler/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ namespace ts {
program.getSemanticDiagnostics(sourceFile, cancellationToken));

if (program.getCompilerOptions().declaration) {
diagnostics.concat(program.getDeclarationDiagnostics(sourceFile, cancellationToken));
diagnostics = diagnostics.concat(program.getDeclarationDiagnostics(sourceFile, cancellationToken));
}

return sortAndDeduplicateDiagnostics(diagnostics);
Expand Down
4 changes: 2 additions & 2 deletions src/harness/harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1121,7 +1121,7 @@ namespace Harness {

let emitResult = program.emit();

let errors = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
let errors = ts.getPreEmitDiagnostics(program);
this.lastErrors = errors;

let result = new CompilerResult(fileOutputs, errors, program, Harness.IO.getCurrentDirectory(), emitResult.sourceMaps);
Expand Down Expand Up @@ -1666,7 +1666,7 @@ namespace Harness {
let encoded_actual = Utils.encodeString(actual);
if (expected != encoded_actual) {
// Overwrite & issue error
let errMsg = "The baseline file " + relativeFileName + " has changed.\nExpected:\n" + expected + "\nActual:\n" + encoded_actual;
let errMsg = "The baseline file " + relativeFileName + " has changed.";
throw new Error(errMsg);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
EmitSkipped: true
Diagnostics:
Cannot write file 'tests/cases/fourslash/b.js' which is one of the input files.

EmitSkipped: false
FileName : tests/cases/fourslash/a.js
function foo2() { return 30; } // no error - should emit a.js

Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
EmitSkipped: false
EmitSkipped: true
Diagnostics:
Exported variable 'foo' has or is using private name 'C'.
FileName : tests/cases/fourslash/inputFile.js
var M;
(function (M) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
EmitSkipped: false
EmitSkipped: true
Diagnostics:
Exported variable 'foo' has or is using private name 'C'.
FileName : tests/cases/fourslash/inputFile.js
define(["require", "exports"], function (require, exports) {
var C = (function () {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
EmitSkipped: false
EmitSkipped: true
Diagnostics:
Type 'string' is not assignable to type 'number'.
FileName : tests/cases/fourslash/inputFile.js
var x = "hello world";

Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
EmitSkipped: false
EmitSkipped: true
Diagnostics:
Type 'string' is not assignable to type 'boolean'.
FileName : out.js
// File to emit, does not contain semantic errors, but --out is passed
// expected to not generate declarations because of the semantic errors in the other file
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/// <reference path="fourslash.ts" />

// @BaselineFile: compileOnSaveWorksWhenEmitBlockingErrorOnOtherFile.baseline
// @jsExtensions: js
// @Filename: b.js
// @emitThisFile: true
////function foo() { } // This has error because js file cannot be overwritten - emitSkipped should be true

// @Filename: a.ts
// @emitThisFile: true
////function foo2() { return 30; } // no error - should emit a.js

verify.baselineGetEmitOutput();
0