From cd4321c88a97a9a6f9d0f972dcebe5e19a1326bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Tue, 19 Nov 2024 19:22:24 +0900 Subject: [PATCH] doc(types): Document `Assumptions` API (#9746) **Related issue:** - Closes https://github.com/swc-project/swc/issues/9743 --- packages/types/assumptions.ts | 113 ++++++++++++++++++++++++++++++++++ packages/types/index.ts | 9 ++- packages/types/package.json | 2 +- 3 files changed, 120 insertions(+), 4 deletions(-) create mode 100644 packages/types/assumptions.ts diff --git a/packages/types/assumptions.ts b/packages/types/assumptions.ts new file mode 100644 index 000000000000..880f969da559 --- /dev/null +++ b/packages/types/assumptions.ts @@ -0,0 +1,113 @@ +export interface Assumptions { + /** + * https://babeljs.io/docs/en/assumptions#arraylikeisiterable + */ + arrayLikeIsIterable?: boolean; + + /** + * https://babeljs.io/docs/en/assumptions#constantreexports + */ + constantReexports?: boolean; + + /** + * https://babeljs.io/docs/en/assumptions#constantsuper + */ + constantSuper?: boolean; + + /** + * https://babeljs.io/docs/en/assumptions#enumerablemodulemeta + */ + enumerableModuleMeta?: boolean; + + /** + * https://babeljs.io/docs/en/assumptions#ignorefunctionlength + */ + ignoreFunctionLength?: boolean; + + ignoreFunctionName?: boolean; + + /** + * https://babeljs.io/docs/en/assumptions#ignoretoprimitivehint + */ + ignoreToPrimitiveHint?: boolean; + + /** + * https://babeljs.io/docs/en/assumptions#iterableisarray + */ + iterableIsArray?: boolean; + + /** + * https://babeljs.io/docs/en/assumptions#mutabletemplateobject + */ + mutableTemplateObject?: boolean; + + /** + * https://babeljs.io/docs/en/assumptions#noclasscalls + */ + noClassCalls?: boolean; + + /** + * https://babeljs.io/docs/en/assumptions#nodocumentall + */ + noDocumentAll?: boolean; + + /** + * https://babeljs.io/docs/en/assumptions#noincompletensimportdetection + */ + noIncompleteNsImportDetection?: boolean; + + /** + * https://babeljs.io/docs/en/assumptions#nonewarrows + */ + noNewArrows?: boolean; + + /** + * https://babeljs.io/docs/en/assumptions#objectrestnosymbols + */ + objectRestNoSymbols?: boolean; + + /** + * https://babeljs.io/docs/en/assumptions#privatefieldsasproperties + */ + privateFieldsAsProperties?: boolean; + + /** + * https://babeljs.io/docs/en/assumptions#puregetters + */ + pureGetters?: boolean; + + /** + * https://babeljs.io/docs/en/assumptions#setclassmethods + */ + setClassMethods?: boolean; + + /** + * https://babeljs.io/docs/en/assumptions#setcomputedproperties + */ + setComputedProperties?: boolean; + + /** + * https://babeljs.io/docs/en/assumptions#setpublicclassfields + */ + setPublicClassFields?: boolean; + + /** + * https://babeljs.io/docs/en/assumptions#setspreadproperties + */ + setSpreadProperties?: boolean; + + /** + * https://babeljs.io/docs/en/assumptions#skipforofiteratorclosing + */ + skipForOfIteratorClosing?: boolean; + + /** + * https://babeljs.io/docs/en/assumptions#superiscallableconstructor + */ + superIsCallableConstructor?: boolean; + + /** + * @deprecated This value will be always true + */ + tsEnumIsReadonly?: boolean; +} diff --git a/packages/types/index.ts b/packages/types/index.ts index 7d3d7cacd9cd..01f4f66c39fb 100644 --- a/packages/types/index.ts +++ b/packages/types/index.ts @@ -1,3 +1,5 @@ +import { Assumptions } from "./assumptions"; + export interface Plugin { (module: Program): Program; } @@ -349,7 +351,7 @@ export interface TerserMangleOptions { reserved?: string[]; } -export interface TerserManglePropertiesOptions { } +export interface TerserManglePropertiesOptions {} /** * Programmatic options. @@ -608,6 +610,7 @@ export interface EnvConfig { } export interface JscConfig { + assumptions?: Assumptions; loose?: boolean; /** @@ -1175,7 +1178,7 @@ export interface Output { map?: string; } -export interface MatchPattern { } +export interface MatchPattern {} // ------------------------------- // ---------- Ast nodes ---------- @@ -1407,7 +1410,7 @@ export type Expression = | OptionalChainingExpression | Invalid; -interface ExpressionBase extends Node, HasSpan { } +interface ExpressionBase extends Node, HasSpan {} export interface Identifier extends ExpressionBase { type: "Identifier"; diff --git a/packages/types/package.json b/packages/types/package.json index fc1a0ab9c80f..68ad287e34a0 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,7 +1,7 @@ { "name": "@swc/types", "packageManager": "yarn@4.0.2", - "version": "0.1.15", + "version": "0.1.16", "description": "Typings for the swc project.", "sideEffects": false, "scripts": {