delphirtl
Version:
RTL functions from Delphi
37 lines (21 loc) • 913 B
Markdown
[**delphirtl**](../README.md) • **Docs**
***
[](../globals.md) / hasFieldOfType
> **hasFieldOfType**\<`T`\>(`obj`, `fieldName`, `fieldType`): `obj is Object`
Checks that obj is an object, and it has a field named fieldName and that its type is fieldType
Assuming e is an object with the field code of type string.
* If you use this, then the expression following it is valid, for example:
- hasFieldOfType<string>(e, "code", "string") && e.code === "INSUFFICIENT_FUNDS")
* If you do not use it, then
- e.code is invalid when checked by code analyzer
• **T**
• **obj**: `unknown`
• **fieldName**: `string`
• **fieldType**: `string`
`obj is Object`
[](https://github.com/chuacw/delphirtl/blob/b2d86277a5251f0037cf01044224c3e29dc4c6be/src/sysutils.ts#L466)