From f45a53cb5bb0966cd4287959718c7e3dc929c5ae Mon Sep 17 00:00:00 2001 From: Lolleko Date: Wed, 12 Jun 2019 22:16:00 +0200 Subject: [PATCH 01/10] globalThis to _G Closes #592 --- src/LuaTransformer.ts | 8 ++++++- test/unit/identifiers.spec.ts | 43 +++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/src/LuaTransformer.ts b/src/LuaTransformer.ts index 02e837a6e..1ed2c65c2 100644 --- a/src/LuaTransformer.ts +++ b/src/LuaTransformer.ts @@ -4630,6 +4630,10 @@ export class LuaTransformer { } public transformIdentifier(identifier: ts.Identifier): tstl.Identifier { + if (identifier.escapedText === "globalThis") { + return tstl.createIdentifier("_G", identifier, this.getIdentifierSymbolId(identifier)); + } + if (identifier.originalKeywordKind === ts.SyntaxKind.UndefinedKeyword) { // TODO this is a hack that allows use to keep Identifier // as return time as changing that would break a lot of stuff. @@ -5172,7 +5176,9 @@ export class LuaTransformer { protected hasUnsafeSymbolName(symbol: ts.Symbol, tsOriginal?: ts.Identifier): boolean { const isLuaKeyword = luaKeywords.has(symbol.name); const isInvalidIdentifier = !tsHelper.isValidLuaIdentifier(symbol.name); - const isAmbient = symbol.declarations.some(d => tsHelper.isAmbient(d)); + // TODO investigate: declarations will be undefined if "globalThis" is passed, could be a TS bug + // WORKAROUND: added check for symbol.declarations + const isAmbient = symbol.declarations && symbol.declarations.some(d => tsHelper.isAmbient(d)); if ((isLuaKeyword || isInvalidIdentifier) && isAmbient) { // Catch ambient declarations of identifiers with bad names throw TSTLErrors.InvalidAmbientIdentifierName(tsOriginal || ts.createIdentifier(symbol.name)); diff --git a/test/unit/identifiers.spec.ts b/test/unit/identifiers.spec.ts index e4677c5dc..5a5a776a1 100644 --- a/test/unit/identifiers.spec.ts +++ b/test/unit/identifiers.spec.ts @@ -788,3 +788,46 @@ test("exported variable with lua keyword as name is not renamed", () => { expect(util.transpileExecuteAndReturnExport(code, "print")).toBe("foobar"); }); + +describe("globalThis translation", () => { + test("globalThis to _G (expression)", () => { + const code = ` + var foo = "bar"; + return globalThis.foo;`; + + const lua = util.transpileString(code); + + expect(util.executeLua(lua)).toBe("bar"); + }); + + test("globalThis to _G (assign)", () => { + const code = ` + globalThis.foo = "bar"; + return globalThis.foo;`; + + const lua = util.transpileString(code); + + expect(util.executeLua(lua)).toBe("bar"); + }); + + test("globalThis to _G (reassign)", () => { + const code = ` + globalThis.foo = "bar"; + globalThis.foo = "baz"; + return globalThis.foo;`; + + const lua = util.transpileString(code); + + expect(util.executeLua(lua)).toBe("baz"); + }); + + test("globalThis to _G (function)", () => { + const code = ` + globalThis.foo = () => "bar"; + return globalThis.foo();`; + + const lua = util.transpileString(code); + + expect(util.executeLua(lua)).toBe("bar"); + }); +}); \ No newline at end of file From 59de49ee3ae480fcc37a6de0989e3f9d09ea5147 Mon Sep 17 00:00:00 2001 From: Lolleko Date: Thu, 13 Jun 2019 00:14:29 +0200 Subject: [PATCH 02/10] moved globalThis check to transformIdentifierExpression --- src/LuaTransformer.ts | 30 ++++++++++++++++-------------- test/unit/identifiers.spec.ts | 18 +++++++++--------- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/LuaTransformer.ts b/src/LuaTransformer.ts index 1ed2c65c2..15ee7c60f 100644 --- a/src/LuaTransformer.ts +++ b/src/LuaTransformer.ts @@ -4630,18 +4630,6 @@ export class LuaTransformer { } public transformIdentifier(identifier: ts.Identifier): tstl.Identifier { - if (identifier.escapedText === "globalThis") { - return tstl.createIdentifier("_G", identifier, this.getIdentifierSymbolId(identifier)); - } - - if (identifier.originalKeywordKind === ts.SyntaxKind.UndefinedKeyword) { - // TODO this is a hack that allows use to keep Identifier - // as return time as changing that would break a lot of stuff. - // But this should be changed to return tstl.createNilLiteral() - // at some point. - return tstl.createIdentifier("nil"); - } - const text = this.hasUnsafeIdentifierName(identifier) ? this.createSafeName(this.getIdentifierText(identifier)) : this.getIdentifierText(identifier); @@ -4658,6 +4646,10 @@ export class LuaTransformer { return this.createExportedIdentifier(identifier, exportScope); } + if (expression.originalKeywordKind === ts.SyntaxKind.UndefinedKeyword) { + return tstl.createNilLiteral(); + } + switch (this.getIdentifierText(expression)) { case "NaN": return tstl.createParenthesizedExpression( @@ -4673,6 +4665,17 @@ export class LuaTransformer { const math = tstl.createIdentifier("math"); const huge = tstl.createStringLiteral("huge"); return tstl.createTableIndexExpression(math, huge, expression); + + case "globalThis": + const isIdentifierStandardLibraryType = !tsHelper.isStandardLibraryType( + this.checker.getTypeAtLocation(expression), + undefined, + this.program + ); + if (isIdentifierStandardLibraryType) { + return tstl.createIdentifier("_G", expression, this.getIdentifierSymbolId(expression)); + } + break; } return identifier; @@ -5176,8 +5179,7 @@ export class LuaTransformer { protected hasUnsafeSymbolName(symbol: ts.Symbol, tsOriginal?: ts.Identifier): boolean { const isLuaKeyword = luaKeywords.has(symbol.name); const isInvalidIdentifier = !tsHelper.isValidLuaIdentifier(symbol.name); - // TODO investigate: declarations will be undefined if "globalThis" is passed, could be a TS bug - // WORKAROUND: added check for symbol.declarations + // TODO rework once microsoft/TypeScript#24706 is fixed and maybe remove check for symbol.declarations const isAmbient = symbol.declarations && symbol.declarations.some(d => tsHelper.isAmbient(d)); if ((isLuaKeyword || isInvalidIdentifier) && isAmbient) { // Catch ambient declarations of identifiers with bad names diff --git a/test/unit/identifiers.spec.ts b/test/unit/identifiers.spec.ts index 5a5a776a1..8b4069505 100644 --- a/test/unit/identifiers.spec.ts +++ b/test/unit/identifiers.spec.ts @@ -794,9 +794,9 @@ describe("globalThis translation", () => { const code = ` var foo = "bar"; return globalThis.foo;`; - + const lua = util.transpileString(code); - + expect(util.executeLua(lua)).toBe("bar"); }); @@ -804,9 +804,9 @@ describe("globalThis translation", () => { const code = ` globalThis.foo = "bar"; return globalThis.foo;`; - + const lua = util.transpileString(code); - + expect(util.executeLua(lua)).toBe("bar"); }); @@ -815,9 +815,9 @@ describe("globalThis translation", () => { globalThis.foo = "bar"; globalThis.foo = "baz"; return globalThis.foo;`; - + const lua = util.transpileString(code); - + expect(util.executeLua(lua)).toBe("baz"); }); @@ -825,9 +825,9 @@ describe("globalThis translation", () => { const code = ` globalThis.foo = () => "bar"; return globalThis.foo();`; - + const lua = util.transpileString(code); - + expect(util.executeLua(lua)).toBe("bar"); }); -}); \ No newline at end of file +}); From d692b8107d97ef767e8f6566c637f125463dbc0f Mon Sep 17 00:00:00 2001 From: Lolleko Date: Thu, 13 Jun 2019 11:15:07 +0200 Subject: [PATCH 03/10] support for "typeof globalThis" WIP --- src/LuaTransformer.ts | 23 ++++++++++++----------- test/unit/identifiers.spec.ts | 15 +++++++++++++++ 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/LuaTransformer.ts b/src/LuaTransformer.ts index 15ee7c60f..549458e76 100644 --- a/src/LuaTransformer.ts +++ b/src/LuaTransformer.ts @@ -4650,6 +4650,18 @@ export class LuaTransformer { return tstl.createNilLiteral(); } + const identifierType = this.checker.getTypeAtLocation(expression); + if (identifierType.symbol && identifierType.symbol.escapedName === "globalThis") { + const isIdentifierStandardLibraryType = !tsHelper.isStandardLibraryType( + this.checker.getTypeAtLocation(expression), + undefined, + this.program + ); + if (isIdentifierStandardLibraryType) { + return tstl.createIdentifier("_G", expression, this.getIdentifierSymbolId(expression)); + } + } + switch (this.getIdentifierText(expression)) { case "NaN": return tstl.createParenthesizedExpression( @@ -4665,17 +4677,6 @@ export class LuaTransformer { const math = tstl.createIdentifier("math"); const huge = tstl.createStringLiteral("huge"); return tstl.createTableIndexExpression(math, huge, expression); - - case "globalThis": - const isIdentifierStandardLibraryType = !tsHelper.isStandardLibraryType( - this.checker.getTypeAtLocation(expression), - undefined, - this.program - ); - if (isIdentifierStandardLibraryType) { - return tstl.createIdentifier("_G", expression, this.getIdentifierSymbolId(expression)); - } - break; } return identifier; diff --git a/test/unit/identifiers.spec.ts b/test/unit/identifiers.spec.ts index 8b4069505..7c1b72752 100644 --- a/test/unit/identifiers.spec.ts +++ b/test/unit/identifiers.spec.ts @@ -830,4 +830,19 @@ describe("globalThis translation", () => { expect(util.executeLua(lua)).toBe("bar"); }); + + test("globalThis to _G (type alias)", () => { + const code = ` + declare let globalAlias: typeof globalThis; + globalAlias.foo = "bar"; + return globalThis.foo;`; + + const lua = util.transpileString(code); + + expect(util.executeLua(lua)).toBe("bar"); + }); + + // TODO globalThis type tests for union and intersection }); + + \ No newline at end of file From 90f322406195ed4041971dee3e8d8e8700d0bfda Mon Sep 17 00:00:00 2001 From: Lolleko Date: Fri, 14 Jun 2019 12:54:18 +0200 Subject: [PATCH 04/10] Removed is standard lib test --- src/LuaTransformer.ts | 9 +-------- test/unit/identifiers.spec.ts | 4 ---- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/src/LuaTransformer.ts b/src/LuaTransformer.ts index 549458e76..8592a1a9d 100644 --- a/src/LuaTransformer.ts +++ b/src/LuaTransformer.ts @@ -4652,14 +4652,7 @@ export class LuaTransformer { const identifierType = this.checker.getTypeAtLocation(expression); if (identifierType.symbol && identifierType.symbol.escapedName === "globalThis") { - const isIdentifierStandardLibraryType = !tsHelper.isStandardLibraryType( - this.checker.getTypeAtLocation(expression), - undefined, - this.program - ); - if (isIdentifierStandardLibraryType) { - return tstl.createIdentifier("_G", expression, this.getIdentifierSymbolId(expression)); - } + return tstl.createIdentifier("_G", expression, this.getIdentifierSymbolId(expression)); } switch (this.getIdentifierText(expression)) { diff --git a/test/unit/identifiers.spec.ts b/test/unit/identifiers.spec.ts index 7c1b72752..4e9002d58 100644 --- a/test/unit/identifiers.spec.ts +++ b/test/unit/identifiers.spec.ts @@ -841,8 +841,4 @@ describe("globalThis translation", () => { expect(util.executeLua(lua)).toBe("bar"); }); - - // TODO globalThis type tests for union and intersection }); - - \ No newline at end of file From 8cd5a644e76f8cb2ff74bdf41d588ca2c53281f7 Mon Sep 17 00:00:00 2001 From: Lolleko Date: Sat, 6 Jul 2019 09:11:22 +0200 Subject: [PATCH 05/10] globalThis transformation only for identifier name not identifier type. --- src/LuaTransformer.ts | 8 +++----- test/unit/identifiers.spec.ts | 27 +++++++++++++++++++++++---- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/LuaTransformer.ts b/src/LuaTransformer.ts index 61680a10e..505b1677d 100644 --- a/src/LuaTransformer.ts +++ b/src/LuaTransformer.ts @@ -4695,11 +4695,6 @@ export class LuaTransformer { return tstl.createNilLiteral(); } - const identifierType = this.checker.getTypeAtLocation(expression); - if (identifierType.symbol && identifierType.symbol.escapedName === "globalThis") { - return tstl.createIdentifier("_G", expression, this.getIdentifierSymbolId(expression)); - } - switch (this.getIdentifierText(expression)) { case "NaN": return tstl.createParenthesizedExpression( @@ -4715,6 +4710,9 @@ export class LuaTransformer { const math = tstl.createIdentifier("math"); const huge = tstl.createStringLiteral("huge"); return tstl.createTableIndexExpression(math, huge, expression); + + case "globalThis": + return tstl.createIdentifier("_G", expression, this.getIdentifierSymbolId(expression)); } return identifier; diff --git a/test/unit/identifiers.spec.ts b/test/unit/identifiers.spec.ts index 4e9002d58..edaf37e67 100644 --- a/test/unit/identifiers.spec.ts +++ b/test/unit/identifiers.spec.ts @@ -831,14 +831,33 @@ describe("globalThis translation", () => { expect(util.executeLua(lua)).toBe("bar"); }); - test("globalThis to _G (type alias)", () => { + test("globalThis to _G (assign + noImplicitAny)", () => { const code = ` - declare let globalAlias: typeof globalThis; - globalAlias.foo = "bar"; - return globalThis.foo;`; + (globalThis).foo = "bar"; + return (globalThis).foo;`; + + const lua = util.transpileString(code, {noImplicitAny: true}); + + expect(util.executeLua(lua)).toBe("bar"); + }); + + test("globalThis to _G (var)", () => { + const code = ` + var globalFoo = "bar"; + return globalThis.globalFoo;`; const lua = util.transpileString(code); expect(util.executeLua(lua)).toBe("bar"); }); + + test("globalThis to _G (let)", () => { + const code = ` + let NotAGlobalFoo = "bar"; + return (globalThis).NotAGlobalFoo;`; + + const lua = util.transpileString(code); + + expect(util.executeLua(lua)).toBe(undefined); + }); }); From 3d1ed489fa944219a10ff674f9dbba1c1dd6bb7b Mon Sep 17 00:00:00 2001 From: Lolleko Date: Sat, 6 Jul 2019 09:19:22 +0200 Subject: [PATCH 06/10] fixed prettier --- test/unit/identifiers.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/identifiers.spec.ts b/test/unit/identifiers.spec.ts index edaf37e67..dff851072 100644 --- a/test/unit/identifiers.spec.ts +++ b/test/unit/identifiers.spec.ts @@ -836,7 +836,7 @@ describe("globalThis translation", () => { (globalThis).foo = "bar"; return (globalThis).foo;`; - const lua = util.transpileString(code, {noImplicitAny: true}); + const lua = util.transpileString(code, { noImplicitAny: true }); expect(util.executeLua(lua)).toBe("bar"); }); From f3d0d2d5711bc552311ca7bf0ae38f85077da5d5 Mon Sep 17 00:00:00 2001 From: Lolleko Date: Sat, 6 Jul 2019 09:36:31 +0200 Subject: [PATCH 07/10] Fixed prettier script --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ebb6e2591..7358098e8 100644 --- a/package.json +++ b/package.json @@ -23,9 +23,9 @@ "pretest": "npm run lint && ts-node --transpile-only ./build_lualib.ts", "test": "jest", "lint": "npm run lint:tslint && npm run lint:prettier", - "lint:prettier": "prettier --check **/*.{js,ts,yml,json,md} || (echo 'Run `npm run fix:prettier` to fix it.' && exit 1)", + "lint:prettier": "prettier --check \"**/*.{js,ts,yml,json,md}\" || (echo 'Run `npm run fix:prettier` to fix it.' && exit 1)", "lint:tslint": "tslint -p . && tslint -p test && tslint -p src/lualib", - "fix:prettier": "prettier --check --write **/*.{js,ts,yml,json,md}", + "fix:prettier": "prettier --check --write \"**/*.{js,ts,yml,json,md}\"", "release-major": "npm version major", "release-minor": "npm version minor", "release-patch": "npm version patch", From 68a067aeb3898e8cbda032ba95b574d079fc4d79 Mon Sep 17 00:00:00 2001 From: Lolleko Date: Sat, 6 Jul 2019 10:01:37 +0200 Subject: [PATCH 08/10] Changed transpile -> execute to transpileAndExecute where possible --- test/unit/identifiers.spec.ts | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/test/unit/identifiers.spec.ts b/test/unit/identifiers.spec.ts index dff851072..b3740a45c 100644 --- a/test/unit/identifiers.spec.ts +++ b/test/unit/identifiers.spec.ts @@ -805,9 +805,7 @@ describe("globalThis translation", () => { globalThis.foo = "bar"; return globalThis.foo;`; - const lua = util.transpileString(code); - - expect(util.executeLua(lua)).toBe("bar"); + expect(util.transpileAndExecute(code)).toBe("bar"); }); test("globalThis to _G (reassign)", () => { @@ -816,9 +814,7 @@ describe("globalThis translation", () => { globalThis.foo = "baz"; return globalThis.foo;`; - const lua = util.transpileString(code); - - expect(util.executeLua(lua)).toBe("baz"); + expect(util.transpileAndExecute(code)).toBe("baz"); }); test("globalThis to _G (function)", () => { @@ -826,9 +822,7 @@ describe("globalThis translation", () => { globalThis.foo = () => "bar"; return globalThis.foo();`; - const lua = util.transpileString(code); - - expect(util.executeLua(lua)).toBe("bar"); + expect(util.transpileAndExecute(code)).toBe("bar"); }); test("globalThis to _G (assign + noImplicitAny)", () => { @@ -836,9 +830,7 @@ describe("globalThis translation", () => { (globalThis).foo = "bar"; return (globalThis).foo;`; - const lua = util.transpileString(code, { noImplicitAny: true }); - - expect(util.executeLua(lua)).toBe("bar"); + expect(util.transpileAndExecute(code)).toBe("bar"); }); test("globalThis to _G (var)", () => { @@ -856,8 +848,6 @@ describe("globalThis translation", () => { let NotAGlobalFoo = "bar"; return (globalThis).NotAGlobalFoo;`; - const lua = util.transpileString(code); - - expect(util.executeLua(lua)).toBe(undefined); + expect(util.transpileAndExecute(code)).toBe(undefined); }); }); From d05f1a8683abb61d0762ac514026ac20f8539062 Mon Sep 17 00:00:00 2001 From: Lolleko Date: Sat, 6 Jul 2019 10:13:00 +0200 Subject: [PATCH 09/10] readd symbol.declaration check --- src/CompilerOptions.ts | 2 +- src/LuaTransformer.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/CompilerOptions.ts b/src/CompilerOptions.ts index ca09566d0..b429790b3 100644 --- a/src/CompilerOptions.ts +++ b/src/CompilerOptions.ts @@ -1,7 +1,7 @@ import * as ts from "typescript"; type KnownKeys = { [K in keyof T]: string extends K ? never : number extends K ? never : K } extends { - [_ in keyof T]: infer U; + [_ in keyof T]: infer U } ? U : never; diff --git a/src/LuaTransformer.ts b/src/LuaTransformer.ts index 3366dec00..07c82680e 100644 --- a/src/LuaTransformer.ts +++ b/src/LuaTransformer.ts @@ -5431,7 +5431,8 @@ export class LuaTransformer { protected hasUnsafeSymbolName(symbol: ts.Symbol, tsOriginal?: ts.Identifier): boolean { const isLuaKeyword = luaKeywords.has(symbol.name); const isInvalidIdentifier = !tsHelper.isValidLuaIdentifier(symbol.name); - const isAmbient = symbol.declarations.some(d => tsHelper.isAmbientNode(d)); + // TODO rework once microsoft/TypeScript#24706 is fixed and remove check for symbol.declarations + const isAmbient = symbol.declarations && symbol.declarations.some(d => tsHelper.isAmbientNode(d)); if ((isLuaKeyword || isInvalidIdentifier) && isAmbient) { // Catch ambient declarations of identifiers with bad names throw TSTLErrors.InvalidAmbientIdentifierName(tsOriginal || ts.createIdentifier(symbol.name)); From 17694fb67c6d2f13ef349e935dfeb55dedd8b0ac Mon Sep 17 00:00:00 2001 From: Lolleko Date: Sat, 6 Jul 2019 10:20:59 +0200 Subject: [PATCH 10/10] Fixed prettier version inconsistency (1.17.x / 1.18.x) --- package-lock.json | 41 +++++++++++------------------------------ src/CompilerOptions.ts | 2 +- 2 files changed, 12 insertions(+), 31 deletions(-) diff --git a/package-lock.json b/package-lock.json index d65fdef5c..5514235ca 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2769,8 +2769,7 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "aproba": { "version": "1.2.0", @@ -2791,14 +2790,12 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -2813,20 +2810,17 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -2943,8 +2937,7 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -2956,7 +2949,6 @@ "version": "1.0.0", "bundled": true, "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -2971,7 +2963,6 @@ "version": "3.0.4", "bundled": true, "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -2979,14 +2970,12 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -3005,7 +2994,6 @@ "version": "0.5.1", "bundled": true, "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -3086,8 +3074,7 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -3099,7 +3086,6 @@ "version": "1.4.0", "bundled": true, "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -3185,8 +3171,7 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "safer-buffer": { "version": "2.1.2", @@ -3222,7 +3207,6 @@ "version": "1.0.2", "bundled": true, "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -3242,7 +3226,6 @@ "version": "3.0.1", "bundled": true, "dev": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -3286,14 +3269,12 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "yallist": { "version": "3.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true } } }, diff --git a/src/CompilerOptions.ts b/src/CompilerOptions.ts index b429790b3..ca09566d0 100644 --- a/src/CompilerOptions.ts +++ b/src/CompilerOptions.ts @@ -1,7 +1,7 @@ import * as ts from "typescript"; type KnownKeys = { [K in keyof T]: string extends K ? never : number extends K ? never : K } extends { - [_ in keyof T]: infer U + [_ in keyof T]: infer U; } ? U : never;