Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support TypeScript's moduleResolution: "Node16" #524

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ const info = logger.info.bind(logger);
const error = logger.error.bind(logger);

/**
* @typedef {import("../types/api").JsonSchema} JsonSchema
* @typedef {import("../types/api.js").JsonSchema} JsonSchema
*/
/**
* @typedef {import("../types/api").SchemaList} SchemaList
* @typedef {import("../types/api.js").SchemaList} SchemaList
*/
/**
* @typedef {import("../types/api").SchemaContent} SchemaContent
* @typedef {import("../types/api.js").SchemaContent} SchemaContent
*/
/**
* @typedef {import("../types/api").SchemaFiles} SchemaFiles
* @typedef {import("../types/api.js").SchemaFiles} SchemaFiles
*/
/**
* @typedef {import("../types/api").GeneratedOutput} GeneratedOutput
* @typedef {import("../types/api.js").GeneratedOutput} GeneratedOutput
*/

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/symbols.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/

/**
* @typedef {import("../types/api").UniqueSymbols} UniqueSymbols
* @typedef {import("../types/api.js").UniqueSymbols} UniqueSymbols
*/

export const filename = Symbol('filename');
Expand Down
6 changes: 3 additions & 3 deletions lib/writeMarkdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ import fs from 'fs-extra';
import yaml from 'js-yaml';

/**
* @typedef {import("../types/api").MarkdownAst} MarkdownAst
* @typedef {import("../types/api.js").MarkdownAst} MarkdownAst
*/
/**
* @typedef {import("../types/api").MarkdownContent} MarkdownContent
* @typedef {import("../types/api.js").MarkdownContent} MarkdownContent
*/
/**
* @typedef {import("../types/api").ReadmeContent} ReadmeContent
* @typedef {import("../types/api.js").ReadmeContent} ReadmeContent
*/
/**
* @typedef {{ [name: string]: MarkdownAst }} MarkdownAstFiles
Expand Down
4 changes: 2 additions & 2 deletions lib/writeSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import path from 'path';
import s from './symbols.js';

/**
* @typedef {import("../types/api").ExtendedJsonSchema} ExtendedJsonSchema
* @typedef {import("../types/api.js").ExtendedJsonSchema} ExtendedJsonSchema
*/
/**
* @typedef {import("../types/api").SchemaContent} SchemaContent
* @typedef {import("../types/api.js").SchemaContent} SchemaContent
*/

/**
Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,33 @@
"jsonschema2md": "./cli.js"
},
"type": "module",
"exports": {
".": {
"import": {
"types": "./types/index.d.ts",
"default": "./lib/index.js"
}
},
"./lib/*.js": {
"import": {
"types": "./types/*.d.ts",
"default": "./lib/*.js"
}
},
"./lib/*": {
"import": {
"types": "./types/*.d.ts",
"default": "./lib/*.js"
}
},
"./lib/index": {
"import": {
"types": "./types/index.d.ts",
"default": "./lib/index.js"
}
},
Comment on lines +24 to +35
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are currently needed for backwards compatibility, in case somebody has done import {jsonschema2md} from "@adobe/jsonschema2md/lib/index"; or import { default as schemaLoader } from '@adobe/jsonschema2md/lib/schemaProxy';.

However, as long as you're okay with having a BREAKING CHANGE, we can remove these lines.

"./package.json": "./package.json"
},
"scripts": {
"semantic-release": "npm run emit-types && npx semantic-release",
"commit": "git-cz",
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"moduleResolution": "node",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"allowJs": true,
"declaration": true,
"emitDeclarationOnly": true,
Expand Down
4 changes: 2 additions & 2 deletions types/formatInfo.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export default function formatmeta(schema: any): {
longcomment: import("mdast").Root;
longcomment: import("remark-stringify/node_modules/@types/mdast").Root;
shortcomment: any;
comment: string;
longdescription: import("mdast").Root;
longdescription: import("remark-stringify/node_modules/@types/mdast").Root;
shortdescription: any;
description: any;
abstract: boolean;
Expand Down
22 changes: 11 additions & 11 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/**
* @typedef {import("../types/api").JsonSchema} JsonSchema
* @typedef {import("../types/api.js").JsonSchema} JsonSchema
*/
/**
* @typedef {import("../types/api").SchemaList} SchemaList
* @typedef {import("../types/api.js").SchemaList} SchemaList
*/
/**
* @typedef {import("../types/api").SchemaContent} SchemaContent
* @typedef {import("../types/api.js").SchemaContent} SchemaContent
*/
/**
* @typedef {import("../types/api").SchemaFiles} SchemaFiles
* @typedef {import("../types/api.js").SchemaFiles} SchemaFiles
*/
/**
* @typedef {import("../types/api").GeneratedOutput} GeneratedOutput
* @typedef {import("../types/api.js").GeneratedOutput} GeneratedOutput
*/
/**
* Public API for jsonschema2md that can be used to turn JSON Schema files
Expand Down Expand Up @@ -42,7 +42,7 @@
* skip in markdown.
* @returns {GeneratedOutput} List of raw markdown that were generated from input schema.
*/
export function jsonschema2md(schema: JsonSchema | import("../types/api").SchemaFiles, options: {
export function jsonschema2md(schema: JsonSchema | import("../types/api.js").SchemaFiles, options: {
schemaPath?: string;
outDir?: string;
metadata?: {
Expand All @@ -68,8 +68,8 @@ export function jsonschema2md(schema: JsonSchema | import("../types/api").Schema
export function main(args: {
[key: string]: unknown;
}): Promise<number>;
export type JsonSchema = import("../types/api").JsonSchema;
export type SchemaList = import("../types/api").SchemaList;
export type SchemaContent = import("../types/api").SchemaContent;
export type SchemaFiles = import("../types/api").SchemaFiles;
export type GeneratedOutput = import("../types/api").GeneratedOutput;
export type JsonSchema = import("../types/api.js").JsonSchema;
export type SchemaList = import("../types/api.js").SchemaList;
export type SchemaContent = import("../types/api.js").SchemaContent;
export type SchemaFiles = import("../types/api.js").SchemaFiles;
export type GeneratedOutput = import("../types/api.js").GeneratedOutput;
4 changes: 2 additions & 2 deletions types/symbols.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/**
* @typedef {import("../types/api").UniqueSymbols} UniqueSymbols
* @typedef {import("../types/api.js").UniqueSymbols} UniqueSymbols
*/
export const filename: unique symbol;
export const fullpath: unique symbol;
export default symbols;
export type UniqueSymbols = import("../types/api").UniqueSymbols;
export type UniqueSymbols = import("../types/api.js").UniqueSymbols;
/**
* @type {UniqueSymbols}
* */
Expand Down
12 changes: 6 additions & 6 deletions types/writeMarkdown.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/**
* @typedef {import("../types/api").MarkdownAst} MarkdownAst
* @typedef {import("../types/api.js").MarkdownAst} MarkdownAst
*/
/**
* @typedef {import("../types/api").MarkdownContent} MarkdownContent
* @typedef {import("../types/api.js").MarkdownContent} MarkdownContent
*/
/**
* @typedef {import("../types/api").ReadmeContent} ReadmeContent
* @typedef {import("../types/api.js").ReadmeContent} ReadmeContent
*/
/**
* @typedef {{ [name: string]: MarkdownAst }} MarkdownAstFiles
Expand Down Expand Up @@ -48,9 +48,9 @@ export function writereadme({ out, error, info, meta, }: {
[key: string]: string;
};
}): (markdownAst: MarkdownAst) => ReadmeContent;
export type MarkdownAst = import("../types/api").MarkdownAst;
export type MarkdownContent = import("../types/api").MarkdownContent;
export type ReadmeContent = import("../types/api").ReadmeContent;
export type MarkdownAst = import("../types/api.js").MarkdownAst;
export type MarkdownContent = import("../types/api.js").MarkdownContent;
export type ReadmeContent = import("../types/api.js").ReadmeContent;
export type MarkdownAstFiles = {
[name: string]: import("mdast").Root;
};
8 changes: 4 additions & 4 deletions types/writeSchema.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* @typedef {import("../types/api").ExtendedJsonSchema} ExtendedJsonSchema
* @typedef {import("../types/api.js").ExtendedJsonSchema} ExtendedJsonSchema
*/
/**
* @typedef {import("../types/api").SchemaContent} SchemaContent
* @typedef {import("../types/api.js").SchemaContent} SchemaContent
*/
/**
* Write the JSON Schemas to filesystem or an object
Expand All @@ -15,5 +15,5 @@ export default function writeSchema({ schemadir, origindir }: {
schemadir?: string;
origindir?: string;
}): (schemas: ExtendedJsonSchema[]) => SchemaContent[];
export type ExtendedJsonSchema = import("../types/api").ExtendedJsonSchema;
export type SchemaContent = import("../types/api").SchemaContent;
export type ExtendedJsonSchema = import("../types/api.js").ExtendedJsonSchema;
export type SchemaContent = import("../types/api.js").SchemaContent;