refactor(compiler): remove unreachable code (#40984)
1. The error function throws, so no code after it is reachable. 2. Some switch statements are exhaustive, so no code after them are reachable. PR Close #40984
This commit is contained in:
		
							parent
							
								
									a31da48507
								
							
						
					
					
						commit
						54b088967a
					
				| @ -124,7 +124,6 @@ export class MetadataDtsModuleScopeResolver implements DtsModuleScopeResolver { | |||||||
| 
 | 
 | ||||||
|       // The export was not a directive, a pipe, or a module. This is an error.
 |       // The export was not a directive, a pipe, or a module. This is an error.
 | ||||||
|       // TODO(alxhub): produce a ts.Diagnostic
 |       // TODO(alxhub): produce a ts.Diagnostic
 | ||||||
|       throw new Error(`Exported value ${exportRef.debugName} was not a directive, pipe, or module`); |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     const exportScope: ExportScope = { |     const exportScope: ExportScope = { | ||||||
|  | |||||||
| @ -784,7 +784,6 @@ function modifierFromModifier(modifier: StmtModifier): ts.Modifier { | |||||||
|     case StmtModifier.Static: |     case StmtModifier.Static: | ||||||
|       return ts.createToken(ts.SyntaxKind.StaticKeyword); |       return ts.createToken(ts.SyntaxKind.StaticKeyword); | ||||||
|   } |   } | ||||||
|   return error(`unknown statement modifier`); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function translateModifiers(modifiers: StmtModifier[]|null): ts.Modifier[]|undefined { | function translateModifiers(modifiers: StmtModifier[]|null): ts.Modifier[]|undefined { | ||||||
|  | |||||||
| @ -252,8 +252,6 @@ export class ConstantPool { | |||||||
|       case DefinitionKind.Pipe: |       case DefinitionKind.Pipe: | ||||||
|         return this.pipeDefinitions; |         return this.pipeDefinitions; | ||||||
|     } |     } | ||||||
|     error(`Unknown definition kind ${kind}`); |  | ||||||
|     return this.componentDefinitions; |  | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   public propertyNameOf(kind: DefinitionKind): string { |   public propertyNameOf(kind: DefinitionKind): string { | ||||||
| @ -267,8 +265,6 @@ export class ConstantPool { | |||||||
|       case DefinitionKind.Pipe: |       case DefinitionKind.Pipe: | ||||||
|         return 'ɵpipe'; |         return 'ɵpipe'; | ||||||
|     } |     } | ||||||
|     error(`Unknown definition kind ${kind}`); |  | ||||||
|     return '<unknown>'; |  | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   private freshName(): string { |   private freshName(): string { | ||||||
|  | |||||||
| @ -432,7 +432,6 @@ function selectorsFromGlobalMetadata( | |||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   error('Unexpected query form'); |   error('Unexpected query form'); | ||||||
|   return o.NULL_EXPR; |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function prepareQueryParams(query: R3QueryMetadata, constantPool: ConstantPool): o.Expression[] { | function prepareQueryParams(query: R3QueryMetadata, constantPool: ConstantPool): o.Expression[] { | ||||||
|  | |||||||
| @ -56,8 +56,6 @@ function getHelperDeclaration(name: HelperFunction): ts.Node { | |||||||
|     case HelperFunction.splitNamespace: |     case HelperFunction.splitNamespace: | ||||||
|       return getSplitNamespaceHelper(); |       return getSplitNamespaceHelper(); | ||||||
|   } |   } | ||||||
| 
 |  | ||||||
|   throw new Error(`Unsupported helper called "${name}".`); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /** Creates a helper for a custom `any` type during the migration. */ | /** Creates a helper for a custom `any` type during the migration. */ | ||||||
|  | |||||||
| @ -102,7 +102,6 @@ function getLViewToClone(type: TViewType, name: string|null): Array<any> { | |||||||
|       } |       } | ||||||
|       return embeddedArray; |       return embeddedArray; | ||||||
|   } |   } | ||||||
|   throw new Error('unreachable code'); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function nameSuffix(text: string|null|undefined): string { | function nameSuffix(text: string|null|undefined): string { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user