@@ -9,7 +9,9 @@ const NormalModule = require('webpack/lib/NormalModule');
99
1010
1111function _getContentOfKeyLiteral ( source : ts . SourceFile , node : ts . Node ) : string {
12- if ( node . kind == ts . SyntaxKind . Identifier ) {
12+ if ( ! node ) {
13+ return null ;
14+ } else if ( node . kind == ts . SyntaxKind . Identifier ) {
1315 return ( node as ts . Identifier ) . text ;
1416 } else if ( node . kind == ts . SyntaxKind . StringLiteral ) {
1517 return ( node as ts . StringLiteral ) . text ;
@@ -241,11 +243,16 @@ function _removeModuleId(refactor: TypeScriptFileRefactor) {
241243
242244 refactor . findAstNodes ( sourceFile , ts . SyntaxKind . ObjectLiteralExpression , true )
243245 // Get all their property assignments.
244- . filter ( ( node : ts . ObjectLiteralExpression ) =>
245- node . properties . some ( prop => _getContentOfKeyLiteral ( sourceFile , prop . name ) == 'moduleId' ) )
246+ . filter ( ( node : ts . ObjectLiteralExpression ) => {
247+ return node . properties . some ( prop => {
248+ return prop . kind == ts . SyntaxKind . PropertyAssignment
249+ && _getContentOfKeyLiteral ( sourceFile , prop . name ) == 'moduleId' ;
250+ } ) ;
251+ } )
246252 . forEach ( ( node : ts . ObjectLiteralExpression ) => {
247253 const moduleIdProp = node . properties . filter ( ( prop : ts . ObjectLiteralElement , idx : number ) => {
248- return _getContentOfKeyLiteral ( sourceFile , prop . name ) == 'moduleId' ;
254+ return prop . kind == ts . SyntaxKind . PropertyAssignment
255+ && _getContentOfKeyLiteral ( sourceFile , prop . name ) == 'moduleId' ;
249256 } ) [ 0 ] ;
250257 // get the trailing comma
251258 const moduleIdCommaProp = moduleIdProp . parent . getChildAt ( 1 ) . getChildren ( ) [ 1 ] ;
0 commit comments