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

Manual fix required for Typescript bug that's not fixed in stable #1

Open
AlecDusheck opened this issue Jul 8, 2019 · 1 comment
Open

Comments

@AlecDusheck
Copy link
Member

If you're using Typescript v3.5.2 and are attempting to automatically generate type guards and getting this error:

(node:24782) UnhandledPromiseRejectionWarning: TypeError: realpath is not a function
    at visitDirectory (/home/simplyalec/WebstormProjects/SSManagerV3/node_modules/typescript/lib/typescript.js:16032:45)
    at Object.matchFiles (/home/simplyalec/WebstormProjects/SSManagerV3/node_modules/typescript/lib/typescript.js:16028:13)
    at Object.matchFiles (/home/simplyalec/WebstormProjects/SSManagerV3/node_modules/ts-simple-ast/dist/typescript/tsInternal.js:7:35)
    at Object.readDirectory (/home/simplyalec/WebstormProjects/SSManagerV3/node_modules/ts-simple-ast/dist/utils/compiler/readDirectory.js:16:27)
    at Object.readDirectory (/home/simplyalec/WebstormProjects/SSManagerV3/node_modules/ts-simple-ast/dist/utils/tsconfig/getTsParseConfigHost.js:11:37)
    at getFileNamesFromConfigSpecs (/home/simplyalec/WebstormProjects/SSManagerV3/node_modules/typescript/lib/typescript.js:26140:40)
    at matchFileNames (/home/simplyalec/WebstormProjects/SSManagerV3/node_modules/typescript/lib/typescript.js:26060:16)
    at getFileNames (/home/simplyalec/WebstormProjects/SSManagerV3/node_modules/typescript/lib/typescript.js:25628:26)
    at parseJsonConfigFileContentWorker (/home/simplyalec/WebstormProjects/SSManagerV3/node_modules/typescript/lib/typescript.js:25561:18)
    at Object.parseJsonConfigFileContent (/home/simplyalec/WebstormProjects/SSManagerV3/node_modules/typescript/lib/typescript.js:25510:16)
(node:24782) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:24782) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
s

apply this patch file to your ./node_modules/typescript/lib/typescript.ts file:

@@ -16029,7 +16029,7 @@ var ts;
         }
         return ts.flatten(results);
         function visitDirectory(path, absolutePath, depth) {
-            var canonicalPath = toCanonical(realpath(absolutePath));
+            var canonicalPath = toCanonical(absolutePath);
             if (visited.has(canonicalPath))
                 return;
             visited.set(canonicalPath, true);
@AlecDusheck
Copy link
Member Author

AlecDusheck commented Jul 8, 2019

Sorta a jank workaround but this is probably the smallest fix and won't break much in terms of what this project is using

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant