Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: incorrect extractProperties typings for known object #109

Merged
merged 4 commits into from Aug 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/eleven-suits-drop.md
@@ -0,0 +1,5 @@
---
"synckit": patch
---

fix: incorrect `extractProperties` typings for known object
2 changes: 1 addition & 1 deletion .remarkrc
@@ -1,5 +1,5 @@
{
"plugins": [
"@1stg/remark-config"
"@1stg/preset"
]
}
59 changes: 15 additions & 44 deletions package.json
Expand Up @@ -5,37 +5,6 @@
"description": "Perform async work synchronously in Node.js using `worker_threads` with first-class TypeScript support.",
"repository": "git+https://github.com/un-ts/synckit.git",
"author": "JounQin (https://www.1stG.me) <admin@1stg.me>",
"donate": {
"recipients": [
{
"name": "unts",
"platform": "opencollective",
"address": "https://opencollective.com/unts",
"weight": 60
},
{
"name": "rxts",
"platform": "opencollective",
"address": "https://opencollective.com/rxts",
"weight": 20
},
{
"name": "1stG",
"email": "i@1stg.me",
"weight": 20,
"platforms": [
{
"platform": "opencollective",
"address": "https://opencollective.com/1stG"
},
{
"platform": "patreon",
"address": "https://www.patreon.com/1stG"
}
]
}
]
},
"funding": "https://opencollective.com/unts",
"license": "MIT",
"packageManager": "yarn@1.22.19",
Expand Down Expand Up @@ -79,38 +48,40 @@
"lint:tsc": "tsc --noEmit",
"prepare": "patch-package && simple-git-hooks && yarn-deduplicate --strategy fewer || exit 0",
"prerelease": "yarn build",
"release": "changeset publish",
"release": "clean-pkg-json && changeset publish",
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
"typecov": "type-coverage"
},
"dependencies": {
"@pkgr/utils": "^2.3.0",
"@pkgr/utils": "^2.3.1",
"tslib": "^2.4.0"
},
"devDependencies": {
"@1stg/lib-config": "^9.0.2",
"@1stg/lib-config": "^10.2.1",
"@changesets/changelog-github": "^0.4.6",
"@changesets/cli": "^2.23.2",
"@changesets/cli": "^2.24.3",
"@swc-node/register": "^1.5.1",
"@types/jest": "^28.1.5",
"@types/node": "^18.0.4",
"deasync": "^0.1.27",
"@types/jest": "^28.1.8",
"@types/node": "^18.7.13",
"clean-pkg-json": "^1.2.0",
"deasync": "^0.1.28",
"esbuild-register": "^3.3.3",
"esbuild-runner": "^2.2.1",
"execa": "^6.1.0",
"jest": "^28.1.3",
"jest": "^29.0.1",
"patch-package": "^6.4.7",
"sync-threads": "^1.0.1",
"ts-expect": "^1.3.0",
"ts-jest": "^28.0.6",
"ts-jest": "^28.0.8",
"ts-node": "^10.9.1",
"tsx": "^3.8.0",
"tsx": "^3.8.2",
"type-coverage": "^2.22.0",
"typescript": "^4.7.4",
"yarn-deduplicate": "^5.0.0"
"typescript": "^4.8.2",
"yarn-deduplicate": "^6.0.0"
},
"resolutions": {
"prettier": "^2.7.1"
"prettier": "^2.7.1",
"synckit": "link:."
},
"commitlint": {
"extends": "@1stg"
Expand Down
13 changes: 10 additions & 3 deletions src/index.ts
Expand Up @@ -76,9 +76,11 @@ export interface SynckitOptions {
// MessagePort doesn't copy the properties of Error objects. We still want
// error objects to have extra properties such as "warnings" so implement the
// property copying manually.
export const extractProperties = <T>(object?: T): T | undefined => {
export function extractProperties<T extends object>(object: T): T
export function extractProperties<T>(object?: T): T | undefined
export function extractProperties<T>(object?: T) {
if (object && typeof object === 'object') {
const properties = {} as unknown as T
const properties = {} as T
for (const key in object) {
properties[key as keyof T] = object[key]
}
Expand Down Expand Up @@ -230,8 +232,13 @@ const setupTsRunner = (
/* istanbul ignore if -- https://github.com/facebook/jest/issues/5274 */
if (process.versions.pnp) {
const nodeOptions = NODE_OPTIONS?.split(/\s+/)
const pnpApiPath = cjsRequire.resolve('pnpapi')
let pnpApiPath: string | undefined
try {
/** @see https://github.com/facebook/jest/issues/9543 */
pnpApiPath = cjsRequire.resolve('pnpapi')
} catch {}
if (
pnpApiPath &&
!nodeOptions?.some(
(option, index) =>
['-r', '--require'].includes(option) &&
Expand Down
29 changes: 15 additions & 14 deletions test/fixtures/yarn-pnp/.pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 19 additions & 7 deletions test/fixtures/yarn-pnp/.pnp.loader.mjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.