Skip to content

Commit 2926a4b

Browse files
committed
Fixed language extension playground issue and upgraded to latest tstl
1 parent cbf769a commit 2926a4b

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
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
@@ -29,7 +29,7 @@
2929
"react-dom": "^16.14.0",
3030
"react-json-tree": "^0.13.0",
3131
"react-monaco-editor": "^0.40.0",
32-
"typescript-to-lua": "^0.37.0"
32+
"typescript-to-lua": "^0.37.1"
3333
},
3434
"devDependencies": {
3535
"@ark120202/typescript-config": "^2.2.0",

src/pages/play/monaco.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,14 @@ export function useMonacoTheme() {
2525
},
2626
};
2727

28-
function addLibsFromContext(context: __WebpackModuleApi.RequireContext) {
28+
function addLibsFromContext(context: __WebpackModuleApi.RequireContext, pathPrefix?: string) {
2929
for (const request of context.keys()) {
30-
monaco.languages.typescript.typescriptDefaults.addExtraLib(context(request).default);
30+
if (pathPrefix) {
31+
const filePath = request.replace("./", pathPrefix + "/");
32+
monaco.languages.typescript.typescriptDefaults.addExtraLib(context(request).default, filePath);
33+
} else {
34+
monaco.languages.typescript.typescriptDefaults.addExtraLib(context(request).default);
35+
}
3136
}
3237
}
3338

@@ -48,7 +53,7 @@ for (const module of [
4853
}
4954

5055
// Add tstl language extension types
51-
addLibsFromContext(require.context("!!raw-loader!typescript-to-lua/language-extensions/", true, /\.d\.ts$/));
56+
addLibsFromContext(require.context("!!raw-loader!typescript-to-lua/language-extensions/", true, /\.d\.ts$/), "/language-extensions");
5257
monaco.languages.typescript.typescriptDefaults.addExtraLib(
5358
require("!!raw-loader!typescript-to-lua/language-extensions/index.d.ts").default,
5459
"/language-extensions/index.d.ts",

0 commit comments

Comments
 (0)