Skip to content

Commit c46cc67

Browse files
authored
Fix missing not nil constraint for pairs keys (#74)
* Fix missing not nil constraint * Fix test build error due to type naming collision * Prettier
1 parent 1cc159b commit c46cc67

File tree

7 files changed

+264
-2
lines changed

7 files changed

+264
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules
22
.vscode
33
*.log
4+
*.js

core/global.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ declare function next(table: object, index?: any): LuaMultiReturn<[any, any] | [
164164
* See function next for the caveats of modifying the table during its
165165
* traversal.
166166
*/
167-
declare function pairs<TKey, TValue>(
167+
declare function pairs<TKey extends AnyNotNil, TValue>(
168168
t: LuaTable<TKey, TValue>
169169
): LuaIterable<LuaMultiReturn<[TKey, NonNullable<TValue>]>>;
170170
declare function pairs<T>(t: T): LuaIterable<LuaMultiReturn<[keyof T, NonNullable<T[keyof T]>]>>;

test/testproject/main.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/// <reference path="../../5.4.d.ts" />
2+
const mytable = new LuaMap<string, number>();
3+
4+
for (const [k, v] of pairs(mytable)) {
5+
}

test/testproject/package-lock.json

Lines changed: 242 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/testproject/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"devDependencies": {
3+
"typescript": "~4.8.2",
4+
"typescript-to-lua": "~1.9.0"
5+
}
6+
}

test/testproject/tsconfig.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"compilerOptions": {
3+
"strict": true,
4+
"target": "esnext",
5+
"types": ["typescript-to-lua/language-extensions"]
6+
}
7+
}

test/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"compilerOptions": {
3+
"rootDir": ".",
34
"types": ["node", "jest"]
45
},
5-
"include": ["."]
6+
"include": ["./*.ts"]
67
}

0 commit comments

Comments
 (0)