Welcome to my first question here, please excuse any errors.
Currently, I am in the process of migrating multiple TypeScript-based webservices from Loopback 2 to version 4. This transition has led me to rewrite a significant amount of code due to the changes in model definition syntax introduced in Loopback v4.
For example, consider the old code below...
const foo = ds.define('foo', {
string1 : String,
num1 : Number,
string2 : String,
string3 : String,
num2 : Number,
string4: String,
string5: String
}
Which now needs to be rewritten as...
@model()
export class foo extends Model {
@property({ type: 'string', required: true })
string1 = '';
@property({ type: 'number', required: true })
num1 = 0;
@property({ type: 'string', required: true })
string2 = '';
@property({ type: 'string', required: true })
string3 = '';
@property({ type: 'number', required: true })
num2 = 0;
@property({ type: 'string', required: true })
string4 = '';
@property({ type: 'string', required: true })
string5 = '';
}
This conversion needs to be done several times, and it seems like there should be a more efficient tool available for this task!
In essence, adding a @property marker with the appropriate type...
@property({type: 'string', required: true})
At the beginning of each variable declaration, followed by assigning a value. Even though, maintaining its original type as seen in the old code may work as well.
Are there any tools or extensions in Visual Studio Code that can aid me in swiftly reformatting these model definitions? While I am familiar with multi-cursor and search-replace functions, any suggestions on quicker methods would be greatly appreciated.
So far, I have mostly relied on using multi-line selections and find-replacing techniques - which are more efficient than manually adjusting each field. My online searches have not yielded new solutions, suggesting that either I am not articulating my requirements clearly to the search engine, or that the tool I seek might not exist yet.