Given this code for example:
// src/index.ts
export function hello(props: {
type: 'boolean';
params: {
bool: boolean;
}
}): void;
export function hello(props: {
type: 'string';
params: {
str: string;
num: number;
}
}): void;
export function hello(props: {
type?: any;
params?: any;
}): void {
console.log(props);
}
// index.ts
import { hello } from './src';
hello({
type: 'string', /* autosuggests 'string' and 'boolean' */
params: {
/* autosuggests `str` and `num` (not `bool`) as property options, which is correct and expected */
}
})
The above code is working fine. However, when I transfer the same thing into .js file and .d.ts file, the same declaration doesn't work anymore:
// src/index.d.ts
export function hello(props: {
type: 'boolean';
params: {
bool: boolean;
}
}): void;
export function hello(props: {
type: 'string';
params: {
str: string;
num: number;
}
}): void;
export function hello(props: {
type?: any;
params?: any;
}): void;
// src/index.js
export function hello(props){
console.log(props);
}
// index.js
import { hello } from './src';
/* CTRL + clicking `hello` points me to the `src/index.d.ts` file, which is correct */
hello({
type: 'string', /* does not autosuggest anything */
params: {
/* does not autosuggest anything */
}
})
Can anyone point me to the correct direction?