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
Provide ambient types or TSify some js[x] files. #7114
base: main
Are you sure you want to change the base?
Conversation
This is needed when building terriajs from outside, like from terriamap.
"lodash-es": "^4.17.11", | ||
"markdown-it": "^11.0.0", | ||
"markdown-it": "^14.1.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had this in my pile of security fixes, this fixes CVE-2022-21670.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Just need to confirm the DisclaimerHandler changes.
lib/Core/arrayContains.ts
Outdated
export default function arrayContains<T>(array: readonly T[], value: T) { | ||
for (let i = 0; i < array.length; ++i) { | ||
if (array[i] === value) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've removed this (only used in 1 place in terriajs) and replaced with Array.prototype.includes
.
@@ -449,8 +447,6 @@ export default class ViewState { | |||
} | |||
); | |||
|
|||
this._disclaimerHandler = new DisclaimerHandler(terria, this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this not needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was used in v7 for showing catalog item initial message. In v8 this is handled here:
terriajs/lib/ModelMixins/MappableMixin.ts
Lines 175 to 179 in d4ccee3
if (this.shouldShowInitialMessage) { | |
// Don't await the initialMessage because this causes cyclic dependency between loading | |
// and user interaction (see https://github.com/TerriaJS/terriajs/issues/5528) | |
this.showInitialMessage(); | |
} |
!e.dataTransfer.types || | ||
!arrayContains(e.dataTransfer.types, "Files") | ||
) { | ||
if (!e.dataTransfer.types || !e.dataTransfer.types.includes("Files")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made this change to remove arrayContains
What this PR does
Currently, running
tsc
from an external library like a plugin fails with many... element implicitly has type "any"
errors. This is becausetsc
will not type check js/jsx modules from external libraries innode_modules
. These errors can be suppressed by turning off noImplicitAny option, however this is pretty unsafe.This PR tries not to change any functionality, instead we typify just enough files so that
tsc
will succeed without having to add any extra configuration. We make the following specific modifications:.js[x]
files to.ts[x]
and make necessary changes so that it type checks.js[x]
files, we create an ambient.d.ts
file with type signatures for all the exportsmarkdown-it
andlinkify-it
so that we canimport
their ESM versions and typings.Test me
Please just do a random test adding different catalog items, via catalog explorer, web url and drag-n-drop, open feature info panel, charts etc.
Checklist
There are unit tests to verify my changes are correct or unit tests aren't applicable (if so, write quick reason why unit tests don't exist)Fixed broken specs.doc/
.