You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[compiler] Validate type configs for hooks/non-hooks
Alternative to #30868. The goal is to ensure that the types coming out of moduleTypeProvider are valid wrt to hook typing. If something is named like a hook, then it must be typed as a hook (or don't type it).
ghstack-source-id: 787575b
Pull Request resolved: #30888
reason: `Invalid moduleTypeProvider result for module '${moduleName}', expected type for '${moduleOrPropertyName}' to be a hook based on its name, but the type was not a hook`,
reason: `Invalid moduleTypeProvider result for module '${moduleName}', expected type for '${moduleOrPropertyName}' to be a hook based on its name, but the type was not a hook`,
558
+
loc: GeneratedSource,
559
+
});
560
+
}
561
+
}else{
562
+
// Not named like a hook => must not be a hook
563
+
if(type.kind==='Function'&&type.shapeId!=null){
564
+
constfunctionType=shapes.get(type.shapeId);
565
+
if(
566
+
functionType!=null&&
567
+
functionType.functionType?.hookKind!=null
568
+
){
569
+
CompilerError.throwInvalidConfig({
570
+
reason: `Invalid moduleTypeProvider result for module '${moduleName}', expected type for '${moduleOrPropertyName}' not to be a hook, but it was typed as a hook`,
571
+
loc: GeneratedSource,
572
+
});
573
+
}
574
+
}
575
+
}
576
+
}
577
+
returntype;
578
+
}
579
+
580
+
functionconvertTypeConfig(
581
+
moduleName: string,
535
582
globals: GlobalRegistry,
536
583
shapes: ShapeRegistry,
537
584
typeConfig: TypeConfig,
@@ -554,6 +601,9 @@ export function installTypeConfig(
554
601
case'Any': {
555
602
return{kind: 'Poly'};
556
603
}
604
+
case'JSX': {
605
+
return{kind: 'Object',shapeId: BuiltInJsxId};
606
+
}
557
607
default: {
558
608
assertExhaustive(
559
609
typeConfig.name,
@@ -567,7 +617,12 @@ export function installTypeConfig(
0 commit comments