// import "github.com/some/typedefine.ts"
Closed this issue · 1 comments
Problem
Difficulties I often encounter when writing json:
What properties can be configured in this configuration file?
What type of value does a property require?
What does this attribute do?
I hope that when I write json5, if a property requires a value of type number and I write a string to it, VS code will tell me there is an error, and this property requires a value of type number.
When writing json, vs code will not prompt me.
I hope that when writing json5, if a property requires a certain type of Object, I press ctrl + space vs code to remind me which properties it has that I need to assign to it.
Solution:
json5 adds the 'import' function, such as this:
// import "github.com/chen-bbao-x/typedefine.ts"
// type_define.ts
type root = {
value_1: number;
value_2: string;
value_3: {
value_1: Array<any>;
};
};
// implement.json5
// After importing `type-define.ts`, you can do type checking.
// import "github.com/chen-bbao-x/typedefine.ts"
{
value_1: 1111,
value_2: "str",
value_3: {
value_1: ["element1"],
},
}
In this way, the json5 language server can remind me what attributes I need to fill in and what types of these attributes are.
Yes, I can view the comment on a certain attribute in the type definition.
This will save a lot of time for me to check documents.
Thank you for your interest in JSON5. Unfortunately, there is no official JSON5 language server for Visual Studio Code. If you are using an unofficial language server, please ask this question on their repository.