Klaus Meinhardt ajafff Germany Building awesomeness

ajafff/tsutils 220

utility functions for working with typescript's AST

ajafff/tslint-consistent-codestyle 192

Collection of awesome rules to extend TSLint

ajafff/ts-transform-readonly-array 4

Convert 'readonly T[]' to 'ReadonlyArray<T>' in declaration emit

ajafff/normalize-glob 1

Normalize a glob pattern by expanding braces, making it absolute and resolving parent directories '..'

ajafff/ts-transform-const-enum 1

TypeScript transformer to convert const enums to regular enums in declaration files

ajafff/arrify 0

Convert a value to an array

ajafff/ava 0

:rocket: Futuristic JavaScript test runner

ajafff/babel 0

🐠 Babel is a compiler for writing next generation JavaScript.

ajafff/DefinitelyTyped 0

The repository for high quality TypeScript type definitions.

ajafff/dependency-cruiser 0

Validate and visualize dependencies. With your rules. JavaScript, TypeScript, CoffeeScript. ES6, CommonJS, AMD.

issue commentfimbullinter/wotan

`no-misused-generics`: missing error for function value

This is kinda working as intended. You could use the type parameter within the function body to ensure type safety or infer the return type:

function a<T>(param: T) {
  return param; // type parameter used in inferred return type

function b<T extends string>(param: Map<string, T>) {
  const v = param.get('foo')!;
  param.set('bar', v); // ok
  param.set('bar', 'v'); // should be an error, replacing the type parameter with its constraint makes this pass type checking

If you have a good idea how to handle such cases, especially the second case, I'm happy to change the rule.


comment created time in 3 months

issue commentmicrosoft/TypeScript

wish: add a warning for Map misuses



comment created time in 3 months

Pull request review commentmicrosoft/TypeScript

Error on immediate casts of literals to incompatible literal types

 namespace ts {                     checkTypeComparableTo(exprType, targetType, errNode,
+                else if (targetType.flags & TypeFlags.StringLiteral && isStringLiteral(expression) && expression.text !== (targetType as StringLiteralType).value) {

few questions / suggestions:

  • why limit it to assertions on a string literal expression?
    • should probably apply to all literal types
    • numeric literal
    • boolean literals
    • bigint literals
  • check union types:
    • 'foo' as 'foo' | 'bar' -> Ok
    • 'foo' as 'bar' | 'baz' -> Error
    • 'foo' | 'bar' as 'foo' -> Ok
    • 'bar' | 'baz' as 'foo' -> Error
    • 'foo' | 'bar' as 'foo' | 'baz' -> Ok
    • 'foo' | 'bar' as 'baz' | 'bas' -> Error

comment created time in 3 months