@@ -2846,6 +2846,45 @@ namespace ts.projectSystem {
28462846 const options = project . getCompilerOptions ( ) ;
28472847 assert . equal ( options . outDir , "C:/a/b" , "" ) ;
28482848 } ) ;
2849+
2850+ it ( "dynamic file without external project" , ( ) => {
2851+ const file : FileOrFolder = {
2852+ path : "^walkThroughSnippet:/Users/UserName/projects/someProject/out/someFile#1.js" ,
2853+ content : "var x = 10;"
2854+ } ;
2855+ const host = createServerHost ( [ libFile ] , { useCaseSensitiveFileNames : true } ) ;
2856+ const projectService = createProjectService ( host ) ;
2857+ projectService . setCompilerOptionsForInferredProjects ( {
2858+ module : ModuleKind . CommonJS ,
2859+ allowJs : true ,
2860+ allowSyntheticDefaultImports : true ,
2861+ allowNonTsExtensions : true
2862+ } ) ;
2863+ projectService . openClientFile ( file . path , "var x = 10;" ) ;
2864+
2865+ projectService . checkNumberOfProjects ( { inferredProjects : 1 } ) ;
2866+ const project = projectService . inferredProjects [ 0 ] ;
2867+ checkProjectRootFiles ( project , [ file . path ] ) ;
2868+ checkProjectActualFiles ( project , [ file . path , libFile . path ] ) ;
2869+
2870+ assert . strictEqual ( projectService . getDefaultProjectForFile ( server . toNormalizedPath ( file . path ) , /*ensureProject*/ true ) , project ) ;
2871+ const indexOfX = file . content . indexOf ( "x" ) ;
2872+ assert . deepEqual ( project . getLanguageService ( /*ensureSynchronized*/ true ) . getQuickInfoAtPosition ( file . path , indexOfX ) , {
2873+ kind : ScriptElementKind . variableElement ,
2874+ kindModifiers : "" ,
2875+ textSpan : { start : indexOfX , length : 1 } ,
2876+ displayParts : [
2877+ { text : "var" , kind : "keyword" } ,
2878+ { text : " " , kind : "space" } ,
2879+ { text : "x" , kind : "localName" } ,
2880+ { text : ":" , kind : "punctuation" } ,
2881+ { text : " " , kind : "space" } ,
2882+ { text : "number" , kind : "keyword" }
2883+ ] ,
2884+ documentation : [ ] ,
2885+ tags : [ ]
2886+ } ) ;
2887+ } ) ;
28492888 } ) ;
28502889
28512890 describe ( "tsserverProjectSystem Proper errors" , ( ) => {
0 commit comments