@@ -48,6 +48,21 @@ describe('semanticInfo', () => {
48
48
) ;
49
49
} ) ;
50
50
51
+ it ( `should cache the created ts.program` , ( ) => {
52
+ const filename = testFiles [ 0 ] ;
53
+ const code = readFileSync ( filename , 'utf8' ) ;
54
+ const options = createOptions ( filename ) ;
55
+ const optionsProjectString = {
56
+ ...options ,
57
+ project : './tsconfig.json' ,
58
+ } ;
59
+ expect (
60
+ parseAndGenerateServices ( code , optionsProjectString ) . services . program ,
61
+ ) . toBe (
62
+ parseAndGenerateServices ( code , optionsProjectString ) . services . program ,
63
+ ) ;
64
+ } ) ;
65
+
51
66
it ( `should handle "project": "./tsconfig.json" and "project": ["./tsconfig.json"] the same` , ( ) => {
52
67
const filename = testFiles [ 0 ] ;
53
68
const code = readFileSync ( filename , 'utf8' ) ;
@@ -65,6 +80,38 @@ describe('semanticInfo', () => {
65
80
) ;
66
81
} ) ;
67
82
83
+ it ( `should resolve absolute and relative tsconfig paths the same` , ( ) => {
84
+ const filename = testFiles [ 0 ] ;
85
+ const code = readFileSync ( filename , 'utf8' ) ;
86
+ const options = createOptions ( filename ) ;
87
+ const optionsAbsolutePath = {
88
+ ...options ,
89
+ project : `${ __dirname } /../fixtures/semanticInfo/tsconfig.json` ,
90
+ } ;
91
+ const optionsRelativePath = {
92
+ ...options ,
93
+ project : `./tsconfig.json` ,
94
+ } ;
95
+ const absolutePathResult = parseAndGenerateServices (
96
+ code ,
97
+ optionsAbsolutePath ,
98
+ ) ;
99
+ const relativePathResult = parseAndGenerateServices (
100
+ code ,
101
+ optionsRelativePath ,
102
+ ) ;
103
+ if ( absolutePathResult . services . program === undefined ) {
104
+ throw new Error ( 'Unable to create ts.program for absolute tsconfig' ) ;
105
+ } else if ( relativePathResult . services . program === undefined ) {
106
+ throw new Error ( 'Unable to create ts.program for relative tsconfig' ) ;
107
+ }
108
+ expect (
109
+ absolutePathResult . services . program . getResolvedProjectReferences ( ) ,
110
+ ) . toEqual (
111
+ relativePathResult . services . program . getResolvedProjectReferences ( ) ,
112
+ ) ;
113
+ } ) ;
114
+
68
115
// case-specific tests
69
116
it ( 'isolated-file tests' , ( ) => {
70
117
const fileName = resolve ( FIXTURES_DIR , 'isolated-file.src.ts' ) ;
0 commit comments