Closed elongl closed 10 months ago
Ohhh, you're right.
Didn't notice the Flow typing. This should remain.
And the current setup does not support TypeScript, just adding index.d.ts
would do the job.
I'll edit my branch and then I'd appreciate it if you merge.
But even with your branch, don't the Flow types in index.ios.js
confuse TypeScript?
I think probably for full TS support I should add a postpublish hook that does a babel transpilation to pure JS?
I believe you need to do this, unless React Native has built in Flow type stripping, even if you just want to use JS and not necessarily TS.
Worth mentioning, the new package worked for me just by adding the index.d.ts
file.
Just describe the default export of the module.
@nickmccurdy Yes, agreed. It was my mistake of not thinking outside the default stack RN promotes, which generally does have Flow support. I'll get that and a few other changes I've had in mind into the project and bump the version.
I'm just curious how @elongl is having success with TS despite the Flow types. Maybe a build pipeline which has Babel with flow-strip-types, then feeding into TS or something..?
TypeScript declaration files tell the typechecker to completely ignore the source file.
Isn't TS pretty much always used as a transpiler as well as a typechecker though? Or has this changed with Babel 7?
Yes, but the compiler will see the Flow syntax, not the typechecker.
So you'd expect this to report no type errors, but give a syntax error when it comes to compiling?
@elongl Could you confirm whether your project actually compiles and runs successfully?
I'm not sure, it depends on React Native's build process and how a TypeScript user would set up their build process.
@jamesisaac Yes it does.
You're more than free to clone this project, add the index.d.ts
file to the module in node_modules
and see for yourself. It recognizes the typing and simply suggests it for me as I code.
Everything compiles and runs well. I genuinely invite you to try it, just to make sure that I'm not missing something. As far as I see it, no problem.
Thanks, will give it a look over when I get a chance.
Yup this would be a good addition, thanks. Although of course want to support both Flow and TypeScript, so shouldn't be deleting the existing
types.js
file.Also, does the current project setup actually work with TypeScript, given that the Flow types are baked into the code? I think probably for full TS support I should add a postpublish hook that does a babel transpilation to pure JS?