mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge pull request #5471 from Microsoft/jsFileCompilation
Compilation of Js Files
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
// @declaration: true
|
||||
// @target: es5
|
||||
class a {
|
||||
//constructor ();
|
||||
constructor (n: number);
|
||||
@@ -13,7 +14,7 @@ class a {
|
||||
public get d() {
|
||||
return 30;
|
||||
}
|
||||
public set d() {
|
||||
public set d(a: number) {
|
||||
}
|
||||
|
||||
public static get p2() {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// @declaration: true
|
||||
// @target: es5
|
||||
|
||||
function /*1*/makePoint(x: number) {
|
||||
return {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// @declaration: true
|
||||
// @target: es5
|
||||
|
||||
function /*1*/makePoint(x: number) {
|
||||
return {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// @declaration: true
|
||||
// @target: es5
|
||||
|
||||
function /*1*/makePoint(x: number) {
|
||||
return {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// @declaration: true
|
||||
// @target: es5
|
||||
|
||||
class C {
|
||||
private static x = 1;
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
// @declaration: true
|
||||
|
||||
// @Filename: declFile.d.ts
|
||||
declare module M {
|
||||
declare var x;
|
||||
declare function f();
|
||||
|
||||
declare module N { }
|
||||
|
||||
declare class C { }
|
||||
}
|
||||
|
||||
// @Filename: client.ts
|
||||
///<reference path="declFile.d.ts"/>
|
||||
var x = new M.C(); // Declaration file wont get emitted because there are errors in declaration file
|
||||
@@ -0,0 +1,16 @@
|
||||
// @declaration: true
|
||||
// @out: out.js
|
||||
|
||||
// @Filename: declFile.d.ts
|
||||
declare module M {
|
||||
declare var x;
|
||||
declare function f();
|
||||
|
||||
declare module N { }
|
||||
|
||||
declare class C { }
|
||||
}
|
||||
|
||||
// @Filename: client.ts
|
||||
///<reference path="declFile.d.ts"/>
|
||||
var x = new M.C(); // Declaration file wont get emitted because there are errors in declaration file
|
||||
@@ -0,0 +1,9 @@
|
||||
// @declaration: true
|
||||
|
||||
// @Filename: a.d.ts
|
||||
declare class c {
|
||||
}
|
||||
|
||||
// @FileName: a.ts
|
||||
class d {
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// @declaration: true
|
||||
// @out: tests/cases/compiler/out.js
|
||||
|
||||
// @Filename: out.d.ts
|
||||
declare class c {
|
||||
}
|
||||
|
||||
// @FileName: a.ts
|
||||
class d {
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// @filename: a.ts
|
||||
class c {
|
||||
}
|
||||
|
||||
// @filename: a.tsx
|
||||
function foo() {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// @out: tests/cases/compiler/a.js
|
||||
// @module: amd
|
||||
// @filename: a.ts
|
||||
export class c {
|
||||
}
|
||||
|
||||
// @filename: b.ts
|
||||
function foo() {
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
// @allowJs: true
|
||||
// @filename: a.js
|
||||
declare var v;
|
||||
@@ -0,0 +1,9 @@
|
||||
// @allowJs: true
|
||||
// @out: out.js
|
||||
|
||||
// @FileName: a.js
|
||||
class c {
|
||||
method(a) {
|
||||
let x = a => this.method(a);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
// @allowJs: true
|
||||
// @filename: a.js
|
||||
@internal class C { }
|
||||
@@ -0,0 +1,12 @@
|
||||
// @allowJs: true
|
||||
// @out: out.js
|
||||
// @declaration: true
|
||||
// @filename: b.js
|
||||
function foo() {
|
||||
return 10;
|
||||
}
|
||||
// @filename: a.ts
|
||||
function foo() {
|
||||
return 30;
|
||||
}
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// @allowJs: true
|
||||
// @out: out.js
|
||||
// @declaration: true
|
||||
// @filename: a.ts
|
||||
function foo() {
|
||||
return 30;
|
||||
}
|
||||
|
||||
// @filename: b.js
|
||||
function foo() {
|
||||
return 10;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
// @allowJs: true
|
||||
// @out: out.js
|
||||
// @declaration: true
|
||||
// @filename: a.ts
|
||||
var x = 10;
|
||||
|
||||
// @filename: b.js
|
||||
var x = "hello"; // No error is recorded here and declaration file will show this as number
|
||||
@@ -0,0 +1,8 @@
|
||||
// @allowJs: true
|
||||
// @out: out.js
|
||||
// @declaration: true
|
||||
// @filename: b.js
|
||||
var x = "hello";
|
||||
|
||||
// @filename: a.ts
|
||||
var x = 10; // Error reported so no declaration file generated?
|
||||
@@ -0,0 +1,13 @@
|
||||
// @allowJs: true
|
||||
// @filename: a.ts
|
||||
class c {
|
||||
}
|
||||
|
||||
// @filename: b.ts
|
||||
// this should be emitted
|
||||
class d {
|
||||
}
|
||||
|
||||
// @filename: a.js
|
||||
function foo() {
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// @allowJs: true
|
||||
// @out: out.js
|
||||
// @declaration: true
|
||||
// @filename: a.ts
|
||||
class c {
|
||||
}
|
||||
|
||||
// @filename: b.js
|
||||
function foo() {
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// @allowJs: true
|
||||
// @out: out.js
|
||||
// @declaration: true
|
||||
// @filename: a.ts
|
||||
class c {
|
||||
}
|
||||
|
||||
// @filename: b.js
|
||||
/// <reference path="c.js"/>
|
||||
function foo() {
|
||||
}
|
||||
|
||||
// @filename: c.js
|
||||
function bar() {
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
// @allowJs: true
|
||||
// @filename: a.js
|
||||
enum E { }
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// @allowJs: true
|
||||
// @declaration: true
|
||||
// @filename: a.ts
|
||||
class c {
|
||||
}
|
||||
|
||||
// @filename: b.ts
|
||||
/// <reference path="c.js"/>
|
||||
// b.d.ts should have c.js as the reference path since we dont emit declarations for js files
|
||||
function foo() {
|
||||
}
|
||||
|
||||
// @filename: c.js
|
||||
function bar() {
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// @allowJs: true
|
||||
// @out: out.js
|
||||
// @declaration: true
|
||||
// @filename: a.ts
|
||||
class c {
|
||||
}
|
||||
|
||||
// @filename: b.ts
|
||||
/// <reference path="c.js"/>
|
||||
// error on above reference when emitting declarations
|
||||
function foo() {
|
||||
}
|
||||
|
||||
// @filename: c.js
|
||||
function bar() {
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// @allowJs: true
|
||||
// @declaration: true
|
||||
// @outDir: outDir
|
||||
// @filename: a.ts
|
||||
class c {
|
||||
}
|
||||
|
||||
// @filename: b.ts
|
||||
/// <reference path="c.js"/>
|
||||
// b.d.ts should have c.js as the reference path since we dont emit declarations for js files
|
||||
function foo() {
|
||||
}
|
||||
|
||||
// @filename: c.js
|
||||
function bar() {
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
// @allowJs: true
|
||||
// @filename: a.js
|
||||
export = b;
|
||||
@@ -0,0 +1,3 @@
|
||||
// @allowJs: true
|
||||
// @filename: a.js
|
||||
class C implements D { }
|
||||
@@ -0,0 +1,3 @@
|
||||
// @allowJs: true
|
||||
// @filename: a.js
|
||||
import a = b;
|
||||
@@ -0,0 +1,3 @@
|
||||
// @allowJs: true
|
||||
// @filename: a.js
|
||||
interface I { }
|
||||
@@ -0,0 +1,9 @@
|
||||
// @allowJs: true
|
||||
// @out: out.js
|
||||
|
||||
// @FileName: a.js
|
||||
function foo(a) {
|
||||
for (let a = 0; a < 10; a++) {
|
||||
// do something
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// @allowJs: true
|
||||
// @out: out.js
|
||||
// @declaration: true
|
||||
// @filename: b.js
|
||||
let a = 10;
|
||||
b = 30;
|
||||
|
||||
// @filename: a.ts
|
||||
let b = 30;
|
||||
a = 10;
|
||||
@@ -0,0 +1,9 @@
|
||||
// @allowJs: true
|
||||
// @out: out.js
|
||||
// @declaration: true
|
||||
// @filename: a.ts
|
||||
let b = 30;
|
||||
a = 10;
|
||||
// @filename: b.js
|
||||
let a = 10;
|
||||
b = 30;
|
||||
@@ -0,0 +1,3 @@
|
||||
// @allowJs: true
|
||||
// @filename: a.js
|
||||
module M { }
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// @allowJs: true
|
||||
// @filename: a.ts
|
||||
class c {
|
||||
}
|
||||
|
||||
// @filename: b.ts
|
||||
/// <reference path="c.js"/>
|
||||
// no error on above reference path since not emitting declarations
|
||||
function foo() {
|
||||
}
|
||||
|
||||
// @filename: c.js
|
||||
function bar() {
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// @allowJs: true
|
||||
// @out: out.js
|
||||
// @filename: a.ts
|
||||
class c {
|
||||
}
|
||||
|
||||
// @filename: b.ts
|
||||
/// <reference path="c.js"/>
|
||||
//no error on above reference since not emitting declarations
|
||||
function foo() {
|
||||
}
|
||||
|
||||
// @filename: c.js
|
||||
function bar() {
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
// @allowJs: true
|
||||
// @filename: a.js
|
||||
function F(p?) { }
|
||||
@@ -0,0 +1,3 @@
|
||||
// @allowJs: true
|
||||
// @filename: a.js
|
||||
class C { v }
|
||||
@@ -0,0 +1,6 @@
|
||||
// @allowJs: true
|
||||
// @filename: a.js
|
||||
class C {
|
||||
public foo() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
// @allowJs: true
|
||||
// @filename: a.js
|
||||
class C { constructor(public x) { }}
|
||||
@@ -0,0 +1,5 @@
|
||||
// @allowJs: true
|
||||
// @filename: a.js
|
||||
// @target: es6
|
||||
// @out: b.js
|
||||
function foo(...a) { }
|
||||
@@ -0,0 +1,3 @@
|
||||
// @allowJs: true
|
||||
// @filename: a.js
|
||||
function F(): number { }
|
||||
@@ -0,0 +1,12 @@
|
||||
// @allowJs: true
|
||||
// @out: out.js
|
||||
|
||||
// @FileName: a.js
|
||||
function foo() {
|
||||
var a = 10;
|
||||
var b = "Hello";
|
||||
return {
|
||||
a,
|
||||
b
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// @allowJs: true
|
||||
// @filename: a.js
|
||||
/**
|
||||
* @type {number}
|
||||
* @type {string}
|
||||
*/
|
||||
var v;
|
||||
@@ -0,0 +1,3 @@
|
||||
// @allowJs: true
|
||||
// @filename: a.js
|
||||
type a = b;
|
||||
@@ -0,0 +1,3 @@
|
||||
// @allowJs: true
|
||||
// @filename: a.js
|
||||
Foo<number>();
|
||||
@@ -0,0 +1,3 @@
|
||||
// @allowJs: true
|
||||
// @filename: a.js
|
||||
var v = <string>undefined;
|
||||
@@ -0,0 +1,3 @@
|
||||
// @allowJs: true
|
||||
// @filename: a.js
|
||||
function F(a: number) { }
|
||||
@@ -0,0 +1,3 @@
|
||||
// @allowJs: true
|
||||
// @filename: a.js
|
||||
class C<T> { }
|
||||
@@ -0,0 +1,3 @@
|
||||
// @allowJs: true
|
||||
// @filename: a.js
|
||||
function F<T>() { }
|
||||
@@ -0,0 +1,3 @@
|
||||
// @allowJs: true
|
||||
// @filename: a.js
|
||||
var v: () => number;
|
||||
@@ -0,0 +1,7 @@
|
||||
// @declaration: true
|
||||
// @filename: a.ts
|
||||
class c {
|
||||
}
|
||||
|
||||
// @filename: a.d.ts
|
||||
declare function isC(): boolean;
|
||||
@@ -0,0 +1,8 @@
|
||||
// @allowJs: true
|
||||
// @filename: a.ts
|
||||
class c {
|
||||
}
|
||||
|
||||
// @filename: a.js
|
||||
function foo() {
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// @allowJs: true
|
||||
// @sourcemap: true
|
||||
|
||||
// @filename: a.ts
|
||||
class c {
|
||||
}
|
||||
|
||||
// @filename: b.js.map
|
||||
function foo() {
|
||||
}
|
||||
|
||||
// @filename: b.js
|
||||
function bar() {
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// @allowJs: true
|
||||
// @inlineSourceMap: true
|
||||
|
||||
// @filename: a.ts
|
||||
class c {
|
||||
}
|
||||
|
||||
// @filename: b.js.map
|
||||
function foo() {
|
||||
}
|
||||
|
||||
// @filename: b.js
|
||||
function bar() {
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// @allowJs: true,map
|
||||
// @sourcemap: true
|
||||
// @outdir: out
|
||||
|
||||
// @filename: a.ts
|
||||
class c {
|
||||
}
|
||||
|
||||
// @filename: b.js.map
|
||||
function foo() {
|
||||
}
|
||||
|
||||
// @filename: b.js
|
||||
function bar() {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// @allowJs: true
|
||||
// @out: out.js
|
||||
// @filename: a.ts
|
||||
class c {
|
||||
}
|
||||
|
||||
// @filename: b.js
|
||||
function foo() {
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// @declaration: true
|
||||
// @out: tests/cases/compiler/b.js
|
||||
// @filename: a.ts
|
||||
class c {
|
||||
}
|
||||
|
||||
// @filename: b.d.ts
|
||||
declare function foo(): boolean;
|
||||
@@ -0,0 +1,9 @@
|
||||
// @allowJs: true
|
||||
// @out: tests/cases/compiler/b.js
|
||||
// @filename: a.ts
|
||||
class c {
|
||||
}
|
||||
|
||||
// @filename: b.js
|
||||
function foo() {
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
// @filename: a.js
|
||||
declare var v;
|
||||
@@ -0,0 +1,8 @@
|
||||
// @allowJs: true
|
||||
// @filename: a.ts
|
||||
class c {
|
||||
}
|
||||
|
||||
// @filename: b.js
|
||||
function foo() {
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
// @declaration: true
|
||||
// @target: es5
|
||||
|
||||
module a {
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ module m1 {
|
||||
return "Hello";
|
||||
}
|
||||
}
|
||||
declare export module m2 {
|
||||
export declare module m2 {
|
||||
|
||||
export var a: number;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @BaselineFile: compileOnSaveWorksWhenEmitBlockingErrorOnOtherFile.baseline
|
||||
// @allowJs: true
|
||||
// @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();
|
||||
@@ -1,6 +1,6 @@
|
||||
///<reference path="fourslash.ts" />
|
||||
|
||||
// @allowNonTsExtensions: true
|
||||
// @allowJs: true
|
||||
// @Filename: Foo.js
|
||||
/////** @/*1*/ */
|
||||
////var v1;
|
||||
|
||||
@@ -52,7 +52,13 @@ declare module ts {
|
||||
None = 0,
|
||||
Block = 1,
|
||||
Smart = 2,
|
||||
}
|
||||
}
|
||||
|
||||
interface OutputFile {
|
||||
name: string;
|
||||
writeByteOrderMark: boolean;
|
||||
text: string;
|
||||
}
|
||||
}
|
||||
|
||||
declare namespace FourSlashInterface {
|
||||
@@ -133,7 +139,7 @@ declare namespace FourSlashInterface {
|
||||
class verify extends verifyNegatable {
|
||||
caretAtMarker(markerName?: string): void;
|
||||
indentationIs(numberOfSpaces: number): void;
|
||||
indentationAtPositionIs(fileName: string, position: number, numberOfSpaces: number, indentStyle?: IndentStyle): void;
|
||||
indentationAtPositionIs(fileName: string, position: number, numberOfSpaces: number, indentStyle?: ts.IndentStyle): void;
|
||||
textAtCaretIs(text: string): void;
|
||||
/**
|
||||
* Compiles the current file and evaluates 'expr' in a context containing
|
||||
@@ -144,6 +150,7 @@ declare namespace FourSlashInterface {
|
||||
currentLineContentIs(text: string): void;
|
||||
currentFileContentIs(text: string): void;
|
||||
verifyGetEmitOutputForCurrentFile(expected: string): void;
|
||||
verifyGetEmitOutputContentsForCurrentFile(expected: ts.OutputFile[]): void;
|
||||
currentParameterHelpArgumentNameIs(name: string): void;
|
||||
currentParameterSpanIs(parameter: string): void;
|
||||
currentParameterHelpArgumentDocCommentIs(docComment: string): void;
|
||||
|
||||
@@ -13,10 +13,18 @@
|
||||
//// x : string;
|
||||
//// y : number
|
||||
//// }
|
||||
//// /*1*/
|
||||
|
||||
// @Filename: inputFile2.tsx
|
||||
// @emitThisFile: true
|
||||
//// declare var React: any;
|
||||
//// var y = "my div";
|
||||
//// var x = <div name= {y} />
|
||||
//// /*2*/
|
||||
|
||||
goTo.marker("1");
|
||||
verify.numberOfErrorsInCurrentFile(0);
|
||||
goTo.marker("2");
|
||||
verify.numberOfErrorsInCurrentFile(0);
|
||||
|
||||
verify.baselineGetEmitOutput();
|
||||
@@ -1,6 +1,6 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @allowNonTsExtensions: true
|
||||
// @allowJs: true
|
||||
// @Filename: a.js
|
||||
//// import a = b;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @allowNonTsExtensions: true
|
||||
// @allowJs: true
|
||||
// @Filename: a.js
|
||||
//// function F<T>() { }
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @allowNonTsExtensions: true
|
||||
// @allowJs: true
|
||||
// @Filename: a.js
|
||||
//// function F(): number { }
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @allowNonTsExtensions: true
|
||||
// @allowJs: true
|
||||
// @Filename: a.js
|
||||
//// declare var v;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @allowNonTsExtensions: true
|
||||
// @allowJs: true
|
||||
// @Filename: a.js
|
||||
//// var v: () => number;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @allowNonTsExtensions: true
|
||||
// @allowJs: true
|
||||
// @Filename: a.js
|
||||
//// Foo<number>();
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @allowNonTsExtensions: true
|
||||
// @allowJs: true
|
||||
// @Filename: a.js
|
||||
//// function F(public p) { }
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @allowNonTsExtensions: true
|
||||
// @allowJs: true
|
||||
// @Filename: a.js
|
||||
//// function F(p?) { }
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @allowNonTsExtensions: true
|
||||
// @allowJs: true
|
||||
// @Filename: a.js
|
||||
//// function F(a: number) { }
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @allowNonTsExtensions: true
|
||||
// @allowJs: true
|
||||
// @Filename: a.js
|
||||
//// class C { v }
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @allowNonTsExtensions: true
|
||||
// @allowJs: true
|
||||
// @Filename: a.js
|
||||
//// enum E { }
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @allowNonTsExtensions: true
|
||||
// @allowJs: true
|
||||
// @Filename: a.js
|
||||
//// export = b;
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @allowNonTsExtensions: true
|
||||
// @allowJs: true
|
||||
// @Filename: a.js
|
||||
//// var v = <string>undefined;
|
||||
|
||||
verify.getSyntacticDiagnostics(`[]`);
|
||||
verify.getSemanticDiagnostics(`[
|
||||
{
|
||||
"message": "'type assertion expressions' can only be used in a .ts file.",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @allowNonTsExtensions: true
|
||||
// @allowJs: true
|
||||
// @Filename: a.js
|
||||
//// @internal class C {}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @allowNonTsExtensions: true
|
||||
// @allowJs: true
|
||||
// @Filename: a.js
|
||||
//// function foo(...a) {}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @allowNonTsExtensions: true
|
||||
// @allowJs: true
|
||||
// @Filename: a.js
|
||||
//// class C<T> { }
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @allowNonTsExtensions: true
|
||||
// @allowJs: true
|
||||
// @Filename: a.js
|
||||
//// public class C { }
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @allowNonTsExtensions: true
|
||||
// @allowJs: true
|
||||
// @Filename: a.js
|
||||
//// class C implements D { }
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @allowNonTsExtensions: true
|
||||
// @allowJs: true
|
||||
// @Filename: a.js
|
||||
//// interface I { }
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @allowNonTsExtensions: true
|
||||
// @allowJs: true
|
||||
// @Filename: a.js
|
||||
//// module M { }
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @allowNonTsExtensions: true
|
||||
// @allowJs: true
|
||||
// @Filename: a.js
|
||||
//// type a = b;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @allowNonTsExtensions: true
|
||||
// @allowJs: true
|
||||
// @Filename: a.js
|
||||
//// public function F() { }
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
// Invocations of 'require' stop top-level variables from becoming global
|
||||
|
||||
// @allowNonTsExtensions: true
|
||||
// @allowJs: true
|
||||
|
||||
// @Filename: mod1.js
|
||||
//// var x = require('fs');
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
// Assignments to 'module.exports' create an external module
|
||||
|
||||
// @allowNonTsExtensions: true
|
||||
// @allowJs: true
|
||||
// @Filename: myMod.js
|
||||
//// if (true) {
|
||||
//// module.exports = { a: 10 };
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
// Assignments to 'exports.p' stop global variables from being visible in other files
|
||||
|
||||
// @allowNonTsExtensions: true
|
||||
// @allowJs: true
|
||||
// @Filename: myMod.js
|
||||
//// if (true) {
|
||||
//// exports.b = true;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
// Assignments to 'exports.p' define a property 'p' even if they're not at top-level
|
||||
|
||||
// @allowNonTsExtensions: true
|
||||
// @allowJs: true
|
||||
// @Filename: myMod.js
|
||||
//// if (true) {
|
||||
//// exports.b = true;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
// Assignments to 'exports.p' define a property 'p'
|
||||
|
||||
// @allowNonTsExtensions: true
|
||||
// @allowJs: true
|
||||
// @Filename: myMod.js
|
||||
//// exports.n = 3;
|
||||
//// exports.s = 'foo';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
///<reference path="fourslash.ts" />
|
||||
|
||||
// @allowNonTsExtensions: true
|
||||
// @allowJs: true
|
||||
// @Filename: myMod.js
|
||||
//// module.exports = { n: 3, s: 'foo', b: true };
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
// CommonJS modules should not pollute the global namespace
|
||||
|
||||
// @allowNonTsExtensions: true
|
||||
// @allowJs: true
|
||||
// @Filename: myMod.js
|
||||
//// var x = require('fs');
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @declaration: true
|
||||
// @out: out.js
|
||||
// @allowJs: true
|
||||
// @Filename: b.js
|
||||
// @emitThisFile: true
|
||||
////function foo() { return 10; }/*1*/
|
||||
|
||||
// @Filename: a.ts
|
||||
// @emitThisFile: true
|
||||
////function foo() { return 30; }/*2*/
|
||||
|
||||
goTo.marker("1");
|
||||
verify.getSemanticDiagnostics('[]');
|
||||
goTo.marker("2");
|
||||
verify.getSemanticDiagnostics('[\n {\n "message": "Duplicate function implementation.",\n "start": 9,\n "length": 3,\n "category": "error",\n "code": 2393\n }\n]');
|
||||
verify.verifyGetEmitOutputContentsForCurrentFile([
|
||||
{ name: "out.js", text: "function foo() { return 10; }\r\nfunction foo() { return 30; }\r\n", writeByteOrderMark: false },
|
||||
{ name: "out.d.ts", text: "", writeByteOrderMark: false }]);
|
||||
goTo.marker("2");
|
||||
verify.getSemanticDiagnostics('[\n {\n "message": "Duplicate function implementation.",\n "start": 9,\n "length": 3,\n "category": "error",\n "code": 2393\n }\n]');
|
||||
goTo.marker("1");
|
||||
verify.getSemanticDiagnostics('[]');
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"scenario": "Verify when different named .ts and .js file exists in the folder and tsconfig.json doesnt specify any files",
|
||||
"projectRoot": "tests/cases/projects/jsFileCompilation",
|
||||
"baselineCheck": true,
|
||||
"declaration": true,
|
||||
"project": "DifferentNamesNotSpecified"
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"scenario": "Verify when different named .ts and .js file exists in the folder and tsconfig.json doesnt specify any files and .js files are consumed",
|
||||
"projectRoot": "tests/cases/projects/jsFileCompilation",
|
||||
"baselineCheck": true,
|
||||
"declaration": true,
|
||||
"project": "DifferentNamesNotSpecifiedWithAllowJs"
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"scenario": "Verify when different .ts and .js file exist and their names are specified in tsconfig.json",
|
||||
"projectRoot": "tests/cases/projects/jsFileCompilation",
|
||||
"baselineCheck": true,
|
||||
"declaration": true,
|
||||
"project": "DifferentNamesSpecified"
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"scenario": "Verify when different .ts and .js file exist and their names are specified in tsconfig.json and .js files are consumed",
|
||||
"projectRoot": "tests/cases/projects/jsFileCompilation",
|
||||
"baselineCheck": true,
|
||||
"declaration": true,
|
||||
"project": "DifferentNamesSpecifiedWithAllowJs"
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user