File tree Expand file tree Collapse file tree 2 files changed +17
-8
lines changed
Expand file tree Collapse file tree 2 files changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -481,25 +481,28 @@ describe('resolveType', () => {
481481
482482 test . runIf ( process . platform === 'win32' ) ( 'relative ts on Windows' , ( ) => {
483483 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' :
486486 'type X = { bar: string }; export { X as Y };' +
487487 // 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 }'
489490 }
490491 const { props, deps } = resolve (
491492 `
492493 import { P } from './foo'
493494 import { Y as PP } from './bar'
494- defineProps<P & PP>()
495+ import { Z as PPP } from '../FolderB/buz'
496+ defineProps<P & PP & PPP>()
495497 ` ,
496498 files ,
497499 { } ,
498- 'C:\\Test\\Test.vue'
500+ 'C:\\Test\\FolderA\\ Test.vue'
499501 )
500502 expect ( props ) . toStrictEqual ( {
501503 foo : [ 'Number' ] ,
502- bar : [ 'String' ]
504+ bar : [ 'String' ] ,
505+ buz : [ 'String' ]
503506 } )
504507 expect ( deps && [ ...deps ] . map ( normalize ) ) . toStrictEqual (
505508 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'
3939import { parse } from '../parse'
4040import { createCache } from '../cache'
4141import type TS from 'typescript'
42- import { extname , dirname } from 'path'
42+ import { extname , dirname , join } from 'path'
4343import { minimatch as isMatch } from 'minimatch'
44+ import * as process from 'process'
4445
4546/**
4647 * TypeResolveContext is compatible with ScriptCompileContext
@@ -779,7 +780,12 @@ function importSourceToScope(
779780
780781 let resolved : string | undefined = scope . resolvedImportSources [ source ]
781782 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 ( '.' ) ) {
783789 // relative import - fast path
784790 const filename = joinPaths ( dirname ( scope . filename ) , source )
785791 resolved = resolveExt ( filename , fs )
You can’t perform that action at this time.
0 commit comments