Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

TypeError: Property name expected type of string but got null #300

Open
andresesfm opened this issue Aug 17, 2021 · 0 comments
Open

TypeError: Property name expected type of string but got null #300

andresesfm opened this issue Aug 17, 2021 · 0 comments

Comments

@andresesfm
Copy link

Hello, I ran into this problem I hope this fix can be implemented or the solution helps with the migration by hand
Flow file:

export const MyEnum = {
    birthday: "birthday",
    zip: "zip",
};
export type MyType = {|
  // ...    
userErrors: {
        [type: $Keys<typeof MyEnum>]: string, // <--- this makes it fail
    },
|};

TS file:

//...
userErrors: {
        [key in keyof typeof MyEnum]: string; // <--- My manual translation to TS
    };

Error thrown:

TypeError: Property name expected type of string but got null
    at Object.validate (MY_PROJECT/node_modules/@khanacademy/flow-to-ts/node_modules/@babel/types/lib/definitions/utils.js:160:13)
    at validateField (MY_PROJECT/node_modules/@khanacademy/flow-to-ts/node_modules/@babel/types/lib/validators/validate.js:24:9)
    at validate (MY_PROJECT/node_modules/@khanacademy/flow-to-ts/node_modules/@babel/types/lib/validators/validate.js:17:3)
    at builder (MY_PROJECT/node_modules/@khanacademy/flow-to-ts/node_modules/@babel/types/lib/builders/builder.js:38:27)
    at Object.TSTypeParameter (MY_PROJECT/node_modules/@khanacademy/flow-to-ts/node_modules/@babel/types/lib/builders/generated/index.js:1202:31)
    at MY_PROJECT/node_modules/@khanacademy/flow-to-ts/src/transform.js:568:35
    at Array.forEach (<anonymous>)
    at Object.exit (MY_PROJECT/node_modules/@khanacademy/flow-to-ts/src/transform.js:558:16)
    at NodePath._call (MY_PROJECT/node_modules/@khanacademy/flow-to-ts/babel-traverse/lib/path/context.js:55:20)
    at NodePath.call (MY_PROJECT/node_modules/@khanacademy/flow-to-ts/babel-traverse/lib/path/context.js:42:17)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant