Skip to content

Commit 2813e66

Browse files
committed
support extends "tstl" object tsconfig.json in node_modules
upgrade typescript to 5.0.4 to fix extends resolving. microsoft/TypeScript#53443
1 parent 186cd90 commit 2813e66

File tree

4 files changed

+31
-9
lines changed

4 files changed

+31
-9
lines changed

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,6 @@
7070
"prettier": "^2.8.4",
7171
"ts-jest": "^29.1.0",
7272
"ts-node": "^10.9.1",
73-
"typescript": "^5.0.2"
73+
"typescript": "^5.0.4"
7474
}
7575
}

src/cli/tsconfig.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,29 @@ export function parseConfigFileWithSystem(
5858
return updateParsedConfigFile(parsedConfigFile);
5959
}
6060

61+
function resolveJsonConfig(
62+
moduleName: string,
63+
configRootDir: string,
64+
host: ts.ModuleResolutionHost
65+
): string | undefined {
66+
const resolved = ts.nodeNextJsonConfigResolver(moduleName, path.join(configRootDir, "tsconfig.json"), host);
67+
if (resolved.resolvedModule) {
68+
return resolved.resolvedModule.resolvedFileName;
69+
}
70+
}
71+
6172
function getExtendedTstlOptions(
6273
configFilePath: string,
6374
configRootDir: string,
6475
cycleCache: Set<string>,
6576
system: ts.System
6677
): TypeScriptToLuaOptions {
67-
const absolutePath = path.isAbsolute(configFilePath) ? configFilePath : path.resolve(configRootDir, configFilePath);
78+
const absolutePath = resolveJsonConfig(configFilePath, configRootDir, system);
79+
80+
if (!absolutePath) {
81+
return {};
82+
}
83+
6884
const newConfigRoot = path.dirname(absolutePath);
6985

7086
if (cycleCache.has(absolutePath)) {

src/typescript-internal.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,10 @@ declare module "typescript" {
5050

5151
function skipOuterExpressions(node: Expression, kinds?: OuterExpressionKinds): Expression;
5252
export function isOuterExpression(node: Node, kinds?: OuterExpressionKinds): node is OuterExpression;
53+
54+
export function nodeNextJsonConfigResolver(
55+
moduleName: string,
56+
containingFile: string,
57+
host: ModuleResolutionHost
58+
): ResolvedModuleWithFailedLookupLocations;
5359
}

0 commit comments

Comments
 (0)