@@ -145,7 +145,11 @@ abstract class PathString extends string {
145
145
n = 0 and result .getContainer ( ) = root and root = getARootFolder ( )
146
146
or
147
147
exists ( Path base | base = resolveUpTo ( n - 1 , root ) |
148
- exists ( string next | next = getComponent ( n - 1 ) |
148
+ exists ( string next |
149
+ next = getComponent ( n - 1 )
150
+ or
151
+ next = getOriginalTypeScriptFolder ( getComponent ( n - 1 ) , base .getContainer ( ) )
152
+ |
149
153
// handle empty components and the special "." folder
150
154
( next = "" or next = "." ) and
151
155
result = base
@@ -174,6 +178,42 @@ abstract class PathString extends string {
174
178
Path resolve ( Folder root ) { result = resolveUpTo ( getNumComponent ( ) , root ) }
175
179
}
176
180
181
+ /**
182
+ * Gets the first folder from `path`.
183
+ */
184
+ bindingset [ path]
185
+ private string getRootFolderFromPath ( string path ) {
186
+ not exists ( path .indexOf ( "/" ) ) and result = path
187
+ or
188
+ result = path .substring ( 0 , path .indexOf ( "/" , 0 , 0 ) )
189
+ }
190
+
191
+ /**
192
+ * Gets a folder of TypeScript files that is compiled into JavaScript files in `outdir` relative to a `parent`.
193
+ */
194
+ private string getOriginalTypeScriptFolder ( string outdir , Folder parent ) {
195
+ exists ( JSONObject tsconfig |
196
+ tsconfig .getFile ( ) .getBaseName ( ) = "tsconfig.json" and
197
+ tsconfig .isTopLevel ( ) and
198
+ tsconfig .getFile ( ) .getParentContainer ( ) = parent
199
+ |
200
+ outdir =
201
+ tsconfig
202
+ .getPropValue ( "compilerOptions" )
203
+ .( JSONObject )
204
+ .getPropValue ( "outDir" )
205
+ .( JSONString )
206
+ .getValue ( ) and
207
+ result =
208
+ getRootFolderFromPath ( tsconfig
209
+ .getPropValue ( "include" )
210
+ .( JSONArray )
211
+ .getElementValue ( _)
212
+ .( JSONString )
213
+ .getValue ( ) )
214
+ )
215
+ }
216
+
177
217
/**
178
218
* An expression whose value represents a (relative or absolute) file system path.
179
219
*
0 commit comments