File tree Expand file tree Collapse file tree 5 files changed +22
-1
lines changed
harness/unittests/services Expand file tree Collapse file tree 5 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -2929,6 +2929,7 @@ declare namespace ts {
2929
2929
getTokenText ( ) : string ;
2930
2930
getTokenValue ( ) : string ;
2931
2931
hasExtendedUnicodeEscape ( ) : boolean ;
2932
+ hasPrecedingDot ( ) : boolean ;
2932
2933
hasPrecedingLineBreak ( ) : boolean ;
2933
2934
isIdentifier ( ) : boolean ;
2934
2935
isReservedWord ( ) : boolean ;
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ namespace ts {
22
22
getTokenText ( ) : string ;
23
23
getTokenValue ( ) : string ;
24
24
hasExtendedUnicodeEscape ( ) : boolean ;
25
+ hasPrecedingDot ( ) : boolean ;
25
26
hasPrecedingLineBreak ( ) : boolean ;
26
27
isIdentifier ( ) : boolean ;
27
28
isReservedWord ( ) : boolean ;
@@ -833,6 +834,7 @@ namespace ts {
833
834
getTokenText : ( ) => text . substring ( tokenPos , pos ) ,
834
835
getTokenValue : ( ) => tokenValue ,
835
836
hasExtendedUnicodeEscape : ( ) => ( tokenFlags & TokenFlags . ExtendedUnicodeEscape ) !== 0 ,
837
+ hasPrecedingDot : ( ) => ( tokenFlags & TokenFlags . PrecedingDot ) !== 0 ,
836
838
hasPrecedingLineBreak : ( ) => ( tokenFlags & TokenFlags . PrecedingLineBreak ) !== 0 ,
837
839
isIdentifier : ( ) => token === SyntaxKind . Identifier || token > SyntaxKind . LastReservedWord ,
838
840
isReservedWord : ( ) => token >= SyntaxKind . FirstReservedWord && token <= SyntaxKind . LastReservedWord ,
@@ -1469,6 +1471,7 @@ namespace ts {
1469
1471
pos ++ ;
1470
1472
return token = SyntaxKind . MinusToken ;
1471
1473
case CharacterCodes . dot :
1474
+ tokenFlags |= TokenFlags . PrecedingDot ;
1472
1475
if ( isDigit ( text . charCodeAt ( pos + 1 ) ) ) {
1473
1476
tokenValue = scanNumber ( ) ;
1474
1477
return token = SyntaxKind . NumericLiteral ;
Original file line number Diff line number Diff line change @@ -1585,6 +1585,7 @@ namespace ts {
1585
1585
BinarySpecifier = 1 << 7 , // e.g. `0b0110010000000000`
1586
1586
OctalSpecifier = 1 << 8 , // e.g. `0o777`
1587
1587
ContainsSeparator = 1 << 9 , // e.g. `0b1100_0101`
1588
+ PrecedingDot = 1 << 10 ,
1588
1589
BinaryOrOctalSpecifier = BinarySpecifier | OctalSpecifier ,
1589
1590
NumericLiteralFlags = Scientific | Octal | HexSpecifier | BinarySpecifier | OctalSpecifier | ContainsSeparator
1590
1591
}
Original file line number Diff line number Diff line change @@ -59,6 +59,19 @@ describe("PreProcessFile:", () => {
59
59
} ) ;
60
60
} ) ,
61
61
62
+ it ( "Do not return reference path of non-imports" , ( ) => {
63
+ test ( "Quill.import('delta');" ,
64
+ /*readImportFile*/ true ,
65
+ /*detectJavaScriptImports*/ false ,
66
+ {
67
+ referencedFiles : < ts . FileReference [ ] > [ ] ,
68
+ importedFiles : < ts . FileReference [ ] > [ ] ,
69
+ typeReferenceDirectives : [ ] ,
70
+ ambientExternalModules : undefined ,
71
+ isLibFile : false
72
+ } ) ;
73
+ } ) ,
74
+
62
75
it ( "Correctly return imported files" , ( ) => {
63
76
test ( "import i1 = require(\"r1.ts\"); import i2 =require(\"r2.ts\"); import i3= require(\"r3.ts\"); import i4=require(\"r4.ts\"); import i5 = require (\"r5.ts\");" ,
64
77
/*readImportFile*/ true ,
Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ namespace ts {
78
78
*/
79
79
function tryConsumeImport ( ) : boolean {
80
80
let token = scanner . getToken ( ) ;
81
- if ( token === SyntaxKind . ImportKeyword ) {
81
+ if ( token === SyntaxKind . ImportKeyword && ! scanner . hasPrecedingDot ( ) ) {
82
82
token = nextToken ( ) ;
83
83
if ( token === SyntaxKind . OpenParenToken ) {
84
84
token = nextToken ( ) ;
@@ -293,6 +293,9 @@ namespace ts {
293
293
// export import i = require("mod")
294
294
// (for JavaScript files) require("mod")
295
295
296
+ // Do not look for:
297
+ // AnySymbol.import("mod")
298
+
296
299
while ( true ) {
297
300
if ( scanner . getToken ( ) === SyntaxKind . EndOfFileToken ) {
298
301
break ;
You can’t perform that action at this time.
0 commit comments