Top "Type-safety" questions

Type safety is the extent to which a language discourages using variables in an unsafe manner, according to the variables' type.

What is type-safety?

I had a brainbench exam recently, got high mark, but there were a couple of questions which were hard for …

.net testing type-safety brainbench
Why does the Swift language guide suggest using Int "even when values are known to be non-negative"?

This is a question about programming style in Swift, specifically Int vs UInt. The Swift Programming Language Guide advises programmers …

types coding-style swift type-safety
Type of angular components

Can I refer to angular component class as a type? I see Ionic uses any for components. Is it possible …

angular typescript type-safety
Typescript: declare that ALL properties on an object must be of the same type

In Typescript you can declare that all elements in an array are of the same type like this: const theArray: …

typescript types interface type-hinting type-safety
java generics - cast to List<SomeType> issues unchecked cast warning while cast to SomeType not

Why this : public <T> List<byte[]> getData(T data) { Location loc = (Location) data; // ... } does not generate …

java generics casting type-safety code-design
Generics and sorting in Java

Suppose you write a static function in Java to sort an array, much like Arrays.sort(). The problem with Arrays.…

java generics sorting type-safety
What is the meaning of the type safety warning in certain Java generics casts?

What is the meaning of the Java warning? Type safety: The cast from Object to List<Integer> is …

java generics warnings casting type-safety
Java generics: why someObject.getClass() doesn't return Class<? extends T>?

I would expect that from the aspect of compile time as well as from the aspect of runtime it wouldn't …

java class generics types type-safety
Typesafe Javascript

Is there a way to enforce types in JavaScript? I'm thinking of a pre-processor which takes an input file written …

javascript compiler-construction interface type-safety
Is there a way to represent a non-negative integer in TypeScript so that the compiler would prevent using fractions and negatives?

The number is a very loose representation which sometimes is required to be tighten. In my case I wish a …

typescript type-safety