Skip to content

Commit 4e72b80

Browse files
authoredMar 11, 2024
fix(core): upgrade and fix types for typescript 5.4 (#5943)
1 parent 4e95e09 commit 4e72b80

File tree

6 files changed

+83
-78
lines changed

6 files changed

+83
-78
lines changed
 

‎dev/embedded-studio/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"@types/react": "^18.2.37",
1919
"@types/react-dom": "^18.2.15",
2020
"@vitejs/plugin-react": "^4.2.1",
21-
"typescript": "^5.2.2",
21+
"typescript": "^5.4.2",
2222
"vite": "^4.5.1"
2323
}
2424
}

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@
149149
"sanity": "workspace:*",
150150
"semver": "^7.3.5",
151151
"turbo": "^1.12.4",
152-
"typescript": "^5.2.2",
152+
"typescript": "^5.4.2",
153153
"yargs": "^17.3.0"
154154
},
155155
"optionalDependencies": {

‎packages/@sanity/types/src/schema/define.ts

+10-8
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ import {type FieldDefinitionBase, type IntrinsicTypeName} from './definition'
170170
* @beta
171171
*/
172172
export function defineType<
173-
TType extends string | IntrinsicTypeName, // IntrinsicTypeName here improves autocompletion in _some_ IDEs (not VS Code atm)
174-
TName extends string,
173+
const TType extends string | IntrinsicTypeName, // IntrinsicTypeName here improves autocompletion in _some_ IDEs (not VS Code atm)
174+
const TName extends string,
175175
TSelect extends Record<string, string> | undefined,
176176
TPrepareValue extends Record<keyof TSelect, any> | undefined,
177177
TAlias extends IntrinsicTypeName | undefined,
@@ -211,8 +211,8 @@ export function defineType<
211211
* @beta
212212
*/
213213
export function defineField<
214-
TType extends string | IntrinsicTypeName, // IntrinsicTypeName here improves autocompletion in _some_ IDEs (not VS Code atm)
215-
TName extends string,
214+
const TType extends string | IntrinsicTypeName, // IntrinsicTypeName here improves autocompletion in _some_ IDEs (not VS Code atm)
215+
const TName extends string,
216216
TSelect extends Record<string, string> | undefined,
217217
TPrepareValue extends Record<keyof TSelect, any> | undefined,
218218
TAlias extends IntrinsicTypeName | undefined,
@@ -229,7 +229,8 @@ export function defineField<
229229
// eslint-disable-next-line @typescript-eslint/no-unused-vars
230230
defineOptions?: DefineSchemaOptions<TStrict, TAlias>,
231231
): typeof schemaField & WidenValidation & WidenInitialValue {
232-
return schemaField
232+
// TODO: re-evaluate the need for this cast
233+
return schemaField as typeof schemaField & WidenValidation & WidenInitialValue
233234
}
234235

235236
/**
@@ -253,8 +254,8 @@ export function defineField<
253254
* @beta
254255
*/
255256
export function defineArrayMember<
256-
TType extends string | IntrinsicTypeName, // IntrinsicTypeName here improves autocompletion in _some_ IDEs (not VS Code atm)
257-
TName extends string,
257+
const TType extends string | IntrinsicTypeName, // IntrinsicTypeName here improves autocompletion in _some_ IDEs (not VS Code atm)
258+
const TName extends string,
258259
TSelect extends Record<string, string> | undefined,
259260
TPrepareValue extends Record<keyof TSelect, any> | undefined,
260261
TAlias extends IntrinsicTypeName | undefined,
@@ -276,7 +277,8 @@ export function defineArrayMember<
276277
// eslint-disable-next-line @typescript-eslint/no-unused-vars
277278
defineOptions?: DefineSchemaOptions<TStrict, TAlias>,
278279
): typeof arrayOfSchema & WidenValidation & WidenInitialValue {
279-
return arrayOfSchema
280+
// TODO: re-evaluate the need for this cast
281+
return arrayOfSchema as typeof arrayOfSchema & WidenValidation & WidenInitialValue
280282
}
281283

282284
/**

‎packages/@sanity/types/src/schema/test/alias.test.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {describe, it} from '@jest/globals'
2+
23
/* eslint-disable @typescript-eslint/no-unused-vars */
34
/**
45
* Some of these tests have no expect statement;
@@ -94,7 +95,6 @@ describe('alias type test', () => {
9495
})
9596

9697
it('should support alias with preview', () => {
97-
//@ts-expect-error {error: any} has no properties in common with PreviewValue
9898
defineType({
9999
type: 'custom-object',
100100
name: 'redefined',
@@ -105,7 +105,6 @@ describe('alias type test', () => {
105105
},
106106
})
107107

108-
//@ts-expect-error {error: any} has no properties in common with PreviewValue
109108
defineField({
110109
type: 'custom-object',
111110
name: 'redefined',
@@ -116,7 +115,6 @@ describe('alias type test', () => {
116115
},
117116
})
118117

119-
//@ts-expect-error {error: any} has no properties in common with PreviewValue
120118
defineArrayMember({
121119
type: 'custom-object',
122120
name: 'redefined',

‎perf/tests/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"@types/node": "^18.15.3",
2121
"esbuild": "^0.19.8",
2222
"ts-node": "^10.9.1",
23-
"typescript": "^5.2.2"
23+
"typescript": "^5.4.2"
2424
},
2525
"dependencies": {
2626
"@playwright/test": "^1.41.2",

‎pnpm-lock.yaml

+69-64
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.