Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ tools/tools
*.bak
*.orig
*.rej
vendor/
29 changes: 29 additions & 0 deletions apps/nest-node-probe/correctness/error-subclass.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
class ParseFailure extends Error {
status: number
constructor(status: number, message: string, name = 'Error') {
super(message)
this.name = name
this.status = status
}
}
function fail(): never {
throw new ParseFailure(400, 'bad body', 'SyntaxError')
}
function describe(err: unknown): string {
return err instanceof Error ? `${err.name}: ${err.message}` : String(err)
}
try {
fail()
} catch (err) {
console.log('caught instanceof Error', err instanceof Error)
console.log('caught instanceof ParseFailure', err instanceof ParseFailure)
console.log('describe', describe(err))
console.log('String', String(err))
}
const direct: unknown = new ParseFailure(415, 'unsupported', 'Error')
console.log('direct instanceof Error', direct instanceof Error)
console.log('describe direct', describe(direct))
const plain: unknown = new Error('plain')
console.log('plain describe', describe(plain))
const wrapped: unknown = new TypeError('typed')
console.log('typed describe', describe(wrapped))
19 changes: 19 additions & 0 deletions apps/nest-node-probe/correctness/json-undefined.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class Holder {
body: any = undefined
}
const holder = new Holder()
const fromField: string | undefined = JSON.stringify(holder.body)
console.log('field undefined === undefined', fromField === undefined)
console.log('field typeof', typeof holder.body)
function stringifyUnknown(body: unknown): string | undefined {
return JSON.stringify(body)
}
console.log('param unknown === undefined', stringifyUnknown(holder.body) === undefined)
console.log('param unknown object', stringifyUnknown({ a: 1 }))
const dynamic: unknown = undefined
const fromUnknown: string | undefined = JSON.stringify(dynamic)
console.log('unknown undefined === undefined', fromUnknown === undefined)
holder.body = { a: [1, null, 'x'] }
const fromObject: string | undefined = JSON.stringify(holder.body)
console.log('object', fromObject)
console.log('null', JSON.stringify(null))
1 change: 1 addition & 0 deletions apps/nest-node-probe/oracle.node.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './dist/server.js'
Loading
Loading