The 'any' type is implicitly present in Gulp-CSS-Clean

Struggling to get a new Eleventy website up and running locally on Windows. Even though the codebase works fine on others' machines, I'm facing an issue with a 'missing' CSS file preventing me from launching the site.

[4] `TemplateWriterWriteError` was thrown
[4] > (./src/_includes/layouts/about.html)
[4]   Error: template not found: css/critical.css

Interestingly, I can find the css/critical.css file in my output dist folder.

I'm unsure where the problem originates, but the first thing that caught my eye in VSCode is that the requires(...'gulp-clean-css') line has three dots indicating no declaration for the module, with the package's index file implicitly having an 'any' type.

This leads me to believe that this could potentially be related as the gulp-clean-css package is used in generating the supposedly missing critical.css file.

After some research, it seems like this may be a TypeScript issue with a simple solution.

Solution: Simply edit your TypeScript Config file (tsconfig.json) and add a new key value pair as: "noImplicitAny": false

(source: https://medium.com/@amandeepkochhar/typescript-error-could-not-find-a-declaration-file-for-module-xyz-dfbe6e45c2bd)

But there's no specific direction on where to place the tsconfig file. Should it be in the Eleventy root folder? Or within the package?

Additionally, what other configurations should accompany that specific line? For example, I came across this sample file, which might suffice:

{
  "compilerOptions": {
    "module": "commonjs",
    "esModuleInterop": true,
    "target": "es6",
    "moduleResolution": "node",
    "sourceMap": true,
    "outDir": "dist"
  },
  "lib": ["es2015"]
}

It's possible that I'm chasing a false lead here. If anyone has any guidance on resolving this issue, I would greatly appreciate it!

Answer №1

Using Typescript ended up being a dead end. For some unknown reason, specific gulp plugins weren't functioning correctly on my Windows 10 system (e.g. gulp-clean-css and gulp-imagemin)

After some troubleshooting, I found that switching to WSL was the best solution for me. I installed a Linux subsystem and started developing on Linux, which resolved the plugin issues.

If you're unfamiliar with setting up WSL, it can be a bit complex to explain here. It requires a good understanding of the process, so I recommend researching WSL beforehand. I'll share the links below that I used, in case they are helpful to someone else.

Video: https://www.youtube.com/watch?v=_fntjriRe48

Post:

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Challenges arise with data updating following a mutation in @tanstack/react-query

As I work on building an e-commerce website using React, I have a specific feature where users can add products to their favorites by clicking a button. Following this action, I aim to update the profile request to display the user's information along ...

Having trouble using the 'in' operator to search for 'Symbol(StrapiCustomCoreController)' while transitioning Strapi to TypeScript

I'm in the process of converting my strapi project to typescript. I've updated all strapi packages to version 4.15.5 and converted the files to ts extension. However, upon running strapi develop, I encounter the following error: [2024-01-03 10:50 ...

Tips for creating a versatile object combine function in TypeScript

Is there a way to create a generic function in TypeScript 4.4+ that is equivalent to {...a,...b} operation? Both a and b are records, but their types are unknown in advance. I want to define a generic type that enforces arbitrary functions to perform the { ...

Select one of 2 parameters and begin typing

I recently encountered a situation where I needed to define a type with an id field (string) and an oldId field (number), but I wanted these fields to be exclusive. For example: { id: "1234", name: "foo" } { oldId: 1234, name: "b ...

What is the reason behind not being able to fetch the element id while using event.target?

When I click on the button, I'm trying to retrieve the element id, but sometimes I don't get it. Here's the code snippet where I encounter this issue using TypeScript! Take a look at the image below! <div *ngFor="let item of l ...

Validate a string to determine if it is a legitimate numerical value using Javascript

How can we accurately determine if a string is a valid number in JavaScript? Although the method isNaN(str) is commonly used, it has limitations in certain cases, Current behavior: isNaN("1") = false, as it is a number, isNaN("1 ") = ...

What is the best way to invoke a function in a specific child component from its parent component?

It seems that I might have provided too much information, but the main question remains: how can I call a method in the child component from the parent template's click() event. <button(click)='get()'>GET</button> In my case, th ...

The type definition file for '@types' is not present in Ionic's code base

After updating my Ionic 6 project to use Angular 3, everything works perfectly in debug mode. However, when I attempt to compile for production using 'ionic build --prod' or 'ionic cordova build android --prod', I encounter the followin ...

Problem with Gmail Authentication in Nodemailer

I am currently facing an authentication issue while trying to use Nodemailer in a Node.js application to send emails via Gmail. The error message reads "Missing credentials for 'PLAIN'." I have carefully reviewed my code and environment variables ...

Declaration File for TypeScript External Node Module Typings

In my Node.js module (index.js), I have transpiled the code using Babel and it looks like this: // My code ... var fs = require("fs"); var path = require("path"); exports.fileContent = fs.readFileSync( path.join(__dirname, "file.txt"), 'utf8&apo ...

Exploring the Realm of Javacript Template Literal Capabilities

Is it possible to define a variable inside a template literal and then utilize it within the same template? If this isn't feasible, it appears to be a significant feature that is lacking. const sample = tag` some random words, ${let myvar = 55} addit ...

Using parameters to create unions in TypeScript

Is there a standard method to parametrically define a union? I'm searching for a way to generically define something like: type U<K> = T<K1> | T<K2> | ... | T<Kn> // Where K === (K1 | ... | Kn) Note: I'm encountering a s ...

What is the process for accessing my PayPal Sandbox account?

I'm having trouble logging into my SandBox Account since they updated the menu. The old steps mentioned in this post Can't login to paypal sandbox no longer seem to work. Could someone please provide me with detailed, step-by-step instructions o ...

Tips on transforming Angular 2/4 Reactive Forms custom validation Promise code into Observable design?

After a delay of 1500ms, this snippet for custom validation in reactive forms adds emailIsTaken: true to the errors object of the emailAddress formControl when the user inputs [email protected]. https://i.stack.imgur.com/4oZ6w.png takenEmailAddress( ...

Is there a way to change a .pptx document into a base64 string?

Currently, I am working on a project that involves creating an addin for Office. The challenge I am facing is opening other pptx files from within the addin. After some research, I discovered that I need to use base64 for the PowerPoint.createPresentation( ...

Determining the return type based on the parameter type

Here is an example of my function: const safeIdCastToNumber = (id: string | null | undefined) => isNil(id) ? id : Number(id) When calling safeIdCastToNumber, I can use an id parameter with a type union string | null | undefined, as well as one with a t ...

Tips for asynchronously loading items in a v-select dropdown of Vuetify within a Vue application

I am facing an issue with asynchronously fetching data for the v-select Vuetify Component. The problem is that the v-select component only accepts an Array for the :items attribute. Is there a workaround to fetch data asynchronously? Error: Invalid prop ...

Retrieving information using React Query in TypeScript

When working with React Query and TypeScript, I encountered an issue with the getRecommendations hook. I wanted to only send the latest recommendations (I may create another hook for watchlist items in the future). The error I received was related to the q ...

Errors in TypeScript type definition IntelliSense

While using Visual Studio 2022, I am encountering numerous IntelliSense errors related to type definitions from the node_modules folder appearing in the error list window. I have already excluded the node_modules folder in my tsconfig.json file like this ...

Exploring the possibilities of TypeScript/angularJS in HTTP GET requests

I am a beginner in typescript and angular.js, and I am facing difficulties with an http get request. I rely on DefinitelyTyped for angular's type definitions. This is what my controller code looks like: module game.Controller { 'use strict& ...