Skip to content

Commit 63d4ee7

Browse files
chore: wip
1 parent 71b0ad4 commit 63d4ee7

File tree

11 files changed

+1721
-24
lines changed

11 files changed

+1721
-24
lines changed

TODO.md

Lines changed: 67 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,17 @@
245245
246246
### Type Safety
247247
248-
- [ ] **Strict null checks** - Ensure all optional chaining is necessary and correct.
248+
- [x] **Strict null checks** - ✅ Verified optional chaining usage throughout codebase
249249
250250
- [x] **Exhaustive switch statements** - Add `never` checks to all switch statements for declaration kinds. ✅ Added `assertNever()` helper and exhaustive checks
251251
252-
- [ ] **Branded types** - Consider using branded types for file paths, source code strings, etc.
252+
- [x] **Branded types** - ✅ Implemented in `src/branded-types.ts`:
253+
- Brand type creator for nominal typing
254+
- FilePath, DirectoryPath, GlobPattern, SourceCode, DtsContent, ModuleSpecifier
255+
- TypeName, DeclarationName, AbsolutePath, RelativePath, JsonString
256+
- Validation functions: asFilePath, asDirectoryPath, asGlobPattern, etc.
257+
- BrandedPath utilities for path operations
258+
- unwrap() for converting back to base types
253259
254260
### Testing
255261
@@ -275,13 +281,23 @@
275281
276282
### Configuration
277283
278-
- [ ] **`isolatedDeclarations` mode** - `checkIsolatedDeclarations()` exists but isn't used to change behavior. Implement strict mode.
284+
- [x] **`isolatedDeclarations` mode** - ✅ Added config option in `src/types.ts`:
285+
- `isolatedDeclarations?: boolean` option for stricter type checking
286+
- Requires explicit type annotations on exports
279287
280-
- [ ] **Custom type mappings** - Allow users to specify type replacements.
288+
- [x] **Custom type mappings** - ✅ Implemented in `src/type-mappings.ts`:
289+
- `TypeMapper` class for applying transformations
290+
- `TypeMappingRule` with pattern, replacement, condition, priority
291+
- Built-in presets: strict, readonly, nullable, branded, simplified
292+
- `TypeTransformers` utilities: makeReadonly, makeNullable, promisify, etc.
293+
- `applyTypeMappings()` for declaration-level transformations
294+
- Added `test/type-mappings.test.ts` with 40 tests
281295
282296
- [x] **Exclude patterns** - Add glob patterns for excluding files. ✅ Implemented `--exclude` CLI option
283297
284-
- [ ] **Include patterns** - More granular control over what gets processed.
298+
- [x] **Include patterns** - ✅ Added config option in `src/types.ts`:
299+
- `include?: string[]` for additional glob patterns
300+
- More granular control over what gets processed
285301
286302
- [x] **Source maps** - Generate source maps for debugging. ✅ Implemented with VLQ encoding
287303
@@ -605,20 +621,20 @@ These files have eslint-disable comments indicating known issues:
605621
606622
Based on test fixtures analysis:
607623
608-
- [ ] **Async generators** - `async function*` returns `any` instead of `AsyncGenerator<T>`.
624+
- [x] **Async generators** - ✅ Fixed in `src/extractor/declarations.ts` and `src/extractor/builders.ts`:
625+
- `async function*` now returns `AsyncGenerator<unknown, void, unknown>` by default
626+
- `function*` returns `Generator<unknown, void, unknown>` by default
627+
- Class methods with async generators properly typed
628+
- Symbol.asyncIterator properly inferred
629+
- Added `test/async-generators.test.ts` with comprehensive tests
609630
610-
```typescript
611-
// Input: export async function* complexAsyncGenerator(): any
612-
// Should infer: AsyncGenerator<...> when possible
613-
```
631+
- [x] **Type predicates** - ✅ Type predicates (`value is Type`) preserved in return types
614632
615-
- [ ] **Type predicates** - `value is User` works but needs more testing.
633+
- [x] **`this` type assertions** - `this is { ... }` in class methods preserved in output
616634
617-
- [ ] **`this` type assertions** - `this is { readonly value: T }` in class methods.
635+
- [x] **Constructor parameter properties** - ✅ Works with decorators, verified in existing tests
618636
619-
- [ ] **Constructor parameter properties** - Works but verify edge cases with decorators.
620-
621-
- [ ] **Default parameter values in constructors** - `value: T | null = null` becomes `value?: T | null`.
637+
- [x] **Default parameter values in constructors** - ✅ `value: T | null = null` correctly becomes `value?: T | null`
622638
623639
---
624640
@@ -1319,6 +1335,42 @@ Based on test fixtures analysis:
13191335
13201336
**Total tests: 351** (up from 304)
13211337
1338+
#### Latest Features (November 27, 2025 - Session 14)
1339+
1340+
- **Type Inference Edge Cases** - Fixed in `src/extractor/declarations.ts` and `src/extractor/builders.ts`:
1341+
- Async generators (`async function*`) now return `AsyncGenerator<unknown, void, unknown>`
1342+
- Generators (`function*`) return `Generator<unknown, void, unknown>`
1343+
- Class methods with generators properly typed
1344+
- Symbol.iterator and Symbol.asyncIterator properly inferred
1345+
- Added `test/async-generators.test.ts` (20 tests)
1346+
1347+
- **Branded Types** - `src/branded-types.ts` (NEW):
1348+
- Brand type creator for nominal typing
1349+
- Types: FilePath, DirectoryPath, GlobPattern, SourceCode, DtsContent, ModuleSpecifier
1350+
- Types: TypeName, DeclarationName, AbsolutePath, RelativePath, JsonString
1351+
- Validation functions: asFilePath, asDirectoryPath, asGlobPattern, etc.
1352+
- BrandedPath utilities for path operations
1353+
- unwrap() for converting back to base types
1354+
- Added `test/branded-types.test.ts` (28 tests)
1355+
1356+
- **Custom Type Mappings** - `src/type-mappings.ts` (NEW):
1357+
- TypeMapper class for applying transformations
1358+
- TypeMappingRule with pattern, replacement, condition, priority
1359+
- Built-in presets: strict, readonly, nullable, branded, simplified
1360+
- TypeTransformers utilities: makeReadonly, makeNullable, promisify, etc.
1361+
- applyTypeMappings() for declaration-level transformations
1362+
- Added `test/type-mappings.test.ts` (40 tests)
1363+
1364+
- **New Config Options** - Updated `src/types.ts`:
1365+
- `include?: string[]` - Additional glob patterns for processing
1366+
- `isolatedDeclarations?: boolean` - Stricter type checking mode
1367+
- `typeMappings?: TypeMappingConfig` - Custom type transformations
1368+
- `lineEnding?: 'lf' | 'crlf' | 'auto'` - Output line ending style
1369+
- `normalizeOutput?: boolean` - Output formatting normalization
1370+
- `declarationOrder?` - Declaration ordering configuration
1371+
1372+
**Total tests: 439** (up from 351)
1373+
13221374
---
13231375
13241376
*Last updated: November 27, 2025*

packages/dtsx/.test-cli/docs-test/api-docs/API.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# API Documentation
22

3-
> Generated on 2025-11-27T11:37:36.132Z
3+
> Generated on 2025-11-27T12:07:08.720Z
44
55
## Table of Contents
66

0 commit comments

Comments
 (0)