Skip to content
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

Add 5.0 compiler options #2759

Merged
merged 20 commits into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: "16.x"
cache: yarn

# Install, should be basically instant if cached
- run: yarn install
Expand Down Expand Up @@ -75,7 +74,6 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: "16.x"
cache: yarn

# Get local dependencies
- run: yarn install
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@types/react": "16.9.17",
"@types/estree": "0.0.46",
"node-gyp": "5.1.0",
"typescript": "4.8.1-rc",
"typescript": "5.0.2",
"tslib": "2.1.0",
"prettier": "^2.0.2",
"shelljs": "0.8.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/ata/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"cpy-cli": "^3.1.1",
"esbuild": "^0.12.9",
"esbuild-jest": "^0.5.0",
"jest": "*"
"jest": "^29.5.0"
},
"peerDependencies": {
"typescript": "^4.4.4"
Expand Down
2 changes: 1 addition & 1 deletion packages/documentation/copy/en/handbook-v1/Basic Types.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ Unlike `unknown`, variables of type `any` allow you to access arbitrary properti
These properties include functions and TypeScript will not check their existence or type:

```ts twoslash
// @errors: 2571
// @errors: 2571 18046
let looselyTyped: any = 4;
// OK, ifItExists might exist at runtime
looselyTyped.ifItExists();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ In JavaScript, if you access a property that doesn't exist, you'll get the value
Because of this, when you _read_ from an optional property, you'll have to check for `undefined` before using it.

```ts twoslash
// @errors: 2532
// @errors: 18048
function printName(obj: { first: string; last?: string }) {
// Error - might crash if 'obj.last' wasn't provided!
console.log(obj.last.toUpperCase());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ function myForEach(arr: any[], callback: (arg: any, index?: number) => void) {
What people usually intend when writing `index?` as an optional parameter is that they want both of these calls to be legal:

```ts twoslash
// @errors: 2532
// @errors: 2532 18048
declare function myForEach(
arr: any[],
callback: (arg: any, index?: number) => void
Expand All @@ -396,7 +396,7 @@ What this _actually_ means is that _`callback` might get invoked with one argume
In other words, the function definition says that the implementation might look like this:

```ts twoslash
// @errors: 2532
// @errors: 2532 18048
function myForEach(arr: any[], callback: (arg: any, index?: number) => void) {
for (let i = 0; i < arr.length; i++) {
// I don't feel like providing the index today
Expand All @@ -409,7 +409,7 @@ In turn, TypeScript will enforce this meaning and issue errors that aren't reall

<!-- prettier-ignore -->
```ts twoslash
// @errors: 2532
// @errors: 2532 18048
declare function myForEach(
arr: any[],
callback: (arg: any, index?: number) => void
Expand Down Expand Up @@ -631,7 +631,7 @@ The `unknown` type represents _any_ value.
This is similar to the `any` type, but is safer because it's not legal to do anything with an `unknown` value:

```ts twoslash
// @errors: 2571
// @errors: 2571 18046
function f1(a: any) {
a.b(); // OK
}
Expand Down
6 changes: 3 additions & 3 deletions packages/documentation/copy/en/handbook-v2/Narrowing.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ For example, notice that in the list above, `typeof` doesn't return the string `
Check out the following example:

```ts twoslash
// @errors: 2531
// @errors: 2531 18047
function printAll(strs: string | string[] | null) {
if (typeof strs === "object") {
for (const s of strs) {
Expand Down Expand Up @@ -521,7 +521,7 @@ We can write a `getArea` function that applies the right logic based on if it's
We'll first try dealing with circles.

```ts twoslash
// @errors: 2532
// @errors: 2532 18048
interface Shape {
kind: "circle" | "square";
radius?: number;
Expand All @@ -540,7 +540,7 @@ Under [`strictNullChecks`](/tsconfig#strictNullChecks) that gives us an error -
But what if we perform the appropriate checks on the `kind` property?

```ts twoslash
// @errors: 2532
// @errors: 2532 18048
interface Shape {
kind: "circle" | "square";
radius?: number;
Expand Down
Loading