@@ -13,7 +13,8 @@ export function runTsc(
1313 extraSupportedExtensions : string [ ] ;
1414 extraExtensionsToRemove : string [ ] ;
1515 } ,
16- _getLanguagePlugins : typeof getLanguagePlugins
16+ _getLanguagePlugins : typeof getLanguagePlugins ,
17+ typescriptObject ?: string
1718) {
1819 getLanguagePlugins = _getLanguagePlugins ;
1920
@@ -35,7 +36,7 @@ export function runTsc(
3536 extraExtensionsToRemove = options . extraExtensionsToRemove ;
3637 }
3738
38- return transformTscContent ( tsc , proxyApiPath , extraSupportedExtensions , extraExtensionsToRemove ) ;
39+ return transformTscContent ( tsc , proxyApiPath , extraSupportedExtensions , extraExtensionsToRemove , __filename , typescriptObject ) ;
3940 }
4041 return ( readFileSync as any ) ( ...args ) ;
4142 } ;
@@ -56,14 +57,16 @@ export function runTsc(
5657 * @param extraSupportedExtensions - An array of additional supported extensions.
5758 * @param extraExtensionsToRemove - An array of extensions to remove.
5859 * @param getLanguagePluginsFile - The file to get language plugins from.
60+ * @param typescriptObject - The object to use as typescript.
5961 * @returns The modified typescript code.
6062 */
6163export function transformTscContent (
6264 tsc : string ,
6365 proxyApiPath : string ,
6466 extraSupportedExtensions : string [ ] ,
6567 extraExtensionsToRemove : string [ ] ,
66- getLanguagePluginsFile = __filename
68+ getLanguagePluginsFile = __filename ,
69+ typescriptObject = `new Proxy({}, { get(_target, p, _receiver) { return eval(p); } } )`
6770) {
6871 const neededPatchExtenstions = extraSupportedExtensions . filter ( ext => ! extraExtensionsToRemove . includes ( ext ) ) ;
6972
@@ -93,7 +96,7 @@ export function transformTscContent(
9396 tsc = replace ( tsc , / f u n c t i o n c r e a t e P r o g r a m \( .+ \) { / , s =>
9497 `var createProgram = require(${ JSON . stringify ( proxyApiPath ) } ).proxyCreateProgram(`
9598 + [
96- `new Proxy({}, { get(_target, p, _receiver) { return eval(p); } } )` ,
99+ typescriptObject ,
97100 `_createProgram` ,
98101 `require(${ JSON . stringify ( getLanguagePluginsFile ) } ).getLanguagePlugins` ,
99102 ] . join ( ', ' )
0 commit comments