Skip to content

Upgrade TypeScript 2 to something newer #167

Open
@generalmimon

Description

@generalmimon

See #166 (comment) (cc @GreyCat)

When adding the js-yaml dependency in #166, I couldn't use the TypeScript definitions available in the DefinitelyTyped repo directly, because they use unknown. The unknown type is a feature introduced in TypeScript 3.0 (see https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-0.html#new-unknown-top-type), but we're currently using TypeScript 2, see package.json:

"typescript": "^2.9.2"

So I had to copy the TS definitions to lib/ts-types/js-yaml.d.ts and patch it (i.e. replace unknown by any) to make it compatible with TypeScript 2:

// Adapted from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/65afafadd93759348909de1cdad5df5789c94326/types/js-yaml/index.d.ts
// 1. fixed compatibility with TypeScript 2 (which we're still
// using at the time of writing) by replacing `unknown` with `any`

I believe migrating from TypeScript 2 would allow us to drop our lib/ts-types directory altogether and use the packages in the @types namespace at npm instead. For example, for the js-yaml library, this would be just a matter of adding @types/js-yaml as a dependency (according to my tests, the TS compiler automatically resolves the installed @types/* packages, so no more steps are needed).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions