Next.js Discord

Discord Forum

Cannot find type declarations of public/images/*.svg

Answered
Griffon Nivernais posted this in #help-forum
Open in Discord
Griffon NivernaisOP
I've a type declaration file at src/typigns.d.ts with declare module *.svg and a meriad of other image filetypes yet the errors remain. What am I doing wrong?
declare module "*.json";
declare module "*.png";
declare module "*.scss";
declare module "*.svg";
Answered by Griffon Nivernais
Found out the hard way that *Configs don't support globs, just changed my include to this:
"include": ["**/*.ts", "**/*.tsx", ".next/types/**/*.ts"]
View full answer

2 Replies

Griffon NivernaisOP
My TSConfig:
{
    "$schema": "https://json.schemastore.org/tsconfig",
    "compilerOptions": {
        "allowImportingTsExtensions": true,
        "allowJs": true,
        "baseUrl": ".",
        "esModuleInterop": true,
        "forceConsistentCasingInFileNames": true,
        "incremental": true,
        "isolatedModules": true,
        "jsx": "preserve",
        "lib": ["DOM", "DOM.Iterable", "ESNext"],
        "module": "ESNext",
        "moduleResolution": "Bundler",
        "noEmit": true,
        "paths": {
            "@/*": ["./src/*"],
            "~/*": ["./*"]
        },
        "plugins": [
            {
                "name": "next"
            }
        ],
        "resolveJsonModule": true,
        "skipLibCheck": true,
        "strict": true,
        "target": "ESNext"
    },
    "exclude": ["node_modules", "packages"],
    "include": [
        "./*.{ts,tsx}",
        "./__tests__/**/*",
        "./scripts/**/*",
        "./src/**/*",
        ".next/types/**/*.ts"
    ]
}
Griffon NivernaisOP
Found out the hard way that *Configs don't support globs, just changed my include to this:
"include": ["**/*.ts", "**/*.tsx", ".next/types/**/*.ts"]
Answer