Skip to content

Commit

Permalink
Add command line argument to specify target (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
L2jLiga authored Oct 27, 2020
1 parent 04c6c13 commit 5638512
Show file tree
Hide file tree
Showing 18 changed files with 665 additions and 1,394 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
node_modules/
test/ts3.4/
test/ts*/
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ the Typescript language service won't be able to show the member names.
## Target
Since the earliest downlevel feature is from Typescript 3.5,
downlevel-dts targets Typescript 3.4. In the future the downlevel
target may be configurable as Typescript 3.4 becomes less used.
downlevel-dts targets Typescript 3.4 by default. The downlevel target is
configurable with `--to` argument.
Currently, Typescript 3.0 features like `unknown` are not
downlevelled, nor are there any other plans to support Typescript 2.x.
Expand All @@ -249,7 +249,7 @@ downlevelled, nor are there any other plans to support Typescript 2.x.
## Usage
1. `$ npm install downlevel-dts`
2. `$ npx downlevel-dts . ts3.4`
2. `$ npx downlevel-dts . ts3.4 [--to=3.4]`
3. To your package.json, add
```json
Expand Down
19 changes: 19 additions & 0 deletions baselines/ts3.5/src/test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export class C {
p: number;
readonly q: string;
r: boolean;
}
export namespace N {
class D {
p: number;
readonly q: string;
r: boolean;
}
}
export { C as DetectiveComics };
export type Omit<T, K extends keyof any> = Pick<T, Exclude<keyof T, K>>;
export interface E {
a: number;
b: number;
}
export type F = Omit<E, 'a'>;
50 changes: 50 additions & 0 deletions baselines/ts3.5/test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/// <reference path="./src/test.d.ts" />
/// <reference types="node" />
export class C {
protected p: number;
public readonly q: string;
private r: boolean;
}
// hi, this should still be there
export namespace N {
abstract class D {
/*
* @readonly
* @memberof BlobLeaseClient
* @type {number}
preserve this too */
p: number;
readonly q: any;
abstract r: boolean;
}
}
/** is this a single-line comment? */
import { C as CD } from "./src/test";
import * as rex_1 from "./src/test";
//another comment
export { rex_1 as rex } from "./src/test";
export interface E {
a: number;
b: number;
}
/// is this a single-line comment?
export type F = Omit<E, 'a'>;
export class G {
private "G.#private";
}
export class H extends G {
private "H.#private";
}
export interface I extends Omit<E, 'a'> {
version: number;
}
declare function guardIsString(val: any): val is string;
/** side-effects! */
declare function assertIsString(val: any, msg?: string): void;
declare function assert(val: any, msg?: string): void;
type J = [
/*foo*/ string,
/*bar*/ number,
/*arr*/ ...boolean[]
];
21 changes: 21 additions & 0 deletions baselines/ts3.6/src/test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export class C {
get p(): number;
set p(value: number);
get q(): string;
set r(value: boolean);
}
export namespace N {
class D {
get p(): number;
set p(value: number);
get q(): string;
set r(value: boolean);
}
}
export { C as DetectiveComics };
export type Omit<T, K extends keyof any> = Pick<T, Exclude<keyof T, K>>;
export interface E {
a: number;
b: number;
}
export type F = Omit<E, 'a'>;
52 changes: 52 additions & 0 deletions baselines/ts3.6/test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/// <reference path="./src/test.d.ts" />
/// <reference types="node" />
export class C {
protected get p(): number;
protected set p(value: number);
public get q(): string;
private set r(value: boolean);
}
// hi, this should still be there
export namespace N {
abstract class D {
/**
* @readonly
* @memberof BlobLeaseClient
* @type {number}
*/
get p(): number;
/** preserve this too */
set p(value: number);
get q();
abstract set r(value: boolean);
}
}
/** is this a single-line comment? */
import { C as CD } from "./src/test";
import * as rex_1 from "./src/test";
//another comment
export { rex_1 as rex } from "./src/test";
export interface E {
a: number;
b: number;
}
/// is this a single-line comment?
export type F = Omit<E, 'a'>;
export class G {
private "G.#private";
}
export class H extends G {
private "H.#private";
}
export interface I extends Omit<E, 'a'> {
version: number;
}
declare function guardIsString(val: any): val is string;
/** side-effects! */
declare function assertIsString(val: any, msg?: string): void;
declare function assert(val: any, msg?: string): void;
type J = [
/*foo*/ string,
/*bar*/ number,
/*arr*/ ...boolean[]
];
21 changes: 21 additions & 0 deletions baselines/ts3.7/src/test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export class C {
get p(): number;
set p(value: number);
get q(): string;
set r(value: boolean);
}
export namespace N {
class D {
get p(): number;
set p(value: number);
get q(): string;
set r(value: boolean);
}
}
export { C as DetectiveComics };
export type Omit<T, K extends keyof any> = Pick<T, Exclude<keyof T, K>>;
export interface E {
a: number;
b: number;
}
export type F = Omit<E, 'a'>;
52 changes: 52 additions & 0 deletions baselines/ts3.7/test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/// <reference path="./src/test.d.ts" />
/// <reference types="node" />
export class C {
protected get p(): number;
protected set p(value: number);
public get q(): string;
private set r(value: boolean);
}
// hi, this should still be there
export namespace N {
abstract class D {
/**
* @readonly
* @memberof BlobLeaseClient
* @type {number}
*/
get p(): number;
/** preserve this too */
set p(value: number);
get q();
abstract set r(value: boolean);
}
}
/** is this a single-line comment? */
import { C as CD } from "./src/test";
import * as rex_1 from "./src/test";
//another comment
export { rex_1 as rex } from "./src/test";
export interface E {
a: number;
b: number;
}
/// is this a single-line comment?
export type F = Omit<E, 'a'>;
export class G {
private "G.#private";
}
export class H extends G {
private "H.#private";
}
export interface I extends Omit<E, 'a'> {
version: number;
}
declare function guardIsString(val: any): val is string;
/** side-effects! */
declare function assertIsString(val: any, msg?: string): asserts val is string;
declare function assert(val: any, msg?: string): asserts val;
type J = [
/*foo*/ string,
/*bar*/ number,
/*arr*/ ...boolean[]
];
21 changes: 21 additions & 0 deletions baselines/ts3.8/src/test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export class C {
get p(): number;
set p(value: number);
get q(): string;
set r(value: boolean);
}
export namespace N {
class D {
get p(): number;
set p(value: number);
get q(): string;
set r(value: boolean);
}
}
export type { C as DetectiveComics };
export type Omit<T, K extends keyof any> = Pick<T, Exclude<keyof T, K>>;
export interface E {
a: number;
b: number;
}
export type F = Omit<E, 'a'>;
51 changes: 51 additions & 0 deletions baselines/ts3.8/test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/// <reference path="./src/test.d.ts" />
/// <reference types="node" />
export class C {
protected get p(): number;
protected set p(value: number);
public get q(): string;
private set r(value: boolean);
}
// hi, this should still be there
export namespace N {
abstract class D {
/**
* @readonly
* @memberof BlobLeaseClient
* @type {number}
*/
get p(): number;
/** preserve this too */
set p(value: number);
get q();
abstract set r(value: boolean);
}
}
/** is this a single-line comment? */
import type { C as CD } from "./src/test";
// another comment
export * as rex from "./src/test";
export interface E {
a: number;
b: number;
}
/// is this a single-line comment?
export type F = Omit<E, 'a'>;
export class G {
#private;
}
export class H extends G {
#private;
}
export interface I extends Omit<E, 'a'> {
version: number;
}
declare function guardIsString(val: any): val is string;
/** side-effects! */
declare function assertIsString(val: any, msg?: string): asserts val is string;
declare function assert(val: any, msg?: string): asserts val;
type J = [
/*foo*/ string,
/*bar*/ number,
/*arr*/ ...boolean[]
];
21 changes: 21 additions & 0 deletions baselines/ts3.9/src/test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export class C {
get p(): number;
set p(value: number);
get q(): string;
set r(value: boolean);
}
export namespace N {
class D {
get p(): number;
set p(value: number);
get q(): string;
set r(value: boolean);
}
}
export type { C as DetectiveComics };
export type Omit<T, K extends keyof any> = Pick<T, Exclude<keyof T, K>>;
export interface E {
a: number;
b: number;
}
export type F = Omit<E, 'a'>;
51 changes: 51 additions & 0 deletions baselines/ts3.9/test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/// <reference path="./src/test.d.ts" />
/// <reference types="node" />
export class C {
protected get p(): number;
protected set p(value: number);
public get q(): string;
private set r(value: boolean);
}
// hi, this should still be there
export namespace N {
abstract class D {
/**
* @readonly
* @memberof BlobLeaseClient
* @type {number}
*/
get p(): number;
/** preserve this too */
set p(value: number);
get q();
abstract set r(value: boolean);
}
}
/** is this a single-line comment? */
import type { C as CD } from "./src/test";
// another comment
export * as rex from "./src/test";
export interface E {
a: number;
b: number;
}
/// is this a single-line comment?
export type F = Omit<E, 'a'>;
export class G {
#private;
}
export class H extends G {
#private;
}
export interface I extends Omit<E, 'a'> {
version: number;
}
declare function guardIsString(val: any): val is string;
/** side-effects! */
declare function assertIsString(val: any, msg?: string): asserts val is string;
declare function assert(val: any, msg?: string): asserts val;
type J = [
/*foo*/ string,
/*bar*/ number,
/*arr*/ ...boolean[]
];
Loading

0 comments on commit 5638512

Please sign in to comment.