Skip to content

Commit

Permalink
chore(apidom-error): use API Extractor for TypeScript rollup (#4422)
Browse files Browse the repository at this point in the history
Refs #4382
  • Loading branch information
char0n authored Oct 29, 2024
1 parent bdc0145 commit 1c3f6b3
Show file tree
Hide file tree
Showing 12 changed files with 868 additions and 16 deletions.
458 changes: 458 additions & 0 deletions api-extractor.json

Large diffs are not rendered by default.

383 changes: 383 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
"lerna": "=8.1.8",
"lint-staged": "=15.2.10",
"microtime": "=3.1.1",
"@microsoft/api-extractor": "^7.47.11",
"mocha": "=10.7.3",
"mocha-chai-jest-snapshot": "^1.1.6",
"node-gyp": "=10.2.0",
Expand Down
4 changes: 4 additions & 0 deletions packages/apidom-error/config/api-extractor/api-extractor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"extends": "../../../../api-extractor.json"
}
12 changes: 0 additions & 12 deletions packages/apidom-error/config/rollup/types.dist.js

This file was deleted.

8 changes: 4 additions & 4 deletions packages/apidom-error/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
"unpkg": "./dist/apidom-error.browser.min.js",
"main": "./src/index.cjs",
"exports": {
"types": "./types/dist.d.ts",
"types": "./types/apidom-error.d.ts",
"import": "./src/index.mjs",
"require": "./src/index.cjs"
},
"types": "./types/dist.d.ts",
"types": "./types/apidom-error.d.ts",
"scripts": {
"build": "npm run clean && run-p --max-parallel ${CPU_CORES:-2} typescript:declaration build:es build:cjs build:umd:browser",
"build:es": "cross-env BABEL_ENV=es babel src --out-dir src --extensions '.ts' --out-file-extension '.mjs' --root-mode 'upward'",
Expand All @@ -25,7 +25,7 @@
"lint:fix": "eslint ./ --fix",
"clean": "rimraf --glob 'src/**/*.mjs' 'src/**/*.cjs' 'test/**/*.mjs' ./dist ./types",
"typescript:check-types": "tsc --noEmit",
"typescript:declaration": "copyfiles -u 1 'src/**/*.d.ts' ./types && tsc -p declaration.tsconfig.json && rollup -c config/rollup/types.dist.js",
"typescript:declaration": "copyfiles -u 1 'src/**/*.d.ts' ./types && tsc -p declaration.tsconfig.json && api-extractor run -l -c ./config/api-extractor/api-extractor.json",
"test": "npm run build:es && cross-env BABEL_ENV=es babel test --out-dir test --extensions '.ts' --out-file-extension '.mjs' --root-mode 'upward' && cross-env NODE_ENV=test mocha",
"prepack": "copyfiles -u 3 ../../LICENSES/* LICENSES && copyfiles -u 2 ../../NOTICE .",
"postpack": "rimraf NOTICE LICENSES"
Expand All @@ -43,7 +43,7 @@
"src/**/*.mjs",
"src/**/*.cjs",
"dist/",
"types/dist.d.ts",
"types/apidom-error.d.ts",
"LICENSES",
"NOTICE",
"README.md",
Expand Down
3 changes: 3 additions & 0 deletions packages/apidom-error/src/ApiDOMAggregateError.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import type ApiDOMErrorOptions from './ApiDOMErrorOptions.ts';

/**
* @public
*/
class ApiDOMAggregateError extends AggregateError {
constructor(errors: Iterable<unknown>, message?: string, options?: ApiDOMErrorOptions) {
super(errors, message, options);
Expand Down
3 changes: 3 additions & 0 deletions packages/apidom-error/src/ApiDOMError.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import ApiDOMAggregateError from './ApiDOMAggregateError.ts';
import type ApiDOMErrorOptions from './ApiDOMErrorOptions.ts';

/**
* @public
*/
class ApiDOMError extends Error {
public static [Symbol.hasInstance](instance: unknown) {
// we want to ApiDOMAggregateError to act as if ApiDOMError was its superclass
Expand Down
3 changes: 3 additions & 0 deletions packages/apidom-error/src/ApiDOMErrorOptions.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* @public
*/
export default interface ApiDOMErrorOptions extends ErrorOptions {
readonly cause?: unknown;
readonly [key: string]: unknown;
Expand Down
3 changes: 3 additions & 0 deletions packages/apidom-error/src/ApiDOMStructuredError.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import ApiDOMError from './ApiDOMError.ts';
import type ApiDOMErrorOptions from './ApiDOMErrorOptions.ts';

/**
* @public
*/
class ApiDOMStructuredError extends ApiDOMError {
constructor(message?: string, structuredOptions?: ApiDOMErrorOptions) {
super(message, structuredOptions);
Expand Down
3 changes: 3 additions & 0 deletions packages/apidom-error/src/NotImplementedError.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import UnsupportedOperationError from './UnsupportedOperationError.ts';

/**
* @public
*/
class NotImplementedError extends UnsupportedOperationError {}

export default NotImplementedError;
3 changes: 3 additions & 0 deletions packages/apidom-error/src/UnsupportedOperationError.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import ApiDOMError from './ApiDOMError.ts';

/**
* @public
*/
class UnsupportedOperationError extends ApiDOMError {}

export default UnsupportedOperationError;

0 comments on commit 1c3f6b3

Please sign in to comment.