Questions tagged [tsc]

tsc is a compiler for converting TypeScript into plain JavaScript.

tsc is a compiler for converting TypeScript into plain JavaScript targeting either the ECMAScript 3 or ECMAScript 5 specifications.

927 questions
0
votes
1 answer

Adding Typescript declaration for package with inner modules

I am wanting to add types to a component library written purely in Javascript that I am not currently able to add directly to. I have followed this example for adding declarations to third party packages, which almost got me there. The current issue…
maccoda
  • 98
  • 6
0
votes
1 answer

tsc incorrectly compiling .ts files into .js

Hello I am using typescript and orbit-db in a project and I ran into this issue: This code this.orbitdb = new OrbitDB(this.ipfs); For some reason compiles into: this.orbitdb = new orbit_db_1.default(this.ipfs); instead of this.orbitdb = new…
user7094359
0
votes
1 answer

Typescript compile error when using AWS SDK

Problem I'm using Typescript with @aws/dynamodb-data-mapper-annotations, and it works but keeps throwing compile errors. These errors occurred on both macOS and Ubuntu 16.04 : ../../node_modules/@aws/dynamodb-data-mapper/build/protocols.d.ts(31,45):…
zeck
  • 769
  • 1
  • 7
  • 13
0
votes
1 answer

Return same object as argument

This is probably an anti-pattern, but I want to return the same object as an argument, in this case like so: const handleConnection = (s: net.Socket): net.Socket => { s.pipe(createParser()).on('data', (d: any) => { …
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
0
votes
1 answer

npm package with classes not compatible between typescript and transpiled versions

Hi I'm coding an npm package, is coded in typescript and transpiled. That package is now been used in a typescript app, but I have 1 error: [ts] Argument of type 'import("/home/chriss/Sites/ORM/connection").DB' is not assignable to parameter of type…
Chriss Mejía
  • 110
  • 1
  • 10
0
votes
2 answers

Instantiate class with abstract method

With Java we can create an instance of the ActionListener class which has an abstract method, something like this (it has been awhile): new ActionListener(){ @Override public void actionPerformed(ActionEvent e) { // whatever } } using…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
0
votes
1 answer

Use type as value - add a property on array that references a type

Say we have an array like so: const v = [ {name: 'foo', type: 'Boolean' }, {name: 'bar', type: 'String' }, {name: 'baz', type: 'JSON' }, ]; simple enough, but what if we want to add a type property: const v = [ {name: 'foo', type: 'Boolean' }, …
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
0
votes
2 answers

Get type completion based on dynamic (mapped/conditional) type

You can drop the following code into a foo.ts file. I am trying to dynamically generate types. What I am doing is based off this question: Map array to an interface type TypeMapping = { Boolean: boolean, String: string, Number: number, …
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
0
votes
1 answer

How to compile ts files into js into particular directories

I trying to compile typescript files with tsc command and use and lernajs to manage multi-package repositories. My directory structure is as…
SlawomirG
  • 1
  • 1
0
votes
1 answer

TS2345 error when a key in object args is written like [someKey]

When function StyleMixin(base: React.CSSProperties) {} StyleMixin({ fontWeight: 'bold', lineHeight: 1, textAlign: 'center', [someVariable]: { fontSize: '1rem', } } In [someVariable], it says TS2345: Argument of…
Taichi
  • 2,297
  • 6
  • 25
  • 47
0
votes
1 answer

Give a string a type besides

In many cases, I have a function that accepts many strings: export const acceptsManyStrings = (one: string, two: string, three: string) => { return one.slice(0,1) + two.slice(0,2) + three.slice(0,3); } because from a type perspective, the…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
0
votes
1 answer

How to exclude referenced Firebase modules in TypeScript Compiler - tsc?

I have config "exclude": [ "node_modules", "functions/node_modules", "typings/browser.d.ts", "typings/browser" ] and imports; import * as admin from "firebase-admin"; import DateUtilities from "../Utilities/DateUtilities"; import CoreUtilities from…
Teoman shipahi
  • 47,454
  • 15
  • 134
  • 158
0
votes
1 answer

Generic type with function expression instead of function declartion

This function declaration compiles and seems to be correct: function flattenDeep(arr: Array): Array{ return Array.isArray(arr) ? arr.reduce( (a, b) => [...flattenDeep(a), ...flattenDeep(b)] , []) : [arr]; } but this function expression…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
0
votes
1 answer

Type-checking properties created dynamically with Object.defineProperty

I have this handy construct like so: export class LinkedQueue { private lookup = new Map(); private head = null as any; private tail = null as any; public length: number; constructor() { Object.defineProperty(this,…
user7898461
0
votes
0 answers

Use TS generic type effectively for different functions

Right now I have this situation, a generic function type, an interface, and a function: export type EVCb = (err: any, val: T) => void; export interface RegistryData { exitCode: number, npmVersion: string } export const…
user7898461