File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -592,6 +592,26 @@ describe('resolveType', () => {
592592 expect ( deps && [ ...deps ] ) . toStrictEqual ( Object . keys ( files ) )
593593 } )
594594
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+
595615 test ( 'ts module resolve' , ( ) => {
596616 const files = {
597617 '/node_modules/foo/package.json' : JSON . stringify ( {
Original file line number Diff line number Diff line change @@ -785,6 +785,8 @@ function importSourceToScope(
785785}
786786
787787function 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 $ / , '' )
788790 const tryResolve = ( filename : string ) => {
789791 if ( fs . fileExists ( filename ) ) return filename
790792 }
You can’t perform that action at this time.
0 commit comments