mirror of
				https://github.com/strapi/strapi.git
				synced 2025-10-31 01:47:13 +00:00 
			
		
		
		
	Add example for Strapi type extension
This commit is contained in:
		
							parent
							
								
									60a26e08fc
								
							
						
					
					
						commit
						1aff33e1d1
					
				
							
								
								
									
										7
									
								
								examples/kitchensink-ts/index.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								examples/kitchensink-ts/index.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,7 @@ | ||||
| import '@strapi/strapi'; | ||||
| 
 | ||||
| declare module '@strapi/strapi' { | ||||
|   interface StrapiInterface { | ||||
|     customAddMethod(n1: number, n2: number): number; | ||||
|   } | ||||
| } | ||||
							
								
								
									
										15
									
								
								examples/kitchensink-ts/src/index.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								examples/kitchensink-ts/src/index.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,15 @@ | ||||
| export default { | ||||
|   register({ strapi }: { strapi: Strapi }) { | ||||
|     // No error when trying the access & set the
 | ||||
|     strapi.customAddMethod = (n1, n2) => { | ||||
|       return n1 + n2; | ||||
|     }; | ||||
|   }, | ||||
| 
 | ||||
|   bootstrap({ strapi }: { strapi: Strapi }) { | ||||
|     const result = strapi.customAddMethod(12, 32); | ||||
| 
 | ||||
|     // This should print "42"
 | ||||
|     console.log(result); | ||||
|   }, | ||||
| }; | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Convly
						Convly