JSFiddle - React, Tailwind, and code Playground

by Jeremy Armstrong

TypeScript

const bobHome: absPath1 = ['', 'home', 'bob'];
const timHome: absPath2 = ['', 'home', 'tim'];

const userMusic:  relPath1 = ['Multimedia', 'Music' ];		//<-- Property '0' is missing in type 'string[]' but required in type 'absPath'.ts(2741)
const userVideos: relPath2 = ['Multimedia', 'Videos'];		//<-- Property '0' is missing in type 'string[]' but required in type 'absPath'.ts(2741)

const bobMusic:  absPath1 = [...bobHome, ...userMusic ];	//<-- Property '0' is missing in type 'string[]' but required in type 'absPath'.ts(2741)
const timVideos: absPath2 = [...timHome, ...userVideos];	//<-- Property '0' is missing in type 'string[]' but required in type 'absPath'.ts(2741)

const bobConfig: absPath1 = [...bobHome, '.config'];			//<-- Property '0' is missing in type 'string[]' but required in type 'absPath'.ts(2741)
const timSSH   : absPath2 = [...timHome, '.ssh'   ];			//<-- Property '0' is missing in type 'string[]' but required in type 'absPath'.ts(2741)

const bobHack: absPath1 = ['', ...bobHome.split(1)];			//<-- Property '0' is missing in type 'string[]' but required in type 'absPath'.ts(2741)
const timHack: absPath1 = ['', ...bobHome.split(1)];			//<-- Property '0' is missing in type 'string[]' but required in type 'absPath'.ts(2741)

const bobLoop: absPath1 = (() => {
	const accumulator = [];
  for (let i = 0, i < userMusic.length, i++) accumulator.push(userMusic[i]);
  return accumulator;
})()



type relPath1 = [...string[]];
type absPath1 = ['', ...string[]];

interface relPath2 extends Array<string> {
	[n: number]: string;
}

interface absPath2 extends relPath2 {
	0: '';
}