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

[Ready] Remove deprecated functions #28

Merged
merged 2 commits into from
Sep 7, 2021
Merged

[Ready] Remove deprecated functions #28

merged 2 commits into from
Sep 7, 2021

Conversation

ying-jeanne
Copy link
Collaborator

This is to fix issue #25

@@ -456,7 +456,7 @@ func (g *generator) genInterface(name string, v cue.Value) {
// place in the body of the generated typescript interface. (Or nil, if
// there's no body to generate.)
for fields != nil && fields.Next() {
if fields.IsHidden() {
if fields.Selector().PkgPath() != "" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this the new canonical way to tell if a field is hidden? It seems like this is checking something else

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked the code comments.

// IsHidden reports if a field is hidden from the data model.
//
// Deprecated: use i.Selector().PkgPath() != ""

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the test it seems behaving the same, https://github.com/ying-jeanne/cue_test_cases/blob/d4c23b79200cc30d5a102b9ee90ad197e03da218/test2.go.

When fields are hidden, there pkgpath is _ instead of empty

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha, thanks for the thoroughness! i'll chalk this up to some kinda continued awkwardness in the CUE APIs around hidden fields

encoder/generator.go Outdated Show resolved Hide resolved
@@ -40,8 +41,8 @@ func TestGenerate(t *testing.T) {

for _, c := range cases {
t.Run(c.Name, func(t *testing.T) {
var r cue.Runtime
i, err := r.Compile(c.Name+".cue", c.CUE)
ctx := cuecontext.New()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm... no change necessary for this PR, but i wonder if public cuetsy functions should start taking a context argument and using it to decide things like how far we dereference a structure

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds nice, :) just saw that we can pass the scope parameter, probably able to do it that way.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

created a new ticket #29

@ying-jeanne ying-jeanne linked an issue Sep 6, 2021 that may be closed by this pull request
@ying-jeanne ying-jeanne added this to the 8.2.0 milestone Sep 6, 2021
@sdboyer sdboyer merged commit 3d682cc into main Sep 7, 2021
@sdboyer sdboyer deleted the 25 branch September 7, 2021 01:16
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

Successfully merging this pull request may close these issues.

Migrate cuetsy to cue 0.4.0 remove the deprecated functions
2 participants