Skip to content

Commit a310a55

Browse files
authored
fix: if_type_assert: compliance test passes (#94)
Fixes #92 Related to #91 Signed-off-by: Christian Stewart <christian@aperture.us>
1 parent 4e3fc04 commit a310a55

File tree

5 files changed

+51
-1
lines changed

5 files changed

+51
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Expected: string

compliance/tests/if_type_assert/if_type_assert.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package main
33
func main() {
44
var a any
55
a = "this is a string"
6-
if x, ok := a.(string); ok {
6+
if _, ok := a.(string); ok {
77
println("Expected: string")
88
} else {
99
println("Not Expected: should be a string")
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Generated file based on if_type_assert.go
2+
// Updated when compliance tests are re-run, DO NOT EDIT!
3+
4+
import * as $ from "@goscript/builtin/index.js";
5+
6+
export async function main(): Promise<void> {
7+
let a: null | any = null
8+
a = "this is a string"
9+
{
10+
let { ok: ok } = $.typeAssert<string>(a, {kind: $.TypeKind.Basic, name: 'string'})
11+
if (ok) {
12+
console.log("Expected: string")
13+
}
14+
else {
15+
console.log("Not Expected: should be a string")
16+
}
17+
}
18+
}
19+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"compilerOptions": {
3+
"allowImportingTsExtensions": true,
4+
"baseUrl": ".",
5+
"lib": [
6+
"es2022",
7+
"esnext.disposable",
8+
"dom"
9+
],
10+
"module": "nodenext",
11+
"moduleResolution": "nodenext",
12+
"noEmit": true,
13+
"paths": {
14+
"@goscript/*": [
15+
"../../../gs/*",
16+
"../../../compliance/deps/*"
17+
],
18+
"@goscript/github.com/aperturerobotics/goscript/compliance/tests/if_type_assert/*": [
19+
"./*"
20+
]
21+
},
22+
"sourceMap": true,
23+
"target": "es2022"
24+
},
25+
"extends": "../../../tsconfig.json",
26+
"include": [
27+
"if_type_assert.gs.ts",
28+
"index.ts"
29+
]
30+
}

0 commit comments

Comments
 (0)