File tree 2 files changed +17
-8
lines changed
2 files changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -481,25 +481,28 @@ describe('resolveType', () => {
481
481
482
482
test . runIf ( process . platform === 'win32' ) ( 'relative ts on Windows' , ( ) => {
483
483
const files = {
484
- 'C:\\Test\\foo.ts' : 'export type P = { foo: number }' ,
485
- 'C:\\Test\\bar.d.ts' :
484
+ 'C:\\Test\\FolderA\\ foo.ts' : 'export type P = { foo: number }' ,
485
+ 'C:\\Test\\FolderA\\ bar.d.ts' :
486
486
'type X = { bar: string }; export { X as Y };' +
487
487
// verify that we can parse syntax that is only valid in d.ts
488
- 'export const baz: boolean'
488
+ 'export const baz: boolean' ,
489
+ 'C:\\Test\\FolderB\\buz.ts' : 'export type Z = { buz: string }'
489
490
}
490
491
const { props, deps } = resolve (
491
492
`
492
493
import { P } from './foo'
493
494
import { Y as PP } from './bar'
494
- defineProps<P & PP>()
495
+ import { Z as PPP } from '../FolderB/buz'
496
+ defineProps<P & PP & PPP>()
495
497
` ,
496
498
files ,
497
499
{ } ,
498
- 'C:\\Test\\Test.vue'
500
+ 'C:\\Test\\FolderA\\ Test.vue'
499
501
)
500
502
expect ( props ) . toStrictEqual ( {
501
503
foo : [ 'Number' ] ,
502
- bar : [ 'String' ]
504
+ bar : [ 'String' ] ,
505
+ buz : [ 'String' ]
503
506
} )
504
507
expect ( deps && [ ...deps ] . map ( normalize ) ) . toStrictEqual (
505
508
Object . keys ( files ) . map ( normalize )
Original file line number Diff line number Diff line change @@ -39,8 +39,9 @@ import { parse as babelParse } from '@babel/parser'
39
39
import { parse } from '../parse'
40
40
import { createCache } from '../cache'
41
41
import type TS from 'typescript'
42
- import { extname , dirname } from 'path'
42
+ import { extname , dirname , join } from 'path'
43
43
import { minimatch as isMatch } from 'minimatch'
44
+ import * as process from 'process'
44
45
45
46
/**
46
47
* TypeResolveContext is compatible with ScriptCompileContext
@@ -779,7 +780,12 @@ function importSourceToScope(
779
780
780
781
let resolved : string | undefined = scope . resolvedImportSources [ source ]
781
782
if ( ! resolved ) {
782
- if ( source . startsWith ( '.' ) ) {
783
+ if ( source . startsWith ( '..' ) ) {
784
+ const osSpecificJoinFn = process . platform === 'win32' ? join : joinPaths
785
+
786
+ const filename = osSpecificJoinFn ( dirname ( scope . filename ) , source )
787
+ resolved = resolveExt ( filename , fs )
788
+ } else if ( source . startsWith ( '.' ) ) {
783
789
// relative import - fast path
784
790
const filename = joinPaths ( dirname ( scope . filename ) , source )
785
791
resolved = resolveExt ( filename , fs )
You can’t perform that action at this time.
0 commit comments