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

Unsafe construction of an any type value. #69

Closed
david-tejada opened this issue Mar 24, 2022 · 5 comments
Closed

Unsafe construction of an any type value. #69

david-tejada opened this issue Mar 24, 2022 · 5 comments

Comments

@david-tejada
Copy link

david-tejada commented Mar 24, 2022

I'm getting this linting error in options-storage.ts. I want to use typescript and I just changed the files extensions to .ts like indicated. I also added @sindresorhus/tsconfig and eslint-config-xo-typescript. It's strange because if I hover over the error I get the type information. And if I assign the result of the call to new OptionsSync({...}) to a variable and I hover over it I get the type information:

const options: OptionsSync<{
    colorRed: number;
    colorGreen: number;
    colorBlue: number;
    text: string;
}>

I don't know why it keeps saying that it is of type any

@david-tejada
Copy link
Author

Another similar example, it's really strange because it clearly says that colorRed is of type number:

Screenshot 2022-03-25T13-30-05 - Code

@fregante
Copy link
Owner

I don't know why it keeps saying that it is of type any

I don't know either! I was able to replicate the issue but it went away after I updated the XO extension to v3.9.0. This is an IDE error, not a project error; Try running npm run lint and the error won't appear there.

Additionally make sure:

  • you installed typescript itself in the project
  • you created the tsconfig.json at the root of the project as suggested by @sindresorhus/tsconfig

@fregante
Copy link
Owner

Screen Shot

@david-tejada
Copy link
Author

Thanks for your help! In my case I also got the errors running npm run lint. I also hadn't install typescript in the project, but that didn't solve the issue. What I was missing was the tsconfig.json file. Once I created the file and reloaded the window all the errors went away.

@aspiers
Copy link

aspiers commented Apr 10, 2022

A similar problem happens even with tsconfig.json, as described in #71.

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

3 participants