Skip to content

Commit 3dfbb65

Browse files
committed
Upgarde to TypeScript 6.0
1 parent 57459c6 commit 3dfbb65

File tree

7 files changed

+448
-214
lines changed

7 files changed

+448
-214
lines changed

package-lock.json

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

package.json

Lines changed: 3 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,7 @@
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"
7474
}
7575
}

src/transpilation/resolve.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ interface ResolutionResult {
2727
}
2828

2929
class ResolutionContext {
30-
private noResolvePaths: picomatch.Matcher[];
30+
private noResolvePaths: RegExp[];
3131

3232
public diagnostics: ts.Diagnostic[] = [];
3333
public resolvedFiles = new Map<string, ProcessedFile>();
@@ -39,7 +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));
42+
const matchers = unique.map(x => picomatch.makeRe(x));
4343
this.noResolvePaths = matchers;
4444
}
4545

@@ -73,7 +73,7 @@ class ResolutionContext {
7373
return;
7474
}
7575

76-
if (this.noResolvePaths.find(isMatch => isMatch(required.requirePath))) {
76+
if (this.noResolvePaths.find(isMatch => isMatch.test(required.requirePath))) {
7777
if (this.options.tstlVerbose) {
7878
console.log(
7979
`Skipping module resolution of ${required.requirePath} as it is in the tsconfig noResolvePaths.`
@@ -215,14 +215,20 @@ class ResolutionContext {
215215
const fileFromPath = this.getFileFromPath(resolvedPath);
216216
if (fileFromPath) return fileFromPath;
217217

218-
if (this.options.paths && this.options.baseUrl) {
218+
if (this.options.paths) {
219219
// 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;
220+
// When baseUrl is not set, resolve paths relative to the tsconfig directory (TS 6.0+ behavior)
221+
const pathsBase =
222+
this.options.baseUrl ??
223+
(this.options.configFilePath ? path.dirname(this.options.configFilePath) : undefined);
224+
if (pathsBase) {
225+
const fileFromPaths = this.tryGetModuleNameFromPaths(
226+
dependencyPath,
227+
this.options.paths,
228+
pathsBase
229+
);
230+
if (fileFromPaths) return fileFromPaths;
231+
}
226232
}
227233

228234
// 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/util.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function getLuaBindingsForVersion(target: tstl.LuaTarget): { lauxlib: LauxLib; l
5151
}
5252

5353
export function assert(value: any, message?: string | Error): asserts value {
54-
nativeAssert(value, message);
54+
nativeAssert.ok(value, message);
5555
}
5656

5757
export const formatCode = (...values: unknown[]) => values.map(e => stringify(e)).join(", ");
@@ -92,17 +92,15 @@ export function expectEachVersionExceptJit<T>(
9292
};
9393
}
9494

95-
const memoize: MethodDecorator = (_target, _propertyKey, descriptor) => {
96-
const originalFunction = descriptor.value as any;
95+
const memoize = (originalFunction: any) => {
9796
const memoized = new WeakMap();
98-
descriptor.value = function (this: any, ...args: any[]): any {
97+
return function (this: any, ...args: any[]): any {
9998
if (!memoized.has(this)) {
10099
memoized.set(this, originalFunction.apply(this, args));
101100
}
102101

103102
return memoized.get(this);
104-
} as any;
105-
return descriptor;
103+
};
106104
};
107105

108106
export class ExecutionError extends Error {
@@ -163,7 +161,7 @@ export abstract class TestBuilder {
163161
skipLibCheck: true,
164162
target: ts.ScriptTarget.ES2017,
165163
lib: ["lib.esnext.d.ts"],
166-
moduleResolution: ts.ModuleResolutionKind.Node10,
164+
moduleResolution: ts.ModuleResolutionKind.Bundler,
167165
resolveJsonModule: true,
168166
sourceMap: true,
169167
};

tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"lib": ["es2019"],
55
"types": ["node"],
66
"module": "commonjs",
7-
"experimentalDecorators": true,
87

98
"rootDir": "src",
109
"outDir": "dist",

0 commit comments

Comments
 (0)