Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

declare var test: (s: string) => void;

declare var test: {
    (s: string) => void;
    tests: any[];

At the moment TS compiler shows error: Subsequent variable declarations must have the same type.

Issue Analytics

  • State:open
  • Created 8 years ago
  • Reactions:2
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

andy-mscommented, Jan 25, 2018

It might be useful to support this in the particular case of a property of type any. Often DefinitelyTyped declarations will declare something to be of type any when a particular user will know a better type.

// DefinitelyTyped
interface I { foo: any; }

// My code
interface I { foo: { x: number }; }

Currently we give an error because the types for foo conflict. We might just throw out any declarations typed as any when getting the type.

sdrsdrcommented, Oct 13, 2022

redeclare can have other benefits:

I have a “header” type of interface:

export interface api_msg_t {

function is_api_msg(m:any) :m is api_msg_t {
	return (
		m && typeof(m)=="object" && typeof(m.a)=='string' && typeof(m.devid)=='string'

I want to have extended interface:

interface api_node_online_t extends api_msg_t {
function is_api_node_online(m:api_msg_t) : m is api_node_online_t {
	return (m.a=='onl' && typeof(m.nid)=="number" && is_node_state(m.state));

if there is no inex type in api_msg_t the typeguard is_api_node_online fails to transpile as m.nid does not exist in api_msg_t. But adding index in the api_msg_t propagates it to api_node_online_t that is undesirable. if we can do

function is_api_node_online(m:api_msg_t) : m is api_node_online_t {
	redaclare m as api_msg_t & {[index:string]:unknonw};
	return (m.a=='onl' && typeof(m.nid)=="number" && is_node_state(m.state));

It will allow for elegant and typesafe solution.

We can easily mimic this behavior with

interface api_msg_indexed_t extends api_msg_t {

function is_api_msg_indexed(m:api_msg_t):m is api_msg_indexed_t:{
	return true;

function is_api_node_online(m:api_msg_t) : m is api_node_online_t {
	if (!api_msg_indexed(m)) return;
	return (m.a=='onl' && typeof(m.nid)=="number" && is_node_state(m.state));

but this results in unnecessary JS code emitted and ran

Read more comments on GitHub >

github_iconTop Results From Across the Web

Merging variables - Ipsos
You can merge two or more variables to form a new variable. This is useful when you want to create a total awareness...
Read more >
To merge variables
You can merge two variables, or merge a variable with another object. The variables must be dimension objects, and must come from different...
Read more >
13 Merging | Data Wrangling with R
13 Merging | Data Wrangling with R. ... A simple merge adds the data values in one data set as new variables to...
Read more >
Merge/Append using Stata - Princeton University
Merge – adds variables to a dataset. Type help merge for details. Merging two datasets require that both have at least one variable...
Read more >
Inserting merge variables onto a layout
You can create a merge variable that displays a value from a variable. You can use merge variables for some tasks in place...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found