DefinitelyTyped/types/skatejs
Nathan Shively-Sanders 0f8f845462
Update tests for Typescript 3.7 (#38672)
Typescript 3.7 includes a flag that will allow people to migrate to the
Class Fields ECMA proposal as currently specified, which is at Stage 3.
When `--useDefineForClassFields` is turned on, Typescript
issues 3 new errors in places where the current Typescript semantics
would cause errors with the Stage 3 spec.

Two of the errors are very rare. The third shows up whenever classes want
to redeclare the type of a property from a superclass, usually when the
base property's type is `any` or `unknown`.

```ts
class ColumnSizerExample extends React.Component<any, any> {
  context: React.ContextType<typeof MyContext>
}
```

Without `--useDefineForClassFields`, this *only* redeclares the type of
`context`. With `--useDefineForClassFields`, it redeclares the type of
`context` **and** initialises it to `undefined`. This is very surprising.

To avoid this, Typescript 3.7 introduces new syntax for exactly this scenario:

```ts
class ColumnSizerExample extends React.Component<any, any> {
  declare context: React.ContextType<typeof MyContext>
}
```

However, Definitely Typed tests cannot use this new syntax because it
only works with Typescript 3.7, which isn't even in beta until next
week. So this PR uses several other workarounds instead:

1. Moving a constructor initialiser to a property declaration initialiser.
2. Using a dummy initialiser:
3. Adding type annotations so the type of the base property can be correctly inferred.
4. Deleting the declaration when it has the same type as the base. In this case it's redundant.
2019-09-27 13:01:36 -07:00
..
test
api.d.ts
index.d.ts
tsconfig.json
tslint.json
types.d.ts