Skip to content

Commit

Permalink
update lume cli version, update typescript version
Browse files Browse the repository at this point in the history
  • Loading branch information
trusktr committed Nov 7, 2023
1 parent 2a2d6b2 commit 9b0dd3f
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 11 deletions.
4 changes: 2 additions & 2 deletions dist/observe.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
declare type Options = {
type Options = {
async: boolean;
inherited: boolean;
};
declare type Callback = (propName: PropertyKey, value: any) => unknown;
type Callback = (propName: PropertyKey, value: any) => unknown;
export declare function observe<T extends object>(object: T, propertyNames: (keyof T)[], callback: Callback, options?: Partial<Options>): void;
export declare function unobserve<T extends object>(object: T, props: Callback | (keyof T)[], callback?: Callback): void;
export {};
Expand Down
2 changes: 1 addition & 1 deletion dist/observe.d.ts.map

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

4 changes: 2 additions & 2 deletions dist/observe.js

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

2 changes: 1 addition & 1 deletion dist/observe.js.map

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

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@
"lowclass": "^6.0.0"
},
"devDependencies": {
"@lume/cli": "^0.9.0",
"prettier": "3.0.3"
"@lume/cli": "^0.10.0",
"prettier": "3.0.3",
"typescript": "^5.0.0"
},
"repository": {
"type": "git",
Expand Down
11 changes: 8 additions & 3 deletions src/observe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,14 @@ function defineObservationGetterSetter<T extends object>(object: T, propName: ke
let _value = descriptor.value

if (!descriptor.writable) {
console.error(`Can not observe readonly property "${propName}" with descriptor`, descriptor, `of object:`, object)

throw new Error(`Can not observe readonly property "${propName}" of object: ${object} (see above)`)
console.error(
`Can not observe readonly property "${String(propName)}" with descriptor`,
descriptor,
`of object:`,
object,
)

throw new Error(`Can not observe readonly property "${String(propName)}" of object: ${object} (see above)`)
}

delete descriptor.value
Expand Down

0 comments on commit 9b0dd3f

Please sign in to comment.