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
// no import of the raw definer means the file cannot define a raw parser
107
+
if(!rawLocalName)returnfalse
108
+
109
+
// collect top-level variables initialized via the raw definer so we can
110
+
// detect indirect exports like `const p = defineParamParserRaw(...); export { p as parser }`
111
+
constrawLocals=newSet<string>()
112
+
for(constnodeofast.body){
113
+
if(node.type==='VariableDeclaration'){
114
+
for(constdeclaratorofnode.declarations){
115
+
if(
116
+
declarator.id.type==='Identifier'&&
117
+
isInitRawCall(declarator,rawLocalName)
118
+
){
119
+
rawLocals.add(declarator.id.name)
120
+
}
121
+
}
122
+
}
123
+
}
124
+
125
+
// walk export declarations looking for the `parser` export and check whether
126
+
// it ultimately comes from the raw definer (inline or via a tracked local)
127
+
letisRaw=false
128
+
walkAST(ast,{
129
+
enter(node){
130
+
if(isRaw)return
131
+
if(node.type!=='ExportNamedDeclaration')return
132
+
constexportNode=nodeasExportNamedDeclaration
133
+
// re-exports (`export { parser } from '...'`) can't be resolved locally:
134
+
// we'd need to follow the source module to know if it's raw. Warn so the
135
+
// user notices: runtime still works, but the generated types may not match.
136
+
if(exportNode.source){
137
+
constreExportsParser=exportNode.specifiers.some(
138
+
spec=>
139
+
spec.type==='ExportSpecifier'&&
140
+
spec.exported.type==='Identifier'&&
141
+
spec.exported.name==='parser'
142
+
)
143
+
if(reExportsParser){
144
+
console.warn(
145
+
`Cannot statically determine if "parser" is raw in "${filename}" because it is re-exported from "${exportNode.source.value}". The generated route param types may be incorrect. Define the parser inline in this file with \`defineParamParser\`/\`defineParamParserRaw\` instead of re-exporting it.`
0 commit comments