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

Upgraded supported TypeScript version to v2.7. #3978

Merged
merged 4 commits into from
Feb 25, 2024

Conversation

aleppard
Copy link
Contributor

This PR upgrades compatibility to TypeScript v2.7. It also adds the yield* operator to JavaScript and JSX.

First some minor parsing improvements:

You can now name anonymous functions, e.g.

object = {
     field: function myFunction(arg1) { return arg1; }
}

Assertion typing (casting) is now supported in for statements, e.g.

let object = {"field1":5, "field2:"value"};
for (let [field, value] of Object.entries(object) as [string, any]) {
}

You can now export type aliases, e.g.

export type MyType = {
    field: number, 
    field2: string, 
}

(and they don't need to end with a semi-colon).

Union, intersection type aliases can now start with a leading | or &, e.g.

type EmployeeType =
     | "employee"
     | "manager";

See microsoft/TypeScript#12386

Tuples (and function parameter lists) can have a trailing comma:

[string, number,]

See microsoft/TypeScript#28893

Upgrades based on TypeScript versions:

TypeScript v0.9

You can now declare namespaces, e.g.

declare namespace myLib {
}

See https://www.typescriptlang.org/docs/handbook/declaration-files/by-example.html

TypeScript v1.8

Boolean, number and string literal types are now supported, e.g.

export type CharityStatsJson = {
    type: "single" | "multi"; 
    type: 1 | 2; 
    type: false | 1 | 2; 

See https://www.typescriptlang.org/docs/handbook/release-notes/typescript-1-8.html#type-parameters-as-constraints

TypeScript v2.0

Added non-null assertion operator, e.g.

let s = e!.name; // Assert that e is non-null and access name

See https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-0.html#non-null-assertion-operator

Added undefined type, e.g.

let y: number | undefined;

See https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-0.html#null--and-undefined-aware-types

Added never type, e.g.

function error(message: string): never {
  throw new Error(message);
}

See https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-0.html#the-never-type

TypeScript v2.1

Added keyof and indexed access types, e.g.

interface Person {
  name: string;
  age: number;
  location: string;
}
type Key = keyof Person; // "name" | "age" | "location"
type Age = Person["age"]; 

See https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-1.html#keyof-and-lookup-types

TypeScript v2.2

Added object type, e.g.

declare function create(o: object | null): void;

See https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-2.html#object-type

TypeScript v2.3

Added yield* operator to JavaScript, TypeScript & JSX.

See https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-3.html#generators

Added generic parameter defaults, e.g.

function genericParameterWithDefault<T = DefaultType>(field: T) {}

See https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-3.html#generic-parameter-defaults

TypeScript v2.7

Added unique symbol type, e.g.

declare const Foo: unique symbol;

See https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-7.html#unique-symbol

@teverett
Copy link
Member

@aleppard thanks!

@teverett teverett merged commit c9ee511 into antlr:master Feb 25, 2024
21 checks passed
@KvanTTT KvanTTT added example New example of file(s) parsed by grammar-generated parser typescript labels Mar 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
example New example of file(s) parsed by grammar-generated parser typescript
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants