Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into ClassStatementsGetter…
Browse files Browse the repository at this point in the history
…-rewrite
  • Loading branch information
ajvincent committed Apr 4, 2024
2 parents 13d11a1 + 8c97e22 commit 996eaf9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
13 changes: 12 additions & 1 deletion docs/use-cases/TwoKeyedMap.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,23 @@ if (method.name === "keys") {
LiteralTypeStructureImpl.get("string"),
LiteralTypeStructureImpl.get("string"),
]);
continue;
}
```

Note I probably could've gotten away with replacing the `K` with `{ firstKey: string, secondKey: string }`.

### Other iterator methods

### Methods taking arguments
These already specify `IterableIterator<[K, V]>`. I want `IterableIterator<[string, string, V]>`. I think, from the keys example above, the solution for this should be obvious.

The `values` method I don't need to adjust at all: `IterableIterator<V>`.

### The `forEach` method

Here the adjustments are to the _arguments_ of `forEach` - and they're a little deeper for the first argument, which is a callback function. So we'll be dealing with the `parameters` array property of the method signature.

### Other methods taking arguments

## Creating the existing class structure

Expand Down
16 changes: 16 additions & 0 deletions use-cases/build/StringStringMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,23 @@ export default class StringStringMap<V> {
LiteralTypeStructureImpl.get("string"),
LiteralTypeStructureImpl.get("string"),
]);
continue;
}

if ((method.name === "entries") || (method.name === "[Symbol.iterator]")) {
const { returnTypeStructure } = method;
assert.equal(returnTypeStructure?.kind, TypeStructureKind.TypeArgumented, "Expected a type-argumented type.");
assert.equal(returnTypeStructure.objectType, LiteralTypeStructureImpl.get("IterableIterator"), "Expected an IterableIterator");
assert.equal(returnTypeStructure.childTypes.length, 1);

assert.equal(returnTypeStructure.childTypes[0].kind, TypeStructureKind.Tuple);
returnTypeStructure.childTypes[0].childTypes.splice(
0, 1, LiteralTypeStructureImpl.get("string"), LiteralTypeStructureImpl.get("string")
);
continue;
}


}
}

Expand Down

0 comments on commit 996eaf9

Please sign in to comment.