#js to ts nextjs

10 messages · Page 1 of 1 (latest)

rotund scroll
#

how do i convert my app to ts

errant pivotBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

haughty violet
#

If you created the app via
“create-next-app” it comes with TypeScript preconfigured, you can check this by finding a tsconfig.json in the root directory of your project

#

And checking of you have the TypeScript package installed in package.json under “devDependencies”

In case you already have TypeScript set up but you don’t use it, it’s just matter of switching the file extensions from “.js” and “. jsx” to “.ts” and “.tsx”

vapid inlet
# rotund scroll how do i convert my app to ts

at the end typescript is just typed javascript.
So instead of having a plain variables like:

const variables = 'hello world'

You can "type" this javascript variables:

const variables: string = 'hello world'

Now as you can see, typescript expect the variable to be a string. Make sure to change your file as well (you either want to have .ts or .tsx)
And if you are using stuff like tailwind, make sure to change it inside your config as well

vapid inlet
#

@rotund scroll solved?

rotund scroll
#

yes

vapid inlet
errant pivotBOT