@@ -951,7 +951,9 @@ module Util =
951951 | Fable.BaseValue( None,_) -> Super( None)
952952 | Fable.BaseValue( Some boundIdent,_) -> identAsExpr boundIdent
953953 | Fable.ThisValue _ -> Expression.thisExpression()
954- | Fable.TypeInfo t -> transformTypeInfo com ctx r ( Some Map.empty) t
954+ | Fable.TypeInfo t ->
955+ if com.Options.NoReflection then addErrorAndReturnNull com r " Reflection is disabled"
956+ else transformTypeInfo com ctx r ( Some Map.empty) t
955957 | Fable.Null _ t ->
956958 // if com.Options.typescript
957959 // let ta = typeAnnotation com ctx t |> TypeAnnotation |> Some
@@ -1971,20 +1973,23 @@ module Util =
19711973
19721974 let declareType ( com : IBabelCompiler ) ctx ( ent : Fable.Entity ) entName ( consArgs : Pattern []) ( consBody : BlockStatement ) baseExpr classMembers : ModuleDeclaration list =
19731975 let typeDeclaration = declareClassType com ctx ent entName consArgs consBody baseExpr classMembers
1974- let reflectionDeclaration =
1975- let ta =
1976- if com.Options.Language = TypeScript then
1977- makeImportTypeAnnotation com ctx [] " Reflection" " TypeInfo"
1978- |> TypeAnnotation |> Some
1979- else None
1980- let genArgs = Array.init ( ent.GenericParameters.Length) ( fun i -> " gen" + string i |> makeIdent)
1981- let generics = genArgs |> Array.map identAsExpr
1982- let body = transformReflectionInfo com ctx None ent generics
1983- let args = genArgs |> Array.map ( fun x -> Pattern.identifier( x.Name, ?typeAnnotation= ta))
1984- let returnType = ta
1985- makeFunctionExpression None ( args, body, returnType, None)
1986- |> declareModuleMember ent.IsPublic ( entName + Naming.reflectionSuffix) false
1987- [ typeDeclaration; reflectionDeclaration]
1976+ if com.Options.NoReflection then
1977+ [ typeDeclaration]
1978+ else
1979+ let reflectionDeclaration =
1980+ let ta =
1981+ if com.Options.Language = TypeScript then
1982+ makeImportTypeAnnotation com ctx [] " Reflection" " TypeInfo"
1983+ |> TypeAnnotation |> Some
1984+ else None
1985+ let genArgs = Array.init ( ent.GenericParameters.Length) ( fun i -> " gen" + string i |> makeIdent)
1986+ let generics = genArgs |> Array.map identAsExpr
1987+ let body = transformReflectionInfo com ctx None ent generics
1988+ let args = genArgs |> Array.map ( fun x -> Pattern.identifier( x.Name, ?typeAnnotation= ta))
1989+ let returnType = ta
1990+ makeFunctionExpression None ( args, body, returnType, None)
1991+ |> declareModuleMember ent.IsPublic ( entName + Naming.reflectionSuffix) false
1992+ [ typeDeclaration; reflectionDeclaration]
19881993
19891994 let transformModuleFunction ( com : IBabelCompiler ) ctx ( info : Fable.MemberInfo ) ( membName : string ) args body =
19901995 let args , body , returnType , typeParamDecl =
0 commit comments