From d896934a23174ad8b98e8ea0c177c6380798e875 Mon Sep 17 00:00:00 2001 From: Paulo Vieira Date: Sun, 12 Jan 2025 19:38:21 +0000 Subject: [PATCH] Update typescript.md Change the importing of the `Ajv` object from default import to named import. This will avoid the typescript errors described in https://github.com/ajv-validator/ajv/issues/2132 --- docs/guide/typescript.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/guide/typescript.md b/docs/guide/typescript.md index d7674f8f5..37fbd8e50 100644 --- a/docs/guide/typescript.md +++ b/docs/guide/typescript.md @@ -20,7 +20,7 @@ For the same example as in [Getting started](./getting-started): ```typescript -import Ajv, {JSONSchemaType} from "ajv" +import {Ajv, JSONSchemaType} from "ajv" const ajv = new Ajv() interface MyData { @@ -61,7 +61,7 @@ if (validate(data)) { ```typescript -import Ajv, {JTDSchemaType} from "ajv/dist/jtd" +import {Ajv, JTDSchemaType} from "ajv/dist/jtd.js" const ajv = new Ajv() interface MyData { @@ -110,7 +110,7 @@ You can use JTD schema to construct the type of data using utility type `JTDData ```typescript -import Ajv, {JTDDataType} from "ajv/dist/jtd" +import {Ajv, JTDDataType} from "ajv/dist/jtd.js" const ajv = new Ajv() const schema = { @@ -181,7 +181,7 @@ if (validate(data)) { ```typescript -import {JTDErrorObject} from "ajv/dist/jtd" +import {JTDErrorObject} from "ajv/dist/jtd.js" // ... @@ -214,7 +214,7 @@ This example uses the same data and schema types as above: ```typescript -import Ajv, {JTDSchemaType} from "ajv/dist/jtd" +import {Ajv, JTDSchemaType} from "ajv/dist/jtd.js" const ajv = new Ajv() interface MyData { @@ -290,7 +290,7 @@ Here's a more detailed example showing several union types: ```typescript -import Ajv, {JSONSchemaType} from "ajv" +import {Ajv, JSONSchemaType} from "ajv" const ajv = new Ajv() type MyUnion = {prop: boolean} | string | number