@@ -63,17 +63,19 @@ type OptionsType = {|
63
63
handleMissingStyleName : HandleMissingStyleNameOptionType
64
64
| } ;
65
65
66
- export default ( styleNameValue : string , styleModuleImportMap : StyleModuleImportMapType , options : OptionsType ) : string => {
66
+ export default ( styleNameValue : string , styleModuleImportMap : StyleModuleImportMapType , options ? : OptionsType ) : string => {
67
67
const styleModuleImportMapKeys = Object . keys ( styleModuleImportMap ) ;
68
68
69
+ const handleMissingStyleName = options && options . handleMissingStyleName ;
70
+
69
71
return styleNameValue
70
72
. split ( ' ' )
71
73
. filter ( ( styleName ) => {
72
74
return styleName ;
73
75
} )
74
76
. map ( ( styleName ) => {
75
77
if ( isNamespacedStyleName ( styleName ) ) {
76
- return getClassNameForNamespacedStyleName ( styleName , styleModuleImportMap , options . handleMissingStyleName ) ;
78
+ return getClassNameForNamespacedStyleName ( styleName , styleModuleImportMap , handleMissingStyleName ) ;
77
79
}
78
80
79
81
if ( styleModuleImportMapKeys . length === 0 ) {
@@ -87,10 +89,10 @@ export default (styleNameValue: string, styleModuleImportMap: StyleModuleImportM
87
89
const styleModuleMap : StyleModuleMapType = styleModuleImportMap [ styleModuleImportMapKeys [ 0 ] ] ;
88
90
89
91
if ( ! styleModuleMap [ styleName ] ) {
90
- if ( options . handleMissingStyleName === 'throw' ) {
92
+ if ( handleMissingStyleName === 'throw' ) {
91
93
throw new Error ( 'Could not resolve the styleName \'' + styleName + '\'.' ) ;
92
94
}
93
- if ( options . handleMissingStyleName === 'warn' ) {
95
+ if ( handleMissingStyleName === 'warn' ) {
94
96
// eslint-disable-next-line no-console
95
97
console . warn ( 'Could not resolve the styleName \'' + styleName + '\'.' ) ;
96
98
}
0 commit comments