mirror of https://github.com/vuejs/core.git
				
				
				
			fix(compiler-sfc): infer TS Extract&Exclude runtime type (#7339)
closes #7337 closes #6252
This commit is contained in:
		
							parent
							
								
									3a7572cdb2
								
							
						
					
					
						commit
						6391daf658
					
				|  | @ -1619,6 +1619,8 @@ export default /*#__PURE__*/_defineComponent({ | |||
|     alias: { type: Array, required: true }, | ||||
|     method: { type: Function, required: true }, | ||||
|     symbol: { type: Symbol, required: true }, | ||||
|     extract: { type: Number, required: true }, | ||||
|     exclude: { type: [Number, Boolean], required: true }, | ||||
|     objectOrFn: { type: [Function, Object], required: true }, | ||||
|     union: { type: [String, Number], required: true }, | ||||
|     literalUnion: { type: String, required: true }, | ||||
|  |  | |||
|  | @ -960,6 +960,8 @@ const emit = defineEmits(['a', 'b']) | |||
|         alias: Alias | ||||
|         method(): void | ||||
|         symbol: symbol | ||||
|         extract: Extract<1 | 2 | boolean, 2> | ||||
|         exclude: Exclude<1 | 2 | boolean, 2> | ||||
|         objectOrFn: { | ||||
|           (): void | ||||
|           foo: string | ||||
|  | @ -997,6 +999,10 @@ const emit = defineEmits(['a', 'b']) | |||
|       expect(content).toMatch( | ||||
|         `objectOrFn: { type: [Function, Object], required: true },` | ||||
|       ) | ||||
|       expect(content).toMatch(`extract: { type: Number, required: true }`) | ||||
|       expect(content).toMatch( | ||||
|         `exclude: { type: [Number, Boolean], required: true }` | ||||
|       ) | ||||
|       expect(content).toMatch( | ||||
|         `union: { type: [String, Number], required: true }` | ||||
|       ) | ||||
|  | @ -1031,6 +1037,8 @@ const emit = defineEmits(['a', 'b']) | |||
|         method: BindingTypes.PROPS, | ||||
|         symbol: BindingTypes.PROPS, | ||||
|         objectOrFn: BindingTypes.PROPS, | ||||
|         extract: BindingTypes.PROPS, | ||||
|         exclude: BindingTypes.PROPS, | ||||
|         union: BindingTypes.PROPS, | ||||
|         literalUnion: BindingTypes.PROPS, | ||||
|         literalUnionNumber: BindingTypes.PROPS, | ||||
|  |  | |||
|  | @ -2057,11 +2057,26 @@ function inferRuntimeType( | |||
|           case 'Readonly': | ||||
|           case 'Pick': | ||||
|           case 'Omit': | ||||
|           case 'Exclude': | ||||
|           case 'Extract': | ||||
|           case 'Required': | ||||
|           case 'InstanceType': | ||||
|             return ['Object'] | ||||
| 
 | ||||
|           case 'Extract': | ||||
|             if (node.typeParameters && node.typeParameters.params[1]) { | ||||
|               return inferRuntimeType( | ||||
|                 node.typeParameters.params[1], | ||||
|                 declaredTypes | ||||
|               ) | ||||
|             } | ||||
|             return ['null'] | ||||
|           case 'Exclude': | ||||
|             if (node.typeParameters && node.typeParameters.params[0]) { | ||||
|               return inferRuntimeType( | ||||
|                 node.typeParameters.params[0], | ||||
|                 declaredTypes | ||||
|               ) | ||||
|             } | ||||
|             return ['null'] | ||||
|         } | ||||
|       } | ||||
|       return [`null`] | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue