Reputation: 69
I have the following configuration in snowpack:
/** @type {import("snowpack").SnowpackUserConfig } */
module.exports = {
mount: {
public:{ url: '/', static: true },
src: { url: '/dist' },
runtime: { url: '/runtime' },
},
plugins: [
'@snowpack/plugin-typescript',
['@snowpack/plugin-babel',
{
'input': ['.ts', '.tsx'],
}
]
],
packageOptions: {
/* ... */
},
devOptions: {
/* ... */
},
buildOptions: {
/* ... */
},
};
And this is in my Declaration file index.d.ts
but Snowpack is not reading it when I start the dev server.
declare global {
namespace JSX {
interface IntrinsicElements {
[elName: string]: any;
}
}
}
The only way to get it working is changing the file name to index.ts
Upvotes: 0
Views: 678
Reputation: 111
The way you've phrased the question - snowpack 'not taking' your .d.ts files - is a bit vague for me. If you mean that your editor (assuming VSCode) is not giving you autocompletion then try to add the file to the "include" array in your tsconfig.json:
{
"include": [
...
"index.d.ts",
]
}
I found this solution from the basic typescript template used by the create-snowpack-app CLI tool: https://github.com/snowpackjs/snowpack/tree/main/create-snowpack-app/app-template-blank-typescript There the .d.ts file is inside 'types' folder, and that folder is then included in tsconfig.
Upvotes: -1