File tree 2 files changed +22
-0
lines changed
2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -592,6 +592,26 @@ describe('resolveType', () => {
592
592
expect ( deps && [ ...deps ] ) . toStrictEqual ( Object . keys ( files ) )
593
593
} )
594
594
595
+ // #8339
596
+ test ( 'relative, .js import' , ( ) => {
597
+ const files = {
598
+ '/foo.d.ts' :
599
+ 'import { PP } from "./bar.js"; export type P = { foo: PP }' ,
600
+ '/bar.d.ts' : 'export type PP = "foo" | "bar"'
601
+ }
602
+ const { props, deps } = resolve (
603
+ `
604
+ import { P } from './foo'
605
+ defineProps<P>()
606
+ ` ,
607
+ files
608
+ )
609
+ expect ( props ) . toStrictEqual ( {
610
+ foo : [ 'String' ]
611
+ } )
612
+ expect ( deps && [ ...deps ] ) . toStrictEqual ( Object . keys ( files ) )
613
+ } )
614
+
595
615
test ( 'ts module resolve' , ( ) => {
596
616
const files = {
597
617
'/node_modules/foo/package.json' : JSON . stringify ( {
Original file line number Diff line number Diff line change @@ -785,6 +785,8 @@ function importSourceToScope(
785
785
}
786
786
787
787
function resolveExt ( filename : string , fs : FS ) {
788
+ // #8339 ts may import .js but we should resolve to corresponding ts or d.ts
789
+ filename = filename . replace ( / \. j s $ / , '' )
788
790
const tryResolve = ( filename : string ) => {
789
791
if ( fs . fileExists ( filename ) ) return filename
790
792
}
You can’t perform that action at this time.
0 commit comments