thrownewTypeError(`Number of ${node.type} quasis should be exactly one more than the number of expressions.\nExpected ${val.length+1} quasis but got ${node.quasis.length}`);
thrownewTypeError(`Property ${key} expected value to be one of ${JSON.stringify(values)} but got ${JSON.stringify(val)}`);
}
}
validate.oneOf=values;
returnvalidate;
}
functionassertNodeType(...types){
functionvalidate(node,key,val){
for(consttypeoftypes){
if((0,_is.default)(type,val)){
(0,_validate.validateChild)(node,key,val);
return;
}
}
thrownewTypeError(`Property ${key} of ${node.type} expected node to be of a type ${JSON.stringify(types)} but instead got ${JSON.stringify(val==null?void0:val.type)}`);
thrownewTypeError(`Property ${key} of ${node.type} expected node to be of a type ${JSON.stringify(types)} but instead got ${JSON.stringify(val==null?void0:val.type)}`);
}
validate.oneOfNodeOrValueTypes=types;
returnvalidate;
}
functionassertValueType(type){
functionvalidate(node,key,val){
constvalid=getType(val)===type;
if(!valid){
thrownewTypeError(`Property ${key} expected type of ${type} but got ${getType(val)}`);
thrownewTypeError(`Property ${key} of ${node.type} expected to have the following:\n${errors.join("\n")}`);
}
}
validate.shapeOf=shape;
returnvalidate;
}
functionassertOptionalChainStart(){
functionvalidate(node){
var_current;
letcurrent=node;
while(node){
const{
type
}=current;
if(type==="OptionalCallExpression"){
if(current.optional)return;
current=current.callee;
continue;
}
if(type==="OptionalMemberExpression"){
if(current.optional)return;
current=current.object;
continue;
}
break;
}
thrownewTypeError(`Non-optional ${node.type} must chain from an optional OptionalMemberExpression or OptionalCallExpression. Found chain from ${(_current=current)==null?void0:_current.type}`);