1

We've got a React app that's using create-react-app-typescript to add Typescript support within our solution and this has been working fairly well.

However, now that Typescript is supported natively by Create React App, I'm attempting to migrate the project and did so semi-successfully by following the blog post as recommended in the Create React App docs.

I'm getting several Typscript errors on build, which I'm working through currently, but there's a couple that I'm not sure how to best resolve.

The docs state the following note in regards to support for constant enums and namespaces...

Note: Constant enums and namespaces are not supported.

Does anyone have any migration suggestions when it comes to constant enums and namespaces i.e. any preferred alternatives?

Any advice much appreciated!

1 Answer 1

-4

Does anyone have any migration suggestions when it comes to constant enums and namespaces i.e. any preferred alternatives?

Constant Enums

Delete the const keyword.

Old:

const enum ___

New:

enum ___

Namespaces

They are just the revealing module pattern. Transfer to raw JavaScript.

Old:

namespace X {
  __
}

New:

const X = (function(){
  ___

  return {___}
})()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.