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

refactor: unvendor typescript types definitions #234

Merged
merged 6 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
src/declarations/*
CHANGELOG.md
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
"@types/node": "^18.19.43",
"@types/ts-expose-internals": "npm:ts-expose-internals@4.9.5",
"@types/ts-node": "npm:ts-node@^10.9.2",
"@types/typescript-3": "npm:typescript@3.x",
"@types/typescript-4.7": "npm:typescript@4.7.x",
"changelogen": "^0.5.5",
"eslint": "9.x",
"globals": "^15.9.0",
Expand Down
13,717 changes: 0 additions & 13,717 deletions src/declarations/typescript3.d.ts

This file was deleted.

19,157 changes: 0 additions & 19,157 deletions src/declarations/typescript4.7.d.ts

This file was deleted.

9 changes: 5 additions & 4 deletions src/harmony/versions/four-seven.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/**
* Changes after this point: https://github.com/microsoft/TypeScript/wiki/API-Breaking-Changes#typescript-48
*/
import TsCurrentModule, {
import type {
default as TsCurrentModule,
AssertClause,
ExportDeclaration,
Expression,
Expand All @@ -13,9 +14,9 @@ import TsCurrentModule, {
ModuleName,
NamedExportBindings,
} from "typescript";
import TsFourSevenModule from "../../declarations/typescript4.7";
import { TsTransformPathsContext } from "../../types";
import { DownSampleTsTypes } from "../utils";
import type TsFourSevenModule from "typescript-4.7";
import type { TsTransformPathsContext } from "../../types";
import type { DownSampleTsTypes } from "../utils";

/* ****************************************************************************************************************** */
// region: Mapping
Expand Down
12 changes: 7 additions & 5 deletions src/harmony/versions/three-eight.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/**
* Changes after this point: https://github.com/microsoft/TypeScript/wiki/API-Breaking-Changes#typescript-40
*/
import TsCurrentModule, {
import type {
default as TsCurrentModule,
EntityName,
ExportDeclaration,
Expression,
Expand All @@ -18,9 +19,9 @@ import TsCurrentModule, {
NamedImportBindings,
TypeNode,
} from "typescript";
import type TsThreeEightModule from "../../declarations/typescript3";
import { TsTransformPathsContext } from "../../types";
import { DownSampleTsTypes } from "../utils";
import type TsThreeEightModule from "typescript-3";
import type { TsTransformPathsContext } from "../../types";
import type { DownSampleTsTypes } from "../utils";

/* ****************************************************************************************************************** */
// region: Mapping
Expand All @@ -30,6 +31,7 @@ export type TypeMap = [
[TsCurrentModule.SourceFile, TsThreeEightModule.SourceFile],
[TsCurrentModule.StringLiteral, TsThreeEightModule.StringLiteral],
[TsCurrentModule.CompilerOptions, TsThreeEightModule.CompilerOptions],
// @ts-expect-error typescript 3 doesn't export EmitResolver
[TsCurrentModule.EmitResolver, TsThreeEightModule.EmitResolver],
[TsCurrentModule.CallExpression, TsThreeEightModule.CallExpression],
[TsCurrentModule.ExternalModuleReference, TsThreeEightModule.ExternalModuleReference],
Expand Down Expand Up @@ -74,6 +76,7 @@ export function handler(context: TsTransformPathsContext, prop: string | symbol)
name: Identifier | undefined,
namedBindings: NamedImportBindings | undefined,
) {
// @ts-expect-error TODO investigate type issue
return ts.updateImportClause.apply(void 0, downSample(node, name, namedBindings));
};
case "updateImportDeclaration":
Expand Down Expand Up @@ -108,7 +111,6 @@ export function handler(context: TsTransformPathsContext, prop: string | symbol)
dsNode.modifiers,
dsExportClause,
dsModuleSpecifier,
// @ts-expect-error - This was added in later versions of 3.x
dsNode.isTypeOnly,
);
};
Expand Down
22 changes: 22 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,26 @@ __metadata:
languageName: node
linkType: hard

"@types/typescript-3@npm:typescript@3.x":
version: 3.9.10
resolution: "typescript@npm:3.9.10"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 10c0/863cc06070fa18a0f9c6a83265fb4922a8b51bf6f2c6760fb0b73865305ce617ea4bc6477381f9f4b7c3a8cb4a455b054f5469e6e41307733fe6a2bd9aae82f8
languageName: node
linkType: hard

"@types/typescript-4.7@npm:typescript@4.7.x":
version: 4.7.4
resolution: "typescript@npm:4.7.4"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 10c0/8c1c4007b6ce5b24c49f0e89173ab9e82687cc6ae54418d1140bb63b82d6598d085ac0f993fe3d3d1fbf87a2c76f1f81d394dc76315bc72c7a9f8561c5d8d205
languageName: node
linkType: hard

"@typescript-eslint/eslint-plugin@npm:8.0.1":
version: 8.0.1
resolution: "@typescript-eslint/eslint-plugin@npm:8.0.1"
Expand Down Expand Up @@ -2634,6 +2654,8 @@ __metadata:
"@types/node": "npm:^18.19.43"
"@types/ts-expose-internals": "npm:ts-expose-internals@4.9.5"
"@types/ts-node": "npm:ts-node@^10.9.2"
"@types/typescript-3": "npm:typescript@3.x"
"@types/typescript-4.7": "npm:typescript@4.7.x"
changelogen: "npm:^0.5.5"
eslint: "npm:9.x"
globals: "npm:^15.9.0"
Expand Down