feature-toggle-api 3.4.1 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +115 -96
- package/dist/feature-toggle.d.ts +120 -0
- package/dist/feature-toggle.js +388 -0
- package/dist/feature-toggle.min.cjs +2 -0
- package/dist/feature-toggle.min.cjs.map +1 -0
- package/dist/feature-toggle.min.js +2 -0
- package/dist/feature-toggle.min.js.map +1 -0
- package/dist/feature-toggle.umd.min.js +2 -0
- package/dist/feature-toggle.umd.min.js.map +1 -0
- package/dist/html-plugin.umd.min.js +2 -0
- package/dist/html-plugin.umd.min.js.map +1 -0
- package/dist/url-plugin.umd.min.js +2 -0
- package/dist/url-plugin.umd.min.js.map +1 -0
- package/examples/01_basic_esmodule.js +10 -0
- package/examples/02_basic_cjsmodule.cjs +6 -0
- package/examples/{basic.html → 03_basic_scripttag.html} +3 -2
- package/examples/{example-htmlplugin.html → 04_example-htmlplugin.html} +2 -2
- package/examples/{example-urlplugin.html → 05_example-urlplugin.html} +2 -2
- package/examples/{withListener.html → 06_withListener.html} +1 -1
- package/package.json +32 -38
- package/plugin-html.js +1 -1
- package/plugin-url.js +1 -1
- package/rollup.config.js +107 -0
- package/src/{index.js → featureToggle.ts} +172 -51
- package/src/index.ts +10 -0
- package/src/plugins/htmlplugin/{plugin-html.js → plugin-html.ts} +22 -10
- package/src/plugins/urlplugin/{plugin-url.js → plugin-url.ts} +36 -10
- package/tests/featuretoggle.test.ts +407 -0
- package/tests/polyfills.ts +20 -0
- package/tsconfig.cjs.json +12 -0
- package/tsconfig.json +12 -0
- package/feature-toggle-api.js +0 -273
- package/feature-toggle-api.min.js +0 -1
- package/feature-toggle-api.module.js +0 -273
- package/spec/support/index.spec.js +0 -378
- package/spec/support/jasmine.json +0 -11
- package/spec/support/polyfills.js +0 -6
- package/src/index.cjs.js +0 -8
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
import { describe, it, } from "node:test";
|
|
2
|
+
import assert from "node:assert";
|
|
3
|
+
import {useWindowMock} from './polyfills';
|
|
4
|
+
import { useFeatureToggle, urlPlugin } from '../src/';
|
|
5
|
+
|
|
6
|
+
describe("Initialisation / Basic Tests", function() {
|
|
7
|
+
it("should return a function", function() {
|
|
8
|
+
const type = typeof useFeatureToggle;
|
|
9
|
+
assert.strictEqual(type,'function');
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it("should return 'feature-toggle-api' for property name", function() {
|
|
13
|
+
const api = useFeatureToggle();
|
|
14
|
+
assert.strictEqual(api.name,'feature-toggle-api');
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("should return true if feature is initialized in constructor", function() {
|
|
18
|
+
const api = useFeatureToggle({ feature: true });
|
|
19
|
+
assert.strictEqual(api.isActive('feature'),true);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("should return true if feature with variant is initialized in constructor", function() {
|
|
23
|
+
const api = useFeatureToggle({ "feature#variant": true });
|
|
24
|
+
assert.strictEqual(api.isActive('feature','variant'),true);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("should return true if feature with variant is initialized in constructor with function", function() {
|
|
28
|
+
const api = useFeatureToggle({ "feature#variant": true });
|
|
29
|
+
assert.strictEqual(api.isActive('feature','variant'),true);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
describe("Basic visibility of features", function() {
|
|
34
|
+
const api = useFeatureToggle();
|
|
35
|
+
|
|
36
|
+
it("should return true if parameter is boolean with legacy fn isVisible", function() {
|
|
37
|
+
api.setFlag('featurebool', true);
|
|
38
|
+
const visibility = api.isVisible('featurebool');
|
|
39
|
+
assert.strictEqual(visibility,true);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("should return true if parameter is boolean", function() {
|
|
43
|
+
api.setFlag('featurebool', true);
|
|
44
|
+
const visibility = api.isActive('featurebool');
|
|
45
|
+
assert.strictEqual(visibility,true);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("should ignore case for the api-keys", function() {
|
|
49
|
+
api.setFlag('ignoreCase', true);
|
|
50
|
+
const visibility1 = api.isActive('ignorecase');
|
|
51
|
+
const visibility2 = api.isActive('iGNOrEcaSe');
|
|
52
|
+
assert.strictEqual(visibility1,true);
|
|
53
|
+
assert.strictEqual(visibility2,true);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("should return true if parameter is function", function() {
|
|
57
|
+
api.setFlag('featurebool', function() { return true });
|
|
58
|
+
const visibility = api.isActive('featurebool');
|
|
59
|
+
assert.strictEqual(visibility,true);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("should return true if feature is true", function() {
|
|
63
|
+
api.setFlag('featureTrue', true);
|
|
64
|
+
const visibility = api.isActive('featureTrue');
|
|
65
|
+
assert.strictEqual(visibility,true);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it("should return false if feature is false", function() {
|
|
69
|
+
api.setFlag('featureFalse', false);
|
|
70
|
+
const visibility = api.isActive('featureFalse');
|
|
71
|
+
assert.strictEqual(visibility,false);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("should return false if feature does not exist", function() {
|
|
75
|
+
const visibility = api.isActive('featureNotExists');
|
|
76
|
+
assert.strictEqual(visibility,false);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("should return true if feature with variant is true", function() {
|
|
80
|
+
api.setFlag('featureTrue', 'variant', true);
|
|
81
|
+
const visibility = api.isActive('featureTrue', 'variant');
|
|
82
|
+
assert.strictEqual(visibility,true);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it("should return false if feature with variant is false", function() {
|
|
86
|
+
api.setFlag('featureFalse', 'variant', false);
|
|
87
|
+
const visibility = api.isActive('featureFalse', 'variant');
|
|
88
|
+
assert.strictEqual(visibility,false);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it("should return false if feature with variant does not exist", function() {
|
|
92
|
+
const visibility = api.isActive('featureNotExists', 'variant', false);
|
|
93
|
+
assert.strictEqual(visibility,false);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it("should return true if feature with variant is requested but only featurerule exists", function() {
|
|
97
|
+
api.setFlag('featureTrue', true);
|
|
98
|
+
const visibility = api.isActive('featureTrue', 'variant');
|
|
99
|
+
assert.strictEqual(visibility,true);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("should return false if data returns false", function() {
|
|
103
|
+
api.setFlag('featureFalse', 'variant', function(rule) { return rule.data == 'succeed' });
|
|
104
|
+
const visibility = api.isActive('featureFalse', 'variant', 'fail');
|
|
105
|
+
assert.strictEqual(visibility,false);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it("should return false if data returns true", function() {
|
|
109
|
+
api.setFlag('featureFalse', 'variant', function(rule) { return rule.data == 'succeed' });
|
|
110
|
+
const visibility = api.isActive('featureFalse', 'variant', 'succeed');
|
|
111
|
+
assert.strictEqual(visibility,true);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it("should pass correct parameters for visibilityrule", function() {
|
|
115
|
+
api.setFlag('featureFalse2', 'variant', function(rule) {
|
|
116
|
+
if (rule._internalCall)
|
|
117
|
+
return;
|
|
118
|
+
assert.strictEqual(rule.name,'featureFalse2');
|
|
119
|
+
assert.strictEqual(rule.variant,'variant');
|
|
120
|
+
assert.strictEqual(rule.data,'succeed');
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
api.isActive('featureFalse2', 'variant', 'succeed');
|
|
124
|
+
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
describe("Default Visibility", function() {
|
|
129
|
+
const api = useFeatureToggle();
|
|
130
|
+
api.setDefaultFlag((result) => {
|
|
131
|
+
return true;
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it("should return true with legacy function-call defaultFlagif feature does not exist", function() {
|
|
135
|
+
const legacyApi = useFeatureToggle();
|
|
136
|
+
legacyApi.defaultVisibility((result) => {
|
|
137
|
+
return true;
|
|
138
|
+
});
|
|
139
|
+
const visibility = legacyApi.isActive('featureNotExists');
|
|
140
|
+
assert.strictEqual(visibility,true);
|
|
141
|
+
});
|
|
142
|
+
it("should return true if feature does not exist", function() {
|
|
143
|
+
const visibility = api.isActive('featureNotExists');
|
|
144
|
+
assert.strictEqual(visibility,true);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it("should return true if feature withVariant does not exist", function() {
|
|
148
|
+
const visibility = api.isActive('featureNotExists', 'variant');
|
|
149
|
+
assert.strictEqual(visibility,true);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it("should return false if feature is False", function() {
|
|
153
|
+
api.setFlag('featureFalse', false);
|
|
154
|
+
const visibility = api.isActive('featureFalse');
|
|
155
|
+
assert.strictEqual(visibility,false);
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it("should return false if feature with variant isFalse", function() {
|
|
159
|
+
api.setFlag('featureFalse2', false)
|
|
160
|
+
const visibility = api.isActive('featureFalse2', 'variant', false);
|
|
161
|
+
assert.strictEqual(visibility,false);
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
describe("Required Flag", function() {
|
|
166
|
+
const api = useFeatureToggle();
|
|
167
|
+
api.setRequiredFlag((result) => {
|
|
168
|
+
return result.variant == "valid";
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
it("should return true with legacy function requiredFlag if required rule matches and visibiltiyrule", function() {
|
|
172
|
+
const legacyApi = useFeatureToggle();
|
|
173
|
+
legacyApi.requiredVisibility((result) => {
|
|
174
|
+
return result.variant == "valid";
|
|
175
|
+
});
|
|
176
|
+
legacyApi.setFlag('featureTrue', true);
|
|
177
|
+
const visibility = legacyApi.isActive('featureTrue', 'valid');
|
|
178
|
+
assert.strictEqual(visibility,true);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it("should return false if feature does not exist and requirerule matches", function() {
|
|
182
|
+
api.setFlag('featureNotExists', 'valid', false);
|
|
183
|
+
const visibility = api.isActive('featureNotExists', 'valid');
|
|
184
|
+
assert.strictEqual(visibility,false);
|
|
185
|
+
});
|
|
186
|
+
it("should return false if feature does not exist and requirerule matches not", function() {
|
|
187
|
+
api.setFlag('featureNotExists', 'invalid', false);
|
|
188
|
+
const visibility = api.isActive('featureNotExists', 'invalid');
|
|
189
|
+
assert.strictEqual(visibility,false);
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
it("should return false if only required rule matches", function() {
|
|
194
|
+
api.setFlag('featureFalse', false);
|
|
195
|
+
const visibility = api.isActive('featureFalse', 'valid');
|
|
196
|
+
assert.strictEqual(visibility,false);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it("should return true if required rule matches and visibiltiyrule", function() {
|
|
200
|
+
api.setFlag('featureTrue', true);
|
|
201
|
+
const visibility = api.isActive('featureTrue', 'valid');
|
|
202
|
+
assert.strictEqual(visibility,true);
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
it("should return false if defaultFlag returns true", function() {
|
|
206
|
+
api.setDefaultFlag((result) => {
|
|
207
|
+
return true;
|
|
208
|
+
});
|
|
209
|
+
const visibility = api.isActive('featureTrue', 'invalid');
|
|
210
|
+
assert.strictEqual(visibility,false);
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
describe("Listener", function() {
|
|
215
|
+
const api = useFeatureToggle({
|
|
216
|
+
feature: true,
|
|
217
|
+
"feature2#variant": true
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
it("should have an event called on('visibilityrule')", function() {
|
|
221
|
+
api.on('visibilityrule', function() {
|
|
222
|
+
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
it("should access function twice for two initial eventnames", function() {
|
|
227
|
+
var listenedEvents : string[] = [];
|
|
228
|
+
|
|
229
|
+
api.on('visibilityrule', function(event) {
|
|
230
|
+
listenedEvents.push(event.name + "," + event.variant + "," + event.result);
|
|
231
|
+
})
|
|
232
|
+
|
|
233
|
+
assert.strictEqual(JSON.stringify(listenedEvents),JSON.stringify(['feature,undefined,true', 'feature2,variant,true']));
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
it("should access function twice if visibilityrule is added before listener", function() {
|
|
237
|
+
var listenedEvents :string[]= [];
|
|
238
|
+
var localapi = useFeatureToggle({ feature: true });
|
|
239
|
+
localapi.setFlag("feature2", "variant", true);
|
|
240
|
+
localapi.on('visibilityrule', function(event) {
|
|
241
|
+
listenedEvents.push(event.name + "," + event.variant + "," + event.result);
|
|
242
|
+
})
|
|
243
|
+
|
|
244
|
+
assert.strictEqual(JSON.stringify(listenedEvents),JSON.stringify(['feature,undefined,true', 'feature2,variant,true']));
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
it("should access function twice if visibilityrule is added after listener", function() {
|
|
248
|
+
var listenedEvents :string[]= [];
|
|
249
|
+
var localapi = useFeatureToggle({ feature: true });
|
|
250
|
+
localapi.on('visibilityrule', function(event) {
|
|
251
|
+
listenedEvents.push(event.name + "," + event.variant + "," + event.result);
|
|
252
|
+
});
|
|
253
|
+
localapi.setFlag("feature2", "variant", true);
|
|
254
|
+
|
|
255
|
+
assert.strictEqual(JSON.stringify(listenedEvents),JSON.stringify(['feature,undefined,true', 'feature2,variant,true']));
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
it("should pass parameters as an object with result,name,variant,data", function() {
|
|
259
|
+
var api = useFeatureToggle();
|
|
260
|
+
api.setFlag('feature', 'variant', 'gruempfel', function(rule) {
|
|
261
|
+
return (rule.data + rule.name + rule.variant) == 'gruempfelfeaturevariant';
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
api.on('visibilityrule', function(event) {
|
|
265
|
+
assert.strictEqual(event.result,true);
|
|
266
|
+
assert.strictEqual(event.name,"feature");
|
|
267
|
+
assert.strictEqual(event.variant,"variant");
|
|
268
|
+
assert.strictEqual(event.data,"gruempfel");
|
|
269
|
+
})
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
it("should be executed, when data has changed", function() {
|
|
273
|
+
var api = useFeatureToggle();
|
|
274
|
+
var totalData = '';
|
|
275
|
+
|
|
276
|
+
api.on('visibilityrule', function(event) {
|
|
277
|
+
totalData += event.data + ',';
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
api.setFlag('feature', 'variant', 'gruempfel', true);
|
|
281
|
+
api.setData('feature', 'variant', 'newgruempfel');
|
|
282
|
+
api.setFlag('feature2', null, 'gruempfel2', true);
|
|
283
|
+
api.setData('feature2', 'newgruempfel2');
|
|
284
|
+
assert.strictEqual(totalData,'gruempfel,newgruempfel,gruempfel2,newgruempfel2,');
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
it("should trigger a custom defined event", function() {
|
|
288
|
+
var api = useFeatureToggle();
|
|
289
|
+
|
|
290
|
+
let customEvent :any= false;
|
|
291
|
+
api.on('customevent', function(param) {
|
|
292
|
+
customEvent = param;
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
api.trigger('customevent', 'fired');
|
|
296
|
+
assert.strictEqual(customEvent,'fired');
|
|
297
|
+
});
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
describe("Plugins", function() {
|
|
301
|
+
|
|
302
|
+
it("function addPlugin should exist", function() {
|
|
303
|
+
var api = useFeatureToggle();
|
|
304
|
+
|
|
305
|
+
assert.notStrictEqual(api.addPlugin,null);
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
it("should be possible with legacy-key _plugins", function() {
|
|
309
|
+
function newPlugin(api) {
|
|
310
|
+
api.newplugin = true;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
var api = useFeatureToggle({
|
|
314
|
+
_plugins:[newPlugin]
|
|
315
|
+
});
|
|
316
|
+
assert.strictEqual(api.newplugin,true);
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
it("should add attribute 'newplugin' to the api", function() {
|
|
320
|
+
function newPlugin(api) {
|
|
321
|
+
api.newplugin = true;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
var api = useFeatureToggle();
|
|
325
|
+
api.addPlugin(newPlugin);
|
|
326
|
+
assert.strictEqual(api.newplugin,true);
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
it("should add plugins via attribute constructor config", function() {
|
|
330
|
+
function newPlugin(api) {
|
|
331
|
+
api.newplugin = true;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
var api = useFeatureToggle({ $plugins: [newPlugin] });
|
|
335
|
+
|
|
336
|
+
assert.strictEqual(api.newplugin,true);
|
|
337
|
+
assert.strictEqual(api.isActive('_plugin'),false);
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
it("should only be executed once", function() {
|
|
341
|
+
var api = useFeatureToggle();
|
|
342
|
+
api.count = 0;
|
|
343
|
+
|
|
344
|
+
function countPlugin(api) {
|
|
345
|
+
api.count += 1;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
api.addPlugin(countPlugin);
|
|
349
|
+
api.addPlugin(countPlugin);
|
|
350
|
+
assert.strictEqual(api.count,1);
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
it("should trigger the init-event", function() {
|
|
354
|
+
function newPlugin(api) {
|
|
355
|
+
api.on('init', function() {
|
|
356
|
+
api.initTriggered = true;
|
|
357
|
+
})
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
var api = useFeatureToggle({ $plugins: [newPlugin] });
|
|
361
|
+
assert.strictEqual(api.initTriggered,true);
|
|
362
|
+
});
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
describe("URL-Plugin", function() {
|
|
366
|
+
it("should return empty string for url", function() {
|
|
367
|
+
var api = useFeatureToggle({
|
|
368
|
+
$plugins: [urlPlugin({ useMockedWindow:true})]
|
|
369
|
+
});
|
|
370
|
+
assert.strictEqual(api.url,"");
|
|
371
|
+
})
|
|
372
|
+
it("should have api.url = anydomain.de if set in pluginconfig", function() {
|
|
373
|
+
var api = useFeatureToggle({
|
|
374
|
+
$plugins: [urlPlugin({
|
|
375
|
+
url: "http://anydomain.de",
|
|
376
|
+
useMockedWindow:true
|
|
377
|
+
})]
|
|
378
|
+
});
|
|
379
|
+
assert.strictEqual(api.url,"http://anydomain.de");
|
|
380
|
+
})
|
|
381
|
+
it("should have feature1 visible if param feature1=true exists", function() {
|
|
382
|
+
var api = useFeatureToggle({
|
|
383
|
+
$plugins: [urlPlugin({ url: 'anydomain.de?feature1=true', useMockedWindow:true })]
|
|
384
|
+
});
|
|
385
|
+
const visibilityF1 = api.isActive("feature1");
|
|
386
|
+
const visibilityF2 = api.isActive("feature2");
|
|
387
|
+
assert.strictEqual(visibilityF1,true);
|
|
388
|
+
assert.strictEqual(visibilityF2,false);
|
|
389
|
+
})
|
|
390
|
+
it("should only regard params with prefix", function() {
|
|
391
|
+
var api = useFeatureToggle({
|
|
392
|
+
$plugins: [urlPlugin({
|
|
393
|
+
url: 'anydomain.de?feature1=true&_feature2=true',
|
|
394
|
+
prefix: '_',
|
|
395
|
+
useMockedWindow:true
|
|
396
|
+
})]
|
|
397
|
+
});
|
|
398
|
+
const visibilityF1 = api.isActive("feature1");
|
|
399
|
+
const visibilityF2 = api.isActive("feature2");
|
|
400
|
+
const visibility_F1 = api.isActive("_feature1");
|
|
401
|
+
const visibility_F2 = api.isActive("_feature2");
|
|
402
|
+
assert.strictEqual(visibilityF1,false);
|
|
403
|
+
assert.strictEqual(visibilityF2,true);
|
|
404
|
+
assert.strictEqual(visibility_F1,false);
|
|
405
|
+
assert.strictEqual(visibility_F2,false);
|
|
406
|
+
})
|
|
407
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const window = {
|
|
2
|
+
isMocked: true,
|
|
3
|
+
decodeURIComponent:function(param1){
|
|
4
|
+
return param1;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function useWindowMock(){
|
|
9
|
+
return {
|
|
10
|
+
isMocked: true,
|
|
11
|
+
decodeURIComponent:function(param1){
|
|
12
|
+
return param1;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export {
|
|
18
|
+
window,
|
|
19
|
+
useWindowMock
|
|
20
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"emitDeclarationOnly": false, // Nur Deklarationen ausgeben (false, damit auch JS kompiliert wird)
|
|
4
|
+
"outDir": "dist", // Ausgabeort für die Typen
|
|
5
|
+
"module": "ESNext", // Oder das Modulformat deiner Wahl
|
|
6
|
+
"target": "ESNext",
|
|
7
|
+
"moduleResolution": "node"
|
|
8
|
+
},
|
|
9
|
+
"include": ["src/**/*.ts"], // Eingeschlossene Dateien
|
|
10
|
+
"exclude": ["node_modules"] ,
|
|
11
|
+
|
|
12
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"emitDeclarationOnly": false, // Nur Deklarationen ausgeben (false, damit auch JS kompiliert wird)
|
|
4
|
+
"outDir": "dist", // Ausgabeort für die Typen
|
|
5
|
+
"module": "ESNext", // Oder das Modulformat deiner Wahl
|
|
6
|
+
"target": "ESNext",
|
|
7
|
+
"moduleResolution": "bundler"
|
|
8
|
+
},
|
|
9
|
+
"include": ["src/**/*.ts"], // Eingeschlossene Dateien
|
|
10
|
+
"exclude": ["node_modules"] ,
|
|
11
|
+
|
|
12
|
+
}
|