Skip to content

Commit cd4321c

Browse files
authoredNov 19, 2024··
doc(types): Document Assumptions API (#9746)
**Related issue:** - Closes #9743
1 parent 35b0ca0 commit cd4321c

File tree

3 files changed

+120
-4
lines changed

3 files changed

+120
-4
lines changed
 

‎packages/types/assumptions.ts

+113
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
export interface Assumptions {
2+
/**
3+
* https://babeljs.io/docs/en/assumptions#arraylikeisiterable
4+
*/
5+
arrayLikeIsIterable?: boolean;
6+
7+
/**
8+
* https://babeljs.io/docs/en/assumptions#constantreexports
9+
*/
10+
constantReexports?: boolean;
11+
12+
/**
13+
* https://babeljs.io/docs/en/assumptions#constantsuper
14+
*/
15+
constantSuper?: boolean;
16+
17+
/**
18+
* https://babeljs.io/docs/en/assumptions#enumerablemodulemeta
19+
*/
20+
enumerableModuleMeta?: boolean;
21+
22+
/**
23+
* https://babeljs.io/docs/en/assumptions#ignorefunctionlength
24+
*/
25+
ignoreFunctionLength?: boolean;
26+
27+
ignoreFunctionName?: boolean;
28+
29+
/**
30+
* https://babeljs.io/docs/en/assumptions#ignoretoprimitivehint
31+
*/
32+
ignoreToPrimitiveHint?: boolean;
33+
34+
/**
35+
* https://babeljs.io/docs/en/assumptions#iterableisarray
36+
*/
37+
iterableIsArray?: boolean;
38+
39+
/**
40+
* https://babeljs.io/docs/en/assumptions#mutabletemplateobject
41+
*/
42+
mutableTemplateObject?: boolean;
43+
44+
/**
45+
* https://babeljs.io/docs/en/assumptions#noclasscalls
46+
*/
47+
noClassCalls?: boolean;
48+
49+
/**
50+
* https://babeljs.io/docs/en/assumptions#nodocumentall
51+
*/
52+
noDocumentAll?: boolean;
53+
54+
/**
55+
* https://babeljs.io/docs/en/assumptions#noincompletensimportdetection
56+
*/
57+
noIncompleteNsImportDetection?: boolean;
58+
59+
/**
60+
* https://babeljs.io/docs/en/assumptions#nonewarrows
61+
*/
62+
noNewArrows?: boolean;
63+
64+
/**
65+
* https://babeljs.io/docs/en/assumptions#objectrestnosymbols
66+
*/
67+
objectRestNoSymbols?: boolean;
68+
69+
/**
70+
* https://babeljs.io/docs/en/assumptions#privatefieldsasproperties
71+
*/
72+
privateFieldsAsProperties?: boolean;
73+
74+
/**
75+
* https://babeljs.io/docs/en/assumptions#puregetters
76+
*/
77+
pureGetters?: boolean;
78+
79+
/**
80+
* https://babeljs.io/docs/en/assumptions#setclassmethods
81+
*/
82+
setClassMethods?: boolean;
83+
84+
/**
85+
* https://babeljs.io/docs/en/assumptions#setcomputedproperties
86+
*/
87+
setComputedProperties?: boolean;
88+
89+
/**
90+
* https://babeljs.io/docs/en/assumptions#setpublicclassfields
91+
*/
92+
setPublicClassFields?: boolean;
93+
94+
/**
95+
* https://babeljs.io/docs/en/assumptions#setspreadproperties
96+
*/
97+
setSpreadProperties?: boolean;
98+
99+
/**
100+
* https://babeljs.io/docs/en/assumptions#skipforofiteratorclosing
101+
*/
102+
skipForOfIteratorClosing?: boolean;
103+
104+
/**
105+
* https://babeljs.io/docs/en/assumptions#superiscallableconstructor
106+
*/
107+
superIsCallableConstructor?: boolean;
108+
109+
/**
110+
* @deprecated This value will be always true
111+
*/
112+
tsEnumIsReadonly?: boolean;
113+
}

‎packages/types/index.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { Assumptions } from "./assumptions";
2+
13
export interface Plugin {
24
(module: Program): Program;
35
}
@@ -349,7 +351,7 @@ export interface TerserMangleOptions {
349351
reserved?: string[];
350352
}
351353

352-
export interface TerserManglePropertiesOptions { }
354+
export interface TerserManglePropertiesOptions {}
353355

354356
/**
355357
* Programmatic options.
@@ -608,6 +610,7 @@ export interface EnvConfig {
608610
}
609611

610612
export interface JscConfig {
613+
assumptions?: Assumptions;
611614
loose?: boolean;
612615

613616
/**
@@ -1175,7 +1178,7 @@ export interface Output {
11751178
map?: string;
11761179
}
11771180

1178-
export interface MatchPattern { }
1181+
export interface MatchPattern {}
11791182

11801183
// -------------------------------
11811184
// ---------- Ast nodes ----------
@@ -1407,7 +1410,7 @@ export type Expression =
14071410
| OptionalChainingExpression
14081411
| Invalid;
14091412

1410-
interface ExpressionBase extends Node, HasSpan { }
1413+
interface ExpressionBase extends Node, HasSpan {}
14111414

14121415
export interface Identifier extends ExpressionBase {
14131416
type: "Identifier";

‎packages/types/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@swc/types",
33
"packageManager": "yarn@4.0.2",
4-
"version": "0.1.15",
4+
"version": "0.1.16",
55
"description": "Typings for the swc project.",
66
"sideEffects": false,
77
"scripts": {

0 commit comments

Comments
 (0)
Please sign in to comment.