-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScript
Description
π Search Terms
completion autocompletion string
π Version & Regression Information
- This issue is new in typescript 5.5.0-beta
- Not fixed in nightly at time of submitting issue.
β― Playground Link
π» Code
type Test = 'test';
// Please, try to complete the test by Ctrl-space and then selecting suggestion
const test: Test = 't'; //This works fine
const test2: Test = 't; // This comment definitely should not get deleted on completion, because it could be important code, but it does
const test3: Test = "t; // This comment definitely should not get deleted on completion, because it could be important code, but it does
// Refactoring example where this behavior is bad. Try selecting suggestion from "t" to "test"
const test4: { prop1: number, prop2: number } = {prop1: 5, prop2: 2 };
const test5: {prop0: Test, prop1: number, prop2: number, } = { prop0: 't ,prop1: 5, prop2: 2 };
// Completion in 5.5 results to
const test6: {prop0: Test, prop1: number, prop2: number, } = { prop0: 'test
// Completion in 5.4.5 results to
const test7: {prop0: Test, prop1: number, prop2: number, } = { prop0: 'test ,prop1: 5, prop2: 2 };
π Actual behavior
When trying to complete "t" to "test" in the code for variables test2, test3, everything up to the end of line gets deleted.
This is especially bad when trying to add new string properties to existing objects, as can be seen by example refactoring of test4 to test5 variable. Where poor result of selected suggestion can be seen in test6 variable and good behavior of previous TS versions in test7 variable.
π Expected behavior
When editing new string, typescript should insert suggestions, not replace content. Previous versions behavior seems perfect to me.
Additional information about the issue
EDIT: updated example, one of the previous examples didn't behave very well even in previous versions. Added demonstration of previous good behavior.
No response
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScript