Skip to content

Commit 6698f1e

Browse files
authored
[TypeScript codegen] Fix undefined typeguard for null values (#494)
* Make undefined typeguard return 'true' for 'null' aswell * Add ValidationException to exports
1 parent bfedf5c commit 6698f1e

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

schema_salad/typescript/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export {
22
loadDocument,
33
loadDocumentByString,
4+
ValidationException,
45
${generated_class_imports}
56
} from './util/Internal'

schema_salad/typescript/test/Typeguards.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ describe('Test Typeguards', () => {
6868
describe('Undefined', () => {
6969
it('Should return true', () => {
7070
assert.equal(TypeGuards.Undefined(undefined), true)
71+
assert.equal(TypeGuards.Undefined(null), true)
7172
})
7273

7374
it('Should return false', () => {
@@ -76,7 +77,6 @@ describe('Test Typeguards', () => {
7677
assert.equal(TypeGuards.Undefined(1), false)
7778
assert.equal(TypeGuards.Undefined(1.1), false)
7879
assert.equal(TypeGuards.Undefined({}), false)
79-
assert.equal(TypeGuards.Undefined(null), false)
8080
})
8181
})
8282

schema_salad/typescript/util/Typeguards.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export function String (doc: any): boolean {
1717
}
1818

1919
export function Undefined (doc: any): boolean {
20-
return typeof doc === 'undefined'
20+
return doc == null
2121
}
2222

2323
export function isDictionary (doc: any): doc is Dictionary {

0 commit comments

Comments
 (0)