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

fix: spurious typescript errors #1550

Merged
merged 4 commits into from
Jan 13, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 13 additions & 10 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
{
"compilerOptions": {
"target": "es2017",
"allowJs": true,
"baseUrl": "./",
"downlevelIteration": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"removeComments": false,
"module": "commonjs",
"moduleResolution": "node",
"noImplicitAny": true,
"noImplicitThis": true,
"moduleResolution": "node",
"module": "commonjs",
"outDir": "build",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the reason why we were seeing so many errors in the vscode intellisense - we needed a default output directory so ts wasn't trying to override our javascript files with themselves

"removeComments": false,
"resolveJsonModule": true,
"esModuleInterop": true,
"allowJs": true,
"skipLibCheck": true
"rootDir": "./",
"skipLibCheck": true,
"target": "es5"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2017 is way too modern a target, as Android 5 was released in 2014. I've added downlevelIteration to support this (this allows support for compiling Iterators to this target)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we specify the target in the webpack, no?

es5 seems scary, and unnecessary for Electron.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mm, on second look we do have a BABEL_LOADER which uses @babel/preset-env which ascends up to the system root, looking for the browserlist. So it's there, but not very explicit.

What if I were to set the target here to "esnext" instead and add a comment pointing to the babel config?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh, these things should live in src/cordova and src/electron respectively. I'll remove the target change for now and we can clean this up later.

},
// We don't need TypeScript to check javascript files.
"include": ["./src/**/*.ts"],
"exclude": ["node_modules", "www", "./src/**/*.js", "./src/**/*.mjs", "./www/**/*", "./build/**/*"]
"exclude": ["*.cjs", "*.js", "*.mjs"],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we exclude node_modules?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have an include for src, which scopes all our compilation to src - node_modules is outside of src:

https://www.typescriptlang.org/tsconfig#include
https://www.typescriptlang.org/tsconfig#exclude

"Exclude: Specifies an array of filenames or patterns that should be skipped when resolving include."

"include": ["src"]
}