diff --git a/types/geojson-precision/.npmignore b/types/geojson-precision/.npmignore new file mode 100644 index 00000000000000..93e307400a5456 --- /dev/null +++ b/types/geojson-precision/.npmignore @@ -0,0 +1,5 @@ +* +!**/*.d.ts +!**/*.d.cts +!**/*.d.mts +!**/*.d.*.ts diff --git a/types/geojson-precision/geojson-precision-tests.ts b/types/geojson-precision/geojson-precision-tests.ts new file mode 100644 index 00000000000000..1da19490af5e90 --- /dev/null +++ b/types/geojson-precision/geojson-precision-tests.ts @@ -0,0 +1,14 @@ +import type { LineString, Point } from "geojson"; +import parse from "geojson-precision"; + +const point: Point = { type: "Point", coordinates: [12.45, 56.78] }; +let line: LineString = { type: "LineString", coordinates: [] }; + +let trimmed = parse(point, 3); +// $ExpectType Point +trimmed; + +line = parse(line, 4); +line = parse.parse(line, 4); + +parse.parse.parse.parse.parse; // this is silly, but technically possible diff --git a/types/geojson-precision/index.d.ts b/types/geojson-precision/index.d.ts new file mode 100644 index 00000000000000..10c767f876eac1 --- /dev/null +++ b/types/geojson-precision/index.d.ts @@ -0,0 +1,26 @@ +import * as GeoJSON from "geojson"; + +interface Parse { + /** + * Remove meaningless precision from your GeoJSON. + * + * @param coordinatePrecision A positive integer. If your specified precision value + * is greater than the precision of the input geometry, the output precision + * will be the same as the input. For example, if your input coordinates are + * `[10.0, 20.0]`, and you specify a precision of `5`, the output will be the + * same as the input. + * + * @param extrasPrecision A positive integer specifying extra coordinate precision + * for things like the `z` value when the coordinate is + * `[longitude, latitude, elevation]`. + */ + ( + geometry: T, + coordinatePrecision: number, + extrasPrecision?: number, + ): T; + parse: Parse; +} + +declare const parse: Parse; +export = parse; diff --git a/types/geojson-precision/package.json b/types/geojson-precision/package.json new file mode 100644 index 00000000000000..5bda3ae879e611 --- /dev/null +++ b/types/geojson-precision/package.json @@ -0,0 +1,20 @@ +{ + "private": true, + "name": "@types/geojson-precision", + "version": "1.0.9999", + "projects": [ + "https://github.com/jczaplew/geojson-precision" + ], + "dependencies": { + "@types/geojson": "*" + }, + "devDependencies": { + "@types/geojson-precision": "workspace:." + }, + "owners": [ + { + "name": "Kyle Hensel", + "githubUsername": "k-yle" + } + ] +} diff --git a/types/geojson-precision/tsconfig.json b/types/geojson-precision/tsconfig.json new file mode 100644 index 00000000000000..b514d4d6140cb4 --- /dev/null +++ b/types/geojson-precision/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "node16", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "geojson-precision-tests.ts" + ] +} diff --git a/types/markdown-it-container/index.d.ts b/types/markdown-it-container/index.d.ts index 540a3baf9adbc6..87aafd33c0def0 100644 --- a/types/markdown-it-container/index.d.ts +++ b/types/markdown-it-container/index.d.ts @@ -1,10 +1,11 @@ import MarkdownIt = require("markdown-it"); +import Renderer = require("markdown-it/lib/renderer"); declare namespace MarkdownItContainer { interface ContainerOpts { marker?: string | undefined; validate?(params: string): boolean; - render?: MarkdownIt.Renderer.RenderRule | undefined; + render?: Renderer.RenderRule | undefined; } } diff --git a/types/markdown-it-container/markdown-it-container-tests.ts b/types/markdown-it-container/markdown-it-container-tests.ts index 42e1220908b72e..7b9e1276d3a0de 100644 --- a/types/markdown-it-container/markdown-it-container-tests.ts +++ b/types/markdown-it-container/markdown-it-container-tests.ts @@ -5,7 +5,7 @@ import MarkdownItContainer = require("markdown-it-container"); const md = new MarkdownIt(); md.use(MarkdownItContainer, "spoiler", { - validate: (params: any) => params.trim().match(/^spoiler\s+(.*)$/), + validate: (params: string) => params.trim().match(/^spoiler\s+(.*)$/), render: (tokens: MarkdownIt.Token[], index: number) => { const match = tokens[index].info.trim().match(/^spoiler\s+(.*)$/); const onClick = "this.parentNode.classList.toggle('_expanded');" + "event.preventDefault();"; @@ -26,6 +26,7 @@ md.use(MarkdownItContainer, "spoiler", { return "\n"; } }, + marker: "marker", }); const src = `:::spoiler This Is Spoiler Title diff --git a/types/markdown-it-container/package.json b/types/markdown-it-container/package.json index a1b6f8d6673ef6..dc089f647432bc 100644 --- a/types/markdown-it-container/package.json +++ b/types/markdown-it-container/package.json @@ -6,7 +6,7 @@ "https://github.com/markdown-it/markdown-it-container" ], "dependencies": { - "@types/markdown-it": "*" + "@types/markdown-it": "<14" }, "devDependencies": { "@types/markdown-it-container": "workspace:."