Hey All - Is there any typescript support or plann...
# random
a
Hey All - Is there any typescript support or planned typescript support? I’m poking around a bit but having trouble getting it sorted.
👀 1
b
Hey @acoustic-angle-84817 which files are you trying to use typescript in?
My understanding is that any svelte components should support typescript, you just have to
<script lang="ts">
at the top. With
.md
files, I'm less sure. Our markdown processor MDsveX doesn't officially support TS. But I think some people have made it work in other projects
a
I have some custom components that depend on the evidence components, but am getting some errors regarding the imported svelte components not being modules, but only for the Evidence components, not my other custom components. I certainly may have just misconfigured typescript and can revisit
I also might need to add the typescript preprocessor to the svelte.config file which Evidence defines
b
hmm, now we're outside my level of understanding
@bland-thailand-4711 might be able to shed a bit of light on this when he comes online! (CDT)
What's your exact error in the console?
a
that sounds great, thanks! I’m moving between timezones for the next few weeks so I’m sorry if I respond at strange times (I assume this isn’t actually notifying/bothering anyone, but don’t want to come off as if I’m ignoring a response)
let me reproduce where I was and let you know the error
b
perfect
my sense is this should be achievable. but we might have to mess around with what evidence does under the hood to achieve it
a
sounds great! We’re adding more and more custom components, and I think typescript would make it much more maintainable, especially by engineers who don’t know javascript (our goal is to have our data team do the brunt of the maintenance)
(Also I know I owe you a meeting! Will grab time when I return home)
b
No rush!
potentially relevant? (though old)
a
Thanks! I’ll also check this out
b
👋 Morning guys, Jason do you have an example of the breaking code you can share? A repo would be ideal but a gist / snippets would be okay Also, can you post the full error output? Thanks!
a
Hey! I’m following this, as context: https://svelte.dev/blog/svelte-and-typescript
working on getting it back up to share the error now
I probably can’t get a minimal gist or reproduction at the moment but could in the future for sure
b
I also might need to add the typescript preprocessor to the svelte.config file which Evidence defines
This may be a solution, but would not be a simple task because that file is re-written whenever you build. I have a few ideas, just don't want to jump straight to the more complex ones 😅
Yeah no rush with a repro, I'll be around; feel free to drop me an @
a
So the simple reproduction is to @bland-thailand-4711 1. create a custom component that depends on/imports one of the evidence components 2. in the script tag, set
lang="ts"
3. Get typescript error (assumes you are using VSCode configured with the typescript language server, in which case you’ll see the errors in the editor) Full error example:
Copy code
Cannot find module '$lib/viz/BarChart.svelte' or its corresponding type declarations.
Something like
components/MyComponent.svelte
Copy code
<script lang="ts">
  import BarChart from '$lib/viz/BarChart.svelte';
</script>
b
Ahh okay; I see
I'm assuming you added your own
tsconfig.json
?
a
yep!
Copy code
{
  "extends": "@tsconfig/svelte/tsconfig.json",
  "include": [
    "components/**/*",
    "src/node_modules"
  ],
  "exclude": [
    "node_modules/*",
    "build/*",
    "sources/*",
    "pages/*"
  ],
  "compilerOptions": {
    "moduleResolution": "node"
  }
}
(not confident that it is correct, either…)
b
This seems sane; I'm betting that typescript is looking at
$lib
in a different place than we have assigned svelte's
$lib
. Let me take a look
1
thankyou 1
b
a
(To note, this is a nice to have from my point of view, not urgent or anything)
b
Do you have a
./.svelte-kit/tsconfig.json
?
a
there is one defined in the evidence template
perhaps I need to redefine the
paths
values?
b
Yep that's what I'm thinking
It would need to be in the tsconfig that you're working on, and I think it would be
./.evidence/template/src/components
a
yep
that did it
Copy code
"compilerOptions": {
        "moduleResolution": "node",
        "paths": {
			"$lib": [
				".evidence/template/src/components"
			],
			"$lib/*": [
				".evidence/template/src/components/*"
			]
		},
    }
will that work during build? I suppose only one way to find out!
b
(my suspicion is no, I think we might need to provide an overwrite feature)
a
makes sense. I also think major value would come from having typescript then work in the .md files, but I can poke at that
b
We're currently working on some things that will have types more available in .md files (not having intellisense can be painful!), so we should hopefully see improvements on that soon™️
™️ 1
a
oh, well that is amazing, thanks. Can I track that anywhere?
loading 1
b
There are a number of issues related to the overall project, but that's where this should end up living
a
Love it, and subscribed. Thanks!
Honestly this might be better than actual typescript support for our use case (though having compile-time errors would be great via typescript). For context, our process is, effectively, 1. Leverage Evidence to build a dashboarding framework with the bells and whistles defined by our design team but which requires minimal to no knowledge of javascript. Ideally you only need to know SQL and some basic patterns of the dashboarding framework itself 2. Implement the first few dashboards as the engineering team; cleaning up, simplifying, and documenting the framework as we go 3. Handoff the framework (with a migration period) to our data analytics team to maintain existing and build new dashboards 4. Iterate, as the engineering teams improve the framework and add more features based on design needs in some low-touch model
❤️ 1
b
Excellent - makes complete sense. For context from our side: 1. is where we are aiming to get Evidence to Noting that you may have additional bells and whistles that understandably never make it into the OSS project We also are looking to make it easier to maintain and publish "plugin" libraries, which I could imagine being where you want to take your additional features / components in the future
a
yes! That makes total sense
I’ve implemented five major paradigms on top of evidence that I think generally identify our needs beyond where the product sits right now • The ability to dynamically override echarts options for any particular chart beyond what evidence offers, but in some encapsulated way - effectively following the evidence paradigm for exposing only a subset of echarts features. We just need more. I created a WrappedChart component for this purpose that passes down props and dynamically overrides config via the echarts API upon certain events (primarily renders and filter changes - see below) • Dynamic global filtering - we have date range filters that sit at the top level of the page and are ◦ synced to/from the URL, for sharing links ◦ In a SPA rather than routing that requires page reloads (long story here, but this is both our UX goal and separately we couldn’t handle a multi page app in the way we’re currently hosting it in an iframe within our larger product. That second limitation of routing is short term) • Chart level filter - examples including toggle buttons to change the series/grouping and single/multi select to filter the dataset passed into the evidence component ◦ In the future, I need to add the ability to have a single filter impact multiple charts but I haven’t settled on a design yet • SQL syntax instead of JS - I don’t want our analytics team to need to learn javascript or functional programming in order to work with the filters. As a result, I started to use alasql , which is great! But has some issues (a few bugs, and performance may become an issue). I’m sure that there are better alternatives • Some minor UX bells and whistles (eg a menu component to allow downloading data or saving as JPEG instead of the out of the box UX, which was simple to add) Example component:
Copy code
<WrappedChart
                query={`
                    SELECT
                        COUNT(DISTINCT redacted1) AS redacted2,
                        redacted3
                    FROM ?
                    GROUP BY redacted3
                    ORDER BY redacted3
                `}
                queryParams={[datasetCurrTimePeriod_full]}
                title="Participation by Redacted3"
                subtitle="Short subtitle to help explain the data"
                showTitleMenu=true
                x=redacted3
                y=redacted2
                swapXY=true
                chartType=bar
            />
b
The use of alasql is pretty cool stuff, we've got some more plugin related stuff coming for data sources and general interactions. DuckDB has been on our radar to provide similar functionality (it can run via WASM), were there any other tools you considered outside of alasql?
a
only DuckDB but the implementation is a bit heavier and our timeline for initial release is short. Something I wanted to revisit for sure
1
That all sounds great - would love to watch anything if it makes sense, though I can certainly be patient
s
Very new to evidence, but was trying to understand what is not yet avail in terms of interaction (buttons, menus, drop-down high arity text menus based on data etc. dynamic grouping etc. This thread sounds like manipulating the url params is not yet a basic feature but rapidly evolving? Might be useful to get a snippet about this in the docs as it seems like this is trending ... (I came across from github "for you" feed).
Also interested in echarts specific ideas of click actions -> filter. This is chart interaction grammar stuff .... so gets complicated fast. Just curious on aim/direction/scope.
a
Happy to share my implementation on both but they’re far from generic
b
Hey @swift-architect-88465, All of
buttons, menus, drop-down high arity text menus based on data etc. dynamic grouping
is on the relatively near term roadmap - we imagine most of this will be unlocked with DuckDB as a in browser query engine. Manipulating URL params is possible but a bit hacky right now: https://docs.evidence.dev/core-concepts/filters/, and definitely something we aim to improve.