diff --git a/packages/compiler-sfc/__tests__/compileScript/resolveType.spec.ts b/packages/compiler-sfc/__tests__/compileScript/resolveType.spec.ts index 607654a952b..fc600f1a518 100644 --- a/packages/compiler-sfc/__tests__/compileScript/resolveType.spec.ts +++ b/packages/compiler-sfc/__tests__/compileScript/resolveType.spec.ts @@ -1,3 +1,4 @@ +import { normalize } from 'node:path' import { Identifier } from '@babel/types' import { SFCScriptCompileOptions, parse } from '../../src' import { ScriptCompileContext } from '../../src/script/context' @@ -478,6 +479,33 @@ describe('resolveType', () => { expect(deps && [...deps]).toStrictEqual(Object.keys(files)) }) + test.runIf(process.platform === 'win32')('relative ts on Windows', () => { + const files = { + 'C:\\Test\\foo.ts': 'export type P = { foo: number }', + 'C:\\Test\\bar.d.ts': + 'type X = { bar: string }; export { X as Y };' + + // verify that we can parse syntax that is only valid in d.ts + 'export const baz: boolean' + } + const { props, deps } = resolve( + ` + import { P } from './foo' + import { Y as PP } from './bar' + defineProps
()
+ `,
+ files,
+ {},
+ 'C:\\Test\\Test.vue'
+ )
+ expect(props).toStrictEqual({
+ foo: ['Number'],
+ bar: ['String']
+ })
+ expect(deps && [...deps].map(normalize)).toStrictEqual(
+ Object.keys(files).map(normalize)
+ )
+ })
+
// #8244
test('utility type in external file', () => {
const files = {
@@ -898,19 +926,20 @@ describe('resolveType', () => {
function resolve(
code: string,
files: Record