-
-
Notifications
You must be signed in to change notification settings - Fork 540
Compile time errors being suppressed when using esm #2129
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
Comments
Just a heads up that my error was due to the server.ts file having a variable in an "if" check which I hadn't initialized yet, e.g.
The reason my tsc compilation wasn't catching was due to the same variable name "location_id" being instantiated in another .ts file so I was going mad to search for the cause... |
I encountered this error when there was no use of a defined variable or function, it happens when I execute the script using // the linter will help you with this
const someVar: any // intended to use later, I want to check it out first
//
const _falseCall = (_any: any) => { }; _falseCall(someVar);
// what about this
// You must use this function or it will trigger errors
const myFutureFunc = ()=> {
// ...
// lines of codes
// ...
}
//
_falseCall(myFutureFunc); // I tried this and the error went away
// ...
// tons of lines
// ... here is my module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
} To conclude, if I know which variables or functions are not used, I try to comment out on them. |
I really struggled to think of the correct title for this, so please edit it as required. I went down a rabbithole today whilst moving one of our apps to
esm
, as it was failing to start (with ts-node) due to the following node error:Doesn't really give away much. It turned out however that the root caused we missed a return type on a promise
eg Promise
needed to bePromise<void>
. This error was visible if you did atsc
, butts-node
was giving this output.After gradually chipping away at the code to make a minimal example; i managed to reproduce it with a really simple bit of code that doesn't even technically have an error in it.
Assuming your code is in
./lib
, create./lib/index.ts
:and
./lib/server.ts
:If you try and start this; you'll get the error. The only thing "wrong" with this code is the fact that
webServer
is an unused variable. If i addconsole.log(webServer)
, eg:Then all is well:
Specifications
The text was updated successfully, but these errors were encountered: