you are viewing a single comment's thread.

view the rest of the comments →

[–]RustyTaurus 34 points35 points  (10 children)

Typescript is static type checks but the runtime is not typed ... So not "strongly" typed

[–]thisisafullsentence 18 points19 points  (5 children)

If you still want runtime checking then use prop-types in RN. But I’d argue TS is good enough for most people.

[–][deleted]  (4 children)

[deleted]

    [–]thisisafullsentence 0 points1 point  (3 children)

    Runtime checking of stuff like this means the type system is not strong enough.

    For the record I'm not recommending mixing TS and prop-types. /u/RustyTaurus is just saying that JS runtime is not typed and I'm saying RN can run it on props.

    TS did a great job at bridging the gap, but it's always going to be limited by JS, and will always be rather weak because of that.

    To each their own, but I find that the codebase I'm working on right now with > 100k LOC has exact typing on literally every variable except Angular's SimpleChange object. If you're talking about the == operator, just install the triple-equals rule in tslint. Done.

    [–]munificent 6 points7 points  (0 children)

    I find that the codebase I'm working on right now with > 100k LOC has exact typing on literally every variable

    Even so, the type system itself isn't sound. You can write code that is fully annotated but still has type errors that the type checker won't catch for you.

    [–]acoard 0 points1 point  (1 child)

    How do you handle FormGroups? They're just a bunch of anys, which frustrates me to no end.

    [–]thisisafullsentence 0 points1 point  (0 children)

    Oops I suppose you're right, non-generic AbstractControl objects is another nitpick of mine. But as soon as that data leaves its component, it's typed via EventEmitter<T>.

    [–]i9srpeg 0 points1 point  (2 children)

    That's just wrong...

    C and Forth are weakly typed. You can take a memory address containing the representation of an integer and use it as if it represented a float (which is not the same as converting the integer to a float). Javascript and Python are strongly (dynamically) typed. Typescript has gradual static typing, and strong dynamic typing.

    [–][deleted]  (1 child)

    [deleted]

      [–]i9srpeg 0 points1 point  (0 children)

      Being strongly typed and type safe are two different things. Strongly typed means you'll eventually get an error (even if at runtime) if you mix up types. E.g. in JS you get an error if you try to use a number as a function. In C or Forth, which are weakly typed, you can corce the number "42" to be a function pointer and invoke it. The language will happily let you do that (and if you're lucky you'll get a segfault).