In a JavaScript project, how can I add typed config objects that I can pass into a constructor and that work with VSCode code completion?
Here is a screenshot from the Three.js library that provides the functionality I am referring to. I am trying to replicate this in my own JavaScript project.
Here is what I tried. Both files are in the same directory. I am using Webpack as a bundler, no typescript configuration whatsoever. The .d.ts file appears to get ignored.
What do I need to do to get this to work? Add a config file? Change Webpack setup?
// Person.js
export class Person {
constructor(parameters) {
this.name = parameters.name;
this.age = parameters.age;
}
}
// Person.d.ts
export interface PersonParameters {
name: string,
age?: number
}
export class Person {
constructor(parameters: PersonParameters);
}
