Skip to content

Commit

Permalink
Drop support for typescript v4.4.4 and add support for typescript v5.…
Browse files Browse the repository at this point in the history
…2.2 (#327)

* Add support for typescript 5.2 in lit-analyzer tests

* Drop support for typescript v4.4.4 and add support for typescript v5.2.2

* Removed explicit 5.2 entry in tests
  • Loading branch information
paglobal authored Oct 25, 2023
1 parent 79e8593 commit 6877915
Show file tree
Hide file tree
Showing 11 changed files with 226 additions and 502 deletions.
305 changes: 78 additions & 227 deletions packages/lit-analyzer/package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/lit-analyzer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@
"ts-simple-type": "~2.0.0-next.0",
"vscode-css-languageservice": "4.3.0",
"vscode-html-languageservice": "3.1.0",
"web-component-analyzer": "^2.0.0-next.5"
"web-component-analyzer": "^2.0.0"
},
"devDependencies": {
"@appnest/readme": "^1.2.7",
"@types/node": "^14.0.13",
"ava": "^3.8.2",
"rimraf": "^3.0.2",
"tslib": "^2.0.0",
"typescript": "~4.4.4",
"typescript": "~5.2.2",
"typescript-4.8": "npm:typescript@~4.8.2",
"typescript-5.0": "npm:typescript@~5.0.4",
"typescript-5.1": "npm:typescript@~5.1.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/lit-analyzer/src/lib/analyze/lit-analyzer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SourceFile } from "typescript";
import { FormatCodeSettings, SourceFile } from "typescript";
import { ComponentAnalyzer } from "./component-analyzer/component-analyzer.js";
import { LitCssDocumentAnalyzer } from "./document-analyzer/css/lit-css-document-analyzer.js";
import { LitHtmlDocumentAnalyzer, LitIndexEntry } from "./document-analyzer/html/lit-html-document-analyzer.js";
Expand Down Expand Up @@ -283,7 +283,7 @@ export class LitAnalyzer {
return [];
}

getFormatEditsInFile(file: SourceFile, settings: ts.FormatCodeSettings): LitFormatEdit[] {
getFormatEditsInFile(file: SourceFile, settings: FormatCodeSettings): LitFormatEdit[] {
this.context.setContextBase({ file });

const documents = this.getDocumentsInFile(file);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,9 @@ function emitDirectModuleImportWithName(moduleSpecifier: string, node: Node, con
// Resolve the imported string
let result: tsModule.ResolvedModuleWithFailedLookupLocations | undefined;

if (context.project) {
result = context.project.getResolvedModuleWithFailedLookupLocationsFromCache(moduleSpecifier, fromSourceFile.fileName);
if (context.project && "getResolvedModuleWithFailedLookupLocationsFromCache" in context.project) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
result = (context.project as any).getResolvedModuleWithFailedLookupLocationsFromCache(moduleSpecifier, fromSourceFile.fileName);
} else if ("getResolvedModuleWithFailedLookupLocationsFromCache" in context.program) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
result = (context.program as any)["getResolvedModuleWithFailedLookupLocationsFromCache"](moduleSpecifier, fromSourceFile.fileName);
Expand Down
5 changes: 2 additions & 3 deletions packages/lit-analyzer/src/test/helpers/ts-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { setTypescriptModule } from "../../lib/analyze/ts-module.js";

type TestFunction = (title: string, implementation: Implementation) => void;

const TS_MODULES_ALL = ["current", "4.8", "5.0", "5.1", "5.2"] as const;
const TS_MODULES_ALL = ["current", "4.8", "5.0", "5.1"] as const;

type TsModuleKind = typeof TS_MODULES_ALL[number];

const TS_MODULES_DEFAULT: TsModuleKind[] = ["current", "4.8", "5.0", "5.1", "5.2"];
const TS_MODULES_DEFAULT: TsModuleKind[] = ["current", "4.8", "5.0", "5.1"];

/**
* Returns the name of the module to require for a specific ts module kind
Expand All @@ -21,7 +21,6 @@ function getTsModuleNameWithKind(kind: TsModuleKind | undefined): string {
case "4.8":
case "5.0":
case "5.1":
case "5.2":
return `typescript-${kind}`;
case "current":
case undefined:
Expand Down
Loading

0 comments on commit 6877915

Please sign in to comment.