I would like to test out building out a shopify app using Typescript by starting with the shopify-app-cli boilerplate, which uses Koa as a server and Nextjs for the front end react javascript.
see https://github.com/Shopify/shopify-app-cli
I am having trouble getting the typescript code compiling for both the server and the nextjs frontend code.
Changes:
All of the file extensions to be either
.tsxor.ts. instead of.jsIn package.json, changed "dev" script to use ts-node instead of using
nodemon
before
"dev": "NODE_ENV=development nodemon ./server/index.js --watch ./server/index.js",
after
"dev": "NODE_ENV=development ts-node server/server.ts",
I can get it to compile the server.ts file, however if i change the nextjs files pages/_app.js and pages/index.js to .tsx it can't find them and has this error:
[ event ] client pings, but there's no entry for page: /
This is the tsconfig.json file have set up.
{
"compilerOptions": {
"target": "es6",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "commonjs",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "react"
},
"exclude": ["node_modules"],
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"]
}
also a gist of server.ts, https://gist.github.com/azrielh/73ac202fcce5ce32f19488e4ef5df263.js