preact-cli: TypeError: Cannot read property 'flags' of undefined

Do you want to request a feature or report a bug? A Bug

What is the current behaviour? Running yarn run build when installing @types modules breaks the build.

After installing the Typescript template, I’m trying to install styled-components, all goes fine until I install @types/styled-components.

If the current behaviour is a bug, please provide the steps to reproduce.

  1. preact create typescript my-project
  2. yarn add styled-components
  3. yarn add -D @types/styled-components
  4. yarn run build
  5. INTERNAL ERROR: Cannot read property 'flags' of undefined

What is the expected behaviour? Being able to install @types packages.

OS: macOS 10.15.3 Terminal: Hyper 3.1.0 Shell: zsh Node: v13.8.0 npm: 6.13.7 preact-cli: 2.2.1

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 4
  • Comments: 16 (10 by maintainers)

Commits related to this issue

Most upvoted comments

@RyanChristian4427 wrote:

As @mdziekon is removing Jest, it is fine for that to be removed from the template.

My PR does not remove Jest, but it replaces outdated render spy with Enzyme integration. Just wanted to clarify that to prevent any false assumptions.

Does anyone know if the declaration.d.ts file is still needed? According to the TypeScript’s documentation, TS is able to pick the right JSX declaration from the factory function in use (https://www.typescriptlang.org/docs/handbook/jsx.html#factory-functions), so when using h it will automatically look for h.JSX which is defined in preact’s type definitions (similar story with createElement in compat mode).

As far as I can tell, removing this from a newly created project does not break anything, so unless there’s any other reason for having these re-declarations, could this simply be removed to get rid of the tssserver problem?

I added that, and it was just to allow the test lib to run. Nothing more. Definitely get rid of it. It was a temporary hack so all parts of the template “worked”.

Commenting out the lines in src/declaration.d.ts made the error go away. But removing the lines might break something else.

It seems to be an issue with typescript itself. There is an open issue in typescript for the same.

Reference link: https://github.com/microsoft/TypeScript/issues/37165