Closed pinkasey closed 3 years ago
To support typescript today, you should be able to compile your ts files, then use the —path
fireway flag to point to the compiled directory. While writing these scripts, you won’t have intellisense for the preconfigured Firestore instance. To support that, typescript needs a way to define types for the exports of all files in a directory.
I don’t use typescript in my day-to-day, so I’m open to PRs for code changes/docs if anyone is interested in exploring.
Right! That makes perfect sense! I'll try that. I think I know how to add type information too.
I'll open a PR when I'm done (documentation only, probably), but that might take a while. Thanks!
Luke Edwards's ley
library has an interesting solution to this. It would require ts-node
and look something like:
$ fireway --require ts-node/register migrate
Type annotations could be defined manually in the file w/ ts or jsdoc.
This is resolved in 0.5.1
. See the docs for usage. It works directly with TypeScript or JSDoc, if you prefer.
Hi @kevlened thanks for a great project. I'm aware you don't use typescript on the regular, but I'm having difficulty with using this with ts-node
.
I'm using your simple example to get started, but get the following error when running $ fireway --require ts-node/register migrate
:
export function migrate(_a) {
^^^^^^
SyntaxError: Unexpected token 'export'
I have tracked this down to a setting in my tsconfig.json
- compilerOptions.module: "esnext"
doesn't work (it does with commonjs
, but this is required by react-app-rewired that I'm using for my firebase project
@fringley Thanks for the support. I modeled the TS integration after the ley project. They included an extra step in their TS setup that I omitted, because it wasn’t necessary for my tests. Here are their steps: https://github.com/lukeed/ley#typescript. The step I omitted is below. Add this to your tsconfig.json
and let me know if it helps:
{
"ts-node": {
"transpileOnly": true,
"compilerOptions": {
"module": "commonjs"
}
}
}
@fringley I'll assume that fixed your issue. I've documented the extra step in the README. If you still have trouble, let me know.
I'm not a very good with javascript/typescript, so maybe I'm talking nonsense.
It would be lovely to be able to write the migration scripts in typescript. I've tried it, and got a syntax error when trying to
import
.Is it possible to support typescript?