Skip to content
  •  
  •  
  •  
4 changes: 0 additions & 4 deletions internal/testutil/tsbaseline/js_emit_baseline.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ func DoJSEmitBaseline(
harnessSettings *harnessutil.HarnessOptions,
opts baseline.Options,
) {
if options.GetAllowJS() {
t.Skip("AllowJS is not supported")
return
}
if options.OutFile != "" || options.Out != "" {
t.Skip("OutFile/Out is not supported")
return
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//// [tests/cases/conformance/salsa/deepElementAccessExpressionInJS.ts] ////

//// [declarations.d.ts]
declare var module: {
exports: {
[key: string]: any;
};
}
//// [elementAccessExpressionInJS.js]
if (module[calculatePropertyName(1)]) {
}
function calculatePropertyName(index) {
// this would be some webpack index in real life
return `property${index}`;
}


//// [elementAccessExpressionInJS.js]
if (module[calculatePropertyName(1)]) {
}
function calculatePropertyName(index) {
// this would be some webpack index in real life
return `property${index}`;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//// [tests/cases/conformance/typeTagForMultipleVariableDeclarations.ts] ////

//// [typeTagForMultipleVariableDeclarations.js]
/** @type {number} */
var x,y,z;
x
y
z


//// [typeTagForMultipleVariableDeclarations.js]
/** @type {number} */
var x, y, z;
x;
y;
z;
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//// [tests/cases/compiler/accessorDeclarationEmitJs.ts] ////

//// [a.js]
export const t1 = {
p: 'value',
get getter() {
return 'value';
},
}

export const t2 = {
v: 'value',
set setter(v) {},
}

export const t3 = {
p: 'value',
get value() {
return 'value';
},
set value(v) {},
}




//// [a.d.ts]
export declare const t1: {
p: string;
readonly getter: string;
};
export declare const t2: {
v: string;
setter: any;
};
export declare const t3: {
p: string;
value: string;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
--- old.accessorDeclarationEmitJs.js
+++ new.accessorDeclarationEmitJs.js
@@= skipped -24, +24 lines =@@


//// [a.d.ts]
-export namespace t1 {
- let p: string;
- const getter: string;
-}
-export namespace t2 {
- let v: string;
- let setter: any;
-}
-export namespace t3 {
- let p_1: string;
- export { p_1 as p };
- export let value: string;
-}
+export declare const t1: {
+ p: string;
+ readonly getter: string;
+};
+export declare const t2: {
+ v: string;
+ setter: any;
+};
+export declare const t3: {
+ p: string;
+ value: string;
+};
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//// [tests/cases/compiler/allowJscheckJsTypeParameterNoCrash.ts] ////

//// [func.ts]
interface ComponentOptions<V> {
watch: Record<string, WatchHandler<any>>;
}
type WatchHandler<T> = (val: T) => void;
declare function extend(options: ComponentOptions<{}>): void;
export var vextend = extend;
//// [app.js]
import {vextend} from './func';
// hover on vextend
export var a = vextend({
watch: {
data1(val) {
this.data2 = 1;
},
data2(val) { },
}
});

//// [func.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.vextend = void 0;
exports.vextend = extend;
//// [app.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.a = void 0;
const func_1 = require("./func");
// hover on vextend
exports.a = (0, func_1.vextend)({
watch: {
data1(val) {
this.data2 = 1;
},
data2(val) { },
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--- old.allowJscheckJsTypeParameterNoCrash.js
+++ new.allowJscheckJsTypeParameterNoCrash.js
@@= skipped -27, +27 lines =@@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.a = void 0;
-var func_1 = require("./func");
+const func_1 = require("./func");
// hover on vextend
exports.a = (0, func_1.vextend)({
watch: {
- data1: function (val) {
+ data1(val) {
this.data2 = 1;
},
- data2: function (val) { },
+ data2(val) { },
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//// [tests/cases/compiler/ambientRequireFunction.ts] ////

//// [node.d.ts]
declare function require(moduleName: string): any;

declare module "fs" {
export function readFileSync(s: string): string;
}

//// [app.js]
/// <reference path="node.d.ts"/>

const fs = require("fs");
const text = fs.readFileSync("/a/b/c");

//// [app.js]
/// <reference path="node.d.ts"/>
const fs = require("fs");
const text = fs.readFileSync("/a/b/c");
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--- old.ambientRequireFunction(module=commonjs).js
+++ new.ambientRequireFunction(module=commonjs).js
@@= skipped -14, +14 lines =@@

//// [app.js]
/// <reference path="node.d.ts"/>
-var fs = require("fs");
-var text = fs.readFileSync("/a/b/c");
+const fs = require("fs");
+const text = fs.readFileSync("/a/b/c");
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//// [tests/cases/compiler/ambientRequireFunction.ts] ////

//// [node.d.ts]
declare function require(moduleName: string): any;

declare module "fs" {
export function readFileSync(s: string): string;
}

//// [app.js]
/// <reference path="node.d.ts"/>

const fs = require("fs");
const text = fs.readFileSync("/a/b/c");

//// [app.js]
/// <reference path="node.d.ts"/>
const fs = require("fs");
const text = fs.readFileSync("/a/b/c");
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--- old.ambientRequireFunction(module=preserve).js
+++ new.ambientRequireFunction(module=preserve).js
@@= skipped -14, +14 lines =@@

//// [app.js]
/// <reference path="node.d.ts"/>
-var fs = require("fs");
-var text = fs.readFileSync("/a/b/c");
+const fs = require("fs");
+const text = fs.readFileSync("/a/b/c");
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//// [tests/cases/compiler/amdLikeInputDeclarationEmit.ts] ////

//// [typing.d.ts]
declare function define<T=unknown>(name: string, modules: string[], ready: (...modules: unknown[]) => T);
//// [BaseClass.d.ts]
declare module "deps/BaseClass" {
class BaseClass {
static extends<A>(a: A): new () => A & BaseClass;
}
export = BaseClass;
}
//// [ExtendedClass.js]
define("lib/ExtendedClass", ["deps/BaseClass"],
/**
* {typeof import("deps/BaseClass")}
* @param {typeof import("deps/BaseClass")} BaseClass
* @returns
*/
(BaseClass) => {

const ExtendedClass = BaseClass.extends({
f: function() {
return "something";
}
});

// Exports the module in a way tsc recognize class export
const module = {};
module.exports = ExtendedClass
return module.exports;
});



//// [ExtendedClass.d.ts]
export {};
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- old.amdLikeInputDeclarationEmit.js
+++ new.amdLikeInputDeclarationEmit.js
@@= skipped -32, +32 lines =@@


//// [ExtendedClass.d.ts]
-export = ExtendedClass;
-declare const ExtendedClass: new () => {
- f: () => "something";
-} & import("deps/BaseClass");
+export {};
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//// [tests/cases/compiler/argumentsPropertyNameInJsMode1.ts] ////

//// [a.js]
const foo = {
f1: (params) => { }
}

function f2(x) {
foo.f1({ x, arguments: [] });
}

f2(1, 2, 3);


//// [a.js]
const foo = {
f1: (params) => { }
};
function f2(x) {
foo.f1({ x, arguments: [] });
}
f2(1, 2, 3);


//// [a.d.ts]
declare const foo: {
f1: (params: any) => void;
};
declare function f2(x: any): void;
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
--- old.argumentsPropertyNameInJsMode1.js
+++ new.argumentsPropertyNameInJsMode1.js
@@= skipped -12, +12 lines =@@


//// [a.js]
-var foo = {
- f1: function (params) { }
+const foo = {
+ f1: (params) => { }
};
function f2(x) {
- foo.f1({ x: x, arguments: [] });
+ foo.f1({ x, arguments: [] });
}
f2(1, 2, 3);


//// [a.d.ts]
+declare const foo: {
+ f1: (params: any) => void;
+};
declare function f2(x: any): void;
-declare namespace foo {
- function f1(params: any): void;
-}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//// [tests/cases/compiler/argumentsPropertyNameInJsMode2.ts] ////

//// [a.js]
function f(x) {
arguments;
}

f(1, 2, 3);


//// [a.js]
function f(x) {
arguments;
}
f(1, 2, 3);


//// [a.d.ts]
declare function f(x: any): void;
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
--- old.argumentsPropertyNameInJsMode2.js
+++ new.argumentsPropertyNameInJsMode2.js
@@= skipped -15, +15 lines =@@


//// [a.d.ts]
-declare function f(x: any, ...args: any[]): void;
+declare function f(x: any): void;
Loading
Loading