microsoft / microsoft/TypeScript
F2 can't format the "satisfies" operator in Typescript
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 117
Description
Type: Bug
I'm using Typescript and i have a interface like this in one file:
// src/domain/cases/example.ts
export type ExampleCase = {
example(): Promise<ExampleCaseResult>;
}
export type ExampleCaseResult = {
example: string
}
And i'm using this type with the "satisfies" operator in another file like this:
// src/main/swagger/types.ts
import {OpenAPIV3} from 'openapi-types';
export type RequiredKeys<T> = keyof {
[K in keyof T as string extends K ? never : {} extends Pick<T, K> ? never : K]: 0;
};
export type ObjectSchema<T extends {}> = OpenAPIV3.SchemaObject & {
type: 'object';
required: Array<RequiredKeys<T>>;
properties: {
[K in keyof T]: OpenAPIV3.SchemaObject;
};
};
// src/main/swagger/paths/examplePath.ts
import {ExampleCaseResult} from 'src/domain/cases/example';
import {ObjectSchema} from '../types'
import {OpenAPIV3} from 'openapi-types';
export const examplePath: OpenAPIV3.PathsObject = {
'/example': {
get: {
operationId: 'example',
responses: {
200: {
description: 'ok',
content: {
'application/json': {
schema: {
type: 'object',
required: ['example'],
properties: {
example: { type: 'string' }
}
} satisfies ObjectSchema<ExampleCaseResult>
}
}
}
}
}
}
}
The problem is when try to rename the type ExampleCaseResult in file src/domain/cases/example.ts using the shortcut "F2". When renamed, any inference using satisfies isn't renamed correctly.
VS Code version: Code 1.80.2 (2ccd690cbff1569e4a83d7c43d45101f817401dc, 2023-07-27T20:57:59.134Z)
OS version: Darwin arm64 22.5.0
Modes:
System Info
| Item | Value |
|---|---|
| CPUs | Apple M1 (8 x 24) |
| GPU Status | 2d_canvas: enabled canvas_oop_rasterization: disabled_off direct_rendering_display_compositor: disabled_off_ok gpu_compositing: enabled metal: disabled_off multiple_raster_threads: enabled_on opengl: enabled_on rasterization: enabled raw_draw: disabled_off_ok video_decode: enabled video_encode: enabled vulkan: disabled_off webgl: enabled webgl2: enabled webgpu: enabled |
| Load (avg) | 4, 4, 4 |
| Memory (System) | 8.00GB (0.04GB free) |
| Process Argv | --crash-reporter-id 399b35d4-0274-45b0-8d74-f5516a3f1bf4 |
| Screen Reader | no |
| VM | 0% |
Extensions (30)
| Extension | Author (truncated) | Version |
|---|---|---|
| codesnap | adp | 1.3.4 |
| markdown-mermaid | bie | 1.19.0 |
| vscode-eslint | dba | 2.4.2 |
| emulate | Die | 1.6.0 |
| vscode-reveal | evi | 4.3.3 |
| vscode-expo-tools | exp | 1.0.7 |
| vscode-jest-runner | fir | 0.4.66 |
| vscode-test-explorer | hbe | 2.21.1 |
| elixir-ls | Jak | 0.15.3 |
| vscode-credo | jos | 0.2.0 |
| vscode-python-test-adapter | lit | 0.7.1 |
| ts-barrelr | mik | 1.6.0 |
| graphql | mqu | 0.1.2 |
| vscode-docker | ms- | 1.26.0 |
| black-formatter | ms- | 2023.4.1 |
| isort | ms- | 2023.10.1 |
| python | ms- | 2023.12.0 |
| vscode-pylance | ms- | 2023.7.40 |
| jupyter | ms- | 2023.6.1101941928 |
| jupyter-keymap | ms- | 1.1.2 |
| jupyter-renderers | ms- | 1.0.17 |
| vscode-jupyter-cell-tags | ms- | 0.1.8 |
| vscode-jupyter-slideshow | ms- | 0.1.5 |
| makefile-tools | ms- | 0.7.0 |
| test-adapter-converter | ms- | 0.1.8 |
| vscode-react-native | msj | 1.11.2 |
| vscode-thunder-client | ran | 2.10.0 |
| vscode-xml | red | 0.26.1 |
| vscode-yaml | red | 1.14.0 |
| vscode-icons | vsc | 12.4.0 |
A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
vserr242:30382549
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263cf:30335440
vscod805cf:30301675
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593:30376534
pythonvs932:30410667
py29gd2263:30792226
vsclangdf:30486550
c4g48928:30535728
dsvsc012cf:30540253
pynewext54:30695312
azure-dev_surveyone:30548225
2e4cg342:30602488
f6dab269:30613381
vscrpc:30673769
showlangstatbar:30737416
vsctsb:30748421
03d35959:30757346
24365598:30736109
pythonfmttext:30731395
pythoncmv:30756943
fixshowwlkth:30771522
hideindicator:30785051
pythongtdpath:30769146
i26e3531:30792625
gsofa:30797621
pythonnosmt12:30797651
e537b577:30795824
dsvsc013:30795093
dsvsc014cf:30797590
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the rename from src/domain/cases/example.ts into src/main/swagger/paths/examplePath.ts, using the satisfies ObjectSchema expression shown in the report. Start by confirming which references F2 updates and compare the result with the expected rename of ExampleCaseResult. Done means the inferred reference through satisfies is renamed correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- developer-experience
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100