Skip to content

Commit 279b837

Browse files
committed
only module-resolution test failing
1 parent 82a9090 commit 279b837

8 files changed

Lines changed: 24 additions & 23 deletions

File tree

test/transpile/module-resolution.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ describe("module resolution should not try to resolve modules in noResolvePaths"
446446
.expectToHaveNoDiagnostics();
447447
});
448448

449-
test("can ignore specific files with glob pattern", () => {
449+
test.only("can ignore specific files with glob pattern", () => {
450450
util.testModule`
451451
// Pre-Load as to not error out at runtime
452452
import "preload";
@@ -472,6 +472,7 @@ describe("module resolution should not try to resolve modules in noResolvePaths"
472472
}`
473473
)
474474
.setOptions({ noResolvePaths: ["ignore*"] })
475+
.debug()
475476
.expectToHaveNoDiagnostics()
476477
.expectToEqual({ result: "foo" });
477478
});

test/unit/functions/functionProperties.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,23 +160,23 @@ test("async arrow function with property assigned to variable", () => {
160160

161161
test("call function with property using call method", () => {
162162
util.testFunction`
163-
function foo(s: string) { return this + s; }
163+
function foo(this: string, s: string) { return this + s; }
164164
foo.baz = "baz";
165165
return foo.call("foo", "bar") + foo.baz;
166166
`.expectToMatchJsResult();
167167
});
168168

169169
test("call function with property using apply method", () => {
170170
util.testFunction`
171-
function foo(s: string) { return this + s; }
171+
function foo(this: string, s: string) { return this + s; }
172172
foo.baz = "baz";
173173
return foo.apply("foo", ["bar"]) + foo.baz;
174174
`.expectToMatchJsResult();
175175
});
176176

177177
test("call function with property using bind method", () => {
178178
util.testFunction`
179-
function foo(s: string) { return this + s; }
179+
function foo(this: string, s: string) { return this + s; }
180180
foo.baz = "baz";
181181
return foo.bind("foo", "bar")() + foo.baz;
182182
`.expectToMatchJsResult();

test/unit/modules/modules.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@ test("Default Import and Export Expression", () => {
9494

9595
test("Import and Export Assignment", () => {
9696
util.testModule`
97-
// @ts-ignore
98-
import * as m from "./module";
97+
import m = require("./module");
9998
export const value = m;
10099
`
101100
.setOptions({ module: ts.ModuleKind.CommonJS })

test/unit/namespaces.spec.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
import * as util from "../util";
22

3-
test("legacy internal module syntax", () => {
4-
util.testModule`
5-
module Foo {
6-
export const foo = "bar";
7-
}
8-
9-
export const foo = Foo.foo;
10-
`.expectToMatchJsResult();
11-
});
12-
133
test("global scoping", () => {
144
util.testFunction("return a.foo();")
155
.setTsHeader('namespace a { export function foo() { return "bar"; } }')
@@ -42,7 +32,7 @@ test("context in namespace function", () => {
4232
util.testModule`
4333
namespace a {
4434
export const foo = "foo";
45-
export function bar() { return this.foo + "bar"; }
35+
export function bar(this: typeof a) { return this.foo + "bar"; }
4636
}
4737
4838
export const result = a.bar();

test/unit/precedingStatements.spec.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,16 @@ describe("execution order", () => {
101101
util.testFunction`
102102
const o = {a: "A", b: "B", c: "C"};
103103
let i = 0;
104-
const literal = ${literal};
104+
const literal: Record<string, unknown> = ${literal};
105105
const result: Record<string, unknown> = {};
106106
(Object.keys(result) as Array<number | string>).forEach(
107107
key => { result[key.toString()] = literal[key]; }
108108
);
109109
return result;
110-
`.expectToMatchJsResult();
110+
`
111+
// TS2783: duplicate property in spread — intentional, testing execution order
112+
.ignoreDiagnostics([2783])
113+
.expectToMatchJsResult();
111114
});
112115

113116
test("object literal with computed property names", () => {

test/unit/switch.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ test("switch using variable re-declared in cases", () => {
137137
let foo: number = 0;
138138
switch (foo) {
139139
case 0:
140-
let foo = true;
140+
let foo: boolean | undefined = true;
141141
case 1:
142142
return foo;
143143
}

test/unit/using.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ test("using disposes even when error happens", () => {
116116

117117
test("await using disposes object with await at end of function", () => {
118118
util.testModule`
119-
let disposeAsync;
119+
let disposeAsync: (() => void) | undefined;
120120
121121
function loggedAsyncDisposable(id: string): AsyncDisposable {
122122
logs.push(\`Creating \${id}\`);
@@ -145,7 +145,7 @@ test("await using disposes object with await at end of function", () => {
145145
146146
logs.push("function returned");
147147
148-
disposeAsync();
148+
disposeAsync!();
149149
`
150150
.setTsHeader(usingTestLib)
151151
.setOptions({ luaLibImport: LuaLibImportKind.Inline })
@@ -197,7 +197,7 @@ test("await using no extra diagnostics (#1571)", () => {
197197
// https://github.com/TypeScriptToLua/TypeScriptToLua/issues/1584
198198
test("works with disposable classes (#1584)", () => {
199199
util.testFunction`
200-
const log = [];
200+
const log: string[] = [];
201201
202202
class Scoped {
203203
action(): void {

test/util.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,14 @@ export abstract class TestBuilder {
460460
this.injectLuaFile(L, lua, lauxlib, "lualib_bundle", readLuaLib(luaTarget));
461461
}
462462

463+
// Load extra lua files
464+
for (const [fileName, fileContent] of Object.entries(this.extraFiles))
465+
{
466+
if (fileName.endsWith(".lua")) {
467+
this.injectLuaFile(L, lua, lauxlib, fileName, fileContent);
468+
}
469+
}
470+
463471
// Load all transpiled files into Lua's package cache
464472
const { transpiledFiles } = this.getLuaResult();
465473
for (const transpiledFile of transpiledFiles) {

0 commit comments

Comments
 (0)