-
Notifications
You must be signed in to change notification settings - Fork 9
[2025-11-17] Czy wiesz, że TypeScript ma typ bezpieczniejszy niż Any? #274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
| layout: post | ||
| title: Czy wiesz, że TypeScript ma typ bezpieczniejszy niż Any? | ||
| description: "" | ||
| date: 2025-11-17T08:00:00+01:00 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data się jeszcze zmieni
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jbc sam to w canvie utworzyłem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
poprawie bo logo ts musi być bardziej przesunięte do lewej
| Na pierwszy rzut oka typy `any` i `unknown` wyglądają podobnie. Oba pozwalają przypisać do siebie dowolną wartość. To, co możesz potem z tym zrobić, nieco się różni. | ||
|
|
||
| ### Typ any – "nie wiem i nie interesuje mnie to" | ||
| Typ `any` wyłącza sprawdzanie typów dla danej zmiennej w TypeScript. Kompilator nie sprawdza, co przypisujesz i jak używasz tej zmiennej. Możesz zrobić z nią wszystko, a ewentualny błąd zobaczysz dopiero w trakcie działania aplikacji. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wydaje mi się, że powinniśmy stosować formę wieloosobową lub bezosobową.
przypisujesz → przypisujemy, ew. jest przypisywane.
Jest niespójność. Raz tekst jest w pierwszej osobie raz w liczbie mnogiej
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ogarne
| case 'square': | ||
| return 4; | ||
| default: | ||
| // Jeśli dodasz nowy kształt, taki jak 'triangle', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tutaj też w komentarzach zmieniłbym formę. dodasz -> dodamy, itd
|
|
||
| ## Kiedy i co wybrać? | ||
| - **unknown** – używaj, gdy nie znasz typu danych (np. odpowiedź z API). To bezpieczny wybór, który wymusza weryfikację typu przed użyciem. | ||
| - **any** – najlepiej unikać `any` całkowicie. Wyłącza ono sprawdzanie typów, co jest głównym celem TypeScriptu. Włącz w konfiguracji tryb strict, a dla nieznanych typów stosuj bezpieczniejszy `unknown`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
strict zamiast strict
| - typescript | ||
| --- | ||
|
|
||
| W TypeScript, poza `string` czy `number`, mamy też kilka specjalnych typów do obsługi sytuacji, gdy nie znamy typu danych. Przyjrzyjmy się im z bliska. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
przejrzałem całe, nie mam uwag :) (poza tym, żeby wszystko ujednolicić i przepisać w liczbie mnogiej, z tym się zgadzam)
No description provided.