@@ -91,20 +91,92 @@ test.each([
9191 }
9292) ;
9393
94- test . each ( [ { comment : "" , expectedPath : "src.fake" } , { comment : "/** @noResolution */" , expectedPath : "fake" } ] ) (
95- "noResolution on ambient modules causes no path alterations (%p)" ,
96- ( { comment, expectedPath } ) => {
97- const lua = util . transpileString ( {
98- "src/main.ts" : `import * as fake from "fake"; fake;` ,
99- "module.d.ts" : `${ comment } declare module "fake" {}` ,
100- } ) ;
101- const match = requireRegex . exec ( lua ) ;
94+ test . each ( [
95+ {
96+ declarationStatement : `
97+ declare module 'fake' {}
98+ ` ,
99+ mainCode : "import * as fake from 'fake'; fake;" ,
100+ expectedPath : "src.fake" ,
101+ } ,
102+ {
103+ declarationStatement : `
104+ /** @noResolution */
105+ declare module 'fake' {}
106+ ` ,
107+ mainCode : "import * as fake from 'fake'; fake;" ,
108+ expectedPath : "fake" ,
109+ } ,
110+ {
111+ declarationStatement : `
112+ declare module 'fake' {
113+ export const x: number;
114+ }
115+ ` ,
116+ mainCode : "import { x } from 'fake'; x;" ,
117+ expectedPath : "src.fake" ,
118+ } ,
119+ {
120+ declarationStatement : `
121+ /** @noResolution */
122+ declare module 'fake' {
123+ export const x: number;
124+ }
125+ ` ,
126+ mainCode : "import { x } from 'fake'; x;" ,
127+ expectedPath : "fake" ,
128+ } ,
129+ {
130+ declarationStatement : `
131+ /** @noResolution */
132+ declare module 'fake' {
133+ export const x: number;
134+ }
135+ declare module 'fake' {
136+ export const y: number;
137+ }
138+ ` ,
139+ mainCode : "import { y } from 'fake'; y;" ,
140+ expectedPath : "fake" ,
141+ } ,
142+ {
143+ declarationStatement : `
144+ declare module 'fake' {
145+ export const x: number;
146+ }
147+ declare module 'fake' {
148+ export const y: number;
149+ }
150+ ` ,
151+ mainCode : "import { y } from 'fake'; y;" ,
152+ expectedPath : "src.fake" ,
153+ } ,
154+ {
155+ declarationStatement : `
156+ declare module 'fake' {}
157+ ` ,
158+ mainCode : "import 'fake';" ,
159+ expectedPath : "src.fake" ,
160+ } ,
161+ {
162+ declarationStatement : `
163+ /** @noResolution */
164+ declare module 'fake' {}
165+ ` ,
166+ mainCode : "import 'fake';" ,
167+ expectedPath : "fake" ,
168+ } ,
169+ ] ) ( "noResolution prevents any module path resolution behaviour" , ( { declarationStatement, mainCode, expectedPath } ) => {
170+ const lua = util . transpileString ( {
171+ "src/main.ts" : mainCode ,
172+ "module.d.ts" : declarationStatement ,
173+ } ) ;
174+ const match = requireRegex . exec ( lua ) ;
102175
103- if ( util . expectToBeDefined ( match ) ) {
104- expect ( match [ 1 ] ) . toBe ( expectedPath ) ;
105- }
176+ if ( util . expectToBeDefined ( match ) ) {
177+ expect ( match [ 1 ] ) . toBe ( expectedPath ) ;
106178 }
107- ) ;
179+ } ) ;
108180
109181test ( "ImportEquals declaration require" , ( ) => {
110182 const input = `import foo = require("./foo/bar"); foo;` ;
0 commit comments