You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
### Parsing Differences in Optional Chaining and Non-Null Assertions
330
+
### ์ ํ์ ์ฒด์ด๋๊ณผ ๋์ด ์๋ ๋จ์ธ์์ ํ์ฑ ์ฐจ์ด์ (Parsing Differences in Optional Chaining and Non-Null Assertions)
331
331
332
-
TypeScript recently implemented the optional chaining operator, but we've received user feedback that the behavior of optional chaining (`?.`) with the non-null assertion operator (`!`) is extremely counter-intuitive.
In the above code the parentheses stop the "short-circuiting" behavior of optional chaining, so if`foo` is `undefined`, accessing `baz` will cause a runtime error.
The Babel team who pointed this behavior out, and most users who provided feedback to us, believe that this behavior is wrong.
349
-
We do too!
350
-
The thing we heard the most was that the `!` operator should just "disappear" since the intent was to remove `null` and `undefined` from the type of `bar`.
### `}` and `>` are Now Invalid JSX Text Characters
367
+
### `}`์ `>` ๋ ์ด์ ์ ํจํ์ง ์์ JSX ํ ์คํธ ๋ฌธ์์ ๋๋ค (`}`and `>` are Now Invalid JSX Text Characters)
368
368
369
-
The JSX Specification forbids the use of the `}` and `>`characters in text positions.
370
-
TypeScript and Babel have both decided to enforce this rule to be more comformant.
371
-
The new way to insert these characters is to use an HTML escape code (e.g. `<span>2> 1</div>`) or insert an expression with a string literal (e.g. `<span>2 {">"} 1</div>`).
Luckily, thanks to the [pull request](https://github.com/microsoft/TypeScript/pull/36636) enforcing this from [Brad Zacher](https://github.com/bradzacher), you'll get an error message along the lines of
Unexpected token. Did you mean `{'}'}` or `}`?
378
378
```
379
379
380
-
For example:
380
+
์๋ฅผ ๋ค์ด:
381
381
382
382
```tsx
383
383
let directions =<span>Navigate to: Menu Bar > Tools > Options</div>
384
384
// ~ ~
385
385
// Unexpected token. Did you mean `{'>'}` or `>`?
386
386
```
387
387
388
-
That error message came with a handy quick fix, and thanks to [Alexander Tarasyuk](https://github.com/a-tarasyuk), [you can apply these changes in bulk](https://github.com/microsoft/TypeScript/pull/37436) if you have a lot of errors.
### Stricter Checks on Intersections and Optional Properties
390
+
### ๊ต์งํฉ๊ณผ ์ ํ์ ํ๋กํผํฐ์ ๋ํ ๋ ์๊ฒฉํด์ง ๊ฒ์ฌ (Stricter Checks on Intersections and Optional Properties)
391
391
392
-
Generally, an intersection type like `A&B` is assignable to `C` if either `A` or `B` is assignable to `C`; however, sometimes that has problems with optional properties.
declare function smushObjects<T, U>(x:T, y:U): T & U;
@@ -450,50 +450,50 @@ let z = smushObjects(x, y);
450
450
console.log(z.kind);
451
451
```
452
452
453
-
This code is slightly weird because there's really no way to create an intersection of a `Circle` and a `Square` - they have two incompatible `kind`fields.
454
-
In previous versions of TypeScript, this code was allowed and the type of `kind` itself was `never` because `"circle"&"square"` described a set of values that could `never` exist.
In TypeScript 3.9, the type system is more aggressive here - it notices that it's impossible to intersect `Circle` and `Square` because of their `kind` properties.
457
-
So instead of collapsing the type of `z.kind` to `never`, it collapses the type of `z`itself (`Circle & Square`) to`never`.
### Getters/Setters๋ ๋ ์ด์ ์ด๊ฑฐํ์ง ์์ต๋๋ค (Getters/Setters are No Longer Enumerable)
468
468
469
-
In older versions of TypeScript, `get` and `set`accessors in classes were emitted in a way that made them enumerable; however, this wasn't compliant with the ECMAScript specification which states that they must be non-enumerable.
470
-
As a result, TypeScript code that targeted ES5 and ES2015 could differ in behavior.
Thanks to [a pull request](https://github.com/microsoft/TypeScript/pull/32264) from GitHub user [pathurs](https://github.com/pathurs), TypeScript 3.9 now conforms more closely with ECMAScript in this regard.
0 commit comments