Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

// import "github.com/some/typedefine.ts" #57

Open
chen-bao-x opened this issue Sep 17, 2024 · 0 comments
Open

// import "github.com/some/typedefine.ts" #57

chen-bao-x opened this issue Sep 17, 2024 · 0 comments

Comments

@chen-bao-x
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant