You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After running the code above, without any warnings you will get this:
100
+
101
+
```json
102
+
// 📁someNumber.json
103
+
"[object Object]1"
104
+
```
105
+
106
+
That's because callback `n => n + 1` has transformed `n` (object) into string.
107
+
108
+
Here, despite of the TS type (number), `n` is object in runtime, so `n + 1` just stringified `n` and returned `[object Object]1`.
109
+
Then this module just stringified the string to store output as valid JSON string in file.
57
110
58
-
We're using [detect-indent](https://www.npmjs.com/package/detect-indent) to preserve the tab size in `.json` files.
111
+
Remember, **this module doesn't do any type checking in runtime**, you need to use `typeof` in callback for checking root types or schema validators (like [ajv](http://npmjs.com/ajv)) for objects.
59
112
113
+
### Formatting
114
+
115
+
By default, it will preserve tab size (thanks to [detect-indent](https://www.npmjs.com/package/detect-indent)), but you can control this by overriding `tabSize` option. For example, we can use it to just format the file:
0 commit comments