(file: string)
| 1320 | |
| 1321 | // e.g. @hono/arktype-validator, reading only `type.errors` |
| 1322 | readsOnlyRuntime(file: string): boolean { |
| 1323 | const source = this.host.readFile(file) |
| 1324 | if (source === undefined) return false |
| 1325 | const module = new SourceModule(file, source, file) |
| 1326 | if (module.parseErrors.length) return false |
| 1327 | let readsOnlyRuntime = true |
| 1328 | walk(module.program, node => { |
| 1329 | if (!readsOnlyRuntime) return false |
| 1330 | const specifier = |
| 1331 | ( |
| 1332 | node.type === "ImportDeclaration" || |
| 1333 | node.type === "ExportNamedDeclaration" || |
| 1334 | node.type === "ExportAllDeclaration" |
| 1335 | ) ? |
| 1336 | node.source |
| 1337 | : loadedSourceOf(node) |
| 1338 | if (!specifier) return true |
| 1339 | if ( |
| 1340 | specifier.type !== "Literal" || |
| 1341 | typeof specifier.value !== "string" || |
| 1342 | !/^arktype(?:\/|$)/.test(specifier.value) |
| 1343 | ) |
| 1344 | return true |
| 1345 | readsOnlyRuntime = |
| 1346 | node.type === "ImportDeclaration" && |
| 1347 | (node.importKind === "type" || |
| 1348 | (specifier.value === "arktype" && |
| 1349 | node.specifiers.every( |
| 1350 | imported => |
| 1351 | imported.type === "ImportSpecifier" && |
| 1352 | (imported.importKind === "type" || |
| 1353 | readsRuntimeExport(module, imported)) |
| 1354 | ))) |
| 1355 | return false |
| 1356 | }) |
| 1357 | return readsOnlyRuntime |
| 1358 | } |
| 1359 | |
| 1360 | // an arktype entry other than its runtime, imported or required |
| 1361 | importsArktype(id: string): boolean { |
no test coverage detected