Is it possible to wrap it with simple typings for TypeScript?
See original GitHub issueTrying to use tcomb-form-native with typescript.
import * as t from 'tcomb-form-native';
let Form = t.form.Form;
Error:(3, 20) TS2656: Exported external package typings file ‘…/node_modules/tcomb-form-native/index.d.ts’ is not a module. Please contact the package author to update the package definition.
Error:(17, 14) TS2339: Property ‘form’ does not exist on type ‘typeof ‘tcomb-form-native’’.
Please suggest simple index.d.ts. Somehow wrap all in “any”? My newbie attempts didn’t help:
declare module 'tcomb-form-native' {
import * as React from 'react';
class Form extends React.Component<any, any> {
}
let t: any;
// if the module has a default export
export default t; // where t is the actual default export
/* Definistions from tcomb lib */
type Predicate<T> = (x: T) => boolean;
type TypeGuardPredicate<T> = (x: any) => x is T;
interface Type<T> extends Function {
...
}
No success even with this article: https://templecoding.com/blog/2016/03/31/creating-typescript-typings-for-existing-react-components/
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:6
Top Results From Across the Web
Typescript object wrapping, typings and generics [duplicate]
It gives the possibility to keep clever typings and mainly code completion when using some dynamic patterns. Now, it's still a choice to...
Read more >Documentation - Advanced Types - TypeScript
This page lists some of the more advanced ways in which you can model types, it works in tandem with the Utility Types...
Read more >The definitive guide to typing functions in TypeScript
The definitive guide to typing functions in TypeScript ; Below is a simple function called subtraction ; This subtraction ; When we paste...
Read more >A typed chain: exploring the limits of TypeScript
Update (2020): it is now possible to correctly type _.chain by overloading the type of this on the wrapper interface. This is how...
Read more >How to Use Wrappers in Typescript React - Twilio
With that said, how can you write code as efficiently and clean as ... how to use wrappers for custom components in a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Can we integrate this into the library? Most people are using typescript these days and not having typings for this is a big inhibiter in usage. Thanks in advance.
tcomb-form-native.d.zip
Here is tcomb-form-native.d.ts
It is just cheating TS compiler…
Put it into:
.\typings_local\tcomb-form-native.d.ts
then install with typings by command:
typings install --save --global file:.\typings_local\tcomb-form-native.d.ts
Using it with https://auth0.com/blog/2016/06/15/adding-authentication-to-react-native-using-jwt/ https://github.com/jeffreylees/reactnative-jwts/blob/master/index.ios.js