Intro Flashcards

1
Q

What is a type System?

A

A set of rules to assign a property called a type to the constructs of a computer program.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the main purpose of a type system?

A

Reduce possibilities for bugs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How does a type System prevent bugs in a computer program?

A

By defining interfaces between the parts of the computer program.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How type Systems check that the parts have been conected in a consistent way?

A

Statically ( at compile time )
Dynamically ( at run time )
or… a combination of Both

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is typeScript?

A

A strict superset of Javascript that adds optional static typing to the lenguage.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are the two main goals of TypeScript?

A
  • Provide an optional type system for JavaScript.

- Provide planned features from future JavaScript editions to current JavaScript engines.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Why add types to JavaScript?

A

Types have proven ability to enhance code quality and understandability.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is refactoring?

A

Improving the design of existing code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Why is that Types are one of the best forms of documentation you can have?

A

Because The function signature is a theorem and the function body is the proof.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

TypeScript is Javascript?

A

False. Typescript is a superset of Javascript.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Why is type inference well motivated?

A

Typescript do this to give type safety.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Why types can be implicit?

A

Typescript will infer a type if is not specified, but it cannot be change in the future.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Why would Typescript use annotations?

A
  • To document stuff and read later in the code.

- To match the developer understanding with the compiler understanding of the algorithm.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Why types can be Explicit?

A

Because we can strongly specify the types manually in the interfaces of the program.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is nominally?

A

In name only, perhaps not in reality.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is duck typing?

A

The type or the class of an object is less important than the methods it defines.

17
Q

Why types are structural?

A

Because the code has to be arranged in a specific way.

18
Q

What does ir mean ‘Type errors do not prevent Javascript emit’ ?

A

Typescript will emit valid javascript the best that it can.

19
Q

Como se le conoce a este patron?

let idUser: number | string;

A

union type

20
Q

Como se le conoce a este patron?

type squareSize = ‘100x100’ | ‘500x500’
let img1 : squareSize ;

A

Alias type

21
Q

Que es asercion de tipo?

A

Es decirle al compilador “se lo que estoy haciendo”

22
Q

Cuales son las dos sintaxis de aserciones de tipos?

A

Variable as tipo

23
Q

Que hace este codigo?

let message: string = (username.length) > 5

A

La sercion de forza el tipo de username a que sea tipo string