@@ -41,6 +41,7 @@ export function replaceResources(
4141 resourceImportDeclarations ,
4242 moduleKind ,
4343 inlineStyleFileExtension ,
44+ node ,
4445 ) ,
4546 ) ,
4647 ...( ts . getModifiers ( node ) ?? [ ] ) ,
@@ -87,6 +88,7 @@ function visitDecorator(
8788 resourceImportDeclarations : ts . ImportDeclaration [ ] ,
8889 moduleKind ?: ts . ModuleKind ,
8990 inlineStyleFileExtension ?: string ,
91+ classDeclaration ?: ts . ClassDeclaration ,
9092) : ts . Decorator {
9193 if ( ! isComponentDecorator ( node , typeChecker ) ) {
9294 return node ;
@@ -106,6 +108,8 @@ function visitDecorator(
106108 const objectExpression = args [ 0 ] ;
107109 const styleReplacements : ts . Expression [ ] = [ ] ;
108110
111+ const className = classDeclaration ?. name ?. text ?? 'Unknown' ;
112+
109113 // visit all properties
110114 let properties = ts . visitNodes ( objectExpression . properties , ( node ) =>
111115 ts . isObjectLiteralElementLike ( node )
@@ -116,6 +120,7 @@ function visitDecorator(
116120 resourceImportDeclarations ,
117121 moduleKind ,
118122 inlineStyleFileExtension ,
123+ className ,
119124 )
120125 : node ,
121126 ) as ts . NodeArray < ts . ObjectLiteralElementLike > ;
@@ -148,6 +153,7 @@ function visitComponentMetadata(
148153 resourceImportDeclarations : ts . ImportDeclaration [ ] ,
149154 moduleKind : ts . ModuleKind = ts . ModuleKind . ES2015 ,
150155 inlineStyleFileExtension ?: string ,
156+ className ?: string ,
151157) : ts . ObjectLiteralElementLike | undefined {
152158 if ( ! ts . isPropertyAssignment ( node ) || ts . isComputedPropertyName ( node . name ) ) {
153159 return node ;
@@ -161,7 +167,14 @@ function visitComponentMetadata(
161167 case 'templateUrl' : {
162168 const url = getResourceUrl ( node . initializer ) ;
163169 if ( ! url ) {
164- return node ;
170+ const sourceFile = node . getSourceFile ( ) ;
171+ const { line } = sourceFile . getLineAndCharacterOfPosition ( node . initializer . getStart ( ) ) ;
172+
173+ throw new Error (
174+ `Component '${ className } ' in '${ sourceFile . fileName } ' contains a non-string literal ` +
175+ `'templateUrl' value at line ${ line + 1 } . The 'templateUrl' property must be a ` +
176+ `string literal. Expressions, variables, or other dynamic values are not supported.` ,
177+ ) ;
165178 }
166179
167180 const importName = createResourceImport (
0 commit comments