All errors for existing fields have been detected and suppressed with a `!` assertion. Issue/24571 is tracking proper clean up of those instances. One-line change required in ivy/compilation.ts, because it appears that the new syntax causes tsickle emitted node to no longer track their original sourceFiles. PR Close #24572
		
			
				
	
	
		
			45 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			45 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| /**
 | |
|  * @license
 | |
|  * Copyright Google Inc. All Rights Reserved.
 | |
|  *
 | |
|  * Use of this source code is governed by an MIT-style license that can be
 | |
|  * found in the LICENSE file at https://angular.io/license
 | |
|  */
 | |
| 
 | |
| export class MockScriptElement {
 | |
|   constructor() {}
 | |
| 
 | |
|   listeners: {
 | |
|     load?: (event: Event) => void,
 | |
|     error?: (err: Error) => void,
 | |
|   } = {};
 | |
| 
 | |
|   addEventListener(event: 'load'|'error', handler: Function): void {
 | |
|     this.listeners[event] = handler as any;
 | |
|   }
 | |
| 
 | |
|   removeEventListener(event: 'load'|'error'): void { delete this.listeners[event]; }
 | |
| }
 | |
| 
 | |
| export class MockDocument {
 | |
|   // TODO(issue/24571): remove '!'.
 | |
|   mock !: MockScriptElement | null;
 | |
|   readonly body: any = this;
 | |
| 
 | |
|   createElement(tag: 'script'): HTMLScriptElement {
 | |
|     return new MockScriptElement() as any as HTMLScriptElement;
 | |
|   }
 | |
| 
 | |
|   appendChild(node: any): void { this.mock = node; }
 | |
| 
 | |
|   removeNode(node: any): void {
 | |
|     if (this.mock === node) {
 | |
|       this.mock = null;
 | |
|     }
 | |
|   }
 | |
| 
 | |
|   mockLoad(): void { this.mock !.listeners.load !(null as any); }
 | |
| 
 | |
|   mockError(err: Error) { this.mock !.listeners.error !(err); }
 | |
| }
 |