mirror of https://github.com/vuejs/core.git
test: add test
This commit is contained in:
parent
49299742ac
commit
5fab826ea2
|
@ -1155,6 +1155,45 @@ describe('resolveType', () => {
|
||||||
expect(deps && [...deps]).toStrictEqual(['/user.ts'])
|
expect(deps && [...deps]).toStrictEqual(['/user.ts'])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// #13484
|
||||||
|
test('ts module resolve w/ project reference & extends & ${configDir}', () => {
|
||||||
|
const files = {
|
||||||
|
'/tsconfig.json': JSON.stringify({
|
||||||
|
files: [],
|
||||||
|
references: [{ path: './tsconfig.app.json' }],
|
||||||
|
}),
|
||||||
|
'/tsconfig.app.json': JSON.stringify({
|
||||||
|
extends: ['./tsconfigs/base.json'],
|
||||||
|
}),
|
||||||
|
'/tsconfigs/base.json': JSON.stringify({
|
||||||
|
compilerOptions: {
|
||||||
|
paths: {
|
||||||
|
'@/*': ['${configDir}/src/*'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
include: ['${configDir}/src/**/*.ts', '${configDir}/src/**/*.vue'],
|
||||||
|
}),
|
||||||
|
'/src/types.ts':
|
||||||
|
'export type BaseProps = { foo?: string, bar?: string }',
|
||||||
|
}
|
||||||
|
|
||||||
|
const { props, deps } = resolve(
|
||||||
|
`
|
||||||
|
import { BaseProps } from '@/types.ts';
|
||||||
|
defineProps<BaseProps>()
|
||||||
|
`,
|
||||||
|
files,
|
||||||
|
{},
|
||||||
|
'/src/components/Foo.vue',
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(props).toStrictEqual({
|
||||||
|
foo: ['String'],
|
||||||
|
bar: ['String'],
|
||||||
|
})
|
||||||
|
expect(deps && [...deps]).toStrictEqual(['/src/types.ts'])
|
||||||
|
})
|
||||||
|
|
||||||
test('ts module resolve w/ project reference folder', () => {
|
test('ts module resolve w/ project reference folder', () => {
|
||||||
const files = {
|
const files = {
|
||||||
'/tsconfig.json': JSON.stringify({
|
'/tsconfig.json': JSON.stringify({
|
||||||
|
|
|
@ -1033,7 +1033,7 @@ function resolveWithTS(
|
||||||
function getPattern(base: string, p: string): string {
|
function getPattern(base: string, p: string): string {
|
||||||
return p.startsWith('${configDir}') && major >= 5 && minor >= 5
|
return p.startsWith('${configDir}') && major >= 5 && minor >= 5
|
||||||
? // ts 5.5+ supports ${configDir} in paths
|
? // ts 5.5+ supports ${configDir} in paths
|
||||||
p.replace('${configDir}', dirname(configPath!))
|
normalizePath(p.replace('${configDir}', dirname(configPath!)))
|
||||||
: joinPaths(base, p)
|
: joinPaths(base, p)
|
||||||
}
|
}
|
||||||
// resolve which config matches the current file
|
// resolve which config matches the current file
|
||||||
|
|
Loading…
Reference in New Issue