Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Upgrade to TypeScript 3.8 #4915

Merged
merged 4 commits into from
Mar 10, 2020
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"tslint-config-prettier": "^1.18.0",
"tslint-plugin-prettier": "^2.0.1",
"tslint-test-config-non-relative": "file:test/external/tslint-test-config-non-relative",
"typescript": "~3.6.3",
"typescript": "~3.8.2",
"yarn-deduplicate": "^1.1.1"
},
"engines": {
Expand Down
6 changes: 6 additions & 0 deletions src/language/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -582,3 +582,9 @@ export function isWhiteSpace(ch: number): boolean {
// tslint:disable-next-line
return (ts.isWhiteSpaceLike || (ts as any).isWhiteSpace)(ch);
}

/** Wrapper for compatability with typescript@<3.8.2 */
export function isPrivateIdentifier(node: ts.Node): node is ts.PrivateIdentifier {
// tslint:disable-next-line
return ts.isPrivateIdentifier ? ts.isPrivateIdentifier(node) : false;
}
5 changes: 4 additions & 1 deletion src/rules/importBlacklistRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
ImportKind,
isExportDeclaration,
isImportDeclaration,
isNamedExports,
isNamedImports,
} from "tsutils";
import * as ts from "typescript";
Expand Down Expand Up @@ -237,7 +238,9 @@ function walk(ctx: Lint.WalkContext<Options>) {
toExportName,
)
: []),
...(exportClause !== undefined ? exportClause.elements.map(toExportName) : []),
...(exportClause !== undefined && isNamedExports(exportClause)
? exportClause.elements.map(toExportName)
: []),
];

for (const importName of namedImportsOrReExports) {
Expand Down
2 changes: 1 addition & 1 deletion src/rules/noUnnecessaryQualifierRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function walk(ctx: Lint.WalkContext, checker: ts.TypeChecker): void {

case ts.SyntaxKind.PropertyAccessExpression:
const { expression, name } = node as ts.PropertyAccessExpression;
if (utils.isEntityNameExpression(expression)) {
if (utils.isEntityNameExpression(expression) && !Lint.isPrivateIdentifier(name)) {
visitNamespaceAccess(node, expression, name);
break;
}
Expand Down
4 changes: 2 additions & 2 deletions src/rules/objectLiteralKeyQuotesRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class ObjectLiteralKeyQuotesWalker extends Lint.AbstractWalker<Options> {
return ts.forEachChild(sourceFile, cb);
}

private reportMissing(node: ts.NumericLiteral | ts.Identifier) {
private reportMissing(node: ts.NumericLiteral | ts.Identifier | ts.PrivateIdentifier) {
const start = node.getStart(this.sourceFile);
this.addFailure(
start,
Expand All @@ -178,7 +178,7 @@ class ObjectLiteralKeyQuotesWalker extends Lint.AbstractWalker<Options> {

function mapPropertyName(
property: ts.ObjectLiteralElementLike,
): ts.StringLiteral | ts.NumericLiteral | ts.Identifier | undefined {
): ts.StringLiteral | ts.NumericLiteral | ts.Identifier | ts.PrivateIdentifier | undefined {
if (
property.kind === ts.SyntaxKind.ShorthandPropertyAssignment ||
property.kind === ts.SyntaxKind.SpreadAssignment ||
Expand Down
6 changes: 5 additions & 1 deletion src/rules/whitespaceRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,11 @@ function walk(ctx: Lint.WalkContext<Options>) {

case ts.SyntaxKind.ExportDeclaration:
const { exportClause } = node as ts.ExportDeclaration;
if (options.module && exportClause !== undefined) {
if (
options.module &&
exportClause !== undefined &&
utils.isNamedExports(exportClause)
) {
exportClause.elements.forEach((element, idx, arr) => {
if (idx === arr.length - 1) {
const token = exportClause.getLastToken()!;
Expand Down
14 changes: 14 additions & 0 deletions test/rules/no-unnecessary-qualifier/test.ts.fix
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@ namespace N {
export const b = y;
export const c = z;
}

#if typescript >= 3.8.0
export class C {
#p: string;

constructor() {
this.#p = 'C!';
}

getP() {
return this.#p;
}
}
#endif
}

namespace A.B.C1 {
Expand Down
14 changes: 14 additions & 0 deletions test/rules/no-unnecessary-qualifier/test.ts.lint
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@ namespace N {
export const c = N.M.z;
~~~ [NM]
}

#if typescript >= 3.8.0
export class C {
#p: string;

constructor() {
this.#p = 'C!';
}

getP() {
return this.#p;
}
}
#endif
}

namespace A.B.C1 {
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1820,7 +1820,7 @@ tsconfig@^6.0.0:
strip-bom "^3.0.0"
strip-json-comments "^2.0.0"

tslib@^1.7.1, tslib@^1.8.0, tslib@^1.8.1, tslib@^1.10.0:
tslib@^1.10.0, tslib@^1.7.1, tslib@^1.8.0, tslib@^1.8.1:
version "1.10.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a"
integrity sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==
Expand Down Expand Up @@ -1878,10 +1878,10 @@ type-detect@^1.0.0:
resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-1.0.0.tgz#762217cc06db258ec48908a1298e8b95121e8ea2"
integrity sha1-diIXzAbbJY7EiQihKY6LlRIejqI=

typescript@~3.6.3:
version "3.6.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.6.3.tgz#fea942fabb20f7e1ca7164ff626f1a9f3f70b4da"
integrity sha512-N7bceJL1CtRQ2RiG0AQME13ksR7DiuQh/QehubYcghzv20tnh+MQnQIuJddTmsbqYj+dztchykemz0zFzlvdQw==
typescript@~3.8.2:
version "3.8.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.8.2.tgz#91d6868aaead7da74f493c553aeff76c0c0b1d5a"
integrity sha512-EgOVgL/4xfVrCMbhYKUQTdF37SQn4Iw73H5BgCrF1Abdun7Kwy/QZsE/ssAy0y4LxBbvua3PIbFsbRczWWnDdQ==

uglify-js@^3.1.4:
version "3.5.11"
Expand Down