MCPcopy Create free account
hub / github.com/Effect-TS/effect / parseAnnotation

Function parseAnnotation

packages/tools/api-diff/src/Annotations.ts:15–29  ·  view source on GitHub ↗
(id: string, value: unknown, file: string)

Source from the content-addressed store, hash-verified

13const compareStrings = (left: string, right: string): number => left < right ? -1 : left > right ? 1 : 0
14
15const parseAnnotation = (id: string, value: unknown, file: string): MigrationAnnotation => {
16 if (
17 typeof value !== "object" || value === null ||
18 typeof Reflect.get(value, "replacement") !== "string" ||
19 typeof Reflect.get(value, "note") !== "string" ||
20 (Reflect.get(value, "example") !== undefined && typeof Reflect.get(value, "example") !== "string")
21 ) {
22 throw new Error(`Invalid annotation for ${id} in ${file}`)
23 }
24 return {
25 replacement: Reflect.get(value, "replacement"),
26 note: Reflect.get(value, "note"),
27 ...(Reflect.get(value, "example") === undefined ? {} : { example: Reflect.get(value, "example") })
28 }
29}
30
31const loadAnnotationsInternal = Effect.fnUntraced(function*(directory: string) {
32 const fs = yield* FileSystem.FileSystem

Callers 1

Annotations.tsFile · 0.70

Calls 1

getMethod · 0.65

Tested by

no test coverage detected