@@ -74,6 +74,7 @@ export type SimpleTypeResolveContext = Pick<
7474
7575 // utils
7676 | 'error'
77+ | 'warn'
7778 | 'helper'
7879 | 'getString'
7980
@@ -95,7 +96,12 @@ export type SimpleTypeResolveContext = Pick<
9596 options : SimpleTypeResolveOptions
9697 }
9798
98- export type TypeResolveContext = ScriptCompileContext | SimpleTypeResolveContext
99+ export type TypeResolveContext = (
100+ | ScriptCompileContext
101+ | SimpleTypeResolveContext
102+ ) & {
103+ silentOnExtendsFailure ?: boolean
104+ }
99105
100106type Import = Pick < ImportBinding , 'source' | 'imported' >
101107
@@ -429,16 +435,21 @@ function resolveInterfaceMembers(
429435 ; ( base . calls || ( base . calls = [ ] ) ) . push ( ...calls )
430436 }
431437 } catch ( e ) {
432- ctx . error (
433- `Failed to resolve extends base type.\nIf this previously worked in 3.2, ` +
434- `you can instruct the compiler to ignore this extend by adding ` +
435- `/* @vue-ignore */ before it, for example:\n\n` +
436- `interface Props extends /* @vue-ignore */ Base {}\n\n` +
437- `Note: both in 3.2 or with the ignore, the properties in the base ` +
438- `type are treated as fallthrough attrs at runtime.` ,
439- ext ,
440- scope ,
441- )
438+ // when called from inferRuntimeType context, silently ignore extends
439+ // resolution failure so that properties defined in the interface can
440+ // still be correctly resolved
441+ if ( ! ctx . silentOnExtendsFailure ) {
442+ ctx . error (
443+ `Failed to resolve extends base type.\nIf this previously worked in 3.2, ` +
444+ `you can instruct the compiler to ignore this extend by adding ` +
445+ `/* @vue-ignore */ before it, for example:\n\n` +
446+ `interface Props extends /* @vue-ignore */ Base {}\n\n` +
447+ `Note: both in 3.2 or with the ignore, the properties in the base ` +
448+ `type are treated as fallthrough attrs at runtime.` ,
449+ ext ,
450+ scope ,
451+ )
452+ }
442453 }
443454 }
444455 }
@@ -1519,6 +1530,10 @@ export function inferRuntimeType(
15191530 return [ UNKNOWN_TYPE ]
15201531 }
15211532
1533+ // set flag to silence extends resolution errors in this context
1534+ const prevSilent = ctx . silentOnExtendsFailure
1535+ ctx . silentOnExtendsFailure = true
1536+
15221537 try {
15231538 switch ( node . type ) {
15241539 case 'TSStringKeyword' :
@@ -1886,6 +1901,8 @@ export function inferRuntimeType(
18861901 }
18871902 } catch ( e ) {
18881903 // always soft fail on failed runtime type inference
1904+ } finally {
1905+ ctx . silentOnExtendsFailure = prevSilent
18891906 }
18901907 return [ UNKNOWN_TYPE ] // no runtime check
18911908}
@@ -1898,13 +1915,25 @@ function flattenTypes(
18981915 typeParameters : Record < string , Node > | undefined = undefined ,
18991916) : string [ ] {
19001917 if ( types . length === 1 ) {
1901- return inferRuntimeType ( ctx , types [ 0 ] , scope , isKeyOf , typeParameters )
1918+ return inferRuntimeType (
1919+ ctx ,
1920+ types [ 0 ] ,
1921+ ( types [ 0 ] as MaybeWithScope ) . _ownerScope || scope ,
1922+ isKeyOf ,
1923+ typeParameters ,
1924+ )
19021925 }
19031926 return [
19041927 ...new Set (
19051928 ( [ ] as string [ ] ) . concat (
19061929 ...types . map ( t =>
1907- inferRuntimeType ( ctx , t , scope , isKeyOf , typeParameters ) ,
1930+ inferRuntimeType (
1931+ ctx ,
1932+ t ,
1933+ ( t as MaybeWithScope ) . _ownerScope || scope ,
1934+ isKeyOf ,
1935+ typeParameters ,
1936+ ) ,
19081937 ) ,
19091938 ) ,
19101939 ) ,
0 commit comments