@@ -330,6 +330,53 @@ test("module resolution should not try to resolve @noResolution annotation", ()
330330 . expectToHaveNoDiagnostics ( ) ;
331331} ) ;
332332
333+ // https://github.com/TypeScriptToLua/TypeScriptToLua/issues/1101
334+ test ( "module resolution inline require of environment library workaround" , ( ) => {
335+ util . testModule `
336+ declare function require(this: void, module: string): any;
337+
338+ const test = require("@NoResolution:luasource");
339+ test.foo();
340+ ` . expectToHaveNoDiagnostics ( ) ;
341+ } ) ;
342+
343+ // https://github.com/TypeScriptToLua/TypeScriptToLua/issues/1118
344+ describe ( "module resolution should not try to resolve modules in noResolvePaths" , ( ) => {
345+ test ( "as used in direct import" , ( ) => {
346+ util . testModule `
347+ import * as lua from "directimport";
348+ lua.foo();
349+ `
350+ . addExtraFile (
351+ "directimport.d.ts" ,
352+ `declare module "directimport" {
353+ export function foo(): void;
354+ }`
355+ )
356+ . setOptions ( { noResolvePaths : [ "directimport" ] } )
357+ . expectToHaveNoDiagnostics ( ) ;
358+ } ) ;
359+
360+ test ( "as used in imported lua sources" , ( ) => {
361+ util . testModule `
362+ import * as lua from "./luasource";
363+ lua.foo();
364+ `
365+ . addExtraFile ( "luasource.d.ts" , "export function foo(): void;" )
366+ . addExtraFile (
367+ "luasource.lua" ,
368+ `
369+ require("dontResolveThis")
370+ require("a.b.c.foo")
371+
372+ return { foo = function() return "bar" end }
373+ `
374+ )
375+ . setOptions ( { noResolvePaths : [ "a.b.c.foo" , "somethingExtra" , "dontResolveThis" ] } )
376+ . expectToHaveNoDiagnostics ( ) ;
377+ } ) ;
378+ } ) ;
379+
333380// https://github.com/TypeScriptToLua/TypeScriptToLua/issues/1062
334381test ( "module resolution should not rewrite @NoResolution requires in library mode" , ( ) => {
335382 const { transpiledFiles } = util . testModule `
0 commit comments