Installations
npm install @sounisi5011/ts-type-util-has-own-property
Developer Guide
Typescript
Yes
Module System
N/A
Node Version
12.22.7
NPM Version
6.14.15
Score
56.7
Supply Chain
93.6
Quality
75.5
Maintenance
100
Vulnerability
100
License
Releases
get-nodejs-versions-array-action get-nodejs-versions-array-action-v0.0.4
Published on 09 Mar 2023
get-nodejs-versions-array-action get-nodejs-versions-array-action-v0.0.3
Published on 09 Mar 2023
get-nodejs-versions-array-action get-nodejs-versions-array-action-v0.0.2
Published on 09 Mar 2023
get-nodejs-versions-array-action get-nodejs-versions-array-action-v0.0.1
Published on 04 Mar 2023
jest-binary-data-matchers: v1.2.1
Published on 01 Jan 2023
monorepo-workspace-submodules-finder-action: v1.3.2
Published on 01 Jan 2023
Contributors
Unable to fetch Contributors
Languages
TypeScript (85.07%)
JavaScript (14.37%)
Shell (0.57%)
Developer
sounisi5011
Download Statistics
Total Downloads
1,017
Last Day
3
Last Week
8
Last Month
22
Last Year
186
GitHub Statistics
5 Stars
568 Commits
2 Watching
24 Branches
2 Contributors
Package Meta Information
Latest Version
1.0.3
Package Id
@sounisi5011/ts-type-util-has-own-property@1.0.3
Unpacked Size
7.65 kB
Size
2.72 kB
File Count
5
NPM Version
6.14.15
Node Version
12.22.7
Total Downloads
Cumulative downloads
Total Downloads
1,017
Last day
200%
3
Compared to previous day
Last week
0%
8
Compared to previous week
Last month
340%
22
Compared to previous month
Last year
-12.3%
186
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dev Dependencies
3
@sounisi5011/ts-type-util-has-own-property
Fix the type definition of the Object.prototype.hasOwnProperty()
method.
Installation
1npm install @sounisi5011/ts-type-util-has-own-property
1yarn add @sounisi5011/ts-type-util-has-own-property
1pnpm add @sounisi5011/ts-type-util-has-own-property
Usage
1import { hasOwnProperty } from '@sounisi5011/ts-type-util-has-own-property'; 2 3const hasOwnProp = Object.prototype.hasOwnProperty.call as hasOwnProperty; 4 5if (hasOwnProp(object, 'propertyName')) { 6 // `object.propertyName` is available! 7} 8 9if ((Object.prototype.hasOwnProperty.call as hasOwnProperty)(object, 'propertyName')) { 10 // `object.propertyName` is available! 11}
Optional property
If an object has an optional property, it should not contain the type undefined
.
The hasOwnProperty
type removes the undef type that is implicitly added from the value of an optional property.
1import { hasOwnProperty } from '@sounisi5011/ts-type-util-has-own-property'; 2 3const hasOwnProp = Object.prototype.hasOwnProperty.call as hasOwnProperty; 4 5// ----- // 6 7interface Obj { 8 prop?: string; 9} 10 11const obj: Obj = {}; 12 13if (hasOwnProp(obj, 'prop')) { 14 // `obj.prop` is `string` type. 15 // Not `string | undefined` type! 16}
Optional property for union types with undefined
Since TypeScript 4.4, when the exactOptionalPropertyTypes
option is enabled, optional properties are no longer union types by default.
In this case, it is possible to specify the union type with undefined
type as an optional property.
The hasOwnProperty
type will not remove the undefined
type of a union type whose undefined
type has been explicitly specified.
1import { hasOwnProperty } from '@sounisi5011/ts-type-util-has-own-property'; 2 3const hasOwnProp = Object.prototype.hasOwnProperty.call as hasOwnProperty; 4 5// ----- // 6 7interface Obj { 8 prop?: string | undefined; 9} 10 11const obj: Obj = {}; 12 13if (hasOwnProp(obj, 'prop')) { 14 // If the `exactOptionalPropertyTypes` option is true, `obj.prop` is `string | undefined` type. 15 // If the `exactOptionalPropertyTypes` option is false, `obj.prop` is `string` type. 16}
Union type property with undefined
If it is not an optional property, the undefined
type should not be removed.
The hasOwnProperty
type properly distinguishes between optional properties and the union types of other properties.
1import { hasOwnProperty } from '@sounisi5011/ts-type-util-has-own-property'; 2 3const hasOwnProp = Object.prototype.hasOwnProperty.call as hasOwnProperty; 4 5// ----- // 6 7interface Obj { 8 prop: string | undefined; 9} 10 11const obj: Obj = { prop: undefined }; 12 13if (hasOwnProp(obj, 'prop')) { 14 // `obj.prop` is `string | undefined` type. 15 // Not `string` type! 16}
Non-existent property
We sometimes want to check for the existence of properties whose types are not defined.
The hasOwnProperty
type assumes that the value of a non-existent property is of type unknown
.
1import { hasOwnProperty } from '@sounisi5011/ts-type-util-has-own-property'; 2 3const hasOwnProp = Object.prototype.hasOwnProperty.call as hasOwnProperty; 4 5// ----- // 6 7const obj = {}; 8 9if (hasOwnProp(obj, 'hoge')) { 10 // `obj.hoge` is `unknown` type. 11}
No vulnerabilities found.
Reason
all changesets reviewed
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/check-pr-title.yaml:1
- Warn: no topLevel permission defined: .github/workflows/ci.yaml:1
- Warn: no topLevel permission defined: .github/workflows/pr-auto-approve.yaml:1
- Warn: no topLevel permission defined: .github/workflows/release.yaml:1
- Warn: no topLevel permission defined: .github/workflows/update-license-year.yaml:1
- Info: no jobLevel write permissions found
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Info: Possibly incomplete results: error parsing shell code: parameter expansion requires a literal: packages/encrypted-archive/.github/workflows/post-release.sh:0
- Info: Possibly incomplete results: error parsing shell code: parameter expansion requires a literal: packages/encrypted-archive/.github/workflows/publish.sh:0
- Info: Possibly incomplete results: error parsing shell code: parameter expansion requires a literal: packages/stream-transform-from/.github/workflows/publish.sh:0
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/check-pr-title.yaml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/sounisi5011/npm-packages/check-pr-title.yaml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yaml:69: update your workflow using https://app.stepsecurity.io/secureworkflow/sounisi5011/npm-packages/ci.yaml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yaml:71: update your workflow using https://app.stepsecurity.io/secureworkflow/sounisi5011/npm-packages/ci.yaml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yaml:77: update your workflow using https://app.stepsecurity.io/secureworkflow/sounisi5011/npm-packages/ci.yaml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yaml:105: update your workflow using https://app.stepsecurity.io/secureworkflow/sounisi5011/npm-packages/ci.yaml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yaml:111: update your workflow using https://app.stepsecurity.io/secureworkflow/sounisi5011/npm-packages/ci.yaml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yaml:123: update your workflow using https://app.stepsecurity.io/secureworkflow/sounisi5011/npm-packages/ci.yaml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yaml:125: update your workflow using https://app.stepsecurity.io/secureworkflow/sounisi5011/npm-packages/ci.yaml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yaml:130: update your workflow using https://app.stepsecurity.io/secureworkflow/sounisi5011/npm-packages/ci.yaml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yaml:139: update your workflow using https://app.stepsecurity.io/secureworkflow/sounisi5011/npm-packages/ci.yaml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yaml:145: update your workflow using https://app.stepsecurity.io/secureworkflow/sounisi5011/npm-packages/ci.yaml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yaml:158: update your workflow using https://app.stepsecurity.io/secureworkflow/sounisi5011/npm-packages/ci.yaml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yaml:160: update your workflow using https://app.stepsecurity.io/secureworkflow/sounisi5011/npm-packages/ci.yaml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yaml:165: update your workflow using https://app.stepsecurity.io/secureworkflow/sounisi5011/npm-packages/ci.yaml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yaml:174: update your workflow using https://app.stepsecurity.io/secureworkflow/sounisi5011/npm-packages/ci.yaml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yaml:273: update your workflow using https://app.stepsecurity.io/secureworkflow/sounisi5011/npm-packages/ci.yaml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yaml:275: update your workflow using https://app.stepsecurity.io/secureworkflow/sounisi5011/npm-packages/ci.yaml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yaml:280: update your workflow using https://app.stepsecurity.io/secureworkflow/sounisi5011/npm-packages/ci.yaml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yaml:289: update your workflow using https://app.stepsecurity.io/secureworkflow/sounisi5011/npm-packages/ci.yaml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yaml:369: update your workflow using https://app.stepsecurity.io/secureworkflow/sounisi5011/npm-packages/ci.yaml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yaml:393: update your workflow using https://app.stepsecurity.io/secureworkflow/sounisi5011/npm-packages/ci.yaml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yaml:395: update your workflow using https://app.stepsecurity.io/secureworkflow/sounisi5011/npm-packages/ci.yaml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yaml:400: update your workflow using https://app.stepsecurity.io/secureworkflow/sounisi5011/npm-packages/ci.yaml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yaml:418: update your workflow using https://app.stepsecurity.io/secureworkflow/sounisi5011/npm-packages/ci.yaml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yaml:421: update your workflow using https://app.stepsecurity.io/secureworkflow/sounisi5011/npm-packages/ci.yaml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yaml:455: update your workflow using https://app.stepsecurity.io/secureworkflow/sounisi5011/npm-packages/ci.yaml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/pr-auto-approve.yaml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/sounisi5011/npm-packages/pr-auto-approve.yaml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yaml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/sounisi5011/npm-packages/release.yaml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yaml:66: update your workflow using https://app.stepsecurity.io/secureworkflow/sounisi5011/npm-packages/release.yaml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yaml:135: update your workflow using https://app.stepsecurity.io/secureworkflow/sounisi5011/npm-packages/release.yaml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yaml:143: update your workflow using https://app.stepsecurity.io/secureworkflow/sounisi5011/npm-packages/release.yaml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yaml:151: update your workflow using https://app.stepsecurity.io/secureworkflow/sounisi5011/npm-packages/release.yaml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yaml:228: update your workflow using https://app.stepsecurity.io/secureworkflow/sounisi5011/npm-packages/release.yaml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yaml:231: update your workflow using https://app.stepsecurity.io/secureworkflow/sounisi5011/npm-packages/release.yaml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yaml:242: update your workflow using https://app.stepsecurity.io/secureworkflow/sounisi5011/npm-packages/release.yaml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/update-license-year.yaml:10: update your workflow using https://app.stepsecurity.io/secureworkflow/sounisi5011/npm-packages/update-license-year.yaml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/update-license-year.yaml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/sounisi5011/npm-packages/update-license-year.yaml/main?enable=pin
- Warn: npmCommand not pinned by hash: .github/workflows/ci.yaml:448
- Warn: downloadThenRun not pinned by hash: .github/workflows/ci.yaml:225
- Warn: downloadThenRun not pinned by hash: .github/workflows/ci.yaml:241
- Info: 0 out of 32 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 5 third-party GitHubAction dependencies pinned
- Info: 0 out of 1 npmCommand dependencies pinned
- Info: 0 out of 2 downloadThenRun dependencies pinned
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 30 are checked with a SAST tool
Reason
18 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-4q6p-r6v2-jvc5
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55
- Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-353f-5xf4-qw67
- Warn: Project is vulnerable to: GHSA-c24v-8rfc-w8vw
- Warn: Project is vulnerable to: GHSA-8jhw-289h-jh2g
- Warn: Project is vulnerable to: GHSA-64vr-g452-qvp3
- Warn: Project is vulnerable to: GHSA-9cwx-2883-4wfx
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
- Warn: Project is vulnerable to: GHSA-f9xv-q969-pqx4
- Warn: Project is vulnerable to: GHSA-m95q-7qp3-xv42
Score
3.8
/10
Last Scanned on 2025-01-13
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More