#How do I disable TypeScript altogether?

18 messages · Page 1 of 1 (latest)

drifting saddle
#

I'm loving Payload, but I hate TypeScript. In the docs I saw mention of a "JS Version". How do I configure Payload so I can use only JS?

broken hollyBOT
old ridge
#

I think on installation there's an option to use TypeScript in the project

drifting saddle
#

@old ridge Yes, I saw that in the docs as well, but the option did not appear when I was creating my project via the CLI>

somber crow
#

I think it's enough to just, well, delete the tsconfig file, uninstall typrscript in your project and rename all files to .js

#

Then you can also use node instead of ts-node to run your project

#

Don't think there is anything in payload which requires you to use TypeScript

drifting saddle
#

@somber crow Aces. I'll give that a try. Thanks for taking the time.

drifting saddle
#

@somber crow Okay, my initial experimentation with the "rip it out" approach you described has hit some snags.

#

First, I need to add type: module to the package.json file in order to use import. But, that causes an issue in the Payload Core where require is being used to bring an instance of node-fetch into the /node_modules/payload/dist/uploads/getFileByURL.js module.

#

Seems that TS may be a hard dependency after all. Shame. I really like Payload. But I hate TS more.

bronze perch
#

It doesn't work because you are trying to use ES Modules through type: module when payload depends on CommonJS. It's not an issue in TS, because TS also acts as transpilation to CommonJS. That's not a hard dependency on TS though, other transpilers can do that job as well.

rose marlin
#

^^ @bronze perch nailed it

#

@drifting saddle you should certainly be able to run Payload without TS, it's not an intrinsic relationship

#

but you'll need some sort of transpiler, as the Payload config supports React components which Node can't run on its own obviously

drifting saddle
#

@bronze perch Ah, I see. So if I go with JS-mode then I should use require('cjs-module-name') instead of import?

#

@bronze perch Roger. Good to know.

#

Do you have an any docs or examples that illustrate the best practices and transpiler config that I could use to make this a reality?