Skip to content

Commit 9c4606d

Browse files
committed
upgrade TypeScript to 6.0.2
1 parent c043cdc commit 9c4606d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+801
-491
lines changed

benchmark/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"lib": ["esnext"],
55
// Dev types are JIT
66
"types": ["lua-types/jit", "@typescript-to-lua/language-extensions"],
7-
"moduleResolution": "node",
7+
"moduleResolution": "bundler",
88
"outDir": "dist",
99
"rootDir": "src",
1010
"strict": true,

eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ export default tseslint.config(
214214
{
215215
ignores: [
216216
".github/scripts/create_benchmark_check.js",
217+
"coverage/",
217218
"dist/",
218219
"eslint.config.mjs",
219220
"jest.config.js",

package-lock.json

Lines changed: 492 additions & 261 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"lint:prettier": "prettier --check . || (echo 'Run `npm run fix:prettier` to fix it.' && exit 1)",
3232
"lint:eslint": "eslint .",
3333
"fix:prettier": "prettier --write .",
34-
"check:language-extensions": "tsc --strict language-extensions/index.d.ts",
34+
"check:language-extensions": "tsc --strict --ignoreConfig language-extensions/index.d.ts",
3535
"preversion": "npm run build && npm test",
3636
"postversion": "git push && git push --tags"
3737
},
@@ -42,7 +42,7 @@
4242
"node": ">=16.10.0"
4343
},
4444
"peerDependencies": {
45-
"typescript": "5.9.3"
45+
"typescript": "6.0.2"
4646
},
4747
"dependencies": {
4848
"@typescript-to-lua/language-extensions": "1.19.0",
@@ -69,7 +69,10 @@
6969
"prettier": "^2.8.8",
7070
"ts-jest": "^29.2.5",
7171
"ts-node": "^10.9.2",
72-
"typescript": "5.9.3",
72+
"typescript": "6.0.2",
7373
"typescript-eslint": "^8.46.3"
74+
},
75+
"overrides": {
76+
"typescript": "$typescript"
7477
}
7578
}

src/CompilerOptions.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,7 @@ 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-
}
102+
// paths without baseUrl is now supported (TS 6.0+ resolves paths relative to tsconfig location)
105103

106104
return diagnostics;
107105
}

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: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { couldNotReadDependency, couldNotResolveRequire } from "./diagnostics";
1010
import { BuildMode, CompilerOptions } from "../CompilerOptions";
1111
import { findLuaRequires, LuaRequire } from "./find-lua-requires";
1212
import { Plugin } from "./plugins";
13-
import * as picomatch from "picomatch";
13+
import picomatch from "picomatch";
1414

1515
const resolver = resolve.ResolverFactory.createResolver({
1616
extensions: [".lua"],
@@ -39,8 +39,7 @@ class ResolutionContext {
3939
private readonly plugins: Plugin[]
4040
) {
4141
const unique = [...new Set(options.noResolvePaths)];
42-
const matchers = unique.map(x => picomatch(x));
43-
this.noResolvePaths = matchers;
42+
this.noResolvePaths = unique.map(x => picomatch(x));
4443
}
4544

4645
public addAndResolveDependencies(file: ProcessedFile): void {
@@ -215,14 +214,16 @@ class ResolutionContext {
215214
const fileFromPath = this.getFileFromPath(resolvedPath);
216215
if (fileFromPath) return fileFromPath;
217216

218-
if (this.options.paths && this.options.baseUrl) {
217+
if (this.options.paths) {
219218
// If no file found yet and paths are present, try to find project file via paths mappings
220-
const fileFromPaths = this.tryGetModuleNameFromPaths(
221-
dependencyPath,
222-
this.options.paths,
223-
this.options.baseUrl
224-
);
225-
if (fileFromPaths) return fileFromPaths;
219+
// When baseUrl is not set, resolve paths relative to the tsconfig directory (TS 6.0+ behavior)
220+
const pathsBase =
221+
this.options.baseUrl ??
222+
(this.options.configFilePath ? path.dirname(this.options.configFilePath) : undefined);
223+
if (pathsBase) {
224+
const fileFromPaths = this.tryGetModuleNameFromPaths(dependencyPath, this.options.paths, pathsBase);
225+
if (fileFromPaths) return fileFromPaths;
226+
}
226227
}
227228

228229
// Not a TS file in our project sources, use resolver to check if we can find dependency

src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export function cast<TOriginal, TCast extends TOriginal>(
7777
}
7878

7979
export function assert(value: any, message?: string | Error): asserts value {
80-
nativeAssert(value, message);
80+
nativeAssert.ok(value, message);
8181
}
8282

8383
export function assertNever(_value: never): never {

test/setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ declare global {
1313

1414
expect.extend({
1515
toHaveDiagnostics(diagnostics: ts.Diagnostic[], expected?: number[]): jest.CustomMatcherResult {
16-
assert(Array.isArray(diagnostics));
16+
assert.ok(Array.isArray(diagnostics));
1717
// @ts-ignore
1818
const matcherHint = this.utils.matcherHint("toHaveDiagnostics", undefined, "", this);
1919

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
`;

0 commit comments

Comments
 (0)