Skip to content

Commit 486474f

Browse files
committed
fix module-resolution tests
1 parent 3dfbb65 commit 486474f

File tree

8 files changed

+8
-22
lines changed

8 files changed

+8
-22
lines changed

src/CompilerOptions.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,5 @@ export function validateOptions(options: CompilerOptions): ts.Diagnostic[] {
9999
diagnostics.push(diagnosticFactories.unsupportedJsxEmit());
100100
}
101101

102-
if (options.paths && !options.baseUrl) {
103-
diagnostics.push(diagnosticFactories.pathsWithoutBaseUrl());
104-
}
105-
106102
return diagnostics;
107103
}

src/transpilation/diagnostics.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,3 @@ export const cannotBundleLibrary = createDiagnosticFactory(
5555
);
5656

5757
export const unsupportedJsxEmit = createDiagnosticFactory(() => 'JSX is only supported with "react" jsx option.');
58-
59-
export const pathsWithoutBaseUrl = createDiagnosticFactory(
60-
() => "When configuring 'paths' in tsconfig.json, the option 'baseUrl' must also be provided."
61-
);

src/transpilation/resolve.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,7 @@ class ResolutionContext {
222222
this.options.baseUrl ??
223223
(this.options.configFilePath ? path.dirname(this.options.configFilePath) : undefined);
224224
if (pathsBase) {
225-
const fileFromPaths = this.tryGetModuleNameFromPaths(
226-
dependencyPath,
227-
this.options.paths,
228-
pathsBase
229-
);
225+
const fileFromPaths = this.tryGetModuleNameFromPaths(dependencyPath, this.options.paths, pathsBase);
230226
if (fileFromPaths) return fileFromPaths;
231227
}
232228
}

test/transpile/__snapshots__/module-resolution.spec.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ exports[`supports complicated paths configuration 1`] = `
1010

1111
exports[`supports paths configuration 1`] = `
1212
[
13-
"/paths-simple/myprogram/dist/main.lua",
1413
"/paths-simple/myprogram/dist/mypackage/bar.lua",
1514
"/paths-simple/myprogram/dist/mypackage/index.lua",
15+
"/paths-simple/myprogram/dist/myprogram/main.lua",
1616
]
1717
`;

test/transpile/module-resolution.spec.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import * as util from "../util";
44
import * as ts from "typescript";
55
import { BuildMode } from "../../src";
66
import { normalizeSlashes } from "../../src/utils";
7-
import { pathsWithoutBaseUrl } from "../../src/transpilation/diagnostics";
87

98
describe("basic module resolution", () => {
109
const projectPath = path.resolve(__dirname, "module-resolution", "project-with-node-modules");
@@ -457,6 +456,7 @@ describe("module resolution should not try to resolve modules in noResolvePaths"
457456
458457
export const result = b.foo();
459458
`
459+
.addExtraFile("preload.d.ts", `declare module "preload" {}`)
460460
.addExtraFile("preload.lua", 'package.preload["ignoreme"] = function() return nil end')
461461
.addExtraFile(
462462
"actualfile.ts",
@@ -598,7 +598,7 @@ test("module resolution uses baseURL to resolve imported files", () => {
598598
return { baz = function() return "baz" end }
599599
`
600600
)
601-
.setOptions({ baseUrl: "./myproject/mydeps" })
601+
.setOptions({ baseUrl: "./myproject/mydeps", ignoreDeprecations: "6.0" })
602602
.expectToEqual({
603603
fooResult: "foo",
604604
barResult: "bar",
@@ -707,10 +707,6 @@ test("supports complicated paths configuration", () => {
707707
.expectToEqual({ foo: 314, bar: 271 });
708708
});
709709

710-
test("paths without baseUrl is error", () => {
711-
util.testFunction``.setOptions({ paths: {} }).expectToHaveDiagnostics([pathsWithoutBaseUrl.code]);
712-
});
713-
714710
test("module resolution using plugin", () => {
715711
const baseProjectPath = path.resolve(__dirname, "module-resolution", "project-with-module-resolution-plugin");
716712
const projectTsConfig = path.join(baseProjectPath, "tsconfig.json");

test/transpile/module-resolution/paths-base-tsconfig/tsconfig.base.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"compilerOptions": {
33
"rootDir": ".",
44
"baseUrl": ".",
5+
"ignoreDeprecations": "6.0",
56
"paths": {
67
"mypackage": ["packages/mypackage/src/index.ts"],
78
"mypackage/*": ["packages/mypackage/src/*"]

test/transpile/module-resolution/paths-simple/myprogram/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"compilerOptions": {
3-
"baseUrl": ".",
3+
"rootDir": "..",
44
"outDir": "dist",
55
"paths": {
66
"myOtherPackage": ["../mypackage"],

test/transpile/module-resolution/project-with-node-modules/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"target": "esnext",
88
"lib": ["esnext"],
99
"types": [],
10-
"rootDir": "."
10+
"rootDir": ".",
11+
"noUncheckedSideEffectImports": false
1112
}
1213
}

0 commit comments

Comments
 (0)