This repository was archived by the owner on Jun 27, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +24
-6
lines changed Expand file tree Collapse file tree 2 files changed +24
-6
lines changed Original file line number Diff line number Diff line change @@ -69,12 +69,22 @@ module tss {
69
69
getScriptVersion : ( fileName ) => this . files [ fileName ] && this . files [ fileName ] . version . toString ( ) ,
70
70
getScriptSnapshot : ( fileName ) => {
71
71
var file = this . files [ fileName ] ;
72
- return {
73
- getText : ( start , end ) => file . text . substring ( start , end ) ,
74
- getLength : ( ) => file . text . length ,
75
- getLineStartPositions : ( ) => [ ] ,
76
- getChangeRange : ( oldSnapshot ) => undefined
77
- } ;
72
+ if ( file ) {
73
+ return {
74
+ getText : ( start , end ) => file . text . substring ( start , end ) ,
75
+ getLength : ( ) => file . text . length ,
76
+ getLineStartPositions : ( ) : number [ ] => [ ] ,
77
+ getChangeRange : ( oldSnapshot ) => undefined
78
+ } ;
79
+ }
80
+ else { // This is some reference import
81
+ return {
82
+ getText : ( start , end ) => '' ,
83
+ getLength : ( ) => 0 ,
84
+ getLineStartPositions : ( ) : number [ ] => [ ] ,
85
+ getChangeRange : ( oldSnapshot ) => undefined
86
+ } ;
87
+ }
78
88
} ,
79
89
getCurrentDirectory : ( ) => process . cwd ( ) ,
80
90
getScriptIsOpen : ( ) => true ,
Original file line number Diff line number Diff line change @@ -86,6 +86,14 @@ describe('typescript-update', function() {
86
86
var expected = "var x = 'some string';" + eol ;
87
87
assert . equal ( tss . compile ( src ) , expected ) ;
88
88
} ) ;
89
+
90
+ it ( 'reference imports are ignored' , function ( ) {
91
+ var src = "/// <reference path='./typings/tsd'/>" + eol
92
+ + "var x: number = 'some string';" ;
93
+ var expected = "/// <reference path='./typings/tsd'/>" + eol
94
+ + "var x = 'some string';" + eol ;
95
+ assert . equal ( tss . compile ( src ) , expected ) ;
96
+ } ) ;
89
97
90
98
it ( 'syntactic errors are not ignored' , function ( ) {
91
99
var src = "var x = 123 123;" ;
You can’t perform that action at this time.
0 commit comments