inlined twoslash `filename` tag doesnt seem to be passed through to included snippets
oveddan opened this issue · comments
You can see a full example of this reprod in this repository
Given I have two snippets:
docs/snippets/config.ts
:
import { zora } from "viem/chains";
import { http, createPublicClient } from "viem";
export const publicClient = createPublicClient({
// this will determine which chain to interact with
chain: zora,
transport: http(),
});
and another snippet that imports that code at docs/snippets/example.ts
:
import { publicClient } from "./config";
console.log(publicClient);
I'm attempting to import both with vocs, and use twoslash but run into issues.
Ideally I can have the markdown look like this:
![Screenshot 2024-05-22 at 10 43 31 AM](https://private-user-images.githubusercontent.com/891755/332903999-22bb00f9-9bcc-4675-bd81-6dd2afd07fa6.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTkzMjE5MTcsIm5iZiI6MTcxOTMyMTYxNywicGF0aCI6Ii84OTE3NTUvMzMyOTAzOTk5LTIyYmIwMGY5LTliY2MtNDY3NS1iZDgxLTZkZDJhZmQwN2ZhNi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNjI1JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDYyNVQxMzIwMTdaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT04YmNmMzM1YmE1NjNiNDE4ZTA5MDFhMjUwNzFkNDUzMTcxMjA2ZGZhZTVjYzgwMTk1MGYwN2U1OTU3M2EzY2Y0JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.gmMbDJjB4tgy54C6VOUaLCXijZDYMeSJZ4ZI03ri5gE)
But this results in a twoslash error:
Cannot find module './config' or its corresponding type declarations.
If I try to add twoslash include instructions to example.ts
like:
// @filename: config.ts
// [!include ~/snippets/config.ts]
// @filename: example.ts
// ---cut---
import { publicClient } from "./config";
console.log(publicClient);
I get an error:
example.ts
[2305] 107 - Module '"./config"' has no exported member 'publicClient'.
If I inline that code, the issue goes away:
![Screenshot 2024-05-22 at 10 44 05 AM](https://private-user-images.githubusercontent.com/891755/332904149-a554ee5e-a654-44c8-939f-b2275f90859f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTkzMjE5MTcsIm5iZiI6MTcxOTMyMTYxNywicGF0aCI6Ii84OTE3NTUvMzMyOTA0MTQ5LWE1NTRlZTVlLWE2NTQtNDRjOC05MzlmLWIyMjc1ZjkwODU5Zi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNjI1JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDYyNVQxMzIwMTdaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT02MzNhYWQ4YjM5ZTg4ZWYzODVhYWJmNWM3ODI1MzBiNGMzMjE1YTU4MWVlYWQ2NDgxMjE3ZjYwNGIxOTM5MTA2JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.1-JuGkSKwtT_QNXCvZDa6uJL7ye1SwJ4VyzqmxO8dlA)
It seems like the only way to get the issue to go away while being able to import the file is explicitly setting the external files inline, like:
![Screenshot 2024-05-22 at 10 45 12 AM](https://private-user-images.githubusercontent.com/891755/332904422-cce8f681-826e-4130-92ed-30039b0e2d02.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTkzMjE5MTcsIm5iZiI6MTcxOTMyMTYxNywicGF0aCI6Ii84OTE3NTUvMzMyOTA0NDIyLWNjZThmNjgxLTgyNmUtNDEzMC05MmVkLTMwMDM5YjBlMmQwMi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNjI1JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDYyNVQxMzIwMTdaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0zYWIwMzY5NmZjOWJmMTAxMzdkYWM1ZTM0ZDk4OTI4ZDJhNGJmM2VhYWVmOWNmZjIxYjA0MDMyZWMzMzJhNjg2JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.tA8OMJboiujnWLaESH9iC9WT7Xg0BHxPKWxAOPr4lok)
Would it be possible to pass through the included files from the codegroup to included files?
Or is there another recommended approach for including snippets that include other snippets?