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

[draft] Upgrade TS to 4.5.x, fix some of the broken tests #192

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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 @@ -23,7 +23,7 @@
"lodash": "^4.17.20",
"prettier": "^2.5.1",
"shelljs": "^0.8.4",
"typescript": "~4.4.4",
"typescript": "~4.5.0",
"typescript-compiler": "^1.4.1-2"
},
"devDependencies": {
Expand Down
6 changes: 1 addition & 5 deletions src/nodes/export-declaration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,9 @@ export default class ExportDeclaration extends Node<ExportDeclarationType> {
} else {
typeExports = [];
valueExports = [];
let nextIsType = false;
for (const node of rawElements) {
if (nextIsType) {
if (node.isTypeOnly) {
typeExports.push(node);
nextIsType = false;
} else if (node.name.originalKeywordKind === 150) {
nextIsType = true;
} else {
valueExports.push(node);
}
Expand Down
12 changes: 10 additions & 2 deletions src/printers/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ export function getFullyQualifiedName(
decl.kind === ts.SyntaxKind.TypeParameter ||
leftMostSymbol?.parent?.escapedName === "__global";
}
// TODO: something here is fucky. we want to take the branch when merging namespaces
// so that we get ns$a.b instead of ns$a$b, but we want to not take it when printing
// globalThis.whatever; taking it will print globalThis.whatever instead of whatever
if (!symbol || typeChecker.isUnknownSymbol(symbol) || isExternalSymbol) {
return printEntityName(type);
}
Expand Down Expand Up @@ -655,7 +658,12 @@ export const printType = withEnv<any, [any], string>(
${isTypeImport ? "" : "typeof "}
${getTypeofFullyQualifiedName(targetSymbol, type.typeName)}>`;
}
return printers.declarations.typeReference(type, !targetSymbol);
// double-bang fixes most tests, but also breaks some utility types,
// esp the ones that aren't provided args when they're expected
// need to determine exactly what the difference between these two is
// and why they took different branches in 4.4
return printers.declarations.typeReference(type, targetSymbol);
// return printers.declarations.typeReference(type, !targetSymbol);
};

// if importing an enum, we have to change how the type is used across the file
Expand All @@ -671,7 +679,7 @@ export const printType = withEnv<any, [any], string>(
return getAdjustedType(symbol);
}
}
return printers.declarations.typeReference(type, !symbol);
return printers.declarations.typeReference(type, symbol);
}

case ts.SyntaxKind.VariableDeclaration:
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4783,10 +4783,10 @@ typescript-compiler@^1.4.1-2:
resolved "https://registry.yarnpkg.com/typescript-compiler/-/typescript-compiler-1.4.1-2.tgz#ba4f7db22d91534a1929d90009dce161eb72fd3f"
integrity sha1-uk99si2RU0oZKdkACdzhYety/T8=

typescript@~4.4.4:
version "4.4.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.4.4.tgz#2cd01a1a1f160704d3101fd5a58ff0f9fcb8030c"
integrity sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA==
typescript@~4.5.0:
version "4.5.5"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.5.5.tgz#d8c953832d28924a9e3d37c73d729c846c5896f3"
integrity sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==

unbox-primitive@^1.0.1:
version "1.0.1"
Expand Down