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
fix(check-types): stop regression to unify *all* Object types including parent objects unless there is unifyParentAndChildTypeChecks config (should only unify with arrays); fixesgajus#800
`Object` (with the initial upper-case) if used in the syntax
109
+
`Object.<keyType, valueType>` or `Object<keyType, valueType`, perhaps to
110
+
adhere to what [JSDoc documents](https://jsdoc.app/tags-type.html).
111
+
112
+
So, for optimal compatibility with TypeScript (especially since TypeScript
113
+
tools can be used on plain JavaScript with JSDoc), we are now enforcing this
114
+
TypeScript approach as the default (without the dot) as well as disallowing
115
+
`object.<>` or `object<>`, styles which TypeScript doesn't support in favor
116
+
of `Object<>`, and disallowing plain `Object`—which [it discourages](https://www.typescriptlang.org/docs/handbook/declaration-files/do-s-and-don-ts.html#general-types)
to ours here)—in favor of `object`. (You might wish to use `preferredTypes` to
120
+
prevent `Object<>` too, whether for simplicity and/or because of a general
121
+
preference of the object shorthand TypeScript allows (e.g., `{prop: number}`).)
122
+
Although earlier versions of TypeScript only worked with the dotted `Object.<>`
123
+
form, and although the TypeScript docs currently use this on its [JSDoc page](https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html#type)
124
+
as did [JSDoc](https://jsdoc.app/tags-type.html),
125
+
the dot-less form has nevertheless been supported for some time in both
126
+
environments, and seems to be favored by the community, so we are enforcing
127
+
that now.
128
+
129
+
"preferredTypes": {
130
+
// Use 'object' in typescript mode, see TypeScript's Do's and Dont's
131
+
"Object": "object",
132
+
"object.<>": "Object<>", // see https://github.com/jsdoc-type-pratt-parser/jsdoc-type-pratt-parser/issues/101
133
+
"Object.<>": "Object<>",
134
+
"object<>": "Object<>", // see https://github.com/jsdoc-type-pratt-parser/jsdoc-type-pratt-parser/issues/101
135
+
},
136
+
105
137
106
138
Basically, for primitives, we want to define the type as a primitive, because
107
139
that's what we use in 99.9% of cases. For everything else, we use the type
108
-
rather than the primitive. Otherwise it would all just be `{object}`.
140
+
rather than the primitive. Otherwise it would all just be `{object}` (with the
141
+
additional exception of the special case of `Object.<>` just mentioned).
109
142
110
143
In short: It's not about consistency, rather about the 99.9% use case. (And
111
144
some functions might not even support the objects if they are checking for
`Object` (with the initial upper-case) if used in the syntax
4826
+
`Object.<keyType, valueType>` or `Object<keyType, valueType`, perhaps to
4827
+
adhere to what [JSDoc documents](https://jsdoc.app/tags-type.html).
4828
+
4829
+
So, for optimal compatibility with TypeScript (especially since TypeScript
4830
+
tools can be used on plain JavaScript with JSDoc), we are now enforcing this
4831
+
TypeScript approach as the default (without the dot) as well as disallowing
4832
+
`object.<>` or `object<>`, styles which TypeScript doesn't support in favor
4833
+
of `Object<>`, and disallowing plain `Object`—which [it discourages](https://www.typescriptlang.org/docs/handbook/declaration-files/do-s-and-don-ts.html#general-types)
to ours here)—in favor of `object`. (You might wish to use `preferredTypes` to
4837
+
prevent `Object<>` too, whether for simplicity and/or because of a general
4838
+
preference of the object shorthand TypeScript allows (e.g., `{prop: number}`).)
4839
+
Although earlier versions of TypeScript only worked with the dotted `Object.<>`
4840
+
form, and although the TypeScript docs currently use this on its [JSDoc page](https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html#type)
4841
+
as did [JSDoc](https://jsdoc.app/tags-type.html),
4842
+
the dot-less form has nevertheless been supported for some time in both
4843
+
environments, and seems to be favored by the community, so we are enforcing
4844
+
that now.
4845
+
4846
+
"preferredTypes": {
4847
+
// Use 'object' in typescript mode, see TypeScript's Do's and Dont's
4848
+
"Object": "object",
4849
+
"object.<>": "Object<>", // see https://github.com/jsdoc-type-pratt-parser/jsdoc-type-pratt-parser/issues/101
4850
+
"Object.<>": "Object<>",
4851
+
"object<>": "Object<>", // see https://github.com/jsdoc-type-pratt-parser/jsdoc-type-pratt-parser/issues/101
4852
+
},
4853
+
4822
4854
4823
4855
Basically, for primitives, we want to define the type as a primitive, because
4824
4856
that's what we use in 99.9% of cases. For everything else, we use the type
4825
-
rather than the primitive. Otherwise it would all just be `{object}`.
4857
+
rather than the primitive. Otherwise it would all just be `{object}` (with the
4858
+
additional exception of the special case of `Object.<>` just mentioned).
4826
4859
4827
4860
In short: It's not about consistency, rather about the 99.9% use case. (And
4828
4861
some functions might not even support the objects if they are checking for
0 commit comments