microsoft / react-native-tscodegen Goto Github PK
View Code? Open in Web Editor NEWGenerate react-native turbo modules using TypeScript
License: Other
Generate react-native turbo modules using TypeScript
License: Other
There are a number of places in the file with the following pattern:
function translateSpecFunctionParam(
param: FunctionTypeAnnotationParam,
): string {
switch (param.typeAnnotation.type) {
...
case 'ReservedFunctionValueTypeAnnotation':
if (param.typeAnnotation.name !== 'RootTag')
throw new Error(
`Unknown reserved function: ${param.typeAnnotation.name} in translateSpecFunctionParam`,
);
return 'double';
...
}
}
The TypeScript compiler seems to always evaluate param.typeAnnotation.name
to the 'RootTag' literal, so it believes we will always throw an error in this case. Unsure if this is an issue with tscodegen typings or faulty logic in GenerateNM2.
We should expand the README to include how to install this package as @types/react-native:
I believe this works with many NPM package managers:
"@types/react-native": "npm:[email protected]",
Why were the types published as 0.67.0? Wouldn't it have been better to align with @types/react-native versioning?
After setting everything up, hopefully, properly I try to use the library in an example application.
my react-native-tscodegen.json
{
"libraryName": "NativeMultiplyModule",
"outputDirectory": "./lib/cpp-generated",
"moduleSpecName": "NativeMultiplyModuleSpec",
"inputFile": "./src/turboModule.ts",
"generators": ["modulesCxx"]
}
my ./src/turboModule.ts
import { TurboModule, TurboModuleRegistry } from 'react-native-tscodegen-types';
export interface Spec extends TurboModule {
multiply(a: number, b: number): number;
}
export default TurboModuleRegistry.getEnforcing<Spec>('NativeMultiplyModule');
my stacktrace
[Tue Nov 23 2021 15:56:12.587] BUNDLE ./index.tsx
[Tue Nov 23 2021 15:56:14.170] ERROR Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'NativeModules' could not be found. Verify that a module by this name is registered in the native binary.
[Tue Nov 23 2021 15:56:14.180] ERROR Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)
[Tue Nov 23 2021 15:56:15.440] ERROR Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)
is there a config key I am missing that says the name?
Hi!
I have been messing around a bit with this library and everything seems to be working fine but I am not too sure on how to continue.
I have created a project with bob, to create a cpp turbomodule library for RN, and generated the lib
via the provided example config. Everything works and the cpp code seems to be generated correctly.
However, since the demo application is out yet, I do not see where I would write my cpp implementation of the generated function. It does not help that my cpp is quite lacking, but I just could not figure it out.
tl;dr:
cheers!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.