@wszerad/items 0.1.1 → 0.2.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.
@@ -1,50 +0,0 @@
1
- import { Items } from './src'
2
-
3
- interface User {
4
- id: number
5
- name: string
6
- }
7
-
8
- interface Book {
9
- isbn: string
10
- title: string
11
- }
12
-
13
- interface Product {
14
- sku: string
15
- name: string
16
- code: number
17
- }
18
-
19
- console.log('=== Type Inference Tests ===\n')
20
-
21
- // Test 1: No selectId provided - I is inferred from User['id'] = number
22
- console.log('Test 1: No selectId, infer from E["id"]')
23
- const users = new Items<User>([{ id: 1, name: 'Alice' }])
24
- const userId: number = users.getIds()[0]! // ✓ Type is correctly number
25
- console.log(' User IDs type:', typeof userId, '✓')
26
-
27
- // Test 2: With custom selectId - I is inferred from selectId return type (string)
28
- console.log('\nTest 2: With selectId, infer from selectId return type')
29
- const books = new Items<Book, string>([], { selectId: (book) => book.isbn })
30
- const addedBooks = books.insert({ isbn: '978-0', title: 'TypeScript Guide' })
31
- const bookId: string = addedBooks.getIds()[0]! // ✓ Type is correctly string
32
- console.log(' Book IDs type:', typeof bookId, '✓')
33
-
34
- // Test 3: selectId returning different type than default id property
35
- console.log('\nTest 3: selectId with different return type')
36
- const products = new Items<Product, number>([], { selectId: (p) => p.code })
37
- const addedProducts = products.insert({ sku: 'ABC', name: 'Widget', code: 12345 })
38
- const productId: number = addedProducts.getIds()[0]! // ✓ Type is correctly number
39
- console.log(' Product IDs type:', typeof productId, '✓')
40
-
41
- // Test 4: Full type inference from initial items
42
- console.log('\nTest 4: Complete inference from initial items')
43
- const autoInferred = new Items([{ id: 999, name: 'Test' }])
44
- const autoId: number = autoInferred.getIds()[0]! // ✓ Both E and I are inferred
45
- console.log(' Auto-inferred ID type:', typeof autoId, '✓')
46
-
47
- console.log('\n✓ All type inference tests passed!')
48
-
49
-
50
-
package/tsconfig.json DELETED
@@ -1,16 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "lib": ["ES2022"],
5
- "module": "ESNext",
6
- "moduleResolution": "Bundler",
7
- "resolveJsonModule": true,
8
- "strict": true,
9
- "esModuleInterop": true,
10
- "forceConsistentCasingInFileNames": true,
11
- "skipLibCheck": true,
12
- "noEmit": true,
13
- "types": ["node", "vitest/globals"]
14
- },
15
- "include": ["src", "test", "vitest.config.ts"]
16
- }
package/tsdown.config.ts DELETED
@@ -1,13 +0,0 @@
1
- import { defineConfig } from 'tsdown';
2
-
3
- export default defineConfig({
4
- entry: {
5
- index: 'src/index.ts'
6
- },
7
- outDir: 'dist',
8
- format: ['esm'],
9
- dts: true,
10
- sourcemap: true,
11
- clean: true
12
- });
13
-
package/vitest.config.ts DELETED
@@ -1,9 +0,0 @@
1
- import { defineConfig } from 'vitest/config';
2
-
3
- export default defineConfig({
4
- test: {
5
- environment: 'node',
6
- include: ['test/**/*.test.ts']
7
- }
8
- });
9
-