parent
5ccdece429
commit
a1037d1db2
98 changed files with 4683 additions and 7121 deletions
@ -1,26 +0,0 @@ |
||||
# Type Assertions |
||||
|
||||
Type assertions in TypeScript are a way to tell the compiler to treat a value as a specific type, regardless of its inferred type. |
||||
|
||||
There are two syntaxes for type assertions in TypeScript: |
||||
|
||||
- The "angle-bracket" syntax: `<T>value` |
||||
- The "as" syntax: value as `T` |
||||
|
||||
For example: |
||||
|
||||
```typescript |
||||
let num = 42; |
||||
|
||||
// using angle-bracket syntax |
||||
let str = <string>num; |
||||
|
||||
// using as syntax |
||||
let str2 = num as string; |
||||
``` |
||||
|
||||
In both examples, `num` is a number, but the type assertions tell the compiler to treat the value as a string. |
||||
|
||||
Learn more from the following links: |
||||
|
||||
- [@article@Type Assertions](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#type-assertions) |
@ -0,0 +1,95 @@ |
||||
{ |
||||
"typescript": "KDd40JOAvZ8O1mfhTYB3K", |
||||
"typescript:typescript-vs-javascript": "MQWzN_kXxVJMOYbRXSGJc", |
||||
"typescript:ts-js-interoperability": "dcLaEU_lb0z_QypL1ZhpX", |
||||
"typescript:install-configure": "dA8CNQOgJRDa0T7rmyS7f", |
||||
"typescript:install-configure:tsconfig-json": "DmqrX56d9KnBcOSwlJR2q", |
||||
"typescript:install-configure:compiler-options": "RrExVb7l2gd0s_TlNdLeD", |
||||
"typescript:running-typescript": "qdy4ZIY2EKgmPNdu_ndcg", |
||||
"typescript:running-typescript:tsc": "Iv_t13PSVzet5VPKFtAp1", |
||||
"typescript:running-typescript:ts-node": "ZCM2_X4BiKh5FTCizrr-E", |
||||
"typescript:running-typescript:ts-playground": "_bZ71i36haWgHQTY0yMOx", |
||||
"typescript-types": "qcrGApxNzkGYxgcd7o45d", |
||||
"typescript-types:type-assertions:as-const": "pGFnTqi0-RSj0YRmNA5iy", |
||||
"typescript-types:type-assertions:as-type": "Ba0baUbomrW9td_K8U-5L", |
||||
"typescript-types:type-assertions:as-any": "afTNr36VqeXoJpHxm2IoS", |
||||
"typescript-types:type-assertions:non-null-assertion": "mjaL5ocLnM8VQlhUxW6KU", |
||||
"typescript-types:satisfies-keyword": "HD1UGOidp7JGKdW6CEdQ_", |
||||
"typescript-types:boolean": "hfIHxa5i_5rEpjtzqEsic", |
||||
"typescript-types:number": "UH9d3cvGy_e67WFNFwCyf", |
||||
"typescript-types:string": "d8iV-IBZ6cSnH8Z5_HRmc", |
||||
"typescript-types:void": "yLlQg7BF--ZwRHbXBWfOi", |
||||
"typescript-types:undefined": "Sa6IZtM4XJstultz-pbh0", |
||||
"typescript-types:null": "cjAwawhZLo1qVQ93XIdm2", |
||||
"typescript-types:interface": "mVKsM7R4Ivpdhnbwt1aRb", |
||||
"typescript-types:class": "tTSITP1W1ymS-njbFb8Ts", |
||||
"typescript-types:enum": "bfZIXHceDKDGQl-24kQpT", |
||||
"typescript-types:array": "YbDuIo1BbZKEAZwmXlCdZ", |
||||
"typescript-types:tuple": "jq-GD0DLyzrEXQKUmt5kv", |
||||
"typescript-types:any": "yXiLegSlL7SveU8rBGj8U", |
||||
"typescript-types:object": "vnqvm_WiaKqpdxrW4wRGa", |
||||
"typescript-types:unknown": "O2TYbd9i_OQwQk2dKh-ly", |
||||
"typescript-types:never": "0pi9VTbngcAIswuu5LIYg", |
||||
"type-inference": "KUur-gfOBQodTS-irFet7", |
||||
"type-compatibility": "alMJCEyUZ90xz-2_g3YRj", |
||||
"combining-types": "qefnsugcveizVq2TORRgn", |
||||
"combining-types:union-types": "5z5w3yv1HbOpMlzEd4Iot", |
||||
"combining-types:intersection-types": "RWYXEZMODUrqwRWf_Lqi9", |
||||
"combining-types:type-aliases": "M_3O21zjppgWptIT5dtu8", |
||||
"combining-types:keyof-operator": "t1Tcesfq7bV2TkHcfD6lU", |
||||
"type-guards": "cFZsxpYHDxm7IWwergb3r", |
||||
"type-guards:instanceof-operator": "EDOU5a7UK17yp3PdFBJMc", |
||||
"type-guards:typeof-operator": "ZiOcFZy85p7tLzUkyKDei", |
||||
"type-guards:equality": "Wy2yIK5vgLjEcc9VjuQK5", |
||||
"type-guards:truthiness": "Xonbxc7MvMEonKBvbkCAH", |
||||
"type-guards:type-predicates": "1DOSAieOmWUNNsQQrqf2m", |
||||
"functions": "qOynVkDi1gFz0mxyJHjfJ", |
||||
"functions:typing-functions": "9FIhHwDNzyKpb42NmSv3K", |
||||
"functions:function-overloading": "-0Zp6b8NjDyz9MAQE3HfS", |
||||
"interfaces": "aH1DxiG5xrdNlKutJ_gTz", |
||||
"interfaces:types-vs-interfaces": "TxkEpoOiuUm-fXJuFVKcH", |
||||
"interfaces:extending-interfaces": "O-9WQqidujLIEOTcOfy4n", |
||||
"interfaces:interface-declaration": "fY40W8prpgiNqRL50w7ub", |
||||
"interfaces:hybrid-types": "lvtTSHH9yBTCiLng8btnI", |
||||
"classes": "ib0jfZzukYOZ42AdJqt_W", |
||||
"classes:constructor-params": "3XrKbK5Od2eoM0BLaS4kU", |
||||
"classes:constructor-overloading": "oxzcYXxy2I7GI7nbvFYVa", |
||||
"classes:access-modifiers": "RJ7on8WoxrKcXrR3qY5Rs", |
||||
"classes:abstract-classes": "tZFWeWHdOUJcCEtHfXH9p", |
||||
"classes:inheritance-vs-polymorphism": "8P0-vb9nlnmz7iC4UvyJZ", |
||||
"classes:method-overriding": "aknqutxN2WDQ4RFcT-szM", |
||||
"generics": "4gaKqNtGLFqpk9WVKZl0v", |
||||
"generics:generic-types": "T2-VAVfntouJOoWHpHZ3n", |
||||
"generics:generic-constraints": "0NXHAOUYGIwuPwlN7r_B3", |
||||
"decorators": "TRx3wvWnRdJJf5eL-GBG4", |
||||
"utility-types": "LSwUHfalnk5MgHt21PANb", |
||||
"utility-types:partial": "gBTem9Dp3IQLAkqGX4fOF", |
||||
"utility-types:pick": "E88tHQvARkHURZwGaO02l", |
||||
"utility-types:omit": "yjlxygHl8QONNUrdx-Q0A", |
||||
"utility-types:readonly": "IuO9-O_DQdDYuAbdGWdgb", |
||||
"utility-types:record": "DRdBmF5Dt_r09LoPOxOuq", |
||||
"utility-types:exclude": "0fvOXi9gJbEc7etqTggNE", |
||||
"utility-types:extract": "IIAbAzXiVQm1JEi2MTMZN", |
||||
"utility-types:non-nullable": "_BAZlBEzE7ddr315OeHvl", |
||||
"utility-types:parameters": "a7hl0iMZ-jcUACxqIYVqv", |
||||
"utility-types:return-type": "On75JR_UkiIlha0_qaSeu", |
||||
"utility-types:instance-type": "izGAjNtrh3BzQt3KiZX0W", |
||||
"utility-types:awaited": "aEhI_9mFWXRIZh1ZxTuzu", |
||||
"advanced-types": "2F7vOL__v9dLBohA263aj", |
||||
"advanced-types:mapped-types": "VQ-V9qIdKgnpSJg2UnpuB", |
||||
"advanced-types:conditional-types": "ubGIhi-WLE0EopTYXzmPL", |
||||
"advanced-types:literal-types": "CWzGwvl6NwYCaLYSLIjqQ", |
||||
"advanced-types:template-literal-types": "xP25nGw42VqdfZ_9pDMXd", |
||||
"advanced-types:recursive-types": "N8xBTJ74xv1E5hSLYZtze", |
||||
"modules": "sE9lqkkqwnsVJxTJv37YZ", |
||||
"modules:namespaces": "EtVwQ4lnWi3IIFHGb2Qib", |
||||
"modules:ambient-modules": "k_5y77k8ZZ9_O2WpWXWTY", |
||||
"modules:external-modules": "egQWk1n3p8Pep83yIwCtI", |
||||
"modules:namespace-augmentation": "16TT8R4N-9tCfWmPetqMP", |
||||
"modules:global-augmentation": "JQwWeB1gkANSYfQmH69Bs", |
||||
"ecosystem": "RqZaWGxxNRItBhVwWKysc", |
||||
"ecosystem:formatting": "fU8Vnw1DobM4iXl1Tq6EK", |
||||
"ecosystem:linting": "8PcAPOrKisKRYPWamz4nV", |
||||
"ecosystem:useful-packages": "PCX3KcvMUW3mmQEepLTXp", |
||||
"ecosystem:build-tools": "I5uwfej5XMwR2N2gpBILh" |
||||
} |
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue