Skip to content

Commit

Permalink
Update to TS 5.0, still missing new feature support
Browse files Browse the repository at this point in the history
Closes #2202
  • Loading branch information
Gerrit0 committed Mar 19, 2023
1 parent 88341e0 commit 642dd2e
Show file tree
Hide file tree
Showing 8 changed files with 434 additions and 422 deletions.
798 changes: 396 additions & 402 deletions package-lock.json

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions package.json
Expand Up @@ -31,24 +31,24 @@
"shiki": "^0.14.1"
},
"peerDependencies": {
"typescript": "4.6.x || 4.7.x || 4.8.x || 4.9.x"
"typescript": "4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x"
},
"devDependencies": {
"@types/lunr": "^2.3.4",
"@types/marked": "^4.0.8",
"@types/mocha": "^10.0.1",
"@types/node": "14",
"@typescript-eslint/eslint-plugin": "^5.51.0",
"@typescript-eslint/parser": "^5.51.0",
"@typescript-eslint/eslint-plugin": "^5.55.0",
"@typescript-eslint/parser": "^5.55.0",
"@typestrong/fs-fixture-builder": "github:TypeStrong/fs-fixture-builder#5a9486bc66f6e36988106685768396281f6cbc10",
"c8": "^7.12.0",
"esbuild": "^0.17.7",
"eslint": "^8.34.0",
"c8": "^7.13.0",
"esbuild": "^0.17.12",
"eslint": "^8.36.0",
"mocha": "^10.2.0",
"prettier": "2.8.4",
"puppeteer": "^13.5.2",
"ts-node": "^10.9.1",
"typescript": "4.9.5"
"typescript": "5.0.2"
},
"files": [
"/bin",
Expand Down
7 changes: 5 additions & 2 deletions src/lib/converter/symbols.ts
Expand Up @@ -1021,8 +1021,11 @@ function setModifiers(
);
reflection.setFlag(
ReflectionFlag.Readonly,
hasAllFlags(symbol.checkFlags ?? 0, ts.CheckFlags.Readonly) ||
hasAllFlags(modifiers, ts.ModifierFlags.Readonly)
hasAllFlags(
// TS 4.9: symbol.checkFlags, links was introduced in 5.0
symbol.checkFlags ?? symbol.links?.checkFlags ?? 0,
ts.CheckFlags.Readonly
) || hasAllFlags(modifiers, ts.ModifierFlags.Readonly)
);
reflection.setFlag(
ReflectionFlag.Abstract,
Expand Down
7 changes: 7 additions & 0 deletions src/lib/types/ts-internal/index.d.ts
Expand Up @@ -10,8 +10,15 @@ declare module "typescript" {
}

interface Symbol {
// TS before 5.0
// https://github.com/microsoft/TypeScript/blob/v4.1.5/src/compiler/types.ts#L4734-L4737
checkFlags?: CheckFlags;

// TS 5.0
// https://github.com/microsoft/TypeScript/blob/5.0.2/src/compiler/types.ts#L5891-L5898
links?: {
checkFlags: CheckFlags;
};
}

interface TypeChecker {
Expand Down
6 changes: 3 additions & 3 deletions src/lib/utils/entry-point.ts
Expand Up @@ -411,6 +411,8 @@ function getEntryPointsForPackages(
return;
}

const packageName = packageJson["name"] as string;

if (includeVersion && !validate({ version: String }, packageJson)) {
logger.warn(
`--includeVersion was specified, but "${nicePath(
Expand All @@ -420,9 +422,7 @@ function getEntryPointsForPackages(
}

results.push({
displayName:
typedocPackageConfig?.displayName ??
(packageJson["name"] as string),
displayName: typedocPackageConfig?.displayName ?? packageName,
version: includeVersion
? (packageJson["version"] as string | undefined)
: void 0,
Expand Down
11 changes: 7 additions & 4 deletions src/lib/utils/package-manifest.ts
Expand Up @@ -63,18 +63,21 @@ export function extractTypedocConfigFromPackageManifest(
}
if (
hasOwnProperty(packageJson, "typedoc") &&
typeof packageJson.typedoc == "object" &&
packageJson.typedoc
typeof packageJson["typedoc"] == "object" &&
packageJson["typedoc"]
) {
if (
!validate(typedocPackageManifestConfigSchema, packageJson.typedoc)
!validate(
typedocPackageManifestConfigSchema,
packageJson["typedoc"]
)
) {
logger.error(
`Typedoc config extracted from package manifest file ${packageJsonPath} is not valid`
);
return undefined;
}
return packageJson.typedoc;
return packageJson["typedoc"];
}
return undefined;
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/converter2/issues/gh2044/index.js
Expand Up @@ -5,7 +5,7 @@ export { other } from "./other";

/**
* @typedef {import("./other").Generic<T>} Generic
* @template T
* @template {string} T
*/

/**
Expand Down
11 changes: 8 additions & 3 deletions tsconfig.json
Expand Up @@ -21,12 +21,10 @@
"noUnusedLocals": true,
"noUnusedParameters": true,
"forceConsistentCasingInFileNames": true,
"importsNotUsedAsValues": "error",
// Library
"preserveConstEnums": true,
"declaration": true,
"sourceMap": true,
"isolatedModules": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
// Output
Expand All @@ -35,7 +33,14 @@
"newLine": "LF",
"jsx": "react",
"jsxFactory": "JSX.createElement",
"jsxFragmentFactory": "JSX.Fragment"
"jsxFragmentFactory": "JSX.Fragment",

// TS 5 introduced verbatimModuleSyntax and deprecated importsNotUsedAsValues
// But that flag is intentionally very unfriendly to projects emitting CommonJS
// so for now, we're going to ignore that deprecation.
"ignoreDeprecations": "5.0",
"importsNotUsedAsValues": "error",
"isolatedModules": true
},
"include": ["src"],
"exclude": [
Expand Down

0 comments on commit 642dd2e

Please sign in to comment.